- simonw/files-to-prompt
- Building files-to-prompt entirely using Claude 3 Opus
- Use XML tags to structure your prompts
- Claude Desktop
- Claude Code
- aider
I've really seen the benefit of using files-to-prompt to zip up code files so Claude can better consume them in my prompts.
My workflow is usually this:
- Set up a
prompt.mdin my repo. pip install files-to-prompt- Add an XML
<background>tag with notes on the project, whatever background I want the AI to focus on, whatever expertise I want to reflect - Add an XML
<instructions>tag with very specific instructions on what I want to accomplish (Something like "Use a custom template for this viewMyView" or "Write a test that theMyViewendpoint returns a 200") - Run
files-to-prompt --cxml path/to/file1.py path/to/file2.pyand capture the output - Copy the output and paste it at the bottom of the
prompt.md - Upload the
prompt.mdto Claude Desktop, or pass it to whatever CLI tool (like aider) I am using to interact with Claude. - My prompt is usually something like "Read
prompt.mdand follow the instructions."
# prompt.md
<background>
- You are a [whatever background I specify]
</background>
<instructions>
- Look at [whatever class or file I need]
- Do [very specific small task]
</instructions>
<documents>
This is the part where I paste in the output from `files-to-prompt`
</documents>I use Claude Desktop a lot, and I like being able to reduce the number of files I need to upload because the Desktop app limits the number of files you can upload at once.
Some options to consider:
--ignore <pattern>: Specify a pattern to ignore. This could be useful in getting whole apps but excluding everything inmigrations/.--ignore-ditignore: Ignore thegitignore, and include all files.-e/--extension <extension>: Only retrieve files with a certain extension.-c/--cxml: Output in Claude XML-m/--markdown: Output as Markdown-o/--output <file>: Output to a file
The README has several examples of how to use different options to get the files you want in the format you want.