← Reddit

I built a local context compiler so AI coding agents stop re-reading the same repo

Reddit · CaptainProud4703 · May 22, 2026
Madar, an open-source tool formerly called graphify-ts, addresses the inefficiency of AI coding agents repeatedly exploring and re-reading the same codebases by building a structural graph and generating compact context packs tailored to specific tasks. The tool works locally without requiring API keys and supports TypeScript/Node.js projects with framework-aware extraction for platforms like NestJS, Next.js, and Express, integrating with multiple AI coding assistants through MCP or CLI interfaces. Early testing indicates the tool reduces input token consumption while maintaining answer quality, though results vary based on repository size and task complexity.

Detailed Analysis

A developer working under the GitHub handle mohanagy has released an open-source tool called Madar (@lubab/madar on npm), designed to address a recurring inefficiency in AI-assisted software development: the tendency of coding agents to redundantly re-explore codebases across successive tasks. Rather than allowing agents like Claude Code, Cursor, GitHub Copilot, or Google's Gemini to repeatedly grep through files, summarize structures, and lose accumulated context between sessions, Madar pre-compiles a structural graph of a codebase and assembles targeted "context packs" before any agent begins its work. The tool operates entirely locally and requires no API key for graph construction, lowering the barrier to adoption. Its current feature set includes extraction of relevant files and symbols, route/service/call relationships, runtime execution slices, source location mapping, coverage diagnostics, and pre-formatted compact prompts suited for agent consumption.

The tool's most concrete value proposition lies in token reduction. Because large language model APIs charge by input tokens and impose context window limits, redundant file reads and re-summarizations across tasks impose measurable cost and latency penalties on teams working with substantial TypeScript or Node.js codebases. Madar targets this inefficiency by front-loading structural analysis so agents enter tasks with richer, more targeted context rather than broad exploratory prompts. The developer reports meaningful reductions in provider-reported input tokens during testing against real backend prompts, though appropriately hedges that results vary by repository and task type. Framework-aware extraction for popular ecosystems — NestJS, Next.js, Express, Fastify, Hono, tRPC, Prisma, and routing-controllers — adds practical specificity, allowing the graph-building process to understand idiomatic patterns rather than treating all codebases as undifferentiated file trees.

The integration strategy is notable for its breadth. Madar supports the Model Context Protocol (MCP), enabling direct integration with Claude Code, Cursor, Copilot, and Gemini, while also supporting CLI-generated prompt outputs for tools like Codex, Aider, and OpenCode that do not use MCP. This dual-mode approach reflects a pragmatic understanding of the fragmented AI coding tool landscape, where no single protocol or interface has achieved universal adoption. The MCP pathway is particularly significant given Anthropic's investment in MCP as a standardized interface for tool-augmented agents; by supporting it natively, Madar positions itself within the emerging ecosystem of composable agent infrastructure rather than as a standalone utility.

Madar's emergence reflects a broader trend in AI development tooling: the recognition that raw model capability is increasingly insufficient on its own, and that the infrastructure surrounding how context is prepared, managed, and delivered to agents matters enormously for practical performance. As coding agents are deployed on enterprise-scale repositories, the problem of context window saturation and redundant exploration becomes a genuine engineering constraint rather than a theoretical concern. Tools like Madar represent an emerging category — sometimes called "context engineering" infrastructure — that sits between the raw codebase and the model, optimizing the information pipeline rather than the model itself. This mirrors analogous developments in retrieval-augmented generation (RAG) for document-heavy applications, where the quality of the retrieval layer often determines output quality more than model selection does.

The developer's open questions — whether context compilation constitutes a genuinely useful abstraction layer, whether execution slices improve explanation reliability, and what benchmark formats developers would trust — are substantive research questions that the broader AI engineering community has not yet resolved. The tool's release into the Claude Code and Cursor user communities, where practitioners actively experiment with agent-augmented workflows on real codebases, positions it well for the kind of empirical feedback needed to validate or refine these hypotheses. Whether Madar achieves adoption will likely depend on how consistently the token savings and context quality improvements hold across diverse real-world repositories, and whether the overhead of maintaining a structural graph remains manageable as codebases evolve.

Read original article →