Key takeaways
- CLI tool that converts codebases into formatted LLM prompts with source tree visualization, Handlebars prompt templating, and token counting. Rust core for speed
- 7.4k stars as of June 2026, MIT license. Python bindings for RAG pipelines and an MCP server mode for agent integration
- Actively maintained — repo pushed June 2026 — but tagged releases have slowed: latest is v4.2.0 from December 2025
- Template system lets you customize prompt format for different use cases — code review, documentation, refactoring, etc. Outputs JSON, Markdown, or XML
FAQ
What is code2prompt?
A CLI tool (Rust) that converts your codebase into a single formatted LLM prompt with source tree, prompt templates, and token counting. Also provides Python bindings and an MCP server for programmatic and agent use.
How does it compare to Repomix?
Repomix is TypeScript with XML output optimized for Claude and Tree-sitter compression. code2prompt is Rust (faster) with a Handlebars template system, Python bindings, and an MCP server. Repomix has broader adoption (26k vs 7.4k stars as of June 2026).
Is code2prompt free?
Yes — fully open source under the MIT license. There is no paid tier; the project is community-driven.
Overview
code2prompt is a Rust-powered CLI tool that converts codebases into formatted LLM prompts. It generates a source tree, applies customizable Handlebars prompt templates, counts tokens, and outputs to clipboard, stdout, or file in JSON, Markdown, or XML — ideal for feeding codebases into any LLM.
With 7.4k stars as of June 2026, it remains the second most popular context packing tool after Repomix (26k). The Rust core provides speed, Python bindings enable integration into RAG pipelines, and an MCP server mode lets coding agents pull repo context on demand.
Key stats: 7,399 stars, 423 forks, MIT license, Rust with Python bindings. Created March 2024; repo last pushed June 9, 2026.
Pricing
Free and open source under the MIT license. No paid tier — the project describes itself as "Open-Source & Community-Driven."
Recent Developments
- Latest tagged release is v4.2.0 (December 11, 2025), following v4.0.2 (September 2025) and the v3 → v4 jump in 2025; no new tagged release has shipped since the original profile date, though the repo saw commits as recently as June 9, 2026.
- The project website now promotes an MCP server "for agents" alongside the CLI and SDK — correcting this profile's earlier note that code2prompt lacked an MCP mode.
- Stars grew modestly from 7.2k (March 2026) to 7.4k (June 2026), while Repomix grew to 26k — the adoption gap is widening, not closing.
Competitive Position
Strengths: Fast (Rust). Handlebars template system for customizable output formats. Python bindings for pipeline integration. MCP server for agent workflows. Git diff/log extraction. MIT license.
Weaknesses: Much smaller community than Repomix (7.4k vs 26k stars). No Tree-sitter compression. Less Claude-optimized output format. Release cadence has slowed to roughly two tagged releases per year.
Cautions
- Tagged releases have stalled at v4.2.0 (December 2025) — six months without a release as of June 2026, although the GitHub repo itself remains active with recent pushes.
- Whole-repo prompt packing increasingly competes with agentic retrieval: tools like Claude Code and Cursor read files on demand, narrowing the use case to one-shot context dumps and pipelines.
- Older versions had output-handling quirks (clipboard behavior overriding the output-file flag) reported by users.
What Developers Say
- "I use code2prompt and ChatGPT with pro will reject the prompt as too large." — J_Shelby_J, Hacker News, September 2025 (on whole-repo prompts exceeding model limits)
- "It always puts the output to the paste buffer even if you specify output file" — samsepi01, Hacker News, September 2024 (an early-version quirk)
Mentions on Hacker News are steady but thin — code2prompt is typically named alongside Repomix as an interchangeable option rather than discussed on its own merits.
Bottom Line
Recommended for Rust-speed codebase-to-prompt packing in scripts and RAG pipelines, especially if you want Python bindings or a templating system Repomix lacks. Not recommended if you want the largest community, Tree-sitter compression, or Claude-optimized XML defaults — Repomix wins on all three and is pulling further ahead. Outlook: stable but slowing — active commits and an MCP server keep it relevant, but flat star growth and a six-month release gap suggest it stays a solid second to Repomix.
Research by Ry Walker Research