Effloow
← Back to Articles
ARTICLES ·2026-04-27 ·BY EFFLOOW CONTENT FACTORY

AI Distiller: Extract LLM-Ready Code Context in Seconds

AI Distiller compresses codebases by 90–98% into clean LLM context using public API extraction. Install guide, CLI usage, and MCP integration with Claude.
ai-distiller codebase-context llm-tooling mcp code-analysis developer-tools
SHARE
AI Distiller: Extract LLM-Ready Code Context in Seconds

If you have spent any time asking Claude or GPT-6 to review a large codebase, you have hit the same wall: paste too much and the model bogs down or hallucinates; paste too little and it misses critical dependencies. The context window is generous in 2026—Claude Sonnet 4.6 has 1 million tokens—but feeding raw source code is still the wrong approach. Private helper functions, auto-generated boilerplate, and third-party vendored files are noise. What a model actually needs is the public interface: signatures, types, and the relationships between them.

AI Distiller (aid), an open-source tool from developer Jan Reges, targets this problem directly. It ingests your source tree and outputs a compressed representation containing only public APIs, data types, and structural signatures—stripping away implementations that the model does not need to reason about. The result is typically 90–98% smaller than the original codebase, while preserving enough information for an LLM to produce accurate, compatible code on the first attempt rather than through trial and error.

Why Raw Source Code Is a Poor LLM Context

When developers paste entire files into AI chats, several things go wrong simultaneously.

First, token cost scales with context length. At $3 per million input tokens (Claude Sonnet 4.6), a 500 KB source dump costs roughly $1.50 per request. Multiply by developer sessions across a team and the spend climbs quickly. The cost management strategies used in LLM gateways like LiteLLM do not help here because the code itself changes with every session.

Second, signal-to-noise ratio degrades. Private method implementations, inline comments, and vendored dependencies consume tokens that contribute little to the model's understanding of your API surface. Research on LLM attention patterns consistently shows that models perform better when the relevant information is dense rather than buried.

Third, and most practically: models trained to be helpful tend to try to use everything you give them. Feed an LLM a private internal helper it should not be calling, and there is a good chance it ends up in the generated code—breaking your encapsulation and creating bugs that only appear at runtime.

AI Distiller addresses all three by acting as a preprocessing step before context reaches the model.

What AI Distiller Actually Does

The tool's core operation is structural extraction. Given a source file or directory, aid parses the code using tree-sitter grammars—compiled directly into the binary, zero external dependencies—and emits only the parts of the AST that form the public interface.

For a TypeScript file with five exported functions and twelve private helpers, the distilled output would contain the five function signatures with their parameter types and return types, and nothing else. For a Python module, it would emit class definitions with public method signatures, type annotations, and docstrings—but not the method bodies.

The compression targets are aggressive:

  • 90–98% size reduction on typical application codebases
  • 5–20% of the original token count remaining after distillation
  • Processing speed: tens of megabytes of source code in hundreds of milliseconds, according to the project documentation

Three output formats are available. Text mode produces ultra-compact output optimized for AI consumption. Markdown mode adds structure headings that help models orient within large outputs. JSON Structured mode emits semantic data—useful for tools that want to build their own views over the distilled representation.

Supported Languages

AI Distiller supports 12+ programming languages through its bundled tree-sitter grammars:

  • Python, JavaScript, TypeScript
  • Go, Rust
  • Java, C, C++
  • PHP, Ruby
  • Additional languages via community grammars

Because the grammars are compiled into the binary, there are no per-language installations or runtime dependencies to manage.

Installation: Three Paths

Path 1: MCP Server (Recommended for Claude Code Users)

The most direct path for Claude Code users is a single command:

claude mcp add aid -- npx -y @janreges/ai-distiller-mcp

This registers AI Distiller as an MCP server in your Claude Code configuration. Once added, Claude can invoke aid directly during conversations to distill files or directories on demand—without you manually running any CLI commands.

Effloow Lab inspected the npm package (@janreges/ai-distiller-mcp@1.3.3) and confirmed it is installable via npx. The package is a thin wrapper (24.4 kB compressed) around the native binary. A postinstall script downloads the platform-appropriate binary during installation.

Path 2: Direct Binary Download

For CI/CD pipelines or environments where npx is not available, pre-built binaries are available from the GitHub Releases page for all major platforms:

Platform Variant Notes
macOS x64, ARM (M-series) Universal binaries available
Linux x64, ARM Suitable for Docker/CI
Windows x64 PowerShell compatible

Download the binary, make it executable (chmod +x aid on Unix), and place it in your $PATH. No runtime required.

Path 3: npx One-Shot

For quick experiments without a persistent install:

npx @janreges/ai-distiller-mcp <path-to-directory>

This triggers the postinstall script, downloads the binary for your platform, and runs it. Suitable for one-off analysis tasks.

CLI Usage

Once installed, the aid command works against files or directories:

# Distill a single file
aid src/api/users.ts

# Distill an entire directory
aid src/

# Distill with Markdown output (more readable)
aid src/ --format=md

# Include private members (opt-in)
aid src/ --include-private

# Dependency-aware distillation (analyzes call graphs)
aid main.py --dependency-aware

# Output to a file for piping into AI workflows
aid src/ --format=md > context.md

The --dependency-aware flag is one of the more powerful options. Instead of distilling everything in a directory, it traces the actual import and call graph starting from an entry point, and only includes code that is reachable from that entry. This produces tighter contexts for focused tasks like "explain how the authentication flow works" rather than dumping the full module tree.

AI Prompt Generation

A feature worth highlighting separately: aid can generate ready-to-use prompts that bundle the distilled context with task instructions. This is useful for repeatable workflows like security audits, refactoring sessions, or architecture reviews.

The generated prompt includes both the distilled codebase and a structured instruction for the AI to follow. You paste the output into Claude or GPT-6, and the model starts the task from a well-framed context rather than a blank slate.

Supported prompt templates (from documentation) include:

  • Security audit — prompts the model to look for OWASP-class vulnerabilities in the API surface
  • Refactoring — provides context for suggesting interface improvements
  • Architecture review — frames the distilled output for high-level structural analysis

This prompt generation capability positions AI Distiller as more than a compression utility. It is closer to a workflow tool for repeatable AI-assisted development tasks.

MCP Integration With Claude Code and Cursor

Once registered as an MCP server, AI Distiller exposes tools that Claude Code or Cursor can call during agent sessions. The integration lets you describe a task in natural language and have the agent distill the relevant code automatically before reasoning about it.

Example workflow:

  1. You: "Review the public API of the src/payments/ module for potential type safety issues."
  2. Claude Code calls the aid MCP tool on src/payments/.
  3. aid returns a distilled context of ~500 tokens (instead of the raw ~8,000-token directory).
  4. Claude reasons over the clean interface and returns precise feedback.

This pattern is particularly effective for large monorepos where loading the full codebase would exceed practical token budgets even with a 1M-token context window.

For Cursor users, the integration configuration is similar—add the MCP server via Cursor's MCP settings panel and point it at npx @janreges/ai-distiller-mcp.

Practical Use Cases

RAG Over Code

When building retrieval-augmented generation pipelines over a codebase, the indexing step determines retrieval quality. Indexing raw source files means embedding noisy implementation details alongside the API contracts. Indexing distilled output means embeddings capture the semantic interface rather than the noise.

This pairs naturally with tools like Langfuse for tracing and vector databases like Qdrant—the distilled output reduces index size and often improves retrieval precision for code-related queries.

Onboarding New Developers

New contributors to a codebase often need the "map" before the "territory." Running aid over a module directory and sharing the Markdown output gives newcomers a navigable summary of the public API without requiring them to read thousands of lines of implementation code.

Documentation Generation

Feed the distilled output to a documentation-aware prompt and generate API reference documentation that stays accurate because it is derived from actual type signatures rather than from manually maintained docs that drift over time.

Pre-Commit Code Review Hooks

In CI pipelines, aid can distill changed files and submit the result to an LLM-based reviewer—a pattern that makes automated review faster and cheaper than sending full diffs. The Microsoft markitdown guide covers a related pattern for document ingestion that can complement this workflow when your codebase includes documentation files alongside code.

How It Compares

The codebase context space has several tools now, each with a different philosophy:

ToolApproachOutputMCPBest For
AI DistillerPublic API extraction (AST-level)Text / MD / JSONYesAPI signatures, interface review
RepomixFull repo pack with compressionXML, MD, plain textYes (community)Full codebase handoff
cased/kitSymbol extraction + code searchAPI (programmatic)PartialAI devtools builders
context-hub/generatorDeveloper-curated context docsStructured documentsNoManual, curated context

The key distinction: Repomix is about including everything—it packs the whole repo with configurable filters. AI Distiller is about excluding everything except the interface contract. For tasks where the model needs to understand implementation details (debugging a specific function, for example), Repomix's approach is more appropriate. For tasks involving architectural understanding, code generation against an existing API, or review of public interfaces, AI Distiller's aggressive stripping produces better results.

Limitations to Know

Not for implementation-level debugging. If the bug is inside a private method, AI Distiller's output will not help—the implementation is stripped. You would need to feed the raw file for that specific module.

Accuracy depends on grammar quality. The tree-sitter grammars are compiled in and well-maintained for the primary languages, but edge cases in complex language features (Rust macros, Python metaclasses, C++ template metaprogramming) can produce imperfect distillations. Always verify the output covers what you expect before relying on it.

Binary download on install. The npm postinstall script downloads a platform binary. In locked-down CI environments with no outbound access during build, you may need to cache the binary separately and configure a custom install path.

Not a substitute for documentation. AI Distiller extracts signatures and type information. If your codebase lacks type annotations or docstrings, the distilled output will be sparse. It amplifies existing documentation rather than generating missing documentation.

FAQ

Q: Does AI Distiller send my code to any server?

No. The aid binary runs entirely locally. It does not make network requests during distillation. The only outbound activity is the one-time binary download during installation.

Q: How does it handle monorepos with multiple languages?

aid processes each file according to its language (detected by extension). In a monorepo with TypeScript frontend and Go backend, both will be distilled in a single pass. The output will interleave both, or you can target subdirectories separately with two commands.

Q: What happens to files in languages it does not support?

Unsupported files are skipped by default. You can configure the tool to pass them through as-is or to emit a placeholder.

Q: Can I use it without Claude or any specific LLM?

Yes. AI Distiller is LLM-agnostic. The CLI output is plain text, Markdown, or JSON—paste it into any AI tool or pipeline. The MCP server provides convenient integration with Claude Code and Cursor specifically, but nothing in the core tool is tied to a particular model provider.

Q: How does the dependency-aware mode differ from standard mode?

Standard mode distills all public symbols in a given directory or file, regardless of whether they are actually used from a specific entry point. Dependency-aware mode (--dependency-aware) traces the import and call graph from a given entry point file, and only includes symbols reachable from that entry. The result is a more focused context suitable for tasks scoped to a specific workflow or feature.

Key Takeaways

AI Distiller occupies a specific and useful niche in the growing ecosystem of LLM developer tools. It is not a general-purpose code packer—it is a precision extractor designed for the cases where what you want to communicate to a model is "here is how this system is structured and what its contracts are," not "here is every line of implementation."

For teams running AI-assisted code review, architectural Q&A, or interface generation, it represents a practical way to reduce token cost while improving the quality of AI outputs. The MCP integration makes it available inside Claude Code sessions without any manual context assembly.

The tool is MIT-licensed, zero-dependency at runtime, and available as a single binary across all major platforms. For developers already invested in AI-assisted workflows, adding claude mcp add aid -- npx -y @janreges/ai-distiller-mcp takes under thirty seconds and immediately changes how much context you need to manage manually.

Bottom Line

AI Distiller solves a real problem in AI-assisted development: raw source code is noisy, expensive context. By extracting only public API signatures and types, it produces compact, high-signal inputs that lead to fewer hallucinations and more accurate code generation. If you work with large codebases and Claude Code or Cursor regularly, the MCP integration is worth adding.

Need content like this
for your blog?

We run AI-powered technical blogs. Start with a free 3-article pilot.

Learn more →

More in Articles

Stay in the loop.

One dispatch every Friday. New articles, tool releases, and a short note from the editor.

Get weekly AI tool reviews & automation tips

Join our newsletter. No spam, unsubscribe anytime.