code2prompt is an open source command line tool designed to convert an entire codebase into a structured prompt that can be easily used with large language models. It analyzes a project directory, gathers relevant source files, and formats them into a single prompt that includes the source tree and code content. This approach helps developers quickly provide full project context to AI models without manually copying files or assembling prompts. code2prompt is built in Rust and focuses on performance, enabling fast traversal of large repositories while maintaining low resource usage. It also respects common project conventions such as .gitignore, ensuring that unnecessary files are automatically excluded from the generated prompt. The generated output can be saved to a file, printed to standard output, or copied to the clipboard for immediate use. In addition to the core command line interface, the project also includes a library, Python bindings, and an MCP server.

Features

  • Generates a complete prompt from an entire codebase including source tree
  • Interactive terminal user interface for configuring prompt generation
  • Smart file filtering that respects .gitignore and glob patterns
  • Customizable prompt templates using the Handlebars templating system
  • Token usage tracking to stay within language model context limits
  • Optional Git integration to include diffs, logs, or branch comparisons

Project Samples

Project Activity

See All Activity >

License

MIT License

Follow Code2Prompt

Code2Prompt Web Site

Other Useful Business Software
Gemini 3 and 200+ AI Models on One Platform Icon
Gemini 3 and 200+ AI Models on One Platform

Access Google's best plus Claude, Llama, and Gemma. Fine-tune and deploy from one console.

Build generative AI apps with Vertex AI. Switch between models without switching platforms.
Start Free
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of Code2Prompt!

Additional Project Details

Programming Language

JavaScript, Python, Rust

Related Categories

Python Artificial Intelligence Software, JavaScript Artificial Intelligence Software, Rust Artificial Intelligence Software

Registered

2026-03-13