archmap
Architectural analysis for codebases. Understands dependencies, detects coupling issues, and generates context for AI agents.
Why? Before modifying code, you should understand what depends on it. Before refactoring, you should know where the coupling problems are. Before asking an AI to help, it should understand your architecture. archmap does all of this.
Install
or, locally:
Or build from source:
Quick Start
# Analyze current directory
# AI-optimized output (compact, structured for LLM consumption)
# Check impact before changing a file
# Interactive dependency graph
Commands
analyze — Architectural Analysis
Detects coupling issues, circular dependencies, boundary violations, and god objects.
Options:
| Flag | Description |
|---|---|
-f, --format <FORMAT> |
Output format: markdown, json |
-o, --output <FILE> |
Write to file instead of stdout |
--min-severity <LEVEL> |
Minimum severity: info, warn, error |
--lang <LANGS> |
Languages to analyze (comma-separated) |
-w, --watch |
Re-analyze on file changes |
-x, --exclude <DIR> |
Exclude directories (repeatable) |
--max-depth <N> |
Max dependency chain depth (default: 5) |
--min-cohesion <N> |
Min cohesion score 0.0-1.0 (default: 0.3) |
Example output:
## Issues Found
### High Coupling
- `src/model/mod.rs` - Imported by 15 other modules
### Boundary Violations
**Filesystem** crossed in 21 locations:
- `src/config.rs:81` - `let content = std::fs::read_to_string(...)`
→ Consider centralizing file operations
ai — AI-Optimized Context
Generates compact module summaries optimized for LLM consumption. Fits architectural context into token budgets.
Options:
| Flag | Description |
|---|---|
--tokens <N> |
Maximum tokens (uses tiktoken for accuracy) |
--signatures |
Output only public API surface |
--topo-order |
Topological ordering (deps before dependents) |
-f, --format <FORMAT> |
Output format: markdown, json, xml |
-o, --output <FILE> |
Write to file instead of stdout |
--priority <STRATEGY> |
Prioritization: fan-in, fan-out, combined |
--lang <LANGS> |
Languages to analyze (comma-separated) |
impact — Change Impact Analysis
Shows which files are affected when you modify a specific file. Essential before refactoring.
Options:
| Flag | Description |
|---|---|
--tree |
Show ASCII tree visualization |
-d, --depth <N> |
Maximum traversal depth |
-f, --format <FORMAT> |
Output format: markdown, json |
-o, --output <FILE> |
Write to file instead of stdout |
--path <PATH> |
Project path (default: current directory) |
--lang <LANGS> |
Languages to analyze (comma-separated) |
Example output:
## Summary
- **Total Affected Files**: 19
- **Maximum Chain Length**: 2
## Impact Tree
src/model/mod.rs (TARGET)
├── src/cli.rs
│ └── src/output/ai.rs
├── src/config.rs
│ ├── src/analysis/boundary.rs
│ └── src/analysis/mod.rs
└── src/parser/rust.rs
graph — Interactive Visualization
Launch a web UI to explore the dependency graph.
Options:
| Flag | Description |
|---|---|
--serve |
Start HTTP server |
--open |
Open browser automatically |
--port <PORT> |
Server port (default: 3000) |
-w, --watch |
Live-reload on file changes |
--export <FILE> |
Export as static HTML |
--lang <LANGS> |
Languages to analyze (comma-separated) |
By default, the server starts without opening a browser—ideal for CI/scripts or remote machines.
snapshot & diff — Track Architectural Drift
Save snapshots and compare against baselines. Useful for CI pipelines.
# Save current state
# Compare against baseline
snapshot options:
| Flag | Description |
|---|---|
--save <FILE> |
Save snapshot to file (required) |
--lang <LANGS> |
Languages to analyze (comma-separated) |
diff options:
| Flag | Description |
|---|---|
--fail-on-regression |
Exit with error if regressions found |
-f, --format <FORMAT> |
Output format: markdown, json |
-o, --output <FILE> |
Write to file instead of stdout |
--lang <LANGS> |
Languages to analyze (comma-separated) |
mcp — AI Assistant Integration
Start an MCP (Model Context Protocol) server for integration with AI assistants like Claude.
To get the MCP manifest for client configuration:
This outputs JSON configuration that can be used to register archmap with MCP-compatible AI assistants.
init — Generate Config
Configuration
Create .archmap.toml to customize thresholds and define architectural boundaries:
[]
= 500 # Max lines before flagging
= 5 # Max importers before flagging
= 5 # Max chain length A→B→C→D→E
= 0.3 # 0.0-1.0, lower = less focused
[]
= "Persistence"
= ["sqlx::", "diesel::", "SELECT ", "INSERT "]
= "Consider centralizing in a repository layer"
[]
= "Network"
= ["reqwest::", "fetch(", "axios."]
= "Consider centralizing in an API client service"
[]
= "Filesystem"
= ["std::fs::", "tokio::fs::", "fs.readFile"]
= "Consider centralizing file operations"
Supported Languages
- Rust
- TypeScript/JavaScript
- Python
Performance
archmap uses parallel file walking and thread-local tree-sitter parsers:
| Codebase | Files | Time |
|---|---|---|
| archmap itself | ~30 | 10ms |
| Medium project | ~500 | 200ms |
| Large monorepo | ~5000 | 2s |
For large codebases, exclude test and vendor directories:
Use Cases
Before modifying a core module:
Generate context for an AI assistant:
CI pipeline — fail on architectural regression:
Explore an unfamiliar codebase:
Integrate with Claude or other MCP-compatible AI:
# Add to your AI assistant's MCP configuration
For AI Agents
If you're an AI agent with access to this tool, see CLAUDE.md for usage instructions optimized for your workflow.
License
MIT