Cafeznik
Not a fez-wearing cat in a track suit.
There are many code2prompt tools around, but this one is mine 🪖. It’s built with a sprinkle of practicality, a dash of irreverence, and plenty of laziness—exactly how a good developer tool should be.
What is this?
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.
Installation
Install it directly via RubyGems (requires Ruby 3.3 and the other dependencies listed below):
gem install cafeznik
Then what?
cafeznik # or cafeznik --repo owner/repo
use tab to select multiple files, enter to copy them to your clipboard, and ctrl-c to exit.
looksee
Local mode:
Or remote with grep and exclude:
Dependencies
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
Usage
Local mode
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/"
GitHub mode
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
Noteworthy Flags
--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)
Less important flags
--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
What's a-comin
- 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.
Noteworthy Competitors I did not take inspiration from
- 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
License
Cafeznik is open-source software, licensed under the MIT License.
Contributing
Contributions of all kinds are warmly welcomed.
Enjoy your freshly copied code snacks! 🍪