RAG + call graph: automatic context from a task tracker for Claude Code
Context is the main problem when working with LLM in real projects, not model quality. A developer on Habr described a solution: a repository RAG index with vectors and a call graph, plus a plugin for Claude Code. The system determines on its own which files and functions are related to a task from the tracker, assembles the context automatically, and trims it to a reasonable token limit.
AI-processed from Habr AI; edited by Hamidun News
Context is the main problem when using LLMs in real development. It's not the model quality or window size, but what and how it gets into the prompt. A developer shared a practical solution on Habr: a RAG index of the repository with vectors and a call graph, plus a Claude Code plugin that automatically collects context for a task from the task tracker — without manual selection and wasted tokens.
Why Context Matters More Than Model Quality
When a developer picks up a task from the tracker and opens an AI assistant, the hardest step isn't dialogue with the model, but preparation for it. You need to understand which files relate to the task, which functions are called, which modules are interconnected. In large projects, this takes 10–20 minutes of manual code review — before writing the first prompt. If you dump everything into context at once — tokens are spent quickly, the request gets expensive, and the LLM gets lost in noise from unrelated code. If you take too little — the model doesn't see dependencies, misses important functions, and gives shallow answers. Finding the balance manually is hard.
Classic RAG using embeddings solves part of the problem: semantic search finds semantically similar fragments. But it doesn't understand code structure: function A might be semantically distant from B, yet call it directly — and both are needed in context.
How the Solution Works
The author built a system on two indexing levels:
- Vector layer — code embeddings for semantic search: similar fragments, comments, names
- Call graph — structural dependencies: function A calls B, module C imports D, E inherits from F
- Claude Code plugin — reads task description from task tracker and runs search across both levels
- Ranking and truncation — results are weighted by relevance and cut to token limit
- Incremental updates — index is not recalculated from scratch with every commit
The system is built on top of a code parser (AST) and static analysis tools. The call graph lets you bypass semantic search limitations: even if function names are non-standard or comments are sparse, structural ties in code are still traced through the AST.
The index is stored separately from the code base and doesn't require changes to the repository itself. The Claude Code plugin installs as a standard extension and accesses the index through a local API.
Token Savings
This is where the approach delivers measurable results. Without smart context, developers often dump entire files or directories into the prompt — "just in case." With RAG + graph, the system decides what's relevant itself and returns only that.
"The main problem with using LLMs in a real project is not model
quality, but context," — the article's author.
For large monorepos the effect is especially noticeable: instead of 50,000 tokens of "everything that might be related" — 3,000–5,000 tokens of precise context. That's both response speed and direct API savings. Practice shows: properly collected context reduces the number of model iterations. When AI sees all dependencies at once, it rarely asks for additional fragments or gives incomplete answers.
What This Means
The approach shows real direction for engineering teams implementing AI assistants: automate not the dialogue with the model itself, but context collection before it. Integration with task tracker is a logical step: the task is already described, you just need to tie it correctly to the code. For large teams with hundreds of tickets a day, this can become a standard part of the engineering process.
Want to stop reading about AI and start using it?
AI News is a curated feed of AI/tech news. Hamidun Academy teaches you to use AI systematically in your work.
The AI world, distilled — once a week
Seven stories that actually mattered, hand-picked. No noise, no reposts, no press releases.
Done! Check your inbox for a confirmation.