ctx: an open-source Rust code graph agents can query to save context budget (MCP support)
arcandor · reddit · 2026-08-27
A developer open-sourced ctx (MIT, single Rust binary) that turns a source tree into a queryable code graph, letting coding agents ask where things are instead of grepping and reading files to fill up the context window. The author says he designed the architecture and heuristics while Claude wrote the implementation.
Key queries:
- ctx callers finds callers of a symbol; ctx trace --reverse traces execution paths
- ctx path finds the shortest path between symbols; ctx context --max-tokens 4000 pulls everything needed to edit a target
- ctx changed --api --since main shows what breaks on API changes; ctx parity checks Python/Rust port consistency
Built on Tree-sitter with a unified graph across Rust/Python/TS/Markdown—no language servers, embeddings, or index warm-up; builds in 100ms deterministically against current source. Reports 96.2% internal call-graph recall on its own codebase. Falls back to a unique-name heuristic for unevaluated-expression receivers. MCP support included; install via cargo install code-context or brew.
More from coding & agent
- Dev pushes back on "AI coding means insecure apps": humans always shipped bugs — dreamwieber · 2026-10-15
- Eight non-negotiable principles for building AI that actually learns from experience — tokenbender · 2026-10-15
- Animated teardown of XBOW's Chrome full-chain exploit that won Google's first $250K VRP bounty — moyix · 2026-10-15
- pstack's durable core: 10-20 line skills that distill agent best practices into principles — HankYeomans · 2026-10-15
- 'Children of Elon' forum lets AI agents post and teach each other while humans watch — AiJohnAllen · 2026-10-15
- VoidZero open-sources Void: SDK, CLI and platform to deploy Vite apps on Cloudflare — cnakazawa · 2026-10-15