Skip to main content
skill Claude Code CX Codex Cursor GitHub Copilot

langgraph-fundamentals — skill for LangGraph: StateGraph, nodes, edges

Skill for writing LangGraph code across platforms. Covers StateGraph, state schemas, nodes, edges, Command, Send, invoke, streaming, and error handling.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add langchain-ai/langchain-skills --skill langgraph-fundamentals -a claude-code
Open on GitHub

What langgraph-fundamentals does

LangGraph models agent workflows as directed graphs. StateGraph is the main class for building stateful graph applications. Nodes are functions that perform work and update state; edges define execution order (static or conditional). Special START and END nodes mark entry and exit points, and state reducers control how updates are merged.

The skill provides a design methodology: sketch your workflow (each step becomes a node), identify what each step does, design your state schema as shared memory, implement nodes as functions returning partial updates, then wire nodes together with edges and conditional routing. Graphs must be compiled before execution.

For control flow, use add_edge() for fixed routing, add_conditional_edges() for state-based branching, Command to combine state updates and routing in one return, Send for parallel processing with dynamic inputs. When running, call invoke() for full execution or stream via stream() with modes values, updates, messages, or custom. For errors, use RetryPolicy for transient failures, ToolNode with handle_tool_errors for recoverable tool failures, interrupt() for user-fixable issues.

What it helps with

  • design a stateful graph workflow for an agent
  • implement conditional routing between nodes
  • manage accumulated state data using reducers
  • set up parallel processing across multiple workers
  • handle errors and transient failures in agents

Example prompts for the agent

  • Write a LangGraph agent with three nodes: search, analyze, and output. Use a conditional edge to route based on search result quality.
  • Show me how to use Send to distribute tasks across multiple parallel workers with a reducer to combine results.
  • Write an error handler that retries on network failure using RetryPolicy.

How to install langgraph-fundamentals

1Skills CLI (Vercel)

npx skills add langchain-ai/langchain-skills --skill langgraph-fundamentals -a claude-code

2Manually: put the files in place

~/.claude/skills/langgraph-fundamentals/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/langgraph-fundamentals/

From the same set14

The whole set →
deep-agents-memory langchain-ai A skill that maps where a Deep Agent keeps its files: thread state, a persistent store, or the real disk. Useful once the agent starts dropping context. Claude Code CX Codex Cursor +1 19,000installs langgraph-persistence langchain-ai A Claude Code skill for LangGraph persistence: wiring a checkpointer, keeping conversations apart by thread_id, and replaying older graph state. Claude Code CX Codex Cursor +1 18,000installs langchain-rag langchain-ai Equips coding agents with reference RAG implementations in Python and TypeScript using LangChain loaders, splitters, and vector stores. Claude Code CX Codex Cursor +1 17,500installs langchain-fundamentals langchain-ai Guides LangChain agent work with create_agent(), tools, and middleware. Use it when you need saved conversation state, approval flows, or error handling. Claude Code CX Codex Cursor +1 17,400installs langgraph-human-in-the-loop langchain-ai Skill for building LangGraph workflows that pause and wait for human input. Use it to show agent output, request approval, or validate user responses before continuing. Claude Code CX Codex Cursor +1 17,200installs langchain-middleware langchain-ai Adds middleware hooks for LangChain agents: pauses execution before dangerous tool calls, lets a human approve, edit or reject the action, intercepts calls for logging and retry logic. Claude Code CX Codex Cursor +1 16,200installs deep-agents-orchestration langchain-ai Guides setup of orchestration in Deep Agents: subagent delegation, todo planning, and human approval interrupts. Claude Code CX Codex Cursor +1 16,100installs langchain-dependencies langchain-ai Provides verified package versions and dependency rules for LangChain, LangGraph, and LangSmith. Helps set up clean Python or TypeScript projects without version conflicts. Claude Code CX Codex Cursor +1 16,000installs

Similar

ads-microsoft AgriciDaniel Audits Microsoft Ads, Bing Ads, UET, and audience network campaigns: measurement, conversions, Google imports, keywords, creative, bidding, and budgets. Read-only; use ads-optimize to make changes. Claude Code CX Codex Cursor +1 3,800installs pinchtab pinchtab This skill uses PinchTab to control browser sessions, inspect page controls, fill forms, and export page output. Use it when an agent needs to act through a browser. Claude Code CX Codex Cursor +1 892installs intelligence-docs CopilotKit A skill that keeps the CopilotKit Intelligence landing page aligned with new features and documentation. Automates updates to navigation, feature cards, and links whenever you add or change pages under docs/intelligence. Claude Code CX Codex Cursor +1 751installs rewardkit harbor-framework A skill for writing Harbor task verifiers with Reward Kit: programmatic criteria, LLM judges and a single reward score built from a tests/ directory. Claude Code CX Codex Cursor +1 1,300installs loopy Forward-Future Discovers recurring engineering work, turns it into bounded agent loops, and audits feedback cycles with strict stopping conditions. Claude Code CX Codex Cursor +1 3,100installs skill-forge sanyuan0704 A skill for building production-grade skills in Claude Code. Walks you through eight stages: from understanding the task to packaging, with checklists, iron laws, and writing techniques for reliable prompts. Claude Code CX Codex Cursor +1 4,100installs setup-matt-pocock-skills Matt Pocock This skill configures a repository for Matt Pocock's engineering skills by setting its issue tracker, triage labels, and domain docs layout. Run it before using the other skills. Claude Code 1,052,851installs to-tickets Matt Pocock Turns a plan, spec, or conversation into small end-to-end tickets with explicit blockers. Use it to agree on the work breakdown before tickets go to a tracker. Claude Code 711,230installs

Questions about langgraph-fundamentals

How do I install langgraph-fundamentals in Claude Code?

Run npx skills add langchain-ai/langchain-skills --skill langgraph-fundamentals -a claude-code, then find the skill at ~/.claude/skills/langgraph-fundamentals/SKILL.md.

What does langgraph-fundamentals do?

The skill provides design methodology and patterns for building LangGraph workflows: state management, nodes, edges, routing, parallel processing, and error handling.

What is the difference between Command and Send?

Command combines state updates and routing in a single node return. Send is for parallel processing: you return a list of Send objects to spawn multiple workers with dynamic inputs.

Source text

SKILL.md · MIT
---
name: langgraph-fundamentals
description: "INVOKE THIS SKILL when writing ANY LangGraph code. Covers StateGraph, state schemas, nodes, edges, Command, Send, invoke, streaming, and error handling."
---

<overview>
LangGraph models agent workflows as **directed graphs**:

- **StateGraph**: Main class for building stateful graphs
- **Nodes**: Functions that perform work and update state
- **Edges**: Define execution order (static or conditional)
- **START/END**: Special nodes marking entry and exit points
- **State with Reducers**: Control how state updates are merged

Graphs must be `compile()`d before execution.
</overview>

<design-methodology>

### Designing a LangGraph application

Follow these 5 steps when building a new graph:

1. **Map out discrete steps** — sketch a flowchart of your workflow. Each step becomes a node.
2. **Identify what each step does** — categorize nodes: LLM step, data step, action step, or user input step. For each, determine static context (prompt), dynamic context (from state), retry strategy, and desired outcome.
3. **Design your state** — state is shared memory for all nodes. Store raw data, format prompts on-demand inside nodes.
4. **Build your nodes** — implement each step as a function that takes state and returns partial updates.
5. **Wire it together** — connect nodes with edges, add conditional routing, compile with a checkpointer if needed.

</design-methodology>

<when-to-use-langgraph>

| Use LangGraph When | Use Alternatives When |
|-------------------|----------------------|
| Need fine-grained control over agent orchestration | Quick prototyping → LangChain agents |
| Building complex workflows with branching/loops | Simple stateless workflows → LangChain direct |
| Require human-in-the-loop, persistence | Batteries-included features → Deep Agents |

</when-to-use-langgraph>

---

## State Management

<state-update-strategies>

| Need | Solution | Example |
|------|----------|---------|
| Overwrite value | No reducer (default) | Simple fields like counters |
| Append to list | Reducer (operator.add / concat) | Message history, logs |
| Custom logic | Custom reducer function | Complex merging |

</state-update-strategies>

---

## Nodes

<node-function-signatures>

Node functions return partial state updates. Signatures for configuration and runtime access differ by language; use the applicable implementation reference.

</node-function-signatures>

---

## Edges

<edge-type-selection>

| Need | Edge Type | When to Use |
|------|-----------|-------------|
| Always go to same node | `add_edge()` | Fixed, deterministic flow |
| Route based on state | `add_conditional_edges()` | Dynamic branching |
| Update state AND route | `Command` | Combine logic in single node |
| Fan-out to multiple nodes | `Send` | Parallel processing with dynamic inputs |

</edge-type-selection>

---

## Command

Command combines state updates and routing in a single return value. Fields:
- **`update`**: State updates to apply (like returning a dict from a node)
- **`goto`**: Node name(s) to navigate to next
- **`resume`**: Value to resume after `interrupt()` — see human-in-the-loop skill

<command-return-type-annotations>

**Python**: Use `Command[Literal["node_a", "node_b"]]` as the return type annotation to declare valid goto destinations.

**TypeScript**: Pass `{ ends: ["node_a", "node_b"] }` as the third argument to `addNode` to declare valid goto destinations.

</command-return-type-annotations>

<warning-command-static-edges>

**Warning**: `Command` only adds **dynamic** edges — static edges defined with `add_edge` / `addEdge` still execute. If `node_a` returns `Command(goto="node_c")` and you also have `graph.add_edge("node_a", "node_b")`, **both** `node_b` and `node_c` will run.

</warning-command-static-edges>

---

## Send API

Fan-out with `Send`: return `[Send("worker", {...})]` from a conditional edge to spawn parallel workers. Requires a reducer on the results field.

---

## Running Graphs: Invoke and Stream

<invoke-basics>

Call `graph.invoke(input, config)` to run a graph to completion and return the final state.

</invoke-basics>

<stream-mode-selection>

| Mode | What it Streams | Use Case |
|------|----------------|----------|
| `values` | Full state after each step | Monitor complete state |
| `updates` | State deltas | Track incremental updates |
| `messages` | LLM tokens + metadata | Chat UIs |
| `custom` | User-defined data | Progress indicators |

</stream-mode-selection>

---

## Error Handling

Match the error type to the right handler:

<error-handling-table>

| Error Type | Who Fixes | Strategy | Example |
|---|---|---|---|
| Transient (network, rate limits) | System | `RetryPolicy(max_attempts=3)` | `add_node(..., retry_policy=...)` |
| LLM-recoverable (tool failures) | LLM | `ToolNode(tools, handle_tool_errors=True)` | Error returned as ToolMessage |
| User-fixable (missing info) | Human | `interrupt({"message": ...})` | Collect missing data (see HITL skill) |
| Unexpected | Developer | Let bubble up | `raise` |

</error-handling-table>

---

## Core boundaries

- Return partial state updates from nodes instead of mutating state directly.
- Route loops through a named node; `START` is entry-only.
- Define reducers for accumulated list fields; otherwise, the last write wins.
- Account for static edges when using `Command` with `goto`, because both routes execute.

## Implementation references

If writing, modifying, or debugging LangGraph code, determine the project's language from its existing files, then read the applicable reference before implementing:

- For Python, read [references/python.md](references/python.md).
- For TypeScript, read [references/typescript.md](references/typescript.md).

Read both only when the task covers both languages. For conceptual questions that require no code, do not load either reference.

© langchain-ai · MIT · langchain-ai/langchain-skills

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor