Code2Prompt
Converts a codebase into a single, structured prompt suitable for large language models.
About
Code2Prompt is a versatile tool designed to streamline the process of generating prompts for Large Language Models (LLMs) from your codebase. It offers a CLI, SDK, and MCP server, enabling users to automatically transform their code into well-structured prompts for code analysis, generation, and other tasks. Features include automatic code processing, smart filtering using glob patterns and .gitignore rules, flexible Handlebars templating, token tracking to manage context limits, and Git integration for including diffs, logs, and branch comparisons. Whether you're working on code analysis, AI agents, or automation scripts, Code2Prompt simplifies the interaction between your codebase and LLMs.
Key Features
- Automatically processes codebases of any size into formatted prompts.
- Tracks token usage to stay within LLM context limits.
- Filters files using glob patterns and respects `.gitignore` rules.
- Integrates with Git to include diffs, logs, and branch comparisons.
- Customizes prompts with Handlebars templates.
- 5,173 GitHub stars
Use Cases
- Generating prompts for code analysis tasks.
- Integrating codebase context into AI agents.
- Automating prompt creation for LLM-based code generation.