crabmap-0.1.2 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
# Index a project
# β indexed 9089 nodes, 14355 edges in 168 files
# Get an AI-ready architecture map
# Search for anything
# Explore interactively in the browser
π¦ Commands
crabmap index β Build the graph
crabmap query β Ask questions
crabmap nav β AI-oriented navigation
crabmap analyze β Static analysis
crabmap serve β Web UI
crabmap config β API Keys (for LLM features)
π 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
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)
π Graph Format
The output is a single JSON file (gzipped by default):
| 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
# crabmap 0.1.2 (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