At its core, code2prompt does one thing exceptionally well: it transforms your entire codebase into a single, well-structured prompt that’s ready for LLM consumption. I highly recommend trying this tool out when working on an open source project, or working with a self hosted LLM via say Ollama.
The tool includes several thoughtful features that make it particularly valuable:
- It automatically respects your
.gitignore
file. - It adds each file’s full path as a header to the file’s contents.
- It supports modifying the output via templating.
and a bunch more.
To experiment with code2prompt on a system with Nix, simply run: $ nix-shell -p code2prompt
I’ve found that the latest version (v2.0.0
)’s “automatically copy to clipboard” feature is broken. I’ve worked around this two different ways.
- By leveraging the technique I detailed in this other blog post.
- By having code2prompt to output to a file, and then upload said file to the LLM interface:
$ code2prompt . --output prompt.txt
Overall, code2prompt
has made interacting with LLMs much easier.