OpenViSTAI · Agents · Blockchain · Crypto
Menu
AI Developer Tools & SDKs

Code2Prompt

Code2Prompt is a Rust-based developer tool that turns a codebase into a structured prompt for large language models. Its CLI can generate a source-tree view, filter files, apply Handlebars templates, include Git information and estimate token usage. The project also provides Python bindings and a local MCP server for agent integrations.

Independent OpenViST project profile, based on linked sources.

Code2Prompt — OpenViST project profile in AI Developer Tools & SDKs.
OpenViST project illustration. See the linked sources for product details.
Understand the project

Practical overview

When it fits

Use Code2Prompt when you want a repeatable way to assemble repository context for an LLM, rather than manually collecting and pasting files.

Who it is for

  • Developers preparing repository context for LLM requests
  • Teams or individuals integrating codebase context into Python automation or RAG pipelines
  • Agent workflows that need local codebase context

Documented uses

  • Collect selected repository files and format them as one LLM prompt
  • Produce a source-tree overview alongside code content
  • Reuse prompt layouts with templates
  • Estimate prompt size before sending context to an LLM
  • Include Git diffs, logs or branch comparisons in prompt material
Before you choose

Requirements & limits

The project documents installation through Cargo, Homebrew and pip. Its public GitHub repository is MIT-licensed.

  • Choose the CLI for terminal-based prompt generation and the Python bindings for scripts or deeper Python integration.
  • The documented local MCP server is a separate integration path for agentic applications.
  • Token counts are estimates based on per-file counts and template overhead, not a count of the complete rendered prompt.

Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.

Source-based practical guide

Generate a prompt from a repository

Install the CLI and direct it at a codebase to produce a prompt.

Before you start

  • A terminal
  • A codebase directory
  • Cargo or Homebrew to install the CLI

Steps

  1. Install with the command below or brew install code2prompt.

    Documented command
    cargo install code2prompt
  2. Run code2prompt . from the codebase directory to write the generated prompt to standard output.

  3. To save output instead, run code2prompt path/to/project --output-file prompt.txt.

Expected outcome

A formatted prompt is written to standard output or to the specified file.

Guide limitations

  • Token counts are estimates and do not re-tokenize the complete rendered prompt.
  • The estimate excludes the JSON output envelope.
Evidence and transparency

Sources & review

Source record details
Source availability
Active
Sources checked
7 October 2026
Original website title
mufeedvh/code2prompt · Official homepage title · retained in its source language