Code2Prompt CLI
A Rust CLI that packs a codebase into one prompt with a file tree, templates and token estimates
- 7,743 ★ on the repository
- Last commit
- MIT
Extended access
Why this level
- Reads every file in the chosen directory, so secrets may end up in the prompt
Install
- Works in
In your terminal, with SkillFoxx CLI
npx skillfoxx add cli/code2promptDetects the agents on your machine, shows the access level and pins the version.
Other ways to install
Access and checks
How we reviewExtended accessThe tool runs code or makes network calls and only reads external data.
- Reads every file in the chosen directory, so secrets may end up in the prompt
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 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.
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.
Discussion
No questions or reviews yet.
Related
CLI toolsAn MCP server and CLI for code research: search and understand your project and all of GitHub with fewer tokens
An open macOS app for code context engineering: an MCP server and agent orchestrator that helps agents understand a project before editing
A Rust CLI for TypeScript and JavaScript: dead code, duplicates, cycles, complexity and architecture boundaries from one graph, plus MCP and skills
A local MCP server that indexes your code so the agent pulls the functions it needs instead of rereading whole files
CodeGraph (Rust)
codegraph-rust
A Rust code graph for agents: four MCP tools show what an edit will touch, how the architecture fits together and where the fragile spots are
A code-review CLI and plugin for agents: reads a git diff and writes line-level comments with context
Comparison with similar tools
Entries that share the main search query, and how they differ.
| Entry | Official | Authentication | Repository stars | Main difference |
|---|---|---|---|---|
| Code2Prompt (this entry) | no | 7,743 | ||
| CTX | no | not required | 341 | an MCP server in one binary |
| llm-context: rule-based context packing for agents | no | 307 | a CLI and MCP server that use set rules to pack only the project |
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.