About Code2prompt
Code2Prompt is an open source context engineering tool that ingests a codebase and turns it into a single structured prompt for a large language model. Pointed at a directory, it assembles the source tree and file contents into a formatted prompt, which can be printed, copied to the clipboard or saved to a file. The project frames prompts around a goal, an output format and the context it gathers, and the same approach works on notes or other text folders as well as code.
It is built for developers who paste repository context into chat assistants, people building AI agents in Python, and teams that want scoped context for coding agents. The command line tool includes an interactive terminal interface, include and exclude filters using glob patterns, respect for .gitignore rules, Handlebars templates for custom prompt layouts, and token estimates based on per file counts. It can read formats such as CSV, notebooks and JSONL, and can add Git diffs, logs and branch comparisons to a prompt. The core is written in Rust, and the ecosystem includes a Python SDK and an agent skill that teaches coding agents to map a repository and read the relevant files and tests together.
Code2Prompt is free to use under the MIT license. It installs through Cargo or Homebrew, and the Python SDK installs with pip. No paid plans are published.
The source code is maintained on GitHub, where development remains active.