
Langgraph Fundamentals
Invoke whenever you write or refactor LangGraph code so StateGraph, reducers, edges, Command, Send, compile, invoke, streaming, and errors follow the canonical patterns.
Overview
langgraph-fundamentals is an agent skill most often used in Build (also Ship, Operate) that teaches correct LangGraph patterns—StateGraph, state, nodes, edges, compile, invoke, streaming, and errors—for any agent workflo
Install
npx skills add https://github.com/langchain-ai/langchain-skills --skill langgraph-fundamentalsWhat is this skill?
- 5-step design methodology: map steps, categorize nodes, design state, build nodes, wire edges and compile
- Covers StateGraph, START/END, nodes, static and conditional edges, and state schemas with reducers
- Documents Command, Send, invoke, streaming, and error-handling patterns before production graphs
- Explicit compile() requirement and checkpointer guidance for stateful runs
- When-to-use table contrasts LangGraph vs alternatives for workflow choice
- 5-step methodology for designing LangGraph applications
- Graphs must be compile()d before execution
Adoption & trust: 8.6k installs on skills.sh; 782 GitHub stars; 3/3 security scanners passed (skills.sh audits); trending (+100% hot-view momentum).
What problem does it solve?
You are writing LangGraph agents without a consistent model for state, routing, and execution, so graphs fail at compile time or behave unpredictably in production.
Who is it for?
Indie builders implementing multi-step agents, human-in-the-loop flows, or durable workflows who want one skill invoked on every LangGraph touch.
Skip if: Simple single-shot LLM calls with no graph, or teams committed to non-LangGraph orchestration only—skip until you adopt StateGraph.
When should I use this skill?
INVOKE THIS SKILL when writing ANY LangGraph code.
What do I get? / Deliverables
You ship graphs that compile, route correctly with Command/Send where needed, and handle invoke, stream, and errors using the documented five-step design flow.
- StateGraph design aligned with nodes/edges/state schema
- Implementable node functions and compile-ready graph structure
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
Primary shelf is Build → agent-tooling because LangGraph is the orchestration layer for agent products under active development. Agent-tooling is where graph design, nodes, and checkpointers belong—not generic backend CRUD or frontend UI work.
Where it fits
Sketch a support triage graph with LLM and action nodes before coding the StateGraph.
Add streaming and error-handling nodes so staging runs match production invoke semantics.
Insert a new conditional edge without breaking existing reducer merge rules on shared state.
How it compares
Procedural LangGraph reference skill, not a hosted runtime or LangSmith substitute—pair with dependency and observability skills separately.
Common Questions / FAQ
Who is langgraph-fundamentals for?
Solo and small-team developers building LangGraph-based agents in Python who need enforced patterns whenever graph code is written or changed.
When should I use langgraph-fundamentals?
At build when designing a new graph; at ship when hardening invoke/stream/error paths; at operate when extending nodes without breaking reducers or checkpointers.
Is langgraph-fundamentals safe to install?
It is documentation-style guidance; check this page's Security Audits panel and pin LangGraph versions via langchain-dependencies before running untrusted graph code.
Workflow Chain
Requires first: langchain dependencies
SKILL.md
READMESKILL.md - Langgraph Fundamentals
<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> <ex-state-with-reducer> <python> Define state schema with reducers for accumulating lists and summing integers. ```python from typing_extensions import TypedDict, Annotated import operator class State(TypedDict): name: str # Default: overwrites on update messages: Annotated[list, operator.add] # Appends to list total: Annotated[int, operator.add] # Sums integers ``` </python> <typescript> Use StateSchema with ReducedValue for accumulating arrays. ```typescript import { StateSchema, ReducedValue, MessagesValue } from "@langchain/langgraph"; import { z } from "zod"; const State = new StateSchema({ name: z.string(), // Default: overwrites messages: MessagesValue, // Built-in for messages items: new ReducedValue( z.array(z.string()).default(() => []), { reducer: (current, update) => current.concat(update) } ), }); ``` </typescript> </ex-state-with-reducer> <fix-forgot-reducer-for-list> <python> Without a reducer, returning a list overwrites previous values. ```python # WRONG: List will be OVERWRITTEN class State(TypedDict): messages: list # No reducer! # Node 1 returns: {"messages": ["A"]} # Node 2 returns: {"messages": ["B"]} # Final: {"messages": ["B"]} # "A" is LOST! # CORRECT: Use Annotated with operator.add from typing import Annotated import operator class State(TypedDict): messages: Annotated[list, operator.add] # Final: {"messages": ["A", "B"]} ``` </python> <typescript> Without ReducedValue, arrays are overwritten not appended. ```typescript // WRONG: Array will be overwritten const State = new StateSchema({ items: z.array(z.string()), // No reducer! }); // Node 1: { items: ["A"] }, Node 2: { items: ["B"] } // Final: { items: ["B"] } // A is lost! // CORRECT: Use ReducedValue const State = new StateSc