finds.dev← search

// the find

mufeedvh/code2prompt

★ 7,721 · Rust · MIT · updated Sep 2026

A CLI tool to convert your codebase into a single LLM prompt with source tree, prompt templating, and token counting.

A Rust CLI (plus Python bindings and an MCP server) that walks a codebase and renders it into a single LLM-ready prompt, with gitignore-aware filtering, Handlebars templating, and token counting. Useful for anyone manually pasting code into ChatGPT/Claude or wiring an agent that needs scoped file context without burning its whole window.

The core logic is split into its own crate (code2prompt-core) separate from the CLI and TUI, which is why the same traversal/filtering/templating code can back a Python package and an MCP server instead of being reimplemented three times. Token counting is parallelized per-file rather than tokenizing the final rendered string, so you get a cost estimate before paying for the full render. Filtering is real glob + .gitignore handling, not a naive extension whitelist, and there's a decent spread of ready-made Handlebars templates (bug fix, refactor, PR description, several CTF-solver variants) instead of just one generic dump template. Test layout is sane — unit tests per concern (filter, sort, git, tokenizer) plus integration tests for the CLI and TUI model.

The token estimate explicitly isn't the real token count of what you'll send — it skips the JSON output envelope and doesn't re-tokenize the assembled prompt, so for the XML/JSON output modes the number shown can be noticeably off from what actually gets submitted to the model. The entity-map feature (function/class map for the agent skill) is gated behind an optional build feature with a 'directory map fallback' for standard builds, meaning the skill's main selling point — a compact code map — silently degrades to a plain file tree unless you know to opt in at compile time. The project now spans CLI + core + Python bindings + MCP server + a multi-language Astro docs site + an agent-skill installer that shells out to clone the repo — a lot of surface area for a single maintainer to keep consistent, and it shows in places like the skill installer needing a temporary full clone just to fetch two files. No crate-level benchmarks for traversal/tokenization performance on large monorepos, which is the exact scenario this tool is built for.

View on GitHub → Homepage ↗

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →