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
Full-stack observability with actually useful AI | Grafana Cloud Icon
Full-stack observability with actually useful AI | Grafana Cloud

Our generous forever free tier includes the full platform, including the AI Assistant, for 3 users with 10k metrics, 50GB logs, and 50GB traces.

Built on open standards like Prometheus and OpenTelemetry, Grafana Cloud includes Kubernetes Monitoring, Application Observability, Incident Response, plus the AI-powered Grafana Assistant. Get started with our generous free tier today.
Create free account
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