Not a fez-wearing cat in a track suit.
There are many code2prompt tools around, but this one is mine 🪖
Cafeznik is an interactive CLI (levereging the beautiful fzf) to ease the selection and copying of code files - local or remote (GitHub) - to your clipboard.
Why? You know why - so I can feed it into LLMs like the lazy, lazy script kiddie vibe programmer I am. It’s streamlined, efficient, and dangerously habit-forming.
Install it directly via RubyGems (requires Ruby 3.3 and the other dependencies listed below):
gem install cafeznik
cafeznik # or cafeznik --repo owner/repo
use tab to select multiple files, enter to copy them to your clipboard, and ctrl-c/esc to exit. Selecting a directory will copy all files within it, and selecting ./
will copy everything in sight (respecting your --exclude
s and --grep
s ).
Local mode:
Or remote with grep and exclude:
Cafeznik relies on a few external tools to work its magic:
fzf
– Essential for interactive file selection (absolutely required)fd
– Powers local file discovery (required for local mode)ripgrep
– Enables efficient grep functionality (required when using--grep
)bat
(&tree
) – Provide pretty previews (optional but highly recommended)gh
– Simplifies GitHub authentication (optional; you can alternatively set the GITHUB_TOKEN environment variable)
A homebrew line to install all the dependencies on macOS:
brew install fzf fd ripgrep bat tree gh
Quickly select and copy files from your current directory:
cafeznik
Filter your selection to include only files that contain specific text:
cafeznik --grep "def initialize"
Easily exclude unwanted files or directories:
cafeznik --exclude "*.log" --exclude "tmp/"
Fetch and copy code directly from any GitHub repository:
cafeznik --repo owner/repo
It also supports full URLs:
cafeznik --repo https://github.com/owner/repo
--repo, -r Specify a GitHub repository to fetch files from
--grep, -g Only select files containing specific text patterns (works locally and remotely)
--exclude, -e Exclude files or directories matching provided patterns (also works locally and remotely)
--with-tree, -t Include a detailed file tree structure in your output (Guess what? Works locally and remotely)
--no-header Omit file headers from the copied content for a cleaner paste
--verbose Activate detailed logging output for debugging and transparency
Or, you know:
cafeznik --help
- History of copied files - so you can easily re-copy them. Rinse, repeat.
- Optional minification of copied files
- Binary files support for multi-modal models? Might be a stretch
- Token counting. Everyone loves token counting.
- gitingest - Fellow Ruby that works much better on bigger repos, and packs it all nicely in a prompt file
- onefilellm - Does so much more, expect it's a completely different thing
- your-source-to-prompt.html - If you wanna leave your console for a browser, you'll get plenty of nice features for your code2prompt needs
Cafeznik is open-source software, licensed under the MIT License.
Please! Feel free, this over-engineered tool welcomes all interested parties and fiestas.
Enjoy your freshly copied code! 🍪