Skip to content

code2prompt

Rust CLI that turns a codebase into one LLM prompt, with Handlebars templates, glob filters, git diffs and token counting.

Reviewed by Sheela · Updated

View on GitHub Open source

Our rating

3.8/5

code2prompt is the packer for people who care about the prompt template, held back by a release trail that no longer lines up.

What it is

code2prompt is a command-line tool that builds a single prompt from your code: a source tree followed by file contents in fenced blocks, with a token estimate so you know if it fits. You choose files with include and exclude glob patterns, it respects .gitignore, and you can shape the output with Handlebars templates (a fill-in-the-blanks template language) or pull in git diffs, logs and branch comparisons. An interactive terminal interface sits alongside the plain CLI.

It is written in Rust by Mufeed VH and Olivier D'Ancona under the MIT licence. Besides the CLI there is a Python SDK on PyPI as code2prompt-rs, a separate MCP server project, and since September 2026 an agent skill that teaches coding agents to map a repo before reading it.

Our review

code2prompt is a capable Rust prompt builder whose packaging has drifted out of step with its code. GitHub's latest tagged release is v4.2.0 from December 2025; crates.io carries 4.3.0, published on 13 June 2026, with no matching git tag, and an open issue asks where it came from. The Python SDK on PyPI, code2prompt-rs, is still at 3.2.1 from March 2025. Code commits continued into September 2026, and the repo has about 7,700 stars.

Its strength is control over the prompt. Handlebars templates wrap the code in your own instructions, so one command can produce a review prompt, a documentation prompt or a commit message. The diff, log and branch-comparison options make change-focused prompts easy, and a single Rust binary installs through Cargo or Homebrew with no Node.js.

The token count deserves a caveat. The README says it sums per-file counts plus estimated template overhead and does not re-tokenise the rendered prompt, and the figure excludes the JSON output envelope. That is fine for asking whether a prompt will fit, less so for forecasting a bill. Neither the README nor the site mentions secret scanning, so keeping .env files and credentials out is left to your glob patterns.

The most interesting recent work is not the packer itself. The agent skill, installed with npx skills add mufeedvh/code2prompt, has an agent read a compact map of functions and classes (through an optional entity-map build using sem-core) before opening the relevant files and tests. That map is the part most likely to stay useful once a codebase outgrows a single prompt, which is exactly where whole-repo packers, Repomix included, stop helping.

Where it earns its place

  • A backend developer reviewing a 40-file feature branch with a chat model

    Get an explanation and review of what changed

    Run code2prompt with the git diff or branch comparison options and a review template, copy with -c and paste. Free; the token estimate shows whether it fits before the paste, though the provider bills the full prompt at input rates.

  • A platform team building an internal PR-description bot in Python

    Generate prompts from repositories inside a CI job

    pip install code2prompt-rs gives native bindings, but the SDK is 3.2.1 against a 4.3.0 CLI, so pin it and test, or shell out to the CLI binary instead. No paid tier or hosted service involved.

  • An engineering manager standardising prompts across a 15-person team

    Give everyone the same review and documentation prompt formats

    Commit Handlebars templates to the repo so everyone runs the same command. Because no secret scanning is documented, add exclude globs for .env and config folders to the shared template.

Before you commit

Setup
cargo install code2prompt or brew install code2prompt (prebuilt binaries on GitHub releases); code2prompt . prints the prompt to stdout and -c copies it. Wayland clipboard support needs --features wayland at build time.
Integrations
CLI and terminal UI, the code2prompt_core Rust crate, the code2prompt-rs Python SDK, a separate MCP server project, and an agent skill installed through the Skills CLI for Codex and other agents.
Data and privacy
Runs entirely locally and makes no hosted calls; it respects .gitignore. Telemetry is not mentioned in the README. No secret scanning is documented, so credentials in included files go straight into the prompt. MIT; no published security advisories.
Cost at scale
Free, with no paid edition. The cost is model input tokens: a whole-repo prompt is billed at the provider's input price every time it is sent.
Limits
Token count is an estimate; SDK lags the CLI by a major version; release tags and crates.io disagree; 19 open issues and pull requests, mostly dependency bumps; whole-repo prompts fail once a codebase exceeds the model's context.

What's good

  • Handlebars templates for reusable prompt formats
  • Git diff, log and branch comparison in prompts
  • Single Rust binary via Cargo or Homebrew
  • Agent skill for scoped, map-first context

What's not

  • crates.io 4.3.0 has no matching git tag
  • Python SDK stuck at 3.2.1 from March 2025
  • No secret scanning documented
  • Token count is an estimate, not a re-tokenised total

Best for

Terminal users who want templated prompts or git-diff prompts built from their code.

Alternatives

code2prompt: common questions

Is code2prompt worth it?
code2prompt is the packer for people who care about the prompt template, held back by a release trail that no longer lines up. We rate it 3.8 out of 5.
How much does code2prompt cost?
Free and open source (MIT).
What are the downsides of code2prompt?
crates.io 4.3.0 has no matching git tag; python SDK stuck at 3.2.1 from March 2025; no secret scanning documented; token count is an estimate, not a re-tokenised total.
Who is code2prompt best for?
Terminal users who want templated prompts or git-diff prompts built from their code.
How much does code2prompt cost for a team or in production?
Free, with no paid edition. The cost is model input tokens: a whole-repo prompt is billed at the provider's input price every time it is sent.
Is code2prompt safe for company data?
Runs entirely locally and makes no hosted calls; it respects .gitignore. Telemetry is not mentioned in the README. No secret scanning is documented, so credentials in included files go straight into the prompt. MIT; no published security advisories.
What are the best code2prompt alternatives?
The closest alternatives we have reviewed are Repomix and grepai.

Answers checked Oct 23, 2026.