deep-agents-from-scratch
CLAUDE.md845 starsChanged 16 months agoMITView on GitHub
This repository contains educational materials for building deep agents from scratch using LangGraph. It demonstrates progressive agent architectures through a series of Jupyter notebooks, starting with basic TODO list functionality and advancing to full agents with file systems and subagent spawning. State Management (state.py) - DeepAgentState: Extends LangGraph's AgentState with todos and files - Todo: TypedDict for task tracking with status (pending/in_progress/completed) - file_reducer: Merges file dictionaries in state updates Virtual File System (file_tools.py) - ls(): List files in virtual…
- Reads credentials
The file
We split this CLAUDE.md into the rules it gives an agent
3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 91
All file operations are virtual - files exist only in LangGraph state
- Very specific: line 97
Create .env file in project root with required API keys:
- Distinctive: line 113
No specific test framework is configured.
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
This repository contains educational materials for building deep agents from scratch using LangGraph. It demonstrates progressive agent architectures through a series of Jupyter notebooks, starting with basic TODO list functionality and advancing to full agents with file systems and subagent spawning.
Development Commands
Environment Setup
# Install dependencies using uv (preferred package manager)
uv sync
# Run Jupyter notebooks
uv run jupyter notebook
# Alternative: activate virtual environment
source .venv/bin/activate
jupyter notebookCode Quality
# Run linting with ruff (notebooks and source code)
uv run ruff check
uv run ruff check notebooks/
# Auto-fix linting issues where possible
uv run ruff check --fix
uv run ruff format
# Run type checking with mypy
uv run mypy src/
# Install dev dependencies (includes ruff and mypy)
uv sync --extra devLangGraph Studio Integration
# Start LangGraph Studio (if installed)
langgraph up
# The langgraph.json file defines two agents:
# - studio_react_agent: "./src/deep-agents-from-scratch/studio_react_agent.py:agent"
# - react_agent: "./src/deep-agents-from-scratch/react_agent.py:agent"Architecture
Core Components
State Management (state.py)
DeepAgentState: Extends LangGraph'sAgentStatewith todos and filesTodo: TypedDict for task tracking with status (pending/in_progress/completed)file_reducer: Merges file dictionaries in state updates
Virtual File System (file_tools.py)
ls(): List files in virtual filesystem stored in agent stateread_file(): Read file content with offset/limit supportwrite_file(): Create/overwrite files in virtual filesystemedit_file(): Perform find-and-replace edits with exact string matching
Task Planning (todo_tool.py)
write_todos(): Creates and updates structured task lists- Uses LangGraph
Commandtype for state updates - Critical for context management and long-running tasks
Agent Implementations
react_agent.py: Basic ReAct agent with internet search via Tavilystudio_react_agent.py: Studio-compatible version with detailed documentation
Tutorial Progression (Notebooks)
- 1_todo.ipynb: TODO list tool for task planning and progress tracking
- 2_files.ipynb: Virtual file system tools (read/write/edit/ls)
- 3_subagents.ipynb: Task delegation and context isolation via subagents
- 4_full_agent.ipynb: Complete agent combining all tools and capabilities
Key Patterns
Context Engineering Techniques:
- Context offloading to virtual files stored in state
- TODO lists for planning and progress tracking
- Subagent spawning for context quarantine
- Task-specific prompt engineering
State Management:
- All file operations are virtual - files exist only in LangGraph state
- Enables backtracking/restarting by preserving file system state
- Todo list persisted across agent interactions
Environment Variables
Create .env file in project root with required API keys:
# Required for research agents with external search
TAVILY_API_KEY=your_tavily_api_key_here
# Required for model usage
ANTHROPIC_API_KEY=your_anthropic_api_key_here
# Optional: For evaluation and tracing
LANGSMITH_API_KEY=your_langsmith_api_key_here
LANGSMITH_TRACING=true
LANGSMITH_PROJECT=deep-agents-from-scratchTesting
No specific test framework is configured. Test agents by:
- Running notebooks interactively
- Testing via LangGraph Studio interface
- Direct Python script execution
Important Notes
- Virtual file system is ephemeral - exists only during agent execution
- TODO tool should limit to ONE task in_progress at a time
- File edit operations require exact string matching
- Agents use Claude Sonnet 4 model by default
- Rich formatting utilities in
notebooks/utils.pyfor message display
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

