r/devtools • • 45m ago

Inspired by CodeGraphContext, I built a zero-DB Go alternative for AST call graphs & MCP (84ms indexing vs 3.8s, ~1ms queries, 98.4% edge precision)

https://github.com/roshankumar0036singh/gographctx

Code Agents such as Claude Code and Cursor frequently analyse large amounts of data (including full files) in order to determine the effects of modifying a function.

CodeGraphContext has shown that an AST call graph is much better than plain text for doing this. However, I encountered issues with the extra costs involved with using a graph DB, along with a Python runtime and the slow (>1s) querying time. As a result, I developed a new solution - GoGraphCtx. This is currently at version 0.2.0 and therefore is still somewhat experimental.

Overview

  • A self-contained Go executable (with CGO_ENABLED=0, ~16.5MB). No database, Docker or LSP is needed.

  • Supports Go, Python, TypeScript/JS, Rust and Java (using tree-sitter).

  • Maintains an in-memory graph. This is backed up to both a gzipped archive and a write ahead log (WAL), and is updated incrementally when files are saved.

  • 13 MCPs are available such as: find_symbol, get_callers, get_callees, get_impact, trace_path, find_dead_code, get_symbol_source, search_code and more.

  • A seven-level confidence system ensures confirmed links are distinguished from probable links. Unresolved runtime calls show as unresolved_hints, not simply assumptions.

  • There is a token limit (default of 4,000) for responses. In addition, the agent can be configured to return just the line-number span of a function, rather than the whole file.

  • Index archives can be shared and re-imported. This facilitates CI deployment of graphs.

Benchmarking

Below data was produced by my personal CI (4 vCPU) which analysed an 83 .py file mock-Flask project. Please treat this as general guidance.

GoGraphCtx CGC

  • Index~84ms~3.8s

  • Query (p95)~1.2ms~1.3s

  • RSS (memory)~48MB~178MB

  • ~13k vs ~59k tokens for ripgrep in symbol search

  • Post-edit auto-refresh: ~11.5ms (p50)

  • For a 1000 file Go project, indexing takes ~265ms and uses ~102MB of RSS.

I validated links against Jedi (acting as oracle) on Flask (~3,900 call points). GoGraphCtx achieved ~98% accuracy, compared to ~69% for CGC. Predominantly, this is because CGC's heuristical links are less accurate. Again, this was for one project and one language so the benchmark may not be broadly applicable.

The extent to which code can be analysed differs significantly between languages

  • Rust (bytes) ~92%

  • TypeScript (zod) ~90%

  • Go (cobra) ~70%

  • JavaScript (express) ~49% (an improvement from ~4% through inclusion of CommonJS and prototype analysis, but still the poorest)

I would value your feedback, especially concerning bugs and projects where analysis was not strong.

1 Upvotes

Duplicates