This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
DeepScrap is an agent-powered deep research tool that produces LaTeX-to-PDF investment research reports on publicly traded companies. Uses a multi-agent architecture with a Synthesis-driven feedback loop. Emphasizes forensic due diligence, rigorous valuation, and forward-looking catalyst analysis.
# Install in dev mode
pip install -e ".[dev]"
# Run all tests
pytest tests/ -v
# Run single test
pytest tests/path/test_file.py::TestClass::test_name -v
# Run the tool (from project root; or use python -m deepscrap.cli.main)
deepscrap analyze AAPL --depth shallow
deepscrap analyze AAPL --depth medium
deepscrap analyze AAPL --depth deep --verboseMulti-agent system with hub-and-spoke design:
- Orchestrator (
agents/orchestrator.py) — coordinates generic research agents, runs iterative feedback loop - Research Agents (Sonnet,
agents/research.py) — N generic agents (agent_1throughagent_N) that autonomously plan which data sources to query based on their directive. Count is configurable viaSettings.max_sub_agents(default 6). - Synthesis Agent (Opus,
agents/synthesis.py) — the brain; evaluates coverage, directs research agents by name, produces final qualitative analysis. Dynamic prompt includes agent count so it only references valid agent names. - Adversarial Reviewer (GPT,
agents/adversarial.py) — challenges Synthesis output - Report Generator (
report/generator.py) — Jinja2 LaTeX templates → PDF. Auto-populates appendix (sources list from store metadata, methodology description).
llm/— Provider abstraction (Claude + OpenAI) with role-based model routing viaregistry.py. Supports adaptive thinking and effort levels (output_config.effort) mapped from analysis depth.sources/— Pluggable data sources (Yahoo Finance, SEC EDGAR, Serper.dev, Google News, OpenInsider)store/— Pydantic models + ResearchStore with JSON persistence and coverage trackingreport/— Chart generation (matplotlib) + LaTeX templates (Jinja2 with<% %>delimiters) + PDF compilation
- Executive Summary
- Business Analysis
- Financial Deep Dive (includes accounting quality & red flags)
- Valuation Analysis (comps, DCF, sum-of-parts, pricing verdict)
- Leadership Assessment
- Forensic & Red Flag Analysis (related-party deals, suspicious M&A, SEC inquiries, insider patterns)
- Bull Case
- Bear Case
- Risk Matrix
- Forward-Looking Analysis (next earnings preview, catalyst timeline, what to watch)
- Conclusion
- Confidence Assessment (overall, per-section breakdown, evidence gaps, source quality)
- Orchestrator dispatches 6 research agents with targeted initial directives:
- Company overview + suspicious deals
- Deep financial analysis + accounting red flags
- Valuation models + analyst targets
- Executive team + insider trading patterns
- Forward-looking analysis + catalyst events
- Industry/regulatory/sentiment + short interest
- Synthesis evaluates coverage map, issues targeted directives to
agent_1..agent_N - Iterate until satisfied (or depth limit reached)
- Synthesis produces 12-section qualitative-first analysis
- GPT adversarially reviews → Opus revises/rebuts
- Report agent renders LaTeX → PDF (appendix auto-populated from store)
- Research agents register
ReferenceEntryobjects in the store as they fetch data - SEC filings are downloaded to
{output_dir}/references/during research - Report generator builds a numbered bibliography with
\href{}links - Inline
[Source: ...]citations are linked to bibliography entries via keyword matching
--depth shallow→ effortmedium--depth medium→ efforthigh--depth deep→ effortmax(Opus only)
All Claude calls use adaptive thinking (thinking: {type: "adaptive"}).
API keys via environment variables or .env file: ANTHROPIC_API_KEY, OPENAI_API_KEY, SERPER_API_KEY
Model routing defined in llm/config.py — Sonnet for research agents, Opus for synthesis, GPT for adversarial review.