# Code2Prompt

A CLI and library that converts a codebase into a single LLM prompt, with prompt templating, token counting, and a matching Python SDK and MCP server.

Code2Prompt is a context engineering tool that ingests a codebase and formats it for large language models, whether a user is manually copying context for ChatGPT, building AI agents in Python, or running an MCP server. It installs via Cargo, Homebrew, or as a Python SDK, and generates a prompt from a target directory in one command, sending it to stdout, the clipboard, or a file.

An agent skill teaches a coding agent to install and use code2prompt for repository navigation and scoped context gathering, inspecting a compact map of functions and classes before reading the relevant source files and tests together, with a fallback directory map for builds without the optional entity-map feature.

The project describes itself as an ecosystem with four parts: a core library handling secure file traversal and Git metadata, a CLI for humans with both a minimal mode and an interactive TUI, a Python SDK, and an MCP server.

Website: https://code2prompt.dev
