Show HN: Code2prompt – Generate LLM prompts from your codebase (github.com)
I made code2prompt, a CLI tool to generate LLM prompts from your codebase with support for prompt templating and token counting.
I initially wrote this for personal use to utilize Claude 3.0's 200K context window and it has proven to be pretty useful so I decided to open-source it. Let me know what you think.
7 comments
[ 3.8 ms ] story [ 19.1 ms ] thread- Rewrite the code to another language.
- Find bugs/security vulnerabilities.
- Document the code.
- Implement new features.
You can customize the prompt template to achieve any of the desired use cases. It essentially traverses a codebase and creates a prompt with all source files combined. In short, it automates copy-pasting multiple source files into your prompt and formatting them along with letting you know how many tokens your code consumes.
I could see this tool being useful for a few of my use cases, thank you.
For reference:
- The Flask web framework for Python: 131880 tokens
- The Spring Framework for Java: 11070559 tokens