langchain
Skill11 starsChanged 4 months agoMITView on GitHub
Build AI agents with LangChain framework. Use when building agents, tools, memory, MCP integrations, RAG pipelines, multi-agent systems, or any LLM-powered applications using LangChain or LangGraph in Python or TypeScript.
- Installs packages
8 other projects use a version of this.
Adopted by
Most recently taken up by
- langchain-ai/docstheir own version, first seen Sep 15, 2026
- Zephyrex21/claude-skills-vettedtheir own version, first seen Aug 9, 2026
- magnus919/agent-skillstheir own version, first seen Jul 21, 2026
- sordi-ai/skill-everythingtheir own version, first seen May 13, 2026
- dekoza/oh-my-sloptheir own version, first seen Mar 19, 2026
- Clay-HHK/claude-skillstheir own version, first seen Mar 5, 2026
Used with
Projects with it also use docker.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
akornmeierSkilldocker
Guide for using Docker - a containerization platform for building, running, and deploying applications in isolated containers. Use when containerizing applications, creating Dockerfiles, working with Docker Compose, managing images/containers, configuring networking and storage, optimizing builds, deploying to production, or implementing CI/CD pipelines with Docker.
Also in 3 projects that use this
Other versions8 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 8
- langchain-ai/docs★ 424same name
- hoodini/ai-agents-skills★ 281same name
- magnus919/agent-skills★ 109same name
- sordi-ai/skill-everything★ 20same name
- dekoza/oh-my-slop★ 4same name
- Makiya1202/ai-agents-skills★ 2same name
- Zephyrex21/claude-skills-vetted★ 2same name
- Clay-HHK/claude-skills★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository15 other files it gives its agents.
- AGENTS.mdAGENTS.md
- skills/genai-tk-skill/references/agents.mdAGENTS.md
- adaption-aiSkill
- api-designSkill
- database-designSkill
- dddSkill
- genai-tkSkill
- microservices-patternsSkill
- performance-optimizationSkill
- scalingoSkill
- security-best-practicesSkill
- smolagentsSkill
- testing-patternsSkill
- uiSkill
- unsloth-hf-jobsSkill
The file
Files
LangChain Skill
Build production AI agents using LangChain's pre-built architecture and integrations.
Installation
pip install langchain langchain-anthropic langgraph
# For MCP support
pip install langchain-mcp-adaptersQuick Agent
from langchain.agents import create_agent
from langchain.tools import tool
@tool
def get_weather(city: str) -> str:
"""Get weather for a city."""
return f"Sunny in {city}!"
agent = create_agent(
model="claude-sonnet-4-5-20250929",
tools=[get_weather],
system_prompt="You are a helpful assistant"
)
result = agent.invoke({"messages": [{"role": "user", "content": "Weather in SF?"}]})Tools
Define tools with @tool decorator. Type hints required, docstring becomes description:
from langchain.tools import tool, ToolRuntime
from dataclasses import dataclass
@tool
def search(query: str, limit: int = 10) -> str:
"""Search database for records."""
return f"Found {limit} results for '{query}'"
# With runtime context access
@dataclass
class Context:
user_id: str
@tool
def get_user_data(runtime: ToolRuntime[Context]) -> str:
"""Get current user data."""
user_id = runtime.context.user_id
return f"Data for {user_id}"ToolRuntime Access
runtime.state- Agent state (messages, custom fields)runtime.context- Immutable config (user_id, session)runtime.store- Persistent memory across conversationsruntime.stream_writer- Stream updates during execution
Reserved Parameters
Cannot use as tool args: config, runtime
Memory
from langgraph.checkpoint.memory import InMemorySaver
from langgraph.store.memory import InMemoryStore
# Short-term (conversation) memory
checkpointer = InMemorySaver()
# Long-term (cross-conversation) memory
store = InMemoryStore()
agent = create_agent(
model="claude-sonnet-4-5-20250929",
tools=[...],
checkpointer=checkpointer,
store=store
)
# Use thread_id for conversation continuity
config = {"configurable": {"thread_id": "conversation-1"}}
agent.invoke({"messages": [...]}, config=config)Structured Output
from dataclasses import dataclass
from langchain.agents.structured_output import ToolStrategy
@dataclass
class Response:
answer: str
confidence: float | None = None
agent = create_agent(
model="claude-sonnet-4-5-20250929",
tools=[...],
response_format=ToolStrategy(Response)
)
# Access: result['structured_response']MCP Integration
Connect to MCP servers for external tools:
from langchain_mcp_adapters.client import MultiServerMCPClient
from langchain.agents import create_agent
client = MultiServerMCPClient({
"math": {
"transport": "stdio",
"command": "python",
"args": ["/path/to/server.py"]
},
"api": {
"transport": "http",
"url": "http://localhost:8000/mcp",
"headers": {"Authorization": "Bearer TOKEN"}
}
})
tools = await client.get_tools()
agent = create_agent("claude-sonnet-4-5-20250929", tools)MCP Interceptors
Modify tool calls, inject context, handle errors:
from langchain_mcp_adapters.interceptors import MCPToolCallRequest
async def auth_interceptor(request: MCPToolCallRequest, handler):
runtime = request.runtime
user_id = runtime.context.user_id
modified = request.override(args={**request.args, "user_id": user_id})
return await handler(modified)
client = MultiServerMCPClient({...}, tool_interceptors=[auth_interceptor])Model Configuration
from langchain.chat_models import init_chat_model
model = init_chat_model(
"claude-sonnet-4-5-20250929", # or "gpt-4o", "gemini-1.5-pro"
temperature=0.5,
timeout=10,
max_tokens=1000
)State Updates from Tools
Return Command to update state or control flow:
from langgraph.types import Command
from langchain.messages import RemoveMessage
@tool
def clear_history() -> Command:
"""Clear conversation."""
return Command(update={"messages": [RemoveMessage(id="__all__")]})
@tool
def complete_task() -> Command:
"""End agent run."""
return Command(update={"status": "done"}, goto="__end__")Common Patterns
Full Production Agent
from dataclasses import dataclass
from langchain.agents import create_agent
from langchain.chat_models import init_chat_model
from langchain.tools import tool, ToolRuntime
from langchain.agents.structured_output import ToolStrategy
from langgraph.checkpoint.memory import InMemorySaver
@dataclass
class Context:
user_id: str
@tool
def search_orders(query: str, runtime: ToolRuntime[Context]) -> str:
"""Search user orders."""
return f"Orders for {runtime.context.user_id}: {query}"
@dataclass
class Response:
answer: str
order_ids: list[str] | None = None
agent = create_agent(
model=init_chat_model("claude-sonnet-4-5-20250929", temperature=0),
system_prompt="You are a customer service agent.",
tools=[search_orders],
context_schema=Context,
response_format=ToolStrategy(Response),
checkpointer=InMemorySaver()
)
result = agent.invoke(
{"messages": [{"role": "user", "content": "Find my recent orders"}]},
config={"configurable": {"thread_id": "session-1"}},
context=Context(user_id="user123")
)Anti-Patterns to Avoid
- Tools without type hints or docstrings — the docstring is the tool description the model sees; a missing or vague one means the agent misuses the tool
- Global state in tools — tools that read globals instead of
ToolRuntime[Context]are untestable and unsafe in concurrent runs - No checkpointer, then wondering why the agent forgets — multi-turn agents need
checkpointer=InMemorySaver()(or a persistent saver) plus a stablethread_id - Rebuilding everything as one giant system prompt — tools, structured output (
ToolStrategy/with_structured_output), and retrieval exist to keep prompts small - Letting raw tool exceptions reach the model — wrap tools, catch, and return structured error strings so the agent can recover
- Using deprecated
LLMChain/SequentialChainAPIs — current LangChain builds oncreate_agentand LangGraph; the old chains are removed from recent versions - Stuffing whole documents into context — use the retrieval patterns in retrieval.md instead of naive full-document injection
When to Use / Not Use
Use this skill when:
- Building agents with LangChain or LangGraph (Python or TypeScript)
- Wiring tools, memory, MCP servers, or structured output into an LLM app
- Implementing RAG, multi-agent handoffs, routers, or stateful workflows
Do NOT use this skill when:
- A single stateless LLM call is all you need — the plain provider SDK is lighter
- The project standardizes on another agent framework (e.g., smolagents) — follow the project's stack
- The agent is code-first and benefits from the smaller SmolAgents execution model — see the smolagents skill
References
For detailed patterns, see:
references/langgraph.md- LangGraph workflows, graphs, persistencereferences/multi-agent.md- Handoffs, routers, subagentsreferences/retrieval.md- RAG, vector stores, embeddings
Key Links
- Docs: https://docs.langchain.com
- Python SDK: https://reference.langchain.com/python
- LangGraph: https://docs.langchain.com/oss/python/langgraph
- MCP Adapters: https://github.com/langchain-ai/langchain-mcp-adapters
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

