What is Code2Prompt ?

Code2Prompt is a context engineering tool that ingests your codebase, turning your repository into structured, AI-ready prompts.

Transform any repository into meaningful context following the Goal + Format + Context framework... Check it out !

Codebase 👨‍💻

node_app
├── README.md
├── data
│   └── sample.json
└── src
    ├── index.js
    └── utils.js

Command

$ code2prompt node_app

Goal

What you want to achieve

Add a user filtering feature to sort users by age in ascending order

Format

How you want the output structured

Provide the complete implementation with: - Updated utils.js with the new filterUsersByAge function - Modified index.js to demonstrate the filtering - Clear code comments explaining the logic

Context

Relevant information provided by Code2Prompt

Project Path: node_app

Source Tree:

```txt
node_app
├── README.md
├── data
│   └── sample.json
└── src
    ├── index.js
    └── utils.js
```

`node_app/README.md`:

```md
Simple Node.js app to process JSON data.
Feature idea: Add a filter function to sort users by age.
```

`node_app/data/sample.json`:

```json
{
    "users": [
        {
            "name": "Alice",
            "age": 25
        },
        {
            "name": "Bob",
            "age": 30
        }
    ]
}
```

`node_app/src/index.js`:

```js
const { processData } = require("./utils");

console.log("App started");
processData();
```

`node_app/src/utils.js`:

```js
function processData() {
  console.log("Processing data...");
}

module.exports = { processData };
```

How to use Code2Prompt ?

Code2Prompt comes with different flavors depending on your needs.

Why Code2prompt ?

Code2Prompt introduces a new development workflow, enabling AI and human agents to interact with code efficiently.

Code2Prompt leverages glob patterns to include or exclude only the relevant files.

This allows you to query LLMs without extra noise, thus reducing hallucination and increasing performance.

code2prompt . --include "*.js,*.html" --exclude "node_modules/"
  • Code it
  • Parse it
  • Extract it
  • Format it
  • Analyze it
  • Optimize it
  • Rewrite it
  • Summarize it
  • Filter it
  • Search it
  • Sort it
  • Query it
  • Compare it
  • Deploy it
  • Debug it
  • Refactor it
  • Automate it
  • Run it
  • Monitor it
  • Test it
  • Track it
  • Patch it
  • Secure it
  • Train it
  • Validate it
  • Package it
  • Upgrade it
  • Integrate it
  • Unlock it
LLaMA Grok Qwen Mistral DeepSeek Gemini GPT Claude

Built for creators

Discover the new features

Code2Prompt transforms your codebase into structured prompts for AI models, making it easier to get accurate, context-aware responses.

High-Performance
Written in Rust for speed and efficiency, handling large codebases with minimal resource usage.
Handlebars-Powered
Customizable prompt generation using Handlebars templates, giving you full control over output format.
Smart Filtering
Supports include/exclude patterns with glob matching and smart context for precise code selection (soon).
Multi-Format Support
Exports structured prompts in JSON, Markdown, or XML with different formatting options to suit your workflow.
Git Integration
Includes Git diff and log extraction for better context, making it easier to understand code changes over time.
Open-Source & Community-Driven
Built with developer collaboration under the MIT license, encouraging contributions and extensions.

Join the Community

Code2Prompt is built by and for developers. Contribute, suggest features, and help shape the future of AI-driven code analysis.