code2prompt is a free, open source ai development platforms project written in Rust and released under MIT. It has 7,657 GitHub stars, 438 forks and 16 open issues, and was last pushed 6 days ago. On this registry it ranks #69 of 116 tracked projects in AI Development Platforms, with 5 head-to-head comparisons available.

What is code2prompt?

code2prompt is a Rust command-line tool, also shipped as a Python SDK and an MCP server, that ingests a codebase and formats it into a single LLM prompt with a source tree, prompt templating, and token counting, for developers and agent builders who need to hand repository context to ChatGPT, Claude, or GPT.

What it is

Code2Prompt is a context engineering tool for large language models. It ingests a codebase and formats it for LLM consumption, and it ships as four connected pieces rather than one binary: a core library for secure file traversal, .gitignore rules, and Git metadata; a CLI offering both a minimal mode and an interactive TUI; a Python SDK published on PyPI as code2prompt-rs giving fast bindings to the Rust core; and an MCP server that runs the tool as a local service. The project is written in Rust, licensed under MIT, carries 7,657 stars and 438 forks on GitHub, and sits in this registry under AI & Machine Learning / AI Development Platforms. It is available through crates.io, Homebrew, and PyPI, with documentation and a website at code2prompt.dev.

The problem it solves is context assembly. Reading a repository, deciding which files matter, and pasting them into a chat window is manual, error prone, and burns the context window before the model does any work. Code2Prompt replaces that manual copy-paste loop with one command that walks the project, respects .gitignore, preserves Git metadata, and emits a single formatted prompt. The same core answers the same problem for machines: the Python SDK removes the copying from automation scripts and RAG pipelines, and the MCP server lets agentic applications read a local codebase without inflating their context window.

Key capabilities

  • Minimal CLI plus interactive TUI: code2prompt . writes to stdout by default, and -c copies the result to the clipboard.
  • Saves output to a named file using --output-file prompt.txt.
  • Builds a source tree and structures Git metadata while traversing files under .gitignore rules.
  • Supports prompt templating and reports token usage so prompts can be sized before sending.
  • Publishes Python bindings on PyPI as code2prompt-rs for agents, automation scripts, and RAG pipelines.
  • Runs as an MCP server, exposing a local codebase to agentic applications as a local service.
  • Installs as an agent skill through the Skills CLI with npx skills add mufeedvh/code2prompt, adding skills/code2prompt/SKILL.md; the skill uses sem-core for a compact map of functions and classes, with an optional entity-map feature and a directory map fallback.

Who uses it and how

  • Developers who manually copy context into ChatGPT or Claude, cutting exploration round trips.
  • AI agent builders and automation authors using the code2prompt-rs Python SDK for scripts and RAG pipelines.
  • Teams exposing a local repository to agentic applications through the MCP server, so agents read code without bloating their context window.
  • Agent operators installing the skill globally for one agent, for example Codex, with npx skills add mufeedvh/code2prompt --skill code2prompt --agent codex --global.
  • Wayland desktop users enabling clipboard integration by installing with the wayland feature flag.

Getting started

Install with cargo install code2prompt or brew install code2prompt, then run code2prompt . in a project directory. Python consumers install the SDK with pip install code2prompt-rs.

How it compares

The facts name no competing or superseded products, so no paid-alternative comparison can be drawn; code2prompt stands alone in this registry. The entities closest to it in the topic list are model vendors such as ChatGPT, Claude, and GPT, which are the targets it prepares context for, not substitutes for it.

When to use it — and when not to

Pick it when the goal is reproducible, scriptable context assembly from a local repository, and skip it when a managed hosted pipeline or a graphical-only workflow is required, since no hosted service is described in these facts. A self-hoster operates just the local binary and optional SDK — no database, object storage, or SMTP dependency appears in the provided material — but needs a Rust toolchain or Homebrew for the CLI. The supplied README excerpt is truncated mid-sentence at the documentation link, so readers should treat the install and ecosystem details above as the reliably documented surface rather than the complete feature set.

project readme (upstream, from github) — read inline
Code2prompt

Convert your codebase into a single LLM prompt.

WebsiteDocumentationDiscord

License Crates.io PyPI CI Discord Docs.rs Crates.io Downloads GitHub Stars


code2prompt demo

Flow Diagram

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. Output goes to stdout by default; use -c to copy it to the clipboard.

code2prompt .

Save to file:

code2prompt path/to/project --output-file prompt.txt

🤖 Agent Skill

Teach your coding agent to install and use code2prompt for repository navigation and scoped context gathering with the Skills CLI:

npx skills add mufeedvh/code2prompt

The code2prompt skill helps agents reduce exploration round trips: inspect a compact map of functions and classes using sem-core, then read relevant source files and tests together. It includes a map template and installation instructions for the optional entity-map feature, with a directory map fallback for standard builds. The code2prompt CLI is installed separately.

The installer adds the skill folder and its template to your agent. It may clone the repository temporarily to retrieve them; the rest of the repository is not installed as part of the skill.

To install it globally for a specific agent, for example Codex:

npx skills add mufeedvh/code2prompt --skill code2prompt --agent codex --global

🌐 Ecosystem

Code2Prompt is more than just a CLI tool. It is a complete ecosystem for codebase context.

🧱 Core Library
Rust Core Badge
💻 CLI Tool
CLI Badge
🐍 Python SDK
Python SDK Badge
🤖 MCP Server MCP Server Badge
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.

📚 Documentation

Check our online documentation for detailed instructions

✨ Features

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 .gitignore rules
  • Flexible Templating: Customize prompts with Handlebars templates for different use cases
  • Automatic Code Processing: Convert codebases of any size into readable, formatted prompts
  • Token Estimates: Estimate prompt size using parallel per-file token counts and estimated template overhead, including optional line numbers. The full rendered prompt is not re-tokenized, and the estimate excludes the JSON output envelope.
  • 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.

Alternative Installation

Refer to the documentation for detailed installation instructions.

Binary releases

Download the latest binary for your OS from Releases.

Source build

Requires:

git clone https://github.com/mufeedvh/code2prompt.git
cd code2prompt/
cargo install --path crates/code2prompt

⭐ Star Gazing

Star History Chart

📜 License

Licensed under the MIT License, see LICENSE for more information.

Liked the project?

If you liked the project and found it useful, please give it a :star: !

👥 Contribution

Ways to contribute:

  • Suggest a feature
  • Report a bug
  • Fix something and open a pull request
  • Help me document the code
  • Spread the word

Frequently asked questions

Is code2prompt free to use?

code2prompt is open source under the MIT licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does code2prompt do?

A CLI tool to convert your codebase into a single LLM prompt with source tree, prompt templating, and token counting.

What is code2prompt written in?

code2prompt is primarily written in Rust. Its source is publicly available at https://github.com/mufeedvh/code2prompt, and it has 7,657 GitHub stars.