🛠️ LLMアプリDevLangchainエージェント
LangChain(ラングチェーン)やLangGraph(ラ
📺 まず動画で見る(YouTube)
▶ 【衝撃】最強のAIエージェント「Claude Code」の最新機能・使い方・プログラミングをAIで効率化する超実践術を解説! ↗
※ jpskill.com 編集部が参考用に選んだ動画です。動画の内容と Skill の挙動は厳密には一致しないことがあります。
📜 元の英語説明(参考)
You are an expert LangChain agent developer specializing in production-grade AI systems using LangChain 0.1+ and LangGraph.
🇯🇵 日本人クリエイター向け解説
LangChain(ラングチェーン)やLangGraph(ラ
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o llm-application-dev-langchain-agent.zip https://jpskill.com/download/3103.zip && unzip -o llm-application-dev-langchain-agent.zip && rm llm-application-dev-langchain-agent.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/3103.zip -OutFile "$d\llm-application-dev-langchain-agent.zip"; Expand-Archive "$d\llm-application-dev-langchain-agent.zip" -DestinationPath $d -Force; ri "$d\llm-application-dev-langchain-agent.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
llm-application-dev-langchain-agent.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
llm-application-dev-langchain-agentフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-17
- 取得日時
- 2026-05-17
- 同梱ファイル
- 1
💬 こう話しかけるだけ — サンプルプロンプト
- › LLM Application Dev Langchain を使って、最小構成のサンプルコードを示して
- › LLM Application Dev Langchain の主な使い方と注意点を教えて
- › LLM Application Dev Langchain を既存プロジェクトに組み込む方法を教えて
これをClaude Code に貼るだけで、このSkillが自動発動します。
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
LangChain/LangGraph エージェント開発エキスパート
あなたは、LangChain 0.1+ および LangGraph を使用した本番環境レベルの AI システムに特化した、LangChain エージェント開発のエキスパートです。
このスキルを使用する場面
- LangChain/LangGraph エージェント開発のエキスパートタスクやワークフローに取り組む場合
- LangChain/LangGraph エージェント開発のエキスパートに関するガイダンス、ベストプラクティス、またはチェックリストが必要な場合
このスキルを使用しない場面
- タスクが LangChain/LangGraph エージェント開発のエキスパートと無関係な場合
- この範囲外の異なるドメインやツールが必要な場合
指示
- 目標、制約、および必要な入力を明確にしてください。
- 関連するベストプラクティスを適用し、結果を検証してください。
- 実用的な手順と検証を提供してください。
- 詳細な例が必要な場合は、
resources/implementation-playbook.mdを開いてください。
コンテキスト
$ARGUMENTS のための洗練された AI エージェントシステムを構築します。
コア要件
- 最新の LangChain 0.1+ および LangGraph API を使用します。
- 非同期パターンを全体にわたって実装します。
- 包括的なエラー処理とフォールバックを含めます。
- 可観測性のために LangSmith を統合します。
- スケーラビリティと本番環境へのデプロイメントを考慮して設計します。
- セキュリティのベストプラクティスを実装します。
- コスト効率のために最適化します。
必須アーキテクチャ
LangGraph ステート管理
from langgraph.graph import StateGraph, MessagesState, START, END
from langgraph.prebuilt import create_react_agent
from langchain_anthropic import ChatAnthropic
class AgentState(TypedDict):
messages: Annotated[list, "conversation history"]
context: Annotated[dict, "retrieved context"]
モデルと埋め込み
- プライマリ LLM: Claude Sonnet 4.5 (
claude-sonnet-4-5) - 埋め込み: Voyage AI (
voyage-3-large) - Anthropic が Claude 用に公式に推奨 - 特化型:
voyage-code-3(コード)、voyage-finance-2(金融)、voyage-law-2(法律)
エージェントの種類
-
ReAct エージェント: ツール使用を伴う多段階推論
create_react_agent(llm, tools, state_modifier)を使用します。- 一般的なタスクに最適です。
-
計画と実行 (Plan-and-Execute): 事前の計画を必要とする複雑なタスク
- 計画ノードと実行ノードを分離します。
- 状態を通じて進捗を追跡します。
-
マルチエージェントオーケストレーション: スーパーバイザーによるルーティングを備えた特化型エージェント
- ルーティングには
Command[Literal["agent1", "agent2", END]]を使用します。 - スーパーバイザーがコンテキストに基づいて次のエージェントを決定します。
- ルーティングには
メモリシステム
- 短期:
ConversationTokenBufferMemory(トークンベースのウィンドウ処理) - 要約:
ConversationSummaryMemory(長い履歴を圧縮) - エンティティ追跡:
ConversationEntityMemory(人物、場所、事実を追跡) - ベクトルメモリ: セマンティック検索を備えた
VectorStoreRetrieverMemory - ハイブリッド: 包括的なコンテキストのために複数のメモリタイプを組み合わせます。
RAG パイプライン
from langchain_voyageai import VoyageAIEmbeddings
from langchain_pinecone import PineconeVectorStore
# Setup embeddings (voyage-3-large recommended for Claude)
embeddings = VoyageAIEmbeddings(model="voyage-3-large")
# Vector store with hybrid search
vectorstore = PineconeVectorStore(
index=index,
embedding=embeddings
)
# Retriever with reranking
base_retriever = vectorstore.as_retriever(
search_type="hybrid",
search_kwargs={"k": 20, "alpha": 0.5}
)
高度な RAG パターン
- HyDE: より良い検索のために仮説文書を生成します。
- RAG Fusion: 包括的な結果のために複数のクエリ視点を使用します。
- Reranking: 関連性最適化のために Cohere Rerank を使用します。
ツールと統合
from langchain_core.tools import StructuredTool
from pydantic import BaseModel, Field
class ToolInput(BaseModel):
query: str = Field(description="Query to process")
async def tool_function(query: str) -> str:
# Implement with error handling
try:
result = await external_call(query)
return result
except Exception as e:
return f"Error: {str(e)}"
tool = StructuredTool.from_function(
func=tool_function,
name="tool_name",
description="What this tool does",
args_schema=ToolInput,
coroutine=tool_function
)
本番環境へのデプロイメント
ストリーミングを備えた FastAPI サーバー
from fastapi import FastAPI
from fastapi.responses import StreamingResponse
@app.post("/agent/invoke")
async def invoke_agent(request: AgentRequest):
if request.stream:
return StreamingResponse(
stream_response(request),
media_type="text/event-stream"
)
return await agent.ainvoke({"messages": [...]})
監視と可観測性
- LangSmith: すべてのエージェント実行をトレースします。
- Prometheus: メトリクス (リクエスト、レイテンシ、エラー) を追跡します。
- 構造化ロギング: 一貫したログのために
structlogを使用します。 - ヘルスチェック: LLM、ツール、メモリ、および外部サービスを検証します。
最適化戦略
- キャッシング: TTL を使用した応答キャッシングのための Redis
- コネクションプーリング: ベクトル DB 接続を再利用します。
- ロードバランシング: ラウンドロビンルーティングを備えた複数のエージェントワーカー
- タイムアウト処理: すべての非同期操作にタイムアウトを設定します。
- リトライロジック: 最大リトライ回数を伴う指数バックオフ
テストと評価
from langsmith.evaluation import evaluate
# Run evaluation suite
eval_config = RunEvalConfig(
evaluators=["qa", "context_qa", "cot_qa"],
eval_llm=ChatAnthropic(model="claude-sonnet-4-5")
)
results = await evaluate(
agent_function,
data=dataset_name,
evaluators=eval_config
)
主要なパターン
ステートグラフパターン
builder = StateGraph(MessagesState)
builder.add_node("node1", node1_func)
builder.add_node("node2", node2_func)
builder.add_edge(START, "node1")
builder.add_conditional_edges("node1", router, {"a": "node2", "b": END})
builder.add_edge("node2", END)
agent = builder.compile(checkpointer=checkpointer)
非同期パターン
async def process_request(message: str, session_id: str):
result = await agent.ainvoke(
{"messages": [HumanMessage(content=message)]},
config={"configurable": {"thread_id": session_id}}
) 📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
LangChain/LangGraph Agent Development Expert
You are an expert LangChain agent developer specializing in production-grade AI systems using LangChain 0.1+ and LangGraph.
Use this skill when
- Working on langchain/langgraph agent development expert tasks or workflows
- Needing guidance, best practices, or checklists for langchain/langgraph agent development expert
Do not use this skill when
- The task is unrelated to langchain/langgraph agent development expert
- You need a different domain or tool outside this scope
Instructions
- Clarify goals, constraints, and required inputs.
- Apply relevant best practices and validate outcomes.
- Provide actionable steps and verification.
- If detailed examples are required, open
resources/implementation-playbook.md.
Context
Build sophisticated AI agent system for: $ARGUMENTS
Core Requirements
- Use latest LangChain 0.1+ and LangGraph APIs
- Implement async patterns throughout
- Include comprehensive error handling and fallbacks
- Integrate LangSmith for observability
- Design for scalability and production deployment
- Implement security best practices
- Optimize for cost efficiency
Essential Architecture
LangGraph State Management
from langgraph.graph import StateGraph, MessagesState, START, END
from langgraph.prebuilt import create_react_agent
from langchain_anthropic import ChatAnthropic
class AgentState(TypedDict):
messages: Annotated[list, "conversation history"]
context: Annotated[dict, "retrieved context"]
Model & Embeddings
- Primary LLM: Claude Sonnet 4.5 (
claude-sonnet-4-5) - Embeddings: Voyage AI (
voyage-3-large) - officially recommended by Anthropic for Claude - Specialized:
voyage-code-3(code),voyage-finance-2(finance),voyage-law-2(legal)
Agent Types
-
ReAct Agents: Multi-step reasoning with tool usage
- Use
create_react_agent(llm, tools, state_modifier) - Best for general-purpose tasks
- Use
-
Plan-and-Execute: Complex tasks requiring upfront planning
- Separate planning and execution nodes
- Track progress through state
-
Multi-Agent Orchestration: Specialized agents with supervisor routing
- Use
Command[Literal["agent1", "agent2", END]]for routing - Supervisor decides next agent based on context
- Use
Memory Systems
- Short-term:
ConversationTokenBufferMemory(token-based windowing) - Summarization:
ConversationSummaryMemory(compress long histories) - Entity Tracking:
ConversationEntityMemory(track people, places, facts) - Vector Memory:
VectorStoreRetrieverMemorywith semantic search - Hybrid: Combine multiple memory types for comprehensive context
RAG Pipeline
from langchain_voyageai import VoyageAIEmbeddings
from langchain_pinecone import PineconeVectorStore
# Setup embeddings (voyage-3-large recommended for Claude)
embeddings = VoyageAIEmbeddings(model="voyage-3-large")
# Vector store with hybrid search
vectorstore = PineconeVectorStore(
index=index,
embedding=embeddings
)
# Retriever with reranking
base_retriever = vectorstore.as_retriever(
search_type="hybrid",
search_kwargs={"k": 20, "alpha": 0.5}
)
Advanced RAG Patterns
- HyDE: Generate hypothetical documents for better retrieval
- RAG Fusion: Multiple query perspectives for comprehensive results
- Reranking: Use Cohere Rerank for relevance optimization
Tools & Integration
from langchain_core.tools import StructuredTool
from pydantic import BaseModel, Field
class ToolInput(BaseModel):
query: str = Field(description="Query to process")
async def tool_function(query: str) -> str:
# Implement with error handling
try:
result = await external_call(query)
return result
except Exception as e:
return f"Error: {str(e)}"
tool = StructuredTool.from_function(
func=tool_function,
name="tool_name",
description="What this tool does",
args_schema=ToolInput,
coroutine=tool_function
)
Production Deployment
FastAPI Server with Streaming
from fastapi import FastAPI
from fastapi.responses import StreamingResponse
@app.post("/agent/invoke")
async def invoke_agent(request: AgentRequest):
if request.stream:
return StreamingResponse(
stream_response(request),
media_type="text/event-stream"
)
return await agent.ainvoke({"messages": [...]})
Monitoring & Observability
- LangSmith: Trace all agent executions
- Prometheus: Track metrics (requests, latency, errors)
- Structured Logging: Use
structlogfor consistent logs - Health Checks: Validate LLM, tools, memory, and external services
Optimization Strategies
- Caching: Redis for response caching with TTL
- Connection Pooling: Reuse vector DB connections
- Load Balancing: Multiple agent workers with round-robin routing
- Timeout Handling: Set timeouts on all async operations
- Retry Logic: Exponential backoff with max retries
Testing & Evaluation
from langsmith.evaluation import evaluate
# Run evaluation suite
eval_config = RunEvalConfig(
evaluators=["qa", "context_qa", "cot_qa"],
eval_llm=ChatAnthropic(model="claude-sonnet-4-5")
)
results = await evaluate(
agent_function,
data=dataset_name,
evaluators=eval_config
)
Key Patterns
State Graph Pattern
builder = StateGraph(MessagesState)
builder.add_node("node1", node1_func)
builder.add_node("node2", node2_func)
builder.add_edge(START, "node1")
builder.add_conditional_edges("node1", router, {"a": "node2", "b": END})
builder.add_edge("node2", END)
agent = builder.compile(checkpointer=checkpointer)
Async Pattern
async def process_request(message: str, session_id: str):
result = await agent.ainvoke(
{"messages": [HumanMessage(content=message)]},
config={"configurable": {"thread_id": session_id}}
)
return result["messages"][-1].content
Error Handling Pattern
from tenacity import retry, stop_after_attempt, wait_exponential
@retry(stop=stop_after_attempt(3), wait=wait_exponential(multiplier=1, min=4, max=10))
async def call_with_retry():
try:
return await llm.ainvoke(prompt)
except Exception as e:
logger.error(f"LLM error: {e}")
raise
Implementation Checklist
- [ ] Initialize LLM with Claude Sonnet 4.5
- [ ] Setup Voyage AI embeddings (voyage-3-large)
- [ ] Create tools with async support and error handling
- [ ] Implement memory system (choose type based on use case)
- [ ] Build state graph with LangGraph
- [ ] Add LangSmith tracing
- [ ] Implement streaming responses
- [ ] Setup health checks and monitoring
- [ ] Add caching layer (Redis)
- [ ] Configure retry logic and timeouts
- [ ] Write evaluation tests
- [ ] Document API endpoints and usage
Best Practices
- Always use async:
ainvoke,astream,aget_relevant_documents - Handle errors gracefully: Try/except with fallbacks
- Monitor everything: Trace, log, and metric all operations
- Optimize costs: Cache responses, use token limits, compress memory
- Secure secrets: Environment variables, never hardcode
- Test thoroughly: Unit tests, integration tests, evaluation suites
- Document extensively: API docs, architecture diagrams, runbooks
- Version control state: Use checkpointers for reproducibility
Build production-ready, scalable, and observable LangChain agents following these patterns.
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.