| I was feeling bogged down by the repetitive copy-paste routine to build context prompts for debugging or generating code. This simple solution ended up saving me a lot of time, so I thought I'd share my workflow. With the large context windows of OpenAI and Anthropic models, you can keep entire code repositories in context. But copy-pasting the file-tree and code from lots of places is annoying. Prelude is a tiny CLI tool that creates a context prompt from files in your directory and its subdirectories, then copies it to your clipboard or saves it to a text file. Prelude creates a prompt containing the file tree of your specified directory, minus the files you ignored in .gitignore and .preludeignore, followed by the content of each file. It adds a bit of context prompting at the end, and that's it. Ready to copy-paste into a new chat with your favorite AI-chat. Nothing more, nothing less. Here’s how it works: Install Prelude with Homebrew: brew tap aerugo/prelude
brew install prelude Simply run prelude in your working directory. Need files from a specific subdirectory? Use prelude -p dir. Want to specify a filename to save the prompt? Use prelude -f prompt.txt. Lots of files you don't want in the prompt? Put them in a .preludeignore file in the root folder where you run Prelude Say that you know the names of the files you want to include, for example FooBar.py and BarFoo.md and they are somewhere in your file hierarchy. Just run prelude -M "foobar|barfoo" and you will get a prompt with only those files. It also works with * wildcards. Of course, it also works with the -P option, so you can also run something like prelude -P backend/src -M "*.py" To get all python files in the src directory of your backend. PS. I'm sure this already exists. Lots of people must have done this. But nevertheless, I couldn't find a simple CLI tool to do just this, so I wrote one for myself, and then thought to share it. |
Could you include an example of how you separate files? For example are you using YAML Front Matter or something like that?