# mufeedvh/code2prompt

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/mufeedvh-code2prompt).**

7,145 stars · 401 forks · Rust · mit

## Links

- GitHub: https://github.com/mufeedvh/code2prompt
- Homepage: https://code2prompt.dev
- awesome-repositories: https://awesome-repositories.com/repository/mufeedvh-code2prompt.md

## Topics

`ai` `chatgpt` `claude` `cli` `command-line` `command-line-tool` `gpt` `llm` `prompt` `prompt-engineering` `prompt-generator` `prompt-toolkit` `rust`

## Description

code2prompt is a codebase-to-prompt converter and LLM context generator that transforms source code and directory structures into formatted text blocks for large language models. It functions as both a utility for generating prompts and an AI agent context server that exposes codebase files and metadata to coding assistants via a standardized server protocol.

The tool distinguishes itself through git-aware capabilities, integrating commit messages and branch diffs to provide version control context for AI-generated code changes. It also utilizes the Model Context Protocol to allow external AI assistants to programmatically query project files.

The system manages context through glob-based file filtering and gitignore rule adherence to refine source file selection. It includes a token counter to ensure the aggregated codebase fits within a model's context window and employs custom templates to define the structural layout of the final output.

## Tags

### Artificial Intelligence & ML

- [Repository-to-Prompt Converters](https://awesome-repositories.com/f/artificial-intelligence-ml/prompt-formatting/repository-to-prompt-converters.md) — Transforms entire directory structures and source files into formatted text blocks ready for large language model ingestion. ([source](https://cdn.jsdelivr.net/gh/mufeedvh/code2prompt@main/README.md))
- [Repository-to-Prompt Converters](https://awesome-repositories.com/f/artificial-intelligence-ml/prompt-formatting/repository-to-prompt-converters/repository-to-prompt-converters.md) — Transforms entire directory structures and source files into a single formatted text block for LLM context. ([source](https://cdn.jsdelivr.net/gh/mufeedvh/code2prompt@main/README.md))
- [AI Coding Assistant Integrations](https://awesome-repositories.com/f/artificial-intelligence-ml/ai-coding-assistant-integrations.md) — Exposes the codebase through a standardized server protocol for programmatic analysis by AI coding assistants.
- [AI Integration Protocols](https://awesome-repositories.com/f/artificial-intelligence-ml/ai-integration-protocols.md) — Implements a standardized protocol to allow AI agents to programmatically access and query project files. ([source](https://code2prompt.dev/docs/how_to/install/))
- [Context Preparation Utilities](https://awesome-repositories.com/f/artificial-intelligence-ml/context-preparation-utilities.md) — Processes and formats raw source code and directory structures into structured context for language models.
- [LLM Context Preparation](https://awesome-repositories.com/f/artificial-intelligence-ml/data-preprocessing-pipelines/llm-context-preparation.md) — Aggregates source code and directory structures into a single formatted text block for LLM prompts.
- [Model Context Protocol Servers](https://awesome-repositories.com/f/artificial-intelligence-ml/model-context-protocol-servers.md) — Provides a server-side implementation of the Model Context Protocol to expose codebase files and metadata.
- [Token Context Limiting](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/infrastructure/model-inference-serving/model-integration-pipelines/model-inference/inference-context-customization/token-context-limiting.md) — Tracks token volume to ensure the processed codebase fits within the target model's maximum context window.
- [Git Repository to Prompt Converters](https://awesome-repositories.com/f/artificial-intelligence-ml/prompt-formatting/repository-to-prompt-converters/git-repository-to-prompt-converters.md) — Extracts git commit history and diffs to provide temporal version control context within AI prompts.
- [Prompt Templates](https://awesome-repositories.com/f/artificial-intelligence-ml/prompt-templates.md) — Provides a templating system to define the structure and layout of the aggregated codebase prompt. ([source](https://code2prompt.dev/docs/welcome/))

### Software Engineering & Architecture

- [Context Aggregators](https://awesome-repositories.com/f/software-engineering-architecture/application-frameworks/single-file-backend-servers/single-file-executables/context-aggregators.md) — Flattens multi-file directory structures into a single formatted text stream for efficient LLM ingestion.
- [Model Context Protocol Integrations](https://awesome-repositories.com/f/software-engineering-architecture/integration-extensibility/programmatic-interfaces/model-context-protocol-integrations.md) — Exposes codebase context through the Model Context Protocol for programmatic querying by external AI assistants.

### Development Tools & Productivity

- [Codebase Analysis Tools](https://awesome-repositories.com/f/development-tools-productivity/codebase-analysis-tools/codebase-analysis-tools.md) — Curates specific sets of source files using templates and globs for structured AI-driven documentation.
- [Codebase Size and Token Count Reporters](https://awesome-repositories.com/f/development-tools-productivity/developer-utilities-libraries/workflow-productivity-enhancers/developer-analytics/codebase-metrics/codebase-size-and-token-count-reporters/codebase-size-and-token-count-reporters.md) — Calculates the total token count of the generated text to ensure it fits within the model's context window.
- [Linting File Filters](https://awesome-repositories.com/f/development-tools-productivity/file-ignore-patterns/linting-file-filters.md) — Uses glob patterns and gitignore rules to refine and exclude specific files from the AI context. ([source](https://cdn.jsdelivr.net/gh/mufeedvh/code2prompt@main/README.md))
- [Git Context Injectors](https://awesome-repositories.com/f/development-tools-productivity/git-repository-integrators/ai-optimized-git-repository-ingestors/git-repository-to-text-conversion/commit-summary-generators/git-context-injectors.md) — Includes commit messages and branch diffs in prompts to support automated pull request and commit generation. ([source](https://cdn.jsdelivr.net/gh/mufeedvh/code2prompt@main/README.md))
- [Glob Pattern Resolvers](https://awesome-repositories.com/f/development-tools-productivity/glob-pattern-resolvers.md) — Uses glob patterns and gitignore rules to filter and select relevant source files for processing.
- [Prompt Templates](https://awesome-repositories.com/f/development-tools-productivity/prompt-templates.md) — Employs customizable text templates to ensure consistent formatting of aggregated code and metadata in prompts.
- [Structured File Filtering Systems](https://awesome-repositories.com/f/development-tools-productivity/structured-file-filtering-systems.md) — Applies structured .gitignore and glob rules to filter files during the codebase ingestion process. ([source](https://code2prompt.dev/docs/welcome/))
