Code2Prompt
A Rust CLI that packs a codebase into one prompt with a file tree, templates and token estimates
Install
brew install code2promptThis 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 countLimitations
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.
Related
A skills library that gives coding agents a development process: brainstorming, planning, TDD, subagents and code review
Skills for real engineers by Matt Pocock
Skills For Real Engineers
Small composable skills for engineering with agents: plan grilling, TDD, bug diagnosis, code review and architecture
Reference MCP servers
Model Context Protocol servers
Official reference MCP servers: Filesystem, Fetch, Git, Memory, Sequential Thinking, Time and Everything
Up-to-date, version-specific library docs and code examples in your agent's context, via MCP or a CLI plus skill