Code2Prompt is a powerful context engineering tool built in Rust that transforms entire codebases into well-structured prompts for Large Language Models. It offers a complete ecosystem including a core library, CLI tool with interactive TUI, Python SDK for AI agent integration, and MCP server for local service deployment.
The tool features smart filtering with glob patterns and gitignore support, flexible Handlebars templating, automatic code processing for any codebase size, comprehensive token tracking, smart file reading for CSV, Notebooks, and JSONL formats, Git integration for diffs and branch comparisons, and blazing fast performance for high-speed context preparation without manual file copying.
Use Cases:
Convert your codebase into a single LLM prompt.
Website • Documentation • Discord
License (https://img.shields.io/github/license/mufeedvh/code2prompt.svg?style=flat-square) Crates.io (https://img.shields.io/crates/v/code2prompt.svg?style=flat-square) PyPI (https://img.shields.io/pypi/v/code2prompt-rs?style=flat-square&logo=pypi&logoColor=white) CI (https://github.com/mufeedvh/code2prompt/actions/workflows/ci.yml/badge.svg?style=flat-square) Discord (https://img.shields.io/discord/1342336677905039451?style=flat-square&logo=discord&logoColor=white) Docs.rs (https://docs.rs/code2prompt-core/badge.svg?style=flat-square) Crates.io Downloads (https://img.shields.io/crates/d/code2prompt.svg?style=flat-square) GitHub Stars (https://img.shields.io/github/stars/mufeedvh/code2prompt?style=social)
!Flow Diagram (https://github.com/mufeedvh/code2prompt/blob/main/.assets/flow_diagram.png)
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 code2prompt
brew install code2prompt
pip install code2prompt-rs
Once 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.txt
Code2Prompt is more than just a CLI tool. It is a complete ecosystem for codebase context.
| 🧱 Core Library | 💻 CLI Tool | 🐍 Python SDK | 🤖 MCP Server |
|---|---|---|---|
The internal, high-speed library responsible for secure file traversal, respecting .gitignore rules, and structuring Git metadata. |
Designed for humans, featuring both a minimal CLI and an interactive TUI. Generate formatted prompts, track token usage, and outputs the result to your clipboard or stdout. | Provides fast Python bindings to the Rust Core. Ideal for AI Agents, automation scripts, or deep integration into RAG pipelines. Available on PyPI. | Run Code2Prompt as a local service, enabling agentic applications to read your local codebase efficiently without bloating your context window. |
Open-source Chromium fork with native AI agents, local-first privacy, custom API keys or Ollama integration, and MCP server support for automation.
Unofficial Cloudflare WARP desktop client featuring custom WireGuard VPN implementation with multiple protocols and advanced routing for secure internet access.
Free, open-source, offline speech-to-text desktop app with Whisper and Parakeet models, privacy-first transcription, and shortcut-based dictation for Windows, macOS, and Linux.
Open-source IDE for orchestrating AI coding agents with superhuman workflows, advanced context engineering, and parallel Claude Code sessions built on battle-tested principles.
MacOS app that turns your MacBook Force Touch trackpad into a digital weighing scale using pressure sensors, calibrated for gram-precision measurements.
Lightweight high-performance macOS screen recorder built on ScreenCapture Kit with audio loopback, Presenter Overlay, HEVC Alpha support, and comprehensive recording features.