agentleFS
LangChainKnown publisherlangchain-ai/deep_research_from_scratch/CLAUDE.md

deep_research_from_scratch

CLAUDE.md793 starsChanged 16 months agoMITView on GitHub

This repository builds a comprehensive deep research system from scratch using LangGraph, progressing through 5 tutorial notebooks that demonstrate different components and patterns. The notebooks in notebooks/ are the source of truth and should be the ONLY files modified. The source code in src/deep_research_from_scratch/ is automatically generated from the notebooks using %%writefile magic commands. Here's how it works: The system implements a three-phase deep research workflow: This approach ensures that the interactive tutorials remain the authoritative source while automatically maintaining…

The file

We split this CLAUDE.md into the rules it gives an agent

5 rules. About 0 are common, 5 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Run the modified cells to regenerate source code

    line 74
  2. Distinctive:

    Test the changes by running subsequent notebook cells

    line 75
  3. Distinctive:

    D212: Ensure docstring summaries start on the same line as triple quotes

    line 100
  4. Distinctive:

    F401: Remove unused imports

    line 102
  5. Distinctive:

    D415: Add periods to docstring summaries

    line 103

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

Deep Research From Scratch - Repository Guide

Repository Structure

This repository builds a comprehensive deep research system from scratch using LangGraph, progressing through 5 tutorial notebooks that demonstrate different components and patterns.

deep_research_from_scratch/
├── notebooks/              # Interactive tutorial notebooks (MODIFY THESE)
│   ├── 1_scoping.ipynb     # User clarification and brief generation
│   ├── 2_research_agent.ipynb       # Research agent with custom tools
│   ├── 3_research_agent_mcp.ipynb   # Research agent with MCP servers
│   ├── 4_research_supervisor.ipynb  # Multi-agent supervisor coordination
│   ├── 5_full_agent.ipynb  # Complete end-to-end system
│   └── utils.py            # Shared utilities for notebooks
├── src/deep_research_from_scratch/  # Generated source code (DO NOT MODIFY)
│   ├── multi_agent_supervisor.py
│   ├── prompts.py
│   ├── research_agent.py
│   ├── research_agent_mcp.py
│   ├── state_*.py
│   └── utils.py
└── README.md              # Comprehensive documentation

🚨 Important Development Workflow

The notebooks in notebooks/ are the source of truth and should be the ONLY files modified.

The source code in src/deep_research_from_scratch/ is automatically generated from the notebooks using %%writefile magic commands. Here's how it works:

How Code Generation Works

  1. Notebooks contain %%writefile cells: Each notebook uses Jupyter's %%writefile magic to write code directly to files in src/
  2. Notebooks are executable tutorials: They demonstrate concepts interactively while generating the production code
  3. Source files are generated artifacts: The .py files in src/ are outputs, not inputs

Example from notebooks:

%%writefile ../src/deep_research_from_scratch/research_agent.py

"""
Research Agent Implementation
"""
# ... actual implementation code follows

Development Guidelines

  • ✅ DO: Edit notebooks in notebooks/ directory
  • ✅ DO: Run notebook cells to regenerate source code
  • ✅ DO: Test changes by running the notebooks
  • ❌ DON'T: Directly edit files in src/deep_research_from_scratch/
  • ❌ DON'T: Expect manual changes to src/ files to persist

System Architecture

The system implements a three-phase deep research workflow:

  1. Scope (Notebook 1): Clarify research scope and generate structured briefs
  2. Research (Notebooks 2-4): Perform research using various agent patterns
  3. Write (Notebook 5): Synthesize findings into comprehensive reports

Key Components

  • Scoping Agent: Clarifies user intent and generates research briefs
  • Research Agent: Iterative research with custom tools or MCP servers
  • Supervisor Agent: Coordinates multiple research agents for complex topics
  • Full System: Integrates all components into end-to-end workflow

Quick Start for Development

  1. Make changes to the appropriate notebook in notebooks/
  2. Run the modified cells to regenerate source code
  3. Test the changes by running subsequent notebook cells
  4. The generated code in src/ will automatically reflect your changes

This approach ensures that the interactive tutorials remain the authoritative source while automatically maintaining the corresponding Python package structure.

Code Quality and Formatting

Ruff Formatting Checks

To maintain consistent code formatting across the generated source files, run ruff periodically:

# Check for formatting issues
ruff check src/

# Auto-fix formatting issues where possible
ruff check src/ --fix

# Check specific file
ruff check src/deep_research_from_scratch/research_agent.py

Important: Since source files in src/ are generated from notebooks, any formatting issues should be fixed in the notebook %%writefile cells, not directly in the source files. After fixing formatting in notebooks, regenerate the source files by running the notebook cells.

Common formatting fixes needed:

  • D212: Ensure docstring summaries start on the same line as triple quotes
  • I001: Organize imports properly (standard library → third party → local imports)
  • F401: Remove unused imports
  • D415: Add periods to docstring summaries

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.