A sophisticated multi-agent processing pipeline using the Claude Agent SDK that performs dependency-aware codebase analysis and visualization through multi-agent composition.
- Automatic Service Discovery: Identifies services in Rust (Cargo.toml), Go (go.mod), Node.js (package.json), and Python (pyproject.toml) codebases
- Dependency Graph Analysis: Builds and visualizes service dependency relationships
- Two-Phase Analysis:
- Phase 1: Analyzes foundation services with no dependencies
- Phase 2: Analyzes remaining services in dependency order with upstream context
- Context-Aware: Code analyzers receive analyses of direct dependencies to understand integration patterns
- Comprehensive Documentation: Generates system-wide architecture documentation with patterns, flows, and recommendations
- Multi-Agent Orchestration: Uses specialized agents for discovery, analysis, and documentation synthesis
GitHub Flashlight uses a deterministic discovery engine (zero LLM calls) to classify every component into one of eight ComponentKind values via language-specific plugins:
| Kind | Description |
|---|---|
| Library | Reusable code with no entrypoint |
| Service | Long-running process (HTTP, gRPC, daemon) |
| CLI | Command-line tool |
| Contract | Smart contract, API definition, or schema |
| Infra | Infrastructure-as-code or deployment config (Terraform, Helm, K8s) |
| Pipeline | Data pipeline or workflow definition (Airflow, dbt) |
| Frontend | UI application (React, Vue, Streamlit, SwiftUI) |
| Unknown | Could not classify deterministically |
- Service:
main.goorpackage mainwith server indicators (listenandserve,grpc.newserver,net.listen, etc.) or service-like names (server,daemon,proxy,worker) - CLI:
main.gowith CLI indicators (cobra.command,pflag,os.args) or CLI-like names (cli,tool) - Library: No
main.go, nopackage main, or has acmd/directory (executables insidecmd/become their own components) - Supports single-module monorepos with per-package discovery and Go import tracing
- Service:
[[bin]]orsrc/main.rswith server framework deps (actix-web,axum,warp,rocket,tonic,hyper) or service-like names - CLI: Executable with CLI framework deps (
clap,structopt,argh) or CLI-like names - Library:
[lib]section only, or hybrid crates with bothlib.rsandmain.rs - Supports Cargo workspaces with glob member patterns
- Pipeline: Markers for
airflow,dagster,prefect,dbt,luigi - Frontend: Markers for
streamlit,gradio,panel,dash - Service: Web framework deps (
fastapi,flask,django,starlette, etc.) with[project.scripts]or__main__.py - CLI: Has
[project.scripts]or__main__.pywithout web framework deps - Library: No entry points or framework markers
- Supports both PEP 621 and Poetry dependency formats
- CLI:
"bin"field present - Frontend: Frontend framework deps (
react,vue,svelte,angular,next,nuxt,remix,solid-js, etc.) - Service: Server framework deps (
express,fastify,koa,nestjs,hono) with a"start"script or"main"field - Library: No binary, framework, or server indicators
- Supports npm/yarn/pnpm workspaces with recursive member discovery
- Contract: Contains
contract,abstract contract, orinterfacedeclarations - Library: All declarations are Solidity
librarykeyword - Supports both Foundry and Hardhat projects with import remapping and multi-package discovery
- Service:
.executableTargetwith server framework indicators (Vapor,Hummingbird,SwiftNIO,GRPC) or service-like names - Frontend: Executable with iOS/macOS indicators (
UIApplication,SwiftUI,WindowGroup) - CLI:
.executableTargetwith argument parsing (ParsableCommand,ArgumentParser) or CLI-like names; default for unclassified executables - Library:
.targetwithoutmain.swiftor@main,.binaryTarget,.systemLibrary - Supports SPM multi-target packages with per-target discovery
- Manifest discovery: Scans for language-specific manifest files (
Cargo.toml,go.mod,package.json,pyproject.toml,foundry.toml,Package.swift) - Manifest analysis: Checks for binary/entrypoint indicators in manifest structure
- File structure: Looks for
main.rs,main.go,__main__.py,main.swift,@mainattribute - Dependency scanning: Identifies framework-specific dependencies (e.g.,
axum-> Service,clap-> CLI,react-> Frontend) - Content scanning: Reads source files for server/CLI/UI indicators (Go reads all
.gofiles; Swift reads up to 10.swiftfiles) - Name-based heuristics: Keywords like "server", "api", "daemon" -> Service; "cli", "tool" -> CLI
- Default: Falls back to Library (or Service/CLI for executables, depending on the language)
The pipeline uses four specialized roles:
-
Primary Leader (orchestrator)
- Discovers services by scanning for manifest files
- Builds dependency graph and determines analysis order
- Spawns code analyzer agents with appropriate context
- Spawns external service analyzers for runtime integrations
- Spawns architecture documenter for final synthesis
-
Code Analyzer (multiple instances)
- Deep analysis of individual services
- Examines architecture, components, data flows, dependencies, API surface
- Documents all third-party dependencies with version, category, and purpose
- Receives context from direct dependencies
- Outputs Markdown reports
-
External Service Analyzer (per-service instances)
- Deep-dives into how external services (databases, cloud platforms, APIs) are integrated
- Documents client libraries, authentication, API surface, and configuration
- Produces integration analysis files for architecture synthesis
-
Architecture Documenter (single instance)
- Synthesizes all service analyses
- Aggregates external dependencies into a complete technology inventory
- Identifies system-wide patterns
- Creates comprehensive architecture documentation
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -e .
# Set up API key
cp .env.example .env
# Edit .env and add your ANTHROPIC_API_KEY# Run the pipeline
python -m github_flashlight.agent
# Or use the installed command
github-flashlightThen provide a path to analyze:
You: Analyze the codebase at /path/to/repo
Enable detailed SDK and API interaction logging:
# Verbose mode - Shows API calls, agent spawning, and tool usage
AGENT_VERBOSE=true python -m github_flashlight.agent
# Debug mode - Full trace logging including API request/response details
AGENT_DEBUG=true python -m github_flashlight.agentWhen enabled, you'll see real-time information about:
- π€ API requests to Claude
- π₯ API responses
- π Subagent spawning and lifecycle
- π§ Tool calls with parameters
- β Tool results and success/failure status
- π Agent context and model information
This is useful for:
- Understanding what the agents are doing in real-time
- Debugging analysis pipeline issues
- Monitoring API usage and performance
- Learning how the multi-agent system orchestrates tasks
For real-time visual monitoring of agent execution with interactive profiling:
./observability/live_monitor.shThis launches a web-based profiler that automatically tracks your current session, displaying tool calls, timing metrics, and agent interactions in real-time. The visualization updates live as your agents work, providing an interactive dashboard for monitoring pipeline execution and performance analysis.
The pipeline will:
- Scan for services (Cargo.toml, go.mod, package.json, pyproject.toml files)
- Build dependency graph
- Analyze services in two phases:
- Phase 1: Services with no dependencies (parallel)
- Phase 2: Services with dependencies (in order, with context)
- Generate architecture documentation
files/
βββ service_discovery/
β βββ services.json # Discovered services metadata
β βββ discovery_log.md # Human-readable discovery log
βββ dependency_graphs/
β βββ dependency_graph.json # Machine-readable graph
β βββ dependency_graph.md # Visualization
βββ service_analyses/
β βββ {service1}.json # Structured analysis
β βββ {service1}.md # Human-readable report
β βββ ... (one pair per service)
βββ architecture_docs/
βββ architecture.md # Comprehensive documentation
βββ quick_reference.md # One-page summary
logs/
βββ session_YYYYMMDD_HHMMSS/
βββ transcript.txt # Conversation log
βββ tool_calls.jsonl # Structured tool usage
For a Rust codebase with this structure:
repo/
βββ common-utils/ (no dependencies)
βββ config-loader/ (no dependencies)
βββ database-layer/ (depends on common-utils)
βββ auth-service/ (depends on database-layer)
βββ api-gateway/ (depends on auth-service, database-layer)
The agent will:
- Phase 1: Analyze
common-utilsandconfig-loaderin parallel - Phase 2:
- Analyze
database-layerwith context fromcommon-utils - Analyze
auth-servicewith context fromdatabase-layeronly (not common-utils) - Analyze
api-gatewaywith context fromauth-serviceanddatabase-layer
- Analyze
- Synthesis: Generate comprehensive architecture documentation
- Direct Dependencies Only: Analyzers receive context only from direct dependencies, not transitive ones
- Dependency Order: Services are analyzed in topological order to ensure dependencies are analyzed first
- Parallel Execution: Services at the same dependency level are analyzed in parallel
- Structured Output: Both machine-readable (JSON) and human-readable (Markdown) outputs
- Rust: Full support (Cargo.toml discovery, dependency extraction)
- Go: Full support (go.mod discovery, dependency extraction)
- Node.js: Partial support (package.json discovery)
- Python: Partial support (pyproject.toml discovery)
- Python 3.10+
- Claude API key
- Access to the codebase to analyze
# Install with dev dependencies
pip install -e ".[dev]"
# Run tests (when available)
pytestThe primary leader orchestrates a sophisticated multi-phase workflow:
- Uses Glob to find manifest files (Cargo.toml, go.mod, package.json, pyproject.toml)
- Reads each manifest to extract service metadata
- Identifies internal dependencies (path-based in manifests)
- Saves service inventory to JSON
- Constructs directed dependency graph
- Calculates analysis order using two-phase approach:
- Phase 1: Services with in-degree 0 (no dependencies)
- Phase 2: Topological sort of remaining services
- Visualizes graph in both JSON and Markdown
- Phase 1: Spawns code-analyzer for each no-dependency service (parallel)
- Phase 2: For each remaining service:
- Waits for its direct dependencies to complete
- Loads direct dependency analyses
- Builds context summary (architecture, APIs, components)
- Spawns code-analyzer with context
- Ensures proper ordering while maximizing parallelism
- Spawns architecture-documenter after all analyses complete
- Reads all service analyses and dependency graph
- Identifies system-wide patterns and architectural approaches
- Generates comprehensive documentation with:
- System overview
- Service catalog
- Dependency visualization
- Architectural patterns
- Technology stack
- Major data flows
- Development guide
- Recommendations
This project showcases the Claude Agent SDK's multi-agent composition capabilities. Feel free to extend it with:
- Additional language support (Java, C#, etc.)
- Enhanced metrics collection (LOC, complexity, test coverage)
- Incremental analysis for large repositories
- Custom analysis plugins
- Additional visualization options
See parent repository for license information.