code2prompt  by raphaelmansuy

CLI tool for converting codebases into LLM-ready prompts

created 1 year ago
856 stars

Top 42.7% on sourcepulse

GitHubView on GitHub
Project Summary

Code2Prompt is a command-line tool that transforms entire codebases into comprehensive Markdown prompts for Large Language Models (LLMs). It's designed for developers and researchers aiming to leverage LLMs for code analysis, documentation, and improvement by providing rich, structured context.

How It Works

Code2Prompt intelligently traverses project directories, respecting .gitignore and user-defined filters/exclusions. It generates a hierarchical Markdown representation of the codebase, optionally including line numbers and stripping comments. A key advantage is its Jinja2 templating system, allowing for highly customizable prompt generation tailored to specific AI tasks, with features like file inclusion and dynamic input variables.

Quick Start & Requirements

  • Install via pip: pip install code2prompt or pipx: pipx install code2prompt.
  • Basic usage: code2prompt --path /path/to/your/project
  • More info: Documentation

Highlighted Details

  • Supports custom syntax highlighting via --syntax-map.
  • Integrates with LLM CLI tools like llm for direct analysis.
  • Includes token counting and cost estimation for various LLM providers.
  • Offers an interactive mode for file selection.
  • Supports a .code2promptrc configuration file.

Maintenance & Community

The project is actively maintained by Raphaël Mansuy, founder of Quantalogic and creator of qllm. Contributions are welcome via the contributing guide.

Licensing & Compatibility

Released under the MIT License, allowing for commercial use and integration with closed-source projects.

Limitations & Caveats

Future roadmap items include token counts for Anthropic models and other LLMs, SQL-Lite embedding, and Git diff integration. The current token counting is primarily focused on OpenAI's encodings.

Health Check
Last commit

1 month ago

Responsiveness

1 week

Pull Requests (30d)
0
Issues (30d)
1
Star History
38 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.