Code2Prompt

A Rust CLI that packs a codebase into one prompt with a file tree, templates and token estimates

CLIMedium risk

mufeedvh/code2prompt

Install

brew install code2prompt

This is third-party code. Review the repository files before installing.

What it does

Code2Prompt walks a project directory, honoring .gitignore and glob filters, and assembles file contents into a single LLM prompt. Output format comes from Handlebars templates, and the prompt can include git diffs, logs and branch comparisons. The tool estimates the result size in tokens and writes it to stdout, a file or the clipboard. Besides the CLI there is an interactive TUI, a Python SDK and an agent skill for scoped context gathering.

Who it is for. For developers who paste code into model chats or build their own agent pipelines.

Good fit when

  • You need to hand a model part of a project in one piece
  • You want to know upfront how many tokens the context takes
  • You need a diff or commit history in the prompt

Not a fit when

  • The agent already reads project files and a separate bundle is unnecessary
  • The project is too large for the context window even after filtering

Example request

Bundle the src folder without tests into a prompt and tell me the token count

Limitations

Token counts are estimates: the full rendered prompt is not re-tokenized. The skill requires installing the CLI separately. The tool itself is local; you pick the model.

How to disable. Remove the binary with cargo uninstall code2prompt or brew uninstall code2prompt, and delete the skill from the agent's skills folder.

Security check

  • Reads every file in the chosen directory, so secrets may end up in the prompt

README in short

The README shows install via Cargo, Homebrew and pip, basic usage and saving to a file. A separate section covers the agent skill installed through the Skills CLI. It outlines the ecosystem: Rust core, CLI with TUI, Python SDK and MCP mode. It lists filtering, templates, git integration and token estimates. MIT licensed.

FAQ

Does it respect .gitignore?

Yes, and you can add your own include and exclude patterns.

Can I call it from Python?

Yes, the code2prompt-rs package binds to the Rust core.

Editors’ pick

A skills library that gives coding agents a development process: brainstorming, planning, TDD, subagents and code review

PluginMedium risk286.6K
Editors’ pick

Small composable skills for engineering with agents: plan grilling, TDD, bug diagnosis, code review and architecture

SkillLow risk262K

Reference MCP servers

Model Context Protocol servers

Editors’ pick

Official reference MCP servers: Filesystem, Fetch, Git, Memory, Sequential Thinking, Time and Everything

MCP serverMedium risk90.3K
Editors’ pick

Up-to-date, version-specific library docs and code examples in your agent's context, via MCP or a CLI plus skill

MCP serverMedium risk62K