Website β’ Documentation β’ Discord
Code2Prompt is a powerful context engineering tool designed to ingest codebases and format them for Large Language Models. Whether you are manually copying context for ChatGPT, building AI agents via Python, or running a MCP server, Code2Prompt streamlines the context preparation process.
cargo install code2prompt To enable optional Wayland support (e.g., for clipboard integration on Wayland-based systems), use the wayland feature flag:
cargo install --features wayland code2promptbrew install code2promptpip install code2prompt-rsOnce installed, generating a prompt from your codebase is as simple as pointing the tool to your directory.
Basic Usage: Generate a prompt from the current directory and copy it to the clipboard.
code2prompt .Save to file:
code2prompt path/to/project --output prompt.txtCode2Prompt is more than just a CLI tool. It is a complete ecosystem for codebase context.
Check our online documentation for detailed instructions
Code2Prompt transforms your entire codebase into a well-structured prompt for large language models. Key features include:
- Terminal User Interface (TUI): Interactive terminal interface for configuring and generating prompts
- Smart Filtering: Include/exclude files using glob patterns and respect
.gitignorerules - Flexible Templating: Customize prompts with Handlebars templates for different use cases
- Automatic Code Processing: Convert codebases of any size into readable, formatted prompts
- Token Tracking: Track token usage to stay within LLM context limits
- Smart File Reading: Simplify reading various file formats for LLMs (CSV, Notebooks, JSONL, etc.)
- Git Integration: Include diffs, logs, and branch comparisons in your prompts
- Blazing Fast: Built in Rust for high performance and low resource usage
Stop manually copying files and formatting code for LLMs. Code2Prompt handles the tedious work so you can focus on getting insights and solutions from AI models.
Refer to the documentation for detailed installation instructions.
Download the latest binary for your OS from Releases.
Requires:
git clone https://github.com/mufeedvh/code2prompt.git
cd code2prompt/
cargo install --path crates/code2promptLicensed under the MIT License, see LICENSE for more information.
If you liked the project and found it useful, please give it a β !
Ways to contribute:
- Suggest a feature
- Report a bug
- Fix something and open a pull request
- Help me document the code
- Spread the word

