
Langchain Fundamentals
Scaffold production LangChain agents with create_agent(), @tool definitions, checkpointers, and middleware for HITL and errors.
Overview
langchain-fundamentals is an agent skill for the Build phase that teaches production LangChain agents via create_agent(), tools, checkpointers, and middleware.
Install
npx skills add https://github.com/langchain-ai/langchain-skills --skill langchain-fundamentalsWhat is this skill?
- Mandates create_agent() as the current agent entrypoint (older patterns treated as outdated)
- Configuration table covers model, tools, system_prompt, checkpointer, and middleware
- @tool decorator pattern with typed docstrings for agent-callable functions
- Human-in-the-loop and error-handling via middleware hooks (Python and TypeScript names in doc)
- MemorySaver-style checkpointer for persisted agent state
- Agent configuration table documents 5 parameters: model, tools, system_prompt, checkpointer, middleware
Adoption & trust: 8.3k installs on skills.sh; 782 GitHub stars; 2/3 security scanners passed (skills.sh audits); trending (+100% hot-view momentum).
What problem does it solve?
You are wiring an LLM agent but scattered LangChain examples leave you on deprecated APIs without a clear tool and middleware layout.
Who is it for?
Solo builders implementing LangChain agents in Python or TypeScript who want one enforced pattern before adding RAG or shipping.
Skip if: Teams only needing raw chat completions with no tools, or projects standardized on non-LangChain frameworks only.
When should I use this skill?
Creating or refactoring LangChain agents and you need create_agent(), tools, and middleware patterns.
What do I get? / Deliverables
You get a create_agent()-based agent with defined tools, optional persistence, and middleware slots for human-in-the-loop and error handling.
- create_agent() agent module with tool definitions
- Middleware and checkpointer configuration snippets
Recommended Skills
Journey fit
Agent frameworks and tool wiring are core Build work when you turn an LLM idea into runnable product behavior. agent-tooling is the canonical shelf for LangChain loop, tools, and middleware—not generic app CRUD.
How it compares
Opinionated LangChain agent bootstrap—not a generic prompt pack or an MCP server catalog.
Common Questions / FAQ
Who is langchain-fundamentals for?
Indie developers and small teams building tool-using LangChain agents who want create_agent() and middleware spelled out in one skill.
When should I use langchain-fundamentals?
Use it during Build agent-tooling when you start a new agent, refactor off old LangChain APIs, or add HITL and checkpointers to an existing flow.
Is langchain-fundamentals safe to install?
It is documentation-oriented; check this page’s Security Audits panel and review any generated code that calls shell, network, or secret-bearing tools.
SKILL.md
READMESKILL.md - Langchain Fundamentals
<oneliner> Build production agents using `create_agent()`, middleware patterns, and the `@tool` decorator / `tool()` function. When creating LangChain agents, you MUST use create_agent(), with middleware for custom flows. All other alternatives are outdated. </oneliner> <create_agent> ## Creating Agents with create_agent `create_agent()` is the recommended way to build agents. It handles the agent loop, tool execution, and state management. ### Agent Configuration Options | Parameter | Purpose | Example | |-----------|---------|---------| | `model` | LLM to use | `"anthropic:claude-sonnet-4-5"` or model instance | | `tools` | List of tools | `[search, calculator]` | | `system_prompt` / `systemPrompt` | Agent instructions | `"You are a helpful assistant"` | | `checkpointer` | State persistence | `MemorySaver()` | | `middleware` | Processing hooks | `[HumanInTheLoopMiddleware]` (Python) / `[humanInTheLoopMiddleware({...})]` (TypeScript) | </create_agent> <ex-basic-agent> <python> ```python from langchain.agents import create_agent from langchain_core.tools import tool @tool def get_weather(location: str) -> str: """Get current weather for a location. Args: location: City name """ return f"Weather in {location}: Sunny, 72F" agent = create_agent( model="anthropic:claude-sonnet-4-5", tools=[get_weather], system_prompt="You are a helpful assistant." ) result = agent.invoke({ "messages": [{"role": "user", "content": "What's the weather in Paris?"}] }) print(result["messages"][-1].content) ``` </python> <typescript> ```typescript import { createAgent } from "langchain"; import { tool } from "@langchain/core/tools"; import { z } from "zod"; const getWeather = tool( async ({ location }) => `Weather in ${location}: Sunny, 72F`, { name: "get_weather", description: "Get current weather for a location.", schema: z.object({ location: z.string().describe("City name") }), } ); const agent = createAgent({ model: "anthropic:claude-sonnet-4-5", tools: [getWeather], systemPrompt: "You are a helpful assistant.", }); const result = await agent.invoke({ messages: [{ role: "user", content: "What's the weather in Paris?" }], }); console.log(result.messages[result.messages.length - 1].content); ``` </typescript> </ex-basic-agent> <ex-agent-with-persistence> <python> Add MemorySaver checkpointer to maintain conversation state across invocations. ```python from langchain.agents import create_agent from langgraph.checkpoint.memory import MemorySaver checkpointer = MemorySaver() agent = create_agent( model="anthropic:claude-sonnet-4-5", tools=[search], checkpointer=checkpointer, ) config = {"configurable": {"thread_id": "user-123"}} agent.invoke({"messages": [{"role": "user", "content": "My name is Alice"}]}, config=config) result = agent.invoke({"messages": [{"role": "user", "content": "What's my name?"}]}, config=config) # Agent remembers: "Your name is Alice" ``` </python> <typescript> Add MemorySaver checkpointer to maintain conversation state across invocations. ```typescript import { createAgent } from "langchain"; import { MemorySaver } from "@langchain/langgraph"; const checkpointer = new MemorySaver(); const agent = createAgent({ model: "anthropic:claude-sonnet-4-5", tools: [search], checkpointer, }); const config = { configurable: { thread_id: "user-123" } }; await agent.invoke({ messages: [{ role: "user", content: "My name is Alice" }] }, config); const result = await agent.invoke({ messages: [{ role: "user", content: "What's my name?" }] }, config); // Agent remembers: "Your name is Alice" ``` </typescript> </ex-agent-with-persistence> <tools> ## Defining Tools Tools are functions that agents can call. Use the `@tool` decorator (Python) or `tool()` function (TypeScript). <