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
01Automatically processes codebases of any size into formatted prompts.
02Tracks token usage to stay within LLM context limits.
03Filters files using glob patterns and respects `.gitignore` rules.
04Integrates with Git to include diffs, logs, and branch comparisons.
05Customizes prompts with Handlebars templates.
065,173 GitHub stars