code2prompt

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

What is code2prompt?

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

Overview of code2prompt

What it is

Code2Prompt is a CLI tool that converts a codebase into a single prompt for large language models. It is built in Rust and designed for context engineering, helping users prepare code context for ChatGPT, AI agents, or MCP servers.

Key features

  • Terminal User Interface (TUI) for interactive prompt configuration
  • Smart filtering with glob patterns and .gitignore support
  • Flexible templating using Handlebars templates
  • Automatic code processing for any size codebase
  • Token estimates with parallel per-file counts and estimated template overhead
  • Smart file reading for formats like CSV, notebooks, JSONL
  • Git integration including diffs, logs, and branch comparisons

Use cases

Use Code2Prompt to generate a structured prompt from a codebase for LLM interactions. It is suitable for manually copying context to ChatGPT, building AI agents via Python, or running a local MCP server. The tool also includes an agent skill for repository navigation and scoped context gathering.

Getting started

Install via Cargo:cargo install code2promptOr via Homebrew:brew install code2promptOr install the Python SDK:pip install code2prompt-rsBasic usage:code2prompt .Save to file:code2prompt path/to/project --output-file prompt.txt

License and pricing

Licensed under the MIT License. The project is open source.

Based on the project's public README and repository metadata.

Add this badge to your README

Featured on YunoDB Badge styles & help

Maintain this project? Show that it is featured on YunoDB.

Markdown[![Featured on YunoDB](https://yunodb.com/badge/mufeedvhcode2prompt.svg)](https://yunodb.com/tools/mufeedvhcode2prompt?utm_source=github&utm_medium=badge)
HTML<a href="https://yunodb.com/tools/mufeedvhcode2prompt?utm_source=github&utm_medium=badge"><img src="https://yunodb.com/badge/mufeedvhcode2prompt.svg" alt="Featured on YunoDB" height="20"></a>