explaingit

mufeedvh/code2prompt

7,343RustAudience · developerComplexity · 2/5LicenseSetup · easy

TLDR

A command-line tool that packages an entire code project into a single formatted block of text you can paste into an AI assistant, with token counting, gitignore support, and customizable output templates.

Mindmap

mindmap
  root((code2prompt))
    What it does
      Codebase to AI prompt
      Token counting
      File collection
    Tech Stack
      Rust
      Python
      Handlebars
    Interfaces
      CLI tool
      Python SDK
      Local server mode
    Features
      gitignore support
      Git diff inclusion
      Custom templates
    Audience
      AI-assisted developers
      Vibe coders
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Instantly package your entire codebase into a single AI-ready prompt to ask ChatGPT or Claude to review, explain, or refactor it.

USE CASE 2

Use the Python SDK to integrate automated codebase-to-prompt conversion into your own AI agent or scripting workflow.

USE CASE 3

Add git diffs or commit logs to your AI prompt to ask for a code review of your latest changes.

Tech stack

RustPythonHandlebars

Getting it running

Difficulty · easy Time to first run · 5min

Install via Cargo, Homebrew, pip, or pre-built binary, no external services or API keys required to run the tool itself.

Open source under the MIT License, use freely for any purpose, including commercial projects.

In plain English

code2prompt is a command-line tool that takes a software project on your computer and converts it into a single block of text formatted for use with an AI language model. When you want to ask an AI assistant about a codebase, you typically need to paste the relevant code into the chat. Doing that manually is tedious, especially for large projects with many files. code2prompt automates that process. You point the tool at a directory, and it walks through the files, collects their contents, and formats everything into a structured prompt. It respects .gitignore rules, which means it skips files your project has already marked as unimportant, like compiled output or environment files. It also tracks token counts, which is useful because AI models have limits on how much text they can process at once. The tool has several components. The core is a Rust library that handles file reading and formatting at high speed. On top of that is a command-line interface with a minimal interactive mode, and a Python package for developers who want to integrate this behavior into their own scripts or AI agent workflows. There is also a local server mode that allows AI agent applications to access your codebase without you needing to pipe files around manually. Templating is supported through Handlebars, a templating format, so you can customize how the output is structured for different kinds of questions or tasks. Git integration is also included, letting you add diffs, commit logs, or branch comparisons to the prompt. Installation is available via Cargo (the Rust package manager), Homebrew on macOS, pip for the Python SDK, or by downloading a pre-built binary. The project is open source under the MIT License.

Copy-paste prompts

Prompt 1
I have a Node.js project in ~/myapp. Use code2prompt to package it into a prompt I can paste into Claude to ask for a security review. What command do I run?
Prompt 2
How do I use code2prompt with a custom Handlebars template so the output is formatted specifically for asking an AI to write unit tests for each file?
Prompt 3
I want to use the code2prompt Python SDK inside a script that automatically sends a repo to an AI API for analysis. Show me a minimal example.
Prompt 4
How do I run code2prompt in local server mode so an AI agent can query my codebase without me piping files manually?
Open on GitHub → Explain another repo

← mufeedvh on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.