Skip to content
building-langgraph-agents logo

LangGraph Development Skill

building-langgraph-agents

LangGraph development for stateful multi-agent applications, cyclic workflows, conditional routing, human-in-the-loop patterns, and persistent state management. Use for complex AI orchestration, agent coordination, and production-grade agentic systems.

SKILL.md

Full skill instructions

LangGraph Development Skill

Quick Reference

LangGraph is LangChain's framework for building stateful, multi-actor applications with LLMs. It enables cyclic graphs, conditional branching, persistent state management, and human-in-the-loop workflows.

Key capabilities: StateGraph for workflow orchestration, checkpointers for persistence, prebuilt ReAct agents, streaming at multiple granularities, and LangGraph Platform for managed deployment.


Table of Contents

  1. When to Use
  2. Package Ecosystem
  3. Quick Start - Python
  4. Quick Start - TypeScript
  5. Core Concepts
  6. Prebuilt Components
  7. Common Patterns
  8. Quick Persistence Setup
  9. CLI Commands
  10. Error Quick Reference
  11. When to Use REFERENCE.md
  12. Agent Integration
  13. See Also

When to Use

This skill is loaded by backend-developer when:

  • langgraph in requirements.txt, pyproject.toml, or setup.py
  • @langchain/​langgraph in package.json dependencies
  • Python imports: from langgraph.graph import StateGraph
  • Environment variables LANGSMITH_API_KEY, LANGGRAPH_API_URL, or LANGCHAIN_API_KEY present
  • User mentions "LangGraph", "StateGraph", "agent workflow", "cyclic agent", or "multi-agent graph"

Package Ecosystem

PackageDescription
langgraphCore StateGraph, MessageGraph, prebuilt components
langgraph-checkpoint-postgresPostgreSQL checkpointer for production
langgraph-checkpoint-sqliteSQLite checkpointer with async support
langgraph-sdkPython client for LangGraph Platform API
@langchain/​langgraphTypeScript/​JavaScript implementation

Compatibility: LangGraph 0.2.x requires langchain-core>=0.3.0.


Quick Start - Python

"""LangGraph Quick Start - Python"""
from langgraph.graph import StateGraph, START, END
from typing import TypedDict

# 1. Define state schema
class State(TypedDict):
    messages: list[str]
    count: int

# 2. Define node functions
def process(state: State) -> dict:
    """Process node - increments counter."""
    return {"count": state["count"] + 1}

def respond(state: State) -> dict:
    """Response node - adds message to state."""
    return {"messages": state["messages"] + [f"Processed {state['count']} times"]}

# 3. Build graph
graph = StateGraph(State)
graph.add_node("process", process)
graph.add_node("respond", respond)

graph.add_edge(START, "process")
graph.add_edge("process", "respond")
graph.add_edge("respond", END)

# 4. Compile and run
app = graph.compile()
result = app.invoke({"messages": [], "count": 0})
# {'messages': ['Processed 1 times'], 'count': 1}

With LLM and Tools

"""LangGraph with ChatOpenAI and tools."""
from langgraph.graph import StateGraph, START, MessagesState
from langgraph.prebuilt import ToolNode, tools_condition
from langchain_openai import ChatOpenAI
from langchain_core.tools import tool

@tool
def get_weather(city: str) -> str:
    """Get weather for a city."""
    return f"Weather in {city}: 72F, sunny"

llm = ChatOpenAI(model="gpt-4o")
tools = [get_weather]
llm_with_tools = llm.bind_tools(tools)

def agent(state: MessagesState) -> dict:
    response = llm_with_tools.invoke(state["messages"])
    return {"messages": [response]}

graph = StateGraph(MessagesState)
graph.add_node("agent", agent)
graph.add_node("tools", ToolNode(tools))

graph.add_edge(START, "agent")
graph.add_conditional_edges("agent", tools_condition)
graph.add_edge("tools", "agent")

app = graph.compile()
result = app.invoke({"messages": [("user", "What's the weather in NYC?")]})

Quick Start - TypeScript

import { StateGraph, START, END, Annotation } from "@langchain/​langgraph";

const State = Annotation.Root({
  messages: Annotation<string[]>({
    default: () => [],
    reducer: (curr, update) => [...curr, ...update],
  }),
  count: Annotation<number>({ default: () => 0 }),
});

const process = (state: typeof State.State) => ({
  count: state.count + 1,
});

const respond = (state: typeof State.State) => ({
  messages: [`Processed ${state.count} times`],
});

const graph = new StateGraph(State)
  .addNode("process", process)
  .addNode("respond", respond)
  .addEdge(START, "process")
  .addEdge("process", "respond")
  .addEdge("respond", END);

const app = graph.compile();
const result = await app.invoke({ messages: [], count: 0 });

Core Concepts

StateGraph

The core abstraction - a directed graph where nodes read and write to shared state.

from langgraph.graph import StateGraph

graph = StateGraph(State)  # State is a TypedDict

State Schema

Defines the shape of data flowing through the graph.

from typing import TypedDict, Annotated
from langgraph.graph import add_messages

class State(TypedDict):
    messages: Annotated[list, add_messages]  # With reducer
    context: str                              # Simple overwrite

Nodes

Functions that receive state and return partial updates.

def my_node(state: State) -> dict:
    return {"context": f"{state['context']} - processed"}

Edges

Connections between nodes - unconditional or conditional.

# Unconditional
graph.add_edge("node_a", "node_b")

# Conditional
graph.add_conditional_edges("router", routing_function)

Special Nodes

NodePurpose
STARTEntry point of the graph
ENDTerminal node, execution stops

Prebuilt Components

ComponentImportPurpose
create_react_agentlanggraph.prebuiltFull ReAct agent with tool loop
ToolNodelanggraph.prebuiltExecute tools from AI messages
tools_conditionlanggraph.prebuiltRoute: tools called vs end
MessagesStatelanggraph.graphPrebuilt chat state schema

create_react_agent

from langgraph.prebuilt import create_react_agent
from langchain_openai import ChatOpenAI
from langchain_core.tools import tool

@tool
def search(query: str) -> str:
    """Search the web."""
    return f"Results for: {query}"

llm = ChatOpenAI(model="gpt-4o")
agent = create_react_agent(llm, [search])
result = agent.invoke({"messages": [("user", "Search for LangGraph")]})

Common Patterns

Linear Pipeline

graph.add_edge(START, "extract")
graph.add_edge("extract", "transform")
graph.add_edge("transform", "load")
graph.add_edge("load", END)

Conditional Routing

def router(state: State) -> str:
    if state["intent"] == "search":
        return "search_node"
    return "default_node"

graph.add_conditional_edges("classifier", router)

Cycle with Exit

def check_done(state):
    return END if state["done"] else "process"

graph.add_edge(START, "process")
graph.add_edge("process", "check")
graph.add_conditional_edges("check", check_done)

Quick Persistence Setup

from langgraph.checkpoint.memory import MemorySaver

# Development - in-memory (lost on restart)
memory = MemorySaver()
app = graph.compile(checkpointer=memory)

config = {"configurable": {"thread_id": "user-123"}}
result = app.invoke({"messages": [("user", "Hi")]}, config)

For production persistence, see REFERENCE.md for PostgreSQL/​SQLite setup.


CLI Commands

# Install
pip install langgraph langgraph-checkpoint-postgres

# Verify
python -c "import langgraph; print(langgraph.__version__)"

# LangGraph Platform
langgraph init      # Initialize project
langgraph dev       # Start dev server
langgraph build     # Build for deployment
langgraph up        # Deploy with Docker

Environment Variables

export LANGSMITH_API_KEY="ls-..."
export LANGCHAIN_TRACING_V2="true"
export OPENAI_API_KEY="sk-..."

Error Quick Reference

ErrorSolution
InvalidUpdateErrorNode returned keys not in state schema
GraphRecursionErrorAdd exit condition or increase recursion_limit
ValueError: Checkpointer requiredAdd checkpointer to compile() for thread ops

When to Use REFERENCE.md

Load REFERENCE.md for:

  • Full checkpointer setup (PostgreSQL, SQLite, async)
  • Human-in-the-loop patterns with interrupts
  • Multi-agent patterns (supervisor, hierarchical)
  • Streaming modes and event handling
  • Subgraph composition
  • Production deployment with LangGraph Platform
  • Tool integration patterns
  • Time travel debugging
  • Best practices and anti-patterns

Agent Integration

AgentUse Case
backend-developerGraph implementation, state design
deep-debuggerExecution issues, state bugs
tech-lead-orchestratorMulti-agent architecture
code-reviewerGraph logic review

See Also


Progressive Disclosure: Start here for quick implementation. Load REFERENCE.md for comprehensive patterns, production setup, and advanced features.

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View