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
- Distinctive: line 74
Run the modified cells to regenerate source code
- Distinctive: line 75
Test the changes by running subsequent notebook cells
- Distinctive: line 100
D212: Ensure docstring summaries start on the same line as triple quotes
- Distinctive: line 102
F401: Remove unused imports
- Distinctive: line 103
D415: Add periods to docstring summaries
≈ “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
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
- Notebooks contain
%%writefilecells: Each notebook uses Jupyter's%%writefilemagic to write code directly to files insrc/ - Notebooks are executable tutorials: They demonstrate concepts interactively while generating the production code
- Source files are generated artifacts: The
.pyfiles insrc/are outputs, not inputs
Example from notebooks:
%%writefile ../src/deep_research_from_scratch/research_agent.py
"""
Research Agent Implementation
"""
# ... actual implementation code followsDevelopment 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:
- Scope (Notebook 1): Clarify research scope and generate structured briefs
- Research (Notebooks 2-4): Perform research using various agent patterns
- 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
- Make changes to the appropriate notebook in
notebooks/ - Run the modified cells to regenerate source code
- Test the changes by running subsequent notebook cells
- 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.pyImportant: 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
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.

