Directory Compare FCRS-1.0 /llms.txt
← Back to Directory

code2prompt

$ code2prompt Community Low Risk
Mufeed VH · Agent Bridges & Meta · MIT · macos / linux / windows

code2prompt traverses repositories respecting .gitignore and turns source trees, code files, and git diffs into structured Markdown, XML, or JSON prompts using Handlebars templates. Supports -t/--template, -f/--filter (include globs), -e/--exclude, --tokens, -d/--diff, and -o/--output.

FCRS-1.0 Score
89 /100
Good
Medium Confidence
Zero-Friction Install
brew install code2prompt
CLI vs MCP Decision Hybrid (CLI + MCP)

code2prompt is fastest as a local Rust CLI for deterministic codebase packing and token counting; an optional code2prompt MCP server package also exists.

Agent-Readiness Checklist

✓ JSON Output
✓ Field Filtering
✓ Non-Interactive
— Dry-Run
— Read-Only Mode
— NO_COLOR Clean
✓ Self-Describing
— Official SKILL.md

Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.

FCRS-1.0 6-Dimension Breakdown

Agent-Readiness 23 / 25

Fast Rust CLI with -F json output, -O - stdout mode, --no-clipboard, glob filtering (-f/-e), and --tokens accounting.

  • Supports -F json, -f/--filter, -e/--exclude, --tokens, -d/--diff, and -O -
Trust & Safety 22 / 25

Offline read-only traversal respecting .gitignore; only writes to disk when -o/--output is specified, though it lacks built-in secret scanning.

  • Offline execution respecting .gitignore with explicit -o output path
Setup & Portability 14 / 15

Native Rust binary installable via brew install code2prompt, cargo install code2prompt, and prebuilt releases across macOS, Linux, and Windows.

  • Available on Homebrew and crates.io (code2prompt)
Utility & Efficiency 14 / 15

Handlebars templates, git diff/branch inclusion (-d), and built-in tiktoken counting make prompt assembly predictable.

  • Built-in Handlebars templating, git diff mode, and token estimation
Maintenance & Lineage 8 / 10

Well-established MIT-licensed project (mufeedvh/code2prompt) with active community releases.

  • Active mufeedvh/code2prompt repo under MIT
Docs & Verifiability 8 / 10

Dedicated documentation site (code2prompt.dev) covering CLI flags, templates, and SDK.

  • Official docs at code2prompt.dev

Security, Auth & Guardrails

Auth Modes
No Auth
Credential Storage

Fully offline local CLI; stores no credentials.

Side Effects
Read-Only Local Write
Cost & Quotas

100% free and MIT open-source.

Copyable Guardrail for CLAUDE.md / AGENTS.md
# code2prompt Agent Rules
- Always pass `--no-clipboard` and `-O -` (or `-o <file>`) in headless environments.
- Filter large repos with `-f` / `-e` and check `--tokens` before stuffing output into context.

Agent-Ready Command Recipes

Safe Read-Only Queries

Pack filtered Rust/TypeScript files to stdout with token count
code2prompt . -f "*.rs,*.ts" --tokens format --no-clipboard -O -

Prints a structured prompt for matching files to stdout with formatted token counts without touching the clipboard.

Export codebase summary as JSON with git diff
code2prompt . -d -F json --no-clipboard -O -

Outputs prompt metadata, token count, and git diff in JSON format to stdout.

Controlled Writes & Previews

Write prompt artifact with custom Handlebars template
code2prompt . -t prompt-template.hbs -e "dist/*,node_modules/*" -o prompt.md --no-clipboard

Renders a filtered codebase prompt using a custom Handlebars template to prompt.md.

Strengths for Agents

  • + Fast Rust execution with -f/-e glob filtering and --tokens counting.
  • + Handlebars -t/--template and -d/--diff support tailored review prompts.
  • + -F json and -O - integrate cleanly into agent scripts.

Caveats & Pitfalls

  • ! Does not run Secretlint automatically like Repomix; exclude .env or secret files explicitly.
  • ! Copies to system clipboard by default unless --no-clipboard or -o is used.

Tested Agent Hosts

Claude Code Codex CLI Gemini CLI