Code2prompt Download

Rust-based context engineering tool that converts codebases into structured LLM prompts with CLI, Python SDK, and MCP server for AI agents and automation.

⭐ 6,846 stars on GitHub
Latest Release: v4.0.2

About Software

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 entire codebases into structured LLM prompts with source trees
  • Generate formatted prompts for ChatGPT, Claude, and other AI models
  • Build AI agents and RAG pipelines using Python SDK bindings
  • Run as MCP server for agentic applications to access local codebases
  • Track token usage and customize prompts with Handlebars templates

Downloads

v4.0.2 September 18, 2025
code2prompt-x86_64-pc-windows-msvc.exeexe
v1.1.0 April 15, 2024
code2prompt-x86_64-pc-windows-msvc.exeexe
v1.0.0 March 16, 2024
code2prompt-x86_64-pc-windows-msvc.exeexe
code2prompt.exeexe

Package Info

Last Updated
Sep 18, 2025
Latest Version
v4.0.2
License
MIT
Total Versions
3

README

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.

⚡ Quick Install

Cargo

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

Homebrew

brew install code2prompt

SDK with pip 🐍

pip install code2prompt-rs

🚀 Quick Start

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

🌐 Ecosystem

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.
See full README on repository.