code2prompt
CLI and TUI that converts a codebase into a single LLM prompt with a source tree, Handlebars templates, git context, and token estimates.
code2prompt is a Rust command-line tool that reads a codebase and formats it as a single prompt for large language models. Running code2prompt . writes the prompt to stdout, -c copies it to the clipboard, and --output-file prompt.txt saves it to a file. It also ships an interactive terminal UI for configuring what goes into the prompt.
Input selection uses glob include/exclude patterns and respects .gitignore rules. Output is built from Handlebars templates, so the prompt layout can be customized for different use cases. The tool can also include git diffs, logs, and branch comparisons. It has special handling for formats such as CSV, Jupyter notebooks, and JSONL. Token counts are estimated from parallel per-file counts plus estimated template overhead, with optional line numbers. The README notes that the full rendered prompt is not re-tokenized.
The project is split into a Rust core library, the CLI/TUI, a Python SDK (code2prompt-rs on PyPI) for scripts, agents, and RAG pipelines, and an MCP server that lets agentic applications read a local codebase. An agent skill can be installed with npx skills add mufeedvh/code2prompt. It helps coding agents gather scoped context, using a function and class map when the optional entity-map feature is built, and a directory map otherwise. It suits developers who paste repository context into chat LLMs, and those building automation or agent tooling around codebase context.
Installation
# via Homebrew
brew install code2prompt
# via Cargo
cargo install code2prompt
# via pip (Python SDK)
pip install code2prompt-rs

Alternatives & related tools
AIChat
LLM CLI with a shell assistant, chat REPL, RAG, function calling and agents, supporting 20+ providers including OpenAI, Claude, Gemini and Ollama.
models
TUI and CLI for browsing AI models, benchmarks, coding agents, and provider statuses from multiple data sources.
Codewhale
Rust terminal coding agent that reads a repo, edits files, runs commands and checks results using hosted or local models (Ollama, vLLM, SGLang).
herdr
Terminal multiplexer written in Rust that runs coding agents in persistent panes, tracks working/blocked/idle state, and manages local and SSH machines.
Goose
Open source AI agent for desktop, CLI, and API with 15+ provider integrations and Model Context Protocol extensions
add a badge to your README
Maintain code2prompt? Show that it's featured on trmn. The badge links back to this page.
[](https://www.trmn.sh/tools/code2prompt?utm_source=badge)<a href="https://www.trmn.sh/tools/code2prompt?utm_source=badge"><img src="https://www.trmn.sh/badge/code2prompt.svg" alt="Featured on trmn" height="20"></a>