code2prompt
Allows users to join the project's Discord channel for updates, support, and community discussions about the code2prompt tool.
Integrates with Git to include diffs, logs, and branch comparisons in generated prompts, and respects .gitignore rules when processing codebases.
Enables accessing repositories for code processing and interacting with GitHub-hosted codebases to generate structured prompts.
Provides Python bindings as an SDK for integration with AI agents or automation scripts, installable via pip for seamless codebase interaction.
Offers core functionality through Rust, allowing installation via Cargo and providing the foundation for the tool's code processing capabilities.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@code2promptgenerate a prompt from my current project directory"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.

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 code2promptHomebrew
brew install code2promptSDK with pip π
pip install code2prompt-rsRelated MCP server: Gemini CLI MCP Server
π 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/code2promptThe 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 | π» CLI Tool | π Python SDK | π€ MCP Server |
The internal, high-speed library responsible for secure file traversal, respecting | 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
.gitignorerulesFlexible 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
π 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
This server cannot be deployed
Maintenance
Related MCP Connectors
Code intelligence for LLMs. Analyze, search, and retrieve code from any public git repository.
Provide your AI coding tools with token-efficient access to up-to-date technical documentation forβ¦
Code intelligence platform for AI agents. 20 tools for architecture, security & impact analysis.
Code intelligence for coding agents: semantic, AST, graph, and full-text search. 279+ languages.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceIntelligently analyzes codebases to enhance LLM prompts with relevant context, featuring adaptive context management and task detection to produce higher quality AI responses.2-
- AlicenseNot gradedqualityDmaintenanceEnables comprehensive codebase analysis using Google's Gemini AI through CLI integration. Provides architectural reviews and targeted code analysis with code2prompt integration for efficient context extraction.6 npm2Apache 2.0
- AlicenseAqualityDmaintenanceProvides intelligent code context and analysis through semantic compression, AST parsing, and multi-language support. Offers 60-80% token reduction while enabling AI assistants to understand codebases through local analysis, OpenAI-enhanced insights, and GitHub repository integration.616 npm3MIT
- AlicenseNot gradedqualityDmaintenanceProvides intelligent code context management and semantic search capabilities for software development, enabling natural language queries to find relevant code snippets, functions, and classes across Python, JavaScript, TypeScript, and SQL codebases.MIT