Tooluck logoTooluck
SKILL.md

langgraph-persistence

Agent skill fromlangchain-ai/langchain-skills

INVOKE THIS SKILL when your LangGraph needs to persist state, remember conversations, travel through history, or configure subgraph checkpointer scoping. Covers checkpointers, thread_id, time travel, Store, and subgraph persistence modes.

How to install langgraph-persistence

install langgraph-persistence
# install the langchain-skills pack with the skills CLI
npx skills add langchain-ai/langchain-skills

# or add only this skill to Claude Code: copy the folder

config/skills/langgraph-persistence/

# into

~/.claude/skills/langgraph-persistence/ (all projects)

.claude/skills/langgraph-persistence/ (one project)

config/skills/langgraph-persistence/SKILL.md

MITFull file
1<overview>
2LangGraph's persistence layer enables durable execution by checkpointing graph state:
3
4- **Checkpointer**: Saves/loads graph state at every super-step
5- **Thread ID**: Identifies separate checkpoint sequences (conversations)
6- **Store**: Cross-thread memory for user preferences, facts
7
8**Two memory types:**
9- **Short-term** (checkpointer): Thread-scoped conversation history
10- **Long-term** (store): Cross-thread user preferences, facts
11</overview>
12
13<checkpointer-selection>
14
15| Checkpointer | Use Case | Production Ready |
16|--------------|----------|------------------|
17| `InMemorySaver` | Testing, development | No |
18| `SqliteSaver` | Local development | Partial |
19| `PostgresSaver` | Production | Yes |
20
21</checkpointer-selection>
22
23---
24
25## Checkpointer Setup
26
27<ex-basic-persistence>
28<python>
29Set up a basic graph with in-memory checkpointing and thread-based state persistence.
30
31```python
32from langgraph.checkpoint.memory import InMemorySaver
33from langgraph.graph import StateGraph, START, END
34from typing_extensions import TypedDict, Annotated
35import operator
36
37class State(TypedDict):
38 messages: Annotated[list, operator.add]
39
40def add_message(state: State) -> dict:
41 return {"messages": ["Bot response"]}
42
43checkpointer = InMemorySaver()
44
45graph = (
46 StateGraph(State)
47 .add_node("respond", add_message)
48 .add_edge(START, "respond")
49 .add_edge("respond", END)
50 .compile(checkpointer=checkpointer) # Pass at compile time
51)
52
53# ALWAYS provide thread_id
54…

Excerpt shown under the repository's MIT license.

More skills in langchain-skills

Newsletter

Join the Community

Subscribe to our newsletter for the latest news and updates