Rust code satellite map β index, query, and navigate your codebase
π¨π³ δΈζζζ‘£
Crabmap builds a durable, queryable knowledge graph of any Rust project. Give it to an AI agent β it understands the entire codebase without reading files one by one.
Think of it as a satellite map of your Rust codebase, while LSP (rust-analyzer) gives you a microscope for individual symbols.
| LSP / rust-analyzer | Crabmap |
|---|---|
| One symbol at a time | Whole-project graph in one shot |
| Needs an open IDE | Offline, portable JSON file |
| No "project overview" | nav map β 8000-token architecture summary |
| Find references (flat list) | query impact β full dependency propagation chains |
| No structural health checks | analyze health β cycles, god modules, dead code |
| Human-first (hover, click) | AI-first β designed for LLM context windows |
# Install
cargo install crabmap
# Index a project
crabmap index /path/to/rust/project
# β indexed 9089 nodes, 14355 edges in 168 files
# AI architecture overview (compact)
crabmap nav map
# --full for entry points + feature clusters
# Find anything by name
crabmap query find "handler"
# --mode similar for structurally similar symbols
# Inspect a symbol (with source code)
crabmap query inspect main
# Trace call chains (both directions by default)
crabmap query trace load_config
# --direction up | down for one-way
# Scope: what's in a file or module?
crabmap query scope src/lib.rs
# --kind module for module declarations
# Explore interactively in the browser
crabmap servecrabmap index . # Index current project
crabmap index --all . # Discover & index all Cargo projects
crabmap index --no-tests # Skip test files
crabmap index --no-semantic # Skip rust-analyzer enrichment
crabmap index --output custom.json.gz # Custom output path (gzipped)Discover & Understand
crabmap query stats # Node/edge counts by kind/source/certainty
crabmap query symbols --limit 10 # List symbols (8 filter flags: --dead, --no-docs, --visibility, β¦)
crabmap query inspect main # Symbol detail + source code
crabmap query find "config" # Text search (--mode similar for structural similarity)
crabmap query scope src/lib.rs # File contents (--kind module for module declarations)Trace Relationships
crabmap query trace main # Both directions (--direction up | down)
crabmap query impact Runtime --depth 2 # Full impact: files_affected + call_sites + change_hints
crabmap query path main load_config # Shortest call path between two symbolsExport
crabmap query export # JSON export (--format dot | mermaid)crabmap nav map # Compact overview (~8k tokens, hot symbols)
crabmap nav map --full # + entry points & feature clusters
crabmap nav quality # Graph confidence score
crabmap nav health # Cycles, god modules, dead code
crabmap nav report # Generate GRAPH_REPORT.md + AGENT_GUIDE.mdcrabmap analyze deps # Module dependency matrix + recompile impact
crabmap analyze fanout # File-level fan-in / fan-out
crabmap analyze tests <name> # Call-graph-based test impact (score + call path)
crabmap analyze hotspots # Git churn hotspots
crabmap analyze diff # Graph diff vs git basecrabmap serve # Index + serve
crabmap serve --graph graph.json.gz # Serve a pre-built graph
crabmap serve --watch # Auto-reindex on file changescrabmap config --api-key sk-... --model gpt-4Launch crabmap serve and open http://127.0.0.1:7878:
- Graph visualization β force-directed layout, color-coded by node/edge kind
- Interactive exploration β click nodes to expand, drag to rearrange
- Edge filtering β toggle relationship types (calls, declares, uses_type, β¦)
- Detail drawer β inspect symbols, files, edges
- Chinese UI β full zh-CN interface
| Project | Nodes | Edges | Warnings | Quality |
|---|---|---|---|---|
| crabmap (self) | 1007 | 2,063 | 0 | 99 |
| ripgrep | 9,089 | 14,355 | 0 | 96 |
| tokio | 14,176 | 28,831 | 0 | 98 |
All three projects indexed with zero warnings.
cargo metadataβ discovers packages, targets, source filessynAST walk β extracts structs, enums, functions, methods, impls, macrosβ¦- Call resolution β same-module priority, method-to-trait-impl matching
- rust-analyzer enrichment (optional) β LSP call hierarchy for confirmed edges
- MIR lowering (optional) β rustc MIR for dispatch sites
- Graph persistence β gzip-compressed JSON (14Γ smaller than raw)
The output is a single JSON file (gzipped by default):
{
"schema_version": 2,
"project": { "root": ".", "packages": [β¦] },
"nodes": [
{ "id": "function:crabmap::run", "kind": "function", "name": "run", β¦ }
],
"edges": [
{ "from": "function:crabmap::main", "to": "function:crabmap::run",
"kind": "calls", "source": "ast", "certainty": "definite" }
]
}| Edge Kind | Meaning |
|---|---|
calls |
Function/method call |
declares |
Module declares a symbol |
uses_type |
Type reference |
contains |
File contains a module |
imports |
use statement |
has_method |
Impl block owns a method |
implements |
Trait implementation |
returns |
Return type |
module_file |
File β module mapping |
git clone https://github.com/trtyr/crabmap.git
cd crabmap
cargo build --release
./target/release/crabmap --version
# crabmap 0.1.2 (abc1234 2026-05-21)Requires Rust β₯ 1.85 (edition 2024).
src/
βββ main.rs # CLI entry & command dispatch
βββ cli.rs # clap argument definitions
βββ model.rs # Core data model (Node, Edge, CodeGraph)
βββ analyzer/ # AST indexer (syn walk, 6 sub-modules)
βββ query/ # Graph traversal, search, filtering (6 sub-modules)
β βββ commands.rs # inspect, trace, find, scope, impact
β βββ filter.rs # SymbolFilter β 8 lightweight query flags
β βββ similar.rs # Structural similarity by callee overlap
β βββ source.rs # Source code retrieval by line range
βββ ai/ # AI nav: map, guide, clusters, quality (5 sub-modules)
βββ web/ # Embedded HTTP server + viewer (6 sub-modules)
βββ rag/ # Retrieval: lexical β embedding β rerank (6 sub-modules)
βββ semantic/ # rust-analyzer LSP enrichment (3 sub-modules)
βββ store.rs # Gzip JSON load/save + multi-project auto-discovery
βββ config.rs # Global config (~/.config/crabmap/)
βββ health.rs # Architecture risk detection
βββ mir.rs # MIR lowering
βββ deps.rs # Module dependency + recompile impact
βββ test_impact.rs # Call-graph-based test impact analysis
βββ β¦
web/
βββ index.html
βββ styles/ # CSS (dark theme)
βββ src/ # JS (microkernel architecture)
skills/
βββ crabmap.md # AI agent usage guide (skill file)
MIT
Built for AI. Made with π¦ in Rust.