CLI ToolsMay 12, 2026·2 min read

code2prompt — Turn Repos into LLM-Ready Prompts

code2prompt ingests a codebase and outputs structured, token-aware prompts, helping you move from ad-hoc copy/paste to repeatable context engineering.

Agent ready

This asset can be read and installed directly by agents

TokRepo exposes a universal CLI command, install contract, metadata JSON, adapter-aware plan, and raw content links so agents can judge fit, risk, and next actions.

Native · 94/100Policy: allow
Agent surface
Any MCP/CLI agent
Kind
Cli
Install
Single
Trust
Trust: Established
Entrypoint
code2prompt
Universal CLI install command
npx tokrepo install a87d4ee7-8374-4e00-a757-2422c617bc43
Intro

code2prompt ingests a codebase and outputs structured, token-aware prompts, helping you move from ad-hoc copy/paste to repeatable context engineering.

  • Best for: developers building agent workflows who need consistent, sharable repo context
  • Works with: any Git repo; outputs text you can paste into ChatGPT/Claude/Cursor/Codex
  • Setup time: 5–15 minutes

Practical Notes

  • Quant: run on 2 repos and compare output size (chars/tokens) before/after adding ignore rules.
  • Quant: keep a baseline prompt snapshot and diff it weekly to spot context drift.

Pattern: context as an artifact

Treat the generated prompt like a build artifact:

  • Check it into a scratch folder (or attach to PRs) when you need reproducibility.
  • Add ignore rules aggressively to keep noise down.
  • Prefer smaller, task-scoped prompts over one giant dump.

Agent workflow tip

Use code2prompt as a pre-step before:

  • running an agent to refactor,
  • generating docs,
  • or doing security review of changes.

If you record the prompt file, you can replay the same context across models and compare results.

FAQ

Q: Is this only a CLI? A: No. The repo describes a wider ecosystem, but the CLI alone is already useful for most workflows.

Q: How do I reduce prompt size? A: Add ignores and scope to a subdirectory; prioritize only the files needed for the task.

Q: Can I use it for reviews? A: Yes—generate a snapshot prompt and attach it to a PR so reviewers/agents share the same context.

🙏

Source & Thanks

Source: https://github.com/mufeedvh/code2prompt > License: MIT > GitHub stars: 7,342 · forks: 422

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets