How to save 70% of Claude tokens with targeted code access
A developer built a PHP + SQLite tool to optimize Claude Code for large projects. Two scripts, buildGraph and claudeSearch, create a project dependency graph an

A developer created a tool that saves Claude's context window by 70% when working with large projects. Instead of reading entire files, an AI agent gets targeted access to the code it needs — exactly what's required for the task.
Problem: Valuable context is wasted
Claude Code knows the project architecture from CLAUDE.md and understands which files are responsible for what. But in practice, the agent still reads entire files. Need one method — it reads the whole class with all its methods. Need to find where a function is called — it reads directory after directory searching for patterns. Context depletes quickly, and no useful work has been done yet.
A typical scenario: a developer asks Claude to find a field in an entity. The agent opens the entire file, even though only the first 20 lines with field descriptions and constructor are needed. Or simpler: understand the relationship structure between database tables. Claude reads entire SQL files, though just table names and keys would suffice for the answer.
The context window is the primary resource when working with AI on large projects. Out of 200K tokens, 100K could be spent reading code that could have been obtained more intelligently.
Solution: dependency graph and targeted access
The developer created two PHP scripts that work together:
buildGraph.php — scans the project once and builds a dependency graph in SQLite. Parses PHP and JavaScript code: extracts classes, methods, functions, imports, inheritance chains. Execution is incremental — on subsequent runs, it updates only files that have changed. This takes 100–200 milliseconds for a medium project.
claudeSearch.php — CLI interface for agents. With one command, it gives Claude exactly what it needs:
- A specific class method with signature and body
- All fields and the class constructor
- The entire inheritance chain for an entity
- All SQL queries for a specific table
- A list of all function calls throughout the project
- Dependencies between modules
Instead of `Read(path/to/huge-file.php)`, Claude now writes `search("User", "fields")` and gets 15 lines. Instead of reading three directories, it writes `search("saveOrder()", "calls")` and sees all places where this method is used.
Language support and performance
Currently, the tool fully supports PHP and JavaScript. Support for Go has already been added. C will come later. Parsing speed is critical — the graph must update as fast as the developer changes code. Incremental updates solve this problem: the first pass analyzes the entire project (can take several seconds on a large repo), subsequent passes update only changed files in 100–200 ms.
What it delivers in practice
According to the author's calculations, the tool reduces token consumption by 70% for a typical medium project. This doesn't mean each individual request saves 70% — it means that over one development session, context is used 3 times more efficiently. Instead of spending 150K tokens reading and then 50K working, a developer can spend 70K searching and 80K working.
The tool is especially useful for CLI assistants and bots that cannot see the file system themselves. The graph becomes the source of truth about project structure for them.
What it means
The tool points in a direction: scaling Claude's work on large projects is not just about architectural decisions and a well-written CLAUDE.md. What's needed is intelligent code access. Targeted reading instead of full. Graph instead of file system. When context becomes a constraint, you need to read based on what's actually needed, not on code volume.