crabmap 0.1.1

Rust code satellite map β€” index, query, and navigate your entire codebase
crabmap-0.1.1 is not a library.

πŸ¦€ Crabmap


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.


✨ Why Crabmap?

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

πŸš€ Quick Start

# Install
cargo install crabmap

# Index a project
crabmap index /path/to/rust/project
# βœ“ indexed 9089 nodes, 14355 edges in 168 files

# Get an AI-ready architecture map
crabmap nav map

# Search for anything
crabmap query search "handle_connection"

# Explore interactively in the browser
crabmap serve

πŸ“¦ Commands

crabmap index β€” Build the graph

crabmap index .                           # Index current project
crabmap index --all .                     # Discover & index all Cargo projects
crabmap index --no-tests                  # Skip test files
crabmap index --output custom.json.gz     # Custom output path (gzipped)

crabmap query β€” Ask questions

crabmap query stats                       # Node/edge counts
crabmap query search "config"             # Fuzzy text search
crabmap query symbol main                 # Inspect a symbol
crabmap query callees main --depth 3      # What does main call?
crabmap query callers load_config         # Who calls this?
crabmap query impact Runtime --depth 2    # Full dependency impact
crabmap query path main load_config       # Shortest call path

crabmap nav β€” AI-oriented navigation

crabmap nav map           # Token-budgeted project overview (for LLMs)
crabmap nav guide         # Entry points + call chains
crabmap nav clusters      # Feature clusters by file
crabmap nav quality       # Graph confidence score
crabmap nav health        # Cycles, god modules, dead code

crabmap analyze β€” Static analysis

crabmap analyze deps      # Module dependency matrix
crabmap analyze fanout    # File-level fan-in / fan-out
crabmap analyze tests     # Test impact candidates
crabmap analyze hotspots  # Git churn hotspots
crabmap analyze diff      # Graph diff vs git base

crabmap serve β€” Web UI

crabmap serve                         # Index + serve
crabmap serve --graph graph.json.gz   # Serve a pre-built graph
crabmap serve --watch                 # Auto-reindex on file changes

crabmap config β€” API Keys (for LLM features)

crabmap config --api-key sk-... --model gpt-4

🌐 Web UI

Launch 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

πŸ§ͺ Tested On

Project Nodes Edges Warnings Quality
crabmap (self) 899 1,676 0 99
ripgrep 9,089 14,355 0 96
tokio 14,176 28,831 0 98

All three projects indexed with zero warnings.


πŸ”§ How It Works

  1. cargo metadata β†’ discovers packages, targets, source files
  2. syn AST walk β†’ extracts structs, enums, functions, methods, impls, macros…
  3. Call resolution β†’ same-module priority, method-to-trait-impl matching
  4. rust-analyzer enrichment (optional) β†’ LSP call hierarchy for confirmed edges
  5. MIR lowering (optional) β†’ rustc MIR for dispatch sites
  6. Graph persistence β†’ gzip-compressed JSON (14Γ— smaller than raw)

πŸ“„ Graph Format

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

πŸ›  Building from Source

git clone https://github.com/trtyr/crabmap.git
cd crabmap
cargo build --release
./target/release/crabmap --version
# crabmap 0.1.1 (abc1234 2026-05-21)

Requires Rust β‰₯ 1.85 (edition 2024).


πŸ“ Project Layout

src/
β”œβ”€β”€ main.rs          # CLI entry & command dispatch
β”œβ”€β”€ cli.rs           # clap argument definitions
β”œβ”€β”€ analyzer.rs      # AST indexer (syn walk)
β”œβ”€β”€ query.rs         # Graph traversal & search
β”œβ”€β”€ model.rs         # Core data model
β”œβ”€β”€ store.rs         # Gzip JSON load/save
β”œβ”€β”€ web.rs           # Embedded HTTP server
β”œβ”€β”€ semantic.rs      # rust-analyzer enrichment
β”œβ”€β”€ mir.rs           # MIR lowering
β”œβ”€β”€ ai.rs            # AI nav commands
β”œβ”€β”€ config.rs        # Global config (~/.config/crabmap/)
β”œβ”€β”€ term.rs          # ANSI terminal colors
β”œβ”€β”€ health.rs        # Architecture risk detection
└── …

web/
β”œβ”€β”€ index.html
β”œβ”€β”€ styles/          # CSS (dark theme)
└── src/             # JS (microkernel architecture)

skills/
└── crabmap.md     # AI agent usage guide (skill file)

πŸ“ License

MIT