Code2prompt

github.com/mufeedvh/code2prompt AI Coding Tools Open-source projectOpen source

code2prompt converts a codebase into one language-model prompt with a source tree, templates, and token counts.

github.com/mufeedvh/code2prompt
Code2prompt homepage screenshot

About Code2prompt

Code2Prompt is an open-source, Rust-based command-line tool and associated ecosystem that converts entire codebases into single, structured prompts optimized for large language models. It is hosted publicly on GitHub and includes additional components like a Python SDK and local MCP server for broader integration use cases.

The tool automates the tedious work of gathering, formatting, and contextualizing code for LLM input, with built-in support for .gitignore rule compliance, custom Handlebars templating, token count estimates, and Git metadata inclusion. It supports both minimal CLI usage and an interactive terminal user interface for configuring prompt generation, with output options including stdout, file export, or clipboard copying. It is suited for developers, AI agent builders, and anyone who regularly works with LLMs on code-related tasks, from quick ad-hoc ChatGPT queries to building automated coding agent workflows.

Key features

  • Converts entire codebases into single structured LLM prompts
  • Respects .gitignore rules for file inclusion and exclusion
  • Supports custom Handlebars templates for prompt formatting
  • Provides parallel per-file token count estimates
  • Includes Git metadata (diffs, logs, branch comparisons) in prompts
  • Offers interactive TUI for prompt configuration
Best for: It is most beneficial for developers, AI agent builders, and anyone who regularly feeds code context to large language models.
Good for
  • Open-source and free to use
  • Built in Rust for high performance and low resource usage
  • Offers multiple integration options (CLI, Python SDK, MCP server)
  • Eliminates manual work of formatting code for LLM input
Watch out for
  • Token count estimates are approximate and exclude the JSON output envelope

Code2prompt at a glance

Type
Open-source project
Pricing
Not confirmed. Check the site
Open source
Yes · Source code
Language
English
Last checked
Oct 5, 2026 · Online when checked
Listed
Oct 5, 2026

Code2prompt alternatives

Tools and sites you could use instead, ranked by how closely they match.

All 24 alternatives

Popular in AI Coding Tools

Well-known listings from the same topic.

All 176

Code2prompt FAQ

What is Code2Prompt?
Code2Prompt is an open-source CLI tool and ecosystem that converts entire codebases into single structured prompts for large language models.
How do I install Code2Prompt?
You can install it via Cargo, Homebrew, or the Python SDK using pip, depending on your use case.
Does Code2Prompt respect .gitignore rules?
Yes, the tool automatically respects .gitignore rules when filtering which files to include in generated prompts.
Can I customize the format of generated prompts?
Yes, Code2Prompt supports custom Handlebars templates to format prompts for different use cases.
Is something wrong or out of date?

Tell us and an editor will check it.

Own this website?

Claim the listing and suggest updates yourself. An editor checks every claim first.

Claim this listing