Context Builder
A blazing-fast CLI for creating LLM context from your entire codebase.
Tired of manually copy-pasting files into your LLM prompts? Context Builder automates this tedious process, creating a single, clean, and context-rich markdown file from any directory.
Why Context Builder?
Providing broad context to Large Language Models (LLMs) is key to getting high-quality, relevant responses. This tool was built to solve one problem exceptionally well: packaging your project's source code into a clean, LLM-friendly format with zero fuss.
It's a command-line utility that recursively processes directories and creates comprehensive markdown documentation, optimized for AI conversations.
Core Features
- ⚡ Blazing Fast & Parallel by Default: Processes thousands of files in seconds. It uses
rayonto leverage all available CPU cores for maximum throughput. - 🧠 Smart & Efficient File Discovery: Built on the excellent
ignorecrate, it respects.gitignorerules and custom ignore patterns out-of-the-box using optimized, parallel directory traversal. - 💾 Memory-Efficient Streaming: Handles massive files with ease by reading and writing line-by-line, keeping memory usage low no matter the project size.
- 🛡️ Robust & Safe by Design: Confirms before overwriting files and gracefully skips binary content. Built with Rust's guarantees of memory safety, it's a tool you can trust.
- 🌳 Clear File Tree Visualization: Generates an easy-to-read directory structure at the top of the output file so you can see the project layout at a glance.
- 🔍 Powerful Filtering & Preview: Easily include only the file extensions you need and use the instant
--previewmode to see what will be processed before generating the full output. - 📝 Optional Line-Numbered Code Blocks: Add line numbers to all code blocks for easy reference with a simple
--line-numbersflag.
Installation
From crates.io (Recommended)
From source
Usage
Basic Usage
# Process current directory and create output.md
# Process a specific directory
# Specify an output file
Advanced Options
# Filter by file extensions (e.g., only Rust and TOML files)
# Ignore specific folders/files by name
# Preview mode (shows the file tree without generating output)
# Add line numbers to all code blocks
# Combine multiple options for a powerful workflow
Command Line Options
-d, --input <PATH>- Directory path to process (default: current directory).-o, --output <FILE>- Output file path (default:output.md).-f, --filter <EXT>- File extensions to include (can be used multiple times).-i, --ignore <NAME>- Folder or file names to ignore (can be used multiple times).--preview- Preview mode: only show the file tree, don't generate output.--line-numbers- Add line numbers to code blocks in the output.-h, --help- Show help information.-V, --version- Show version information.
Documentation
- DEVELOPMENT.md: For contributors. Covers setup, testing, linting, and release process.
- BENCHMARKS.md: For performance enthusiasts. Details on running benchmarks and generating datasets.
- CHANGELOG.md: A complete history of releases and changes.
Contributing
Contributions are welcome! Please see DEVELOPMENT.md for setup instructions and guidelines. For major changes, please open an issue first to discuss what you would like to change.
License
This project is licensed under the MIT License. See the LICENSE file for details.