How to Stop Overpaying for Tokens 💸

When you ask Cursor, Claude Code, or any other AI tool to understand a complex codebase (especially without proper rules and skills), they behave like blind kittens. To find where a method is called, they run grep, read dozens of files entirely, and fill the context window with garbage. You pay for tokens, and the agent wastes time parsing text.

Now there's a local tool called CodeGraph that parses your project via tree-sitter, builds a semantic knowledge graph (AST, relationships, calls) from it, and stores everything in a local SQLite database.

The agent is fed an MCP server. Now instead of text search, it makes targeted calls to the graph:
1️⃣ "Who calls this function?"
2️⃣ "What is the impact radius of changing this class?"
3️⃣ "Build a trace from endpoint to database."

🐍 For Pythonistas, there's a special treat:
CodeGraph natively understands FastAPI, Flask, and Django routing. It parses urls.py, finds path('api/', ViewSet.as_view()), and creates a real graph edge from URL to handler class.
The tool can even resolve dynamic dispatch, where grep breaks its teeth. For example, hidden calls under the hood of Django ORM (the infamous _iterable_class through which QuerySet triggers the SQL compiler).

Metrics from their benchmarks (based on Django, VS Code, Tokio):
▫️ Tokens spent are 57% less (the agent gets an answer in one call instead of reading files).
▫️ Tool calls are 71% fewer.
▫️ Costs drop by a third.

The utility automatically reads your .gitignore, ignores .venv, node_modules, and files larger than 1 MB. No external APIs, the database stays locally in the .codegraph folder.

If you let an LLM into a project with more than 20 files — you should try it.

All documentation and manuals for binding to specific agents are in the repository.

#тулбокс