The full upstream README, mirrored here for reference. Install config, tool schemas, adoption signals, and an original overview live on the AI Distiller MCP listing page.
aid)Note: This is the very first version of this tool. We would be very grateful for any feedback in the form of a discussion or by creating an issue on GitHub. Thank you!
🚀 MCP Server Available: Install the Model Context Protocol server for AI Distiller from NPM: @janreges/ai-distiller-mcp - seamlessly integrate with Claude, Cursor, and other MCP-compatible AI tools!
Do you work with large-scale projects that have thousands of files and functions? Do you struggle with AI tools like Claude Code, Gemini, Copilot, or Cursor frequently "hallucinating" and generating code that looks correct at first glance but is actually incompatible with your project?
The problem is context. AI models have a limited context window and cannot comprehend your entire codebase. Instead, AI agents search files, "grep" for keywords, look at a few lines before and after the found term, and try (often, but not always) to guess the interface of your classes and functions. The result? Code full of errors that guesses parameters, returns incorrect data types, and ignores the existing architecture. If you are a sophisticated user of AI agents (vibe coder), you know that you can help yourself by instructing the AI agent to consistently write and run tests, using static code analysis, pre-commit hooks, etc. - the AI agent will usually fix the code itself, but in the meantime it will take 20 steps and 5 minutes. On the other hand, it must be admitted that if you pay for each AI request (and large context is an expensive factor) and are not "playing for time", you may not mind this limited context approach.
AI Distiller (or aid for short) helps solve this problem. Its main function is code "distillation" – a process where it extracts only the most essential information from the entire project (ideally from the main source folder, or a specific module subdirectory for extremely large projects) that the AI needs to write code correctly on the first try. This distillation usually generates a context that is only 5-20% of the original source code volume, allowing AI tools to include it in their context. As a result, the AI uses the existing code exactly as it was designed, not by trial and error.
Very simply, it can be said that aid, within the distillation process, will leave only the public parts of the interface, input and output data types, but in the default state it will discard method implementations and non-public structures. But everything is configurable via CLI Options.
| Feature | Description |
|---|---|
| 🚀 Extreme Speed | Processes tens of megabytes of code in hundreds of milliseconds. By default, it uses 80% of available CPU cores, but can be configured, e.g., with --workers=1 to use only a single CPU core. |
| 🧠 Intelligent Distillation | Understands 12+ programming languages and extracts only public APIs (methods, properties, types). |
| ⚙️ High Configurability | Allows including private, protected, and internal members, implementation, or comments. |
| 🤖 AI Prompt Generation | Generates ready-to-use prompts with distilled code for AI analysis. The tool creates files with prompts that AI agents can then execute for security audits, refactoring, etc. See --ai-action switch. |
| 📋 Analysis Automation | Creates a complete checklist and directory structure for AI agents, who can then systematically analyze the entire project. See the flow-for-* actions for the --ai-action switch. |
| 📜 Git Analysis | Processes commit history and prepares data for in-depth analysis of development quality and team dynamics. |
| 💻 Multi-platform | A single binary file with no dependencies for Windows, Linux, and macOS (x64 & ARM). |
| 🔌 Integration via MCP | Can be integrated into tools like Claude Code, VS Code, Cursor, Windsurf and others thanks to the included MCP server. |
Control exactly what to include with our new granular flag system:
Visibility Control:
--public=1 (default) - Include public members--protected=0 (default) - Exclude protected members--internal=0 (default) - Exclude internal/package-private--private=0 (default) - Exclude private membersContent Control:
--comments=0 (default) - Exclude comments--docstrings=1 (default) - Include documentation--implementation=0 (default) - Exclude function/methods bodies--imports=1 (default) - Include import/use statementsDefault behavior: Shows only public API signatures with basic documentation - perfect for AI understanding while maintaining maximum compression.
AI Distiller generates specialized prompts combined with distilled code for AI-driven analysis:
--ai-action=flow-for-deep-file-to-file-analysis - Generates task lists and prompts for systematic file-by-file analysis--ai-action=flow-for-multi-file-docs - Creates documentation workflow prompts with code structure.aid/ directory (or use --stdout for small codebases)Note: AI Distiller doesn't perform the analysis itself - it prepares optimized prompts that AI agents (Claude, Gemini, ChatGPT) then execute. Users often need to explicitly ask their AI agent to process the generated file or copy its contents to web-based AI tools.
--format text) - Ultra-compact for AI consumption (default)--format md) - Clean, structured Markdown--format json-structured) - Rich semantic data for tools--format jsonl) - Streaming format--format xml) - Legacy system compatibleAfter each distillation, AI Distiller displays a summary showing compression efficiency and processing speed:
Available formats:
visual-progress-bar (default) - Shows compression as a progress barstock-ticker - Compact stock market style displayspeedometer-dashboard - Multi-line dashboard with metricsminimalist-sparkline - Single line with all essential infoci-friendly - Clean format for CI/CD pipelinesjson - Machine-readable JSON outputoff - Disable summary outputUse --no-emoji to remove emojis from any format.
AI Distiller automatically detects your project root and centralizes all outputs in a .aid/ directory:
.aidrc, go.mod, package.json, .git, etc.<project-root>/.aid/ regardless of where you run aid.aid/cache/ for better organization.aid/ to .gitignore to keep outputs out of version controlDetection priority:
.aidrc file - Create this empty file to explicitly mark your project rootgo.mod, package.json, pyproject.toml, etc..git directoryAID_PROJECT_ROOT (fallback if no markers found)Currently supports 12 languages via tree-sitter:
All tree-sitter grammars are compiled into the aid binary - zero external dependencies!
Advanced Feature: AI Distiller includes dependency-aware distillation that analyzes call graphs across files and includes only the code that is actually used from your codebase. This creates focused distillations for deep code analysis by following function/method calls across multiple files.
💡 New to dependency analysis? This feature traces which functions actually call each other in your code, creating a minimal context that includes only the relevant parts. Perfect for AI tools that need to understand code relationships without processing entire files.
Instead of including entire files, dependency-aware distillation:
We've worked extensively to make dependency-aware distillation as reliable as possible across different programming languages. However, the complexity varies significantly between languages, and we want to be transparent about the current state:
| Language | Support Level | Cross-File Analysis | Intra-File Calls | Performance | Notes |
|---|---|---|---|---|---|
| Python | 🟢 Very Good | ✅ Full | ✅ Complete | ~37ms | Package imports, all call patterns |
| JavaScript | 🟢 Very Good | ✅ Full | ✅ Complete | ~38ms | CommonJS & ES6 modules |
| Go | 🟢 Very Good | ✅ Full | ✅ Complete | ~37ms | Package system integration |
| Rust | 🟢 Very Good | ✅ Full | ✅ Complete | ~36ms | Crate system, proper filtering |
| Java | 🟢 Very Good | ✅ Full | ✅ Complete | ~41ms | Package imports, static methods |
| Swift | 🟢 Very Good | ✅ Full | ✅ Complete | ~37ms | Class and static method detection |
| PHP | 🟢 Very Good | ✅ Full | ✅ Complete | ~37ms | Include/require resolution |
| Ruby | 🟢 Very Good | ✅ Full | ✅ Complete | ~40ms | Module system, all call patterns |
| TypeScript | 🟡 Limited | ❌ Issues | ❌ Issues | N/A | Language processor limitations |
| C# | 🟡 Limited | ❌ Issues | ❌ Issues | N/A | Language processor limitations |
| C++ | 🟡 Limited | ❌ Issues | ❌ Issues | N/A | Language processor limitations |
| Kotlin | 🟠 Good | ✅ Partial | ⚠️ Basic | ~45ms | Companion objects, some edge cases |
Legend:
Very Good Performance (8 languages):
Areas for Enhancement:
Perfect for:
Best Practices:
The Problem: Modern codebases contain thousands of files with millions of lines. But for AI to understand your code architecture, suggest improvements, or help with development, it doesn't need to see every implementation detail - it needs the structure and public interfaces.
The Solution: AI Distiller extracts only what matters - public APIs, types, and signatures - reducing codebase size by 90-98% while preserving all essential information for AI comprehension.
| Project | Files | Original Tokens | Distilled Tokens | Fits in Context1 | Speed2 |
|---|---|---|---|---|---|
⚛️ react | 1,781 | ~5.5M | 250K (-95%) | ✅ Gemini3 | 2,875 files/s |
🎨 vscode | 4,768 | ~22.5M | 2M (-91%) | ⚠️ Needs chunking | 5,072 files/s |
🐍 django | 970 | ~10M | 256K (-97%) | ✅ Gemini3 | 4,199 files/s |
📦 prometheus | 685 | ~8.5M | 154K (-98%) | ✅ Claude/Gemini | 3,071 files/s |
🦀 rust-analyzer | 1,275 | ~5.5M | 172K (-97%) | ✅ Claude/Gemini | 10,451 files/s |
🚀 astro | 1,058 | ~10.5M | 149K (-99%) | ✅ Claude/Gemini | 5,212 files/s |
💎 rails | 394 | ~1M | 104K (-90%) | ✅ ChatGPT-4o | 4,864 files/s |
🐘 laravel | 1,443 | ~3M | 238K (-92%) | ✅ Gemini3 | 4,613 files/s |
⚡ nestjs | 802 | ~1.5M | 107K (-93%) | ✅ ChatGPT-4o | 8,813 files/s |
👻 ghost | 2,184 | ~8M | 235K (-97%) | ✅ Gemini3 | 4,719 files/s |
1 Context windows: ChatGPT-4o (128K), Claude (200K), Gemini (1M). ✅ = fits completely, ⚠️ = needs splitting
2 Processing speed with 12 parallel workers on AMD Ryzen 7945HX. Use -w 1 for serial mode or -w N for custom workers.
3 These frameworks exceed 200K tokens and work only with Gemini due to its larger 1M token context window.
Large codebases are overwhelming for AI models. A typical web framework like Django has ~10 million tokens of source code. Even with Claude's 200K context window, you'd need to split it into 50+ chunks, losing coherence and relationships between components.
But here's the good news: Most real-world projects that teams have invested hundreds to thousands of hours developing are much smaller. Thanks to AI Distiller, the vast majority of typical business applications, SaaS products, and internal tools can fit entirely within AI context windows, enabling unprecedented AI assistance quality.
Most AI agents and IDEs are "context misers" - they try to save tokens at the expense of actual codebase knowledge. They rely on:
This is why AI-generated code often fails on first attempts - the AI is literally guessing method signatures, parameter types, and return values because it can't see the full picture.
AI Distiller changes the game by giving AI complete knowledge of:
Instead of playing "code roulette", AI can now write correct code from the start.
Result: Django's 10M tokens compress to just 256K tokens - suddenly the entire framework fits in a single AI conversation, leading to:
Granular Control: Process your entire codebase, specific modules, directories, or even individual files. Perfect for focusing AI on the exact context it needs - whether that's understanding the whole system architecture or diving deep into a specific authentication module.
📈 Full benchmark details | 🧪 Reproduce these results
macOS / Linux / WSL:
Windows PowerShell:
The installer will:
~/.aid/bin/aid by default (no sudo required)/usr/local/bin/aid with --sudo flagInput (car.py):
Output (aid car.py --format text --implementation=0):
Input (api.ts):
Output (aid api.ts --format text --implementation=0):
AI Distiller generates sophisticated analysis prompts that AI assistants can execute for comprehensive codebase understanding:
What AI Distiller generates:
.aid/ANALYSIS-TASK-LIST.PROJECT.DATE.md)How to use the generated prompts:
--stdout to get prompt directly without saving to fileNote: The analysis dimensions (Security, Performance, Maintainability, Readability) are part of the prompts that guide the AI - AI Distiller itself doesn't perform any analysis.
AI Distiller now integrates seamlessly with Claude Code/Desktop through the Model Context Protocol (MCP), enabling AI agents to analyze and understand codebases directly within conversations.
📦 NPM Package: @janreges/ai-distiller-mcp - Full documentation and examples available
🔍 Code Structure Tools:
distill_file - Extract structure from a single filedistill_directory - Extract structure from entire directorieslist_files - Browse directories with file statisticsget_capabilities - Get info about AI Distiller capabilities🎯 Specialized AI Analysis Tools:
aid_hunt_bugs - Generate bug-hunting prompts with distilled codeaid_suggest_refactoring - Create refactoring analysis promptsaid_generate_diagram - Produce diagram generation prompts (Mermaid)aid_analyze_security - Generate security audit prompts (OWASP Top 10)aid_generate_docs - Create documentation generation promptsaid_deep_file_analysis - Systematic file-by-file analysis workflowaid_multi_file_docs - Multi-file documentation workflowaid_complex_analysis - Enterprise-grade analysis promptsaid_performance_analysis - Performance optimization promptsaid_best_practices - Code quality and best practices prompts🔧 Core Analysis Engine:
aid_analyze - Direct access to all AI actions for custom workflowsImportant: AI Distiller generates analysis prompts with distilled code - it does NOT perform the actual analysis! The output is a specialized prompt + distilled code that AI agents (like Claude) then execute. For large codebases, you can copy the output to tools like Gemini 2.0 with 1M context window.
Smart Context Management: AI agents can analyze your entire project for understanding the big picture, then zoom into specific modules (auth, API, database) for detailed work. No more overwhelming AI with irrelevant code!
| Argument | Type | Default | Description |
|---|---|---|---|
<path> | String | (required) | Path to source file or directory to analyze. Use .git for git history mode, - (or empty) for stdin input |
| Option | Type | Default | Description |
|---|---|---|---|
-o, --output | String | .aid/<dirname>.[options].txt | Output file path. Auto-generated based on input directory basename and options if not specified |
--stdout | Flag | false | Print output to stdout in addition to file. When used alone, no file is created |
--format | String | text | Output format: text (ultra-compact), md (clean Markdown), jsonl (one JSON per file), json-structured (rich semantic data), xml (structured XML) |
| Option | Type | Default | Description |
|---|---|---|---|
--ai-action | String | (none) | Generate pre-configured prompts with distilled code for AI analysis. See AI Actions section below |
--ai-output | String | ./.aid/<action>.<timestamp>.<dirname>.md | Custom output path for generated AI prompt files |
| Option | Type | Default | Description |
|---|---|---|---|
--public | 0|1 | 1 | Include public members (methods, functions, classes) |
--protected | 0|1 | 0 | Include protected members |
--internal | 0|1 | 0 | Include internal/package-private members |
--private | 0|1 | 0 | Include private members |
| Option | Type | Default | Description |
|---|---|---|---|
--comments | 0|1 | 0 | Include inline and block comments |
--docstrings | 0|1 | 1 | Include documentation comments (docstrings, JSDoc, etc.) |
--implementation | 0|1 | 0 | Include function/method bodies (implementation details) |
--expand | String | (none) | Keep full implementation only for symbols whose name matches these globs (comma-separated / repeatable). Matches a function/method name; matching a type name expands the methods nested inside it (Python/TypeScript/Java/C# etc.). For Go-style file-level receiver methods, match the method name. e.g. --expand "GetUser", --expand "*Service*". Signatures everywhere else — great for agent-driven context building |
--imports | 0|1 | 1 | Include import/require statements |
--annotations | 0|1 | 1 | Include decorators and annotations |
--fields | 0|1 | 1 | Include class fields and properties |
--methods | 0|1 | 1 | Include methods and functions |
| Option | Type | Default | Description |
|---|---|---|---|
--include-only | String | (none) | Include ONLY these categories (comma-separated: public,protected,imports) |
--exclude-items | String | (none) | Exclude these categories (comma-separated: private,comments,implementation) |
| Option | Type | Default | Description |
|---|---|---|---|
--include | String | (all files) | Include file patterns (comma-separated: *.go,*.py or multiple: --include "*.go" --include "*.py") |
--exclude | String | (none) | Exclude file patterns (comma-separated: *test*,*.json or multiple: --exclude "*test*" --exclude "vendor/**") |
-r, --recursive | 0|1 | 1 | Process directories recursively. Set to 0 to process only immediate directory contents |
| Option | Type | Default | Description |
|---|---|---|---|
--raw | Flag | false | Process all text files without language parsing. Overrides all content filters |
--lang | String | auto | Force language detection: auto, python, typescript, javascript, go, rust, java, csharp, kotlin, cpp, php, ruby, swift |
| Option | Type | Default | Description |
|---|---|---|---|
--file-path-type | String | relative | Path format in output: relative or absolute |
--relative-path-prefix | String | (empty) | Custom prefix for relative paths (e.g., module/ → module/src/file.go) |
| Option | Type | Default | Description |
|---|---|---|---|
-w, --workers | Integer | 0 | Number of parallel workers. 0 = auto (80% of CPU cores), 1 = serial processing, 2+ = specific worker count |
| Option | Type | Default | Description |
|---|---|---|---|
--summary-type | String | visual-progress-bar | Summary format after processing. See Summary Types below |
--no-emoji | Flag | false | Disable emojis in summary output for plain text terminals |
.git)| Option | Type | Default | Description |
|---|---|---|---|
--git-limit | Integer | 200 | Number of commits to analyze. Use 0 for all commits |
--with-analysis-prompt | Flag | false | Add comprehensive AI analysis prompt for commit quality, patterns, and insights |
| Option | Type | Default | Description |
|---|---|---|---|
-v, --verbose | Count | 0 | Verbose output. Use -vv for detailed info, -vvv for full trace with data dumps |
--version | Flag | false | Show version information and exit |
--help | Flag | false | Show help message |
--help-extended | Flag | false | Show complete documentation (man page style) |
--cheat | Flag | false | Show quick reference card |
AI actions generate pre-configured prompts combined with distilled code that AI agents can then execute for specific analysis tasks:
| Action | Generated Prompt Type | AI Agent Will |
|---|---|---|
prompt-for-refactoring-suggestion | Refactoring analysis prompt with distilled code | Analyze code for improvements, technical debt, effort sizing |
prompt-for-complex-codebase-analysis | Enterprise-grade analysis prompt with full codebase | Generate architecture diagrams, compliance checks, findings |
prompt-for-security-analysis | Security audit prompt with OWASP Top 10 guidelines | Detect vulnerabilities, suggest remediation steps |
prompt-for-performance-analysis | Performance optimization prompt with complexity focus | Identify bottlenecks, analyze scalability issues |
prompt-for-best-practices-analysis | Code quality prompt with industry standards | Assess code quality, suggest improvements |
prompt-for-bug-hunting | Bug detection prompt with pattern analysis | Find bugs, analyze quality metrics |
prompt-for-single-file-docs | Documentation generation prompt for single file | Create comprehensive API documentation |
prompt-for-diagrams | Diagram generation prompt with Mermaid syntax | Generate 10+ architecture and process diagrams |
flow-for-deep-file-to-file-analysis | Systematic analysis task list with directory structure | Perform file-by-file deep analysis |
flow-for-multi-file-docs | Documentation workflow with file relationships | Create interconnected documentation |
| Type | Description | Example Output |
|---|---|---|
visual-progress-bar | Default. Shows compression progress bar with colors | ✅ Distilled 150 files [████████░░] 85% (5MB → 750KB) |
stock-ticker | Compact stock market style | 📊 AID 97.5% ▲ | 5MB→128KB | ~1.2M tokens saved |
speedometer-dashboard | Multi-line dashboard with detailed metrics | Shows files, size, tokens, processing time in box format |
minimalist-sparkline | Single line with sparkline visualization | ▁▃▅▇█ 150 files → 97.5% reduction (750KB) ✓ |
ci-friendly | Clean format for CI/CD pipelines | [aid] ✓ 85.9% saved | 21 kB → 2.9 kB | 4ms |
json | Machine-readable JSON output | {"original_bytes":5242880,"distilled_bytes":131072,...} |
off | Disable summary output | No summary displayed |
| Code | Meaning |
|---|---|
0 | Success |
1 | General error (file not found, parse error, etc.) |
2 | Invalid arguments or conflicting options |
.aidignore to skip generated files⚠️ Important: AI Distiller extracts code structure which may include:
processPayment, calculateTaxEvasion)/api/v1/internal/user-data)Recommendations:
--comments=0 to remove potentially sensitive documentation--obfuscate flag to anonymize sensitive identifiersAI Distiller now supports parallel processing for significantly faster analysis of large codebases:
Performance Benefits:
AI Distiller can process code directly from stdin, perfect for:
Language Detection: When using stdin without --lang, AI Distiller automatically detects the language based on syntax patterns. Supported languages for auto-detection: python, typescript, javascript, go, ruby, swift, rust, java, c#, kotlin, c++, php.
AI Distiller respects .aidignore files for excluding files and directories from processing. The syntax is similar to .gitignore.
AI Distiller only processes source code files with these extensions:
.py, .pyw, .pyi.js, .mjs, .cjs, .jsx.ts, .tsx, .d.ts.go.rs.rb, .rake, .gemspec.java.cs.kt, .kts.cpp, .cc, .cxx, .c++, .h, .hpp, .hh, .hxx, .h++.php, .phtml, .php3, .php4, .php5, .php7, .phps, .inc.swiftNote: Files like .log, .txt, .md, images, PDFs, and other non-source files are automatically ignored by AI Distiller, so you don't need to add them to .aidignore.
AI Distiller automatically ignores these common dependency and build directories:
node_modules/ - npm packagesvendor/ - Go and PHP dependenciestarget/ - Rust build outputbuild/, dist/ - Common build directories__pycache__/, .pytest_cache/, venv/, .venv/, env/, .env/ - Python.gradle/, gradle/ - Java/KotlinPods/ - Swift/iOS dependencies.bundle/ - Ruby bundlerbin/, obj/ - Compiled binaries.vs/, .idea/, .vscode/ - IDE directoriescoverage/, .nyc_output/ - Test coveragebower_components/ - Legacy JavaScript.terraform/ - Terraform.git/, .svn/, .hg/ - Version controlYou can override these defaults using ! patterns in .aidignore (see Advanced Usage below).
Create a .aidignore file in your project root or any subdirectory:
.aidignore files work recursively - place them in any directory.aidignore file/ prefix for patterns relative to the .aidignore location** for recursive matching/! prefix to negate a pattern (re-include previously ignored files)Use ! patterns to include directories that are ignored by default:
You can also include files that AI Distiller normally doesn't process:
When you include non-source files with ! patterns, AI Distiller will include their raw content in the output.
You can place .aidignore files in subdirectories for more specific control:
AI Distiller includes a special mode for analyzing git repositories. When you pass a .git directory, it switches to git log mode:
The --with-analysis-prompt flag adds a sophisticated prompt combined with git history that AI agents can use to generate:
The output file contains both the analysis prompt and formatted git history, ready for AI agents to process. Perfect for understanding project history, identifying knowledge silos, or generating impressive development reports.
Token counts are estimated using OpenAI's cl100k_base tokenizer (1 token ≈ 4 characters). Actual token usage varies by model - Claude and GPT-4 use similar tokenizers, while others may differ by ±10%.
Yes! We've tested on repositories with 50,000+ files. The parallel processing mode (-w flag) scales linearly with CPU cores. Memory usage is bounded - large files are processed in streaming chunks.
Create a .aidignore file (same syntax as .gitignore) to exclude generated files, vendor directories, or any paths you don't want processed.
Files with unknown or unsupported extensions are automatically skipped - no errors, no interruption. AI Distiller only processes files it has parsers for, ensuring clean and relevant output. This means you can safely run it on mixed repositories containing documentation, images, configs, etc.
No! AI Distiller runs 100% locally. It only extracts and formats your code structure - you decide what to do with the output. The tool itself makes no network connections.
Currently 12+ languages via tree-sitter: Python, TypeScript, JavaScript, Go, Java, C#, Rust, Ruby, Swift, Kotlin, PHP, C++. All parsers are bundled in the binary - no external dependencies needed.
We welcome contributions! See CONTRIBUTING.md for guidelines.
AI Distiller requires CGO for full language support via tree-sitter parsers. To build release binaries for all supported platforms:
Ubuntu/Debian:
The script automatically detects available toolchains and builds for all possible platforms. Each archive contains the aid binary (or aid.exe for Windows) with full language support.
Note: Without proper toolchains, only the native platform will be built.
MIT License - see LICENSE for details.