codescope

August 31, 2026 ยท View on GitHub

License: MIT OR Apache-2.0 Build

โญ If codescope saves you context tokens, starring the repo helps others find it.

A single-binary, blazing-fast code-intelligence engine for AI coding agents.

๐ŸŽฌ Demo

codescope indexing itself and answering blast-radius queries

codescope indexing its own repo โ€” 196 symbols, 1,322 edges in 188 ms โ€” then a summary and a blast-radius query. Recorded from the actual binary with asciinema + agg.

codescope indexes any repository into a precise, queryable structural graph and serves it to AI agents over MCP (and CLI/JSON). Instead of letting an agent grep blindly through files and burn its context window, it answers "who calls this, what breaks if I change it, where is this defined, what does this module depend on" in milliseconds โ€” with token-budgeted output.

The precision of Sourcegraph, the install footprint of ripgrep, the interface of an MCP server, and no cloud, no database, no Python.

Capabilities

CapabilityCLIMCP tool
Build/refresh the index (incremental)codescope indexcs_index
Who calls a symbol (transitive)codescope callers X --depth Ncs_callers
What a symbol calls (transitive)codescope callees X --depth Ncs_callees
Blast radius of a changecodescope blast-radius Xcs_blast_radius
Where a symbol is definedcodescope def Xcs_definition
All references to a symbolcodescope refs Xcs_references
File/module import graph + cyclescodescope depscs_dependency_graph
Structural searchcodescope search "kind:function calls:db_query"cs_structural_search
Architectural overviewcodescope summarycs_repo_summary

Languages: Rust, TypeScript, JavaScript, Python, Go (tree-sitter).

Every query is token-budgeted (--max-tokens, default 4000): results are compact JSON with symbol, kind, file, line_start/line_end, edge lists, and a truncated flag instead of dumping the whole graph.

Install

cargo install --path .        # from this checkout
# or, once published:
# cargo install codescope

Usage

codescope index                       # build/refresh the index for the cwd
codescope -p /path/to/repo index      # index a specific repo
codescope callers my_func --depth 2
codescope blast-radius src/auth.rs
codescope refs UserSession
codescope summary --max-tokens 4000
codescope search "kind:function calls:db.query returns:Result"
codescope callees do_thing --json     # machine-readable output

Space-separated terms; key:value are filters, bare words match name/signature:

  • kind:function|method|struct|enum|trait|interface|class|module|type|constant|field
  • lang:rust|typescript|javascript|python|go
  • file:<substr> ยท name:<substr> ยท calls:<callee> ยท returns:<type-substr>
codescope search "kind:method lang:rust calls:spawn returns:Result"

MCP server (for agents)

codescope speaks MCP over stdio (newline-delimited JSON-RPC). Start it with:

codescope serve --mcp

Register it with any MCP-capable agent (Claude Code, Cursor, Windsurf, VS Code/Copilot, Cline, Zed, Continue). Example config:

{
  "mcpServers": {
    "codescope": {
      "command": "codescope",
      "args": ["serve", "--mcp", "-p", "/abs/path/to/your/repo"]
    }
  }
}

Then the agent can call cs_index once and query cs_callers, cs_blast_radius, cs_structural_search, etc. See docs/mcp.md for the full tool reference.

Performance

Measured on a 4-core container (release build) โ€” see docs/BENCHMARKS.md:

  • Cold index 100k LOC in ~0.2 s; ~1M LOC in ~1.6 s.
  • Incremental re-index of one changed file in ~55 ms.
  • In-process query latency < 2 ms for every query type.
  • On-disk index size is the one PRD target not met (~75% vs. <15%); the cause and remediation are documented honestly in the benchmarks doc and ADR-0005.

How it works

repo โ†’ Walker (ignore-aware) โ†’ tree-sitter parsers โ†’ Symbol/edge extraction
     โ†’ CodeGraph (in-memory, indexed) โ†’ redb (embedded, on-disk)
     โ†’ Query API โ†’ CLI / JSON / MCP
  • Parsing: tree-sitter (robust error recovery, incremental).
  • Resolution: two-tier โ€” fast tree-sitter name/scope heuristics now (labeled heuristic), with a SCIP precision tier designed in (labeled precise).
  • Storage: embedded, single-file, memory-mapped redb. No external DB.
  • Concurrency: rayon for parallel parsing/extraction.

Documentation

Ecosystem

RepoWhat it does
secret-scanRust secret scanner โ€” pattern + entropy-based detection, Base64/hex obfuscation detection
SentinelDeny-by-default agentic sysadmin: Investigate โ†’ Plan โ†’ Approve โ†’ Act
turbo-flowAgentic dev environment โ€” Ruflo v3.5 orchestration (by ruvnet), 60+ agents, git-worktree isolation

License

Dual-licensed under either MIT or Apache-2.0 at your option.