cli-snip-tool
v1.0.1
Published
A fast CLI snippet manager to save, search, and copy code snippets directly from the terminal.
Maintainers
Readme
snip — A personal code snippet manager for your terminal
Save, search, and copy your most-used code snippets without leaving the terminal.
The problem
Every developer re-searches the same commands over and over.
- "What was that
docker execcommand again?" - "How do I force-push safely in git?"
- "What's the
curlflag for sending JSON headers?"
You either Google it for the 10th time, dig through your shell history, or scroll through old Notion notes.
snip fixes that. It gives you a personal, searchable library of code snippets that lives in your terminal — no browser, no internet, no account needed.
snip find "docker exec" --copy
# ✔ Copied "Docker exec into container" to clipboardFeatures
- Full-text search — searches title, code, and description all at once
- Tag system — organize snippets by topic like
docker,git,sql - Language filter — filter by
bash,javascript,python, and more - Opens your editor — paste code in vim, nano, or vscode — whatever you use
- Clipboard copy — one command to copy any snippet
- Usage tracking — see which snippets you actually use most
- Export and import — back up and restore your library as JSON or Markdown
- Works offline — everything stored locally in a single SQLite file
- Zero config — just install and start saving
Installation
Requirements
- Node.js 18 or higher
- npm
Install globally
npm install -g cli-snip-toolAfter that, the snip command is available everywhere in your terminal.
Verify it works
snip --helpYou should see a list of all available commands.
Quick start — your first snippet
Step 1 — Save a snippet
snip addThe terminal will ask you a few questions:
? Snippet title: Docker exec into container
? Language: bash
? Description (optional): Exec into a running Docker container interactively
? Select existing tags: (none yet)
? Add new tags: docker, devops
Opening your editor — save and close when done…Your editor opens. Paste your code:
docker exec -it $1 /bin/bashSave and close the editor. Done — your snippet is saved.
Step 2 — Find and copy it
snip find "docker exec" --copy
# ✔ Copied "Docker exec into container" to clipboardNow paste it anywhere with Ctrl+V.
All commands
snip add — Save a new snippet
Opens an interactive prompt that asks for the title, language, tags, and code.
snip addYou can also skip the prompts with flags:
snip add --title "Docker exec" --language bash --tags docker,devopsOr pipe code directly from a file (no editor opens):
cat deploy.sh | snip add --stdin --title "Deploy script" --language bashAvailable flags:
| Flag | What it does |
|---|---|
| --title <text> | Set the title directly |
| --language <lang> | Set the language directly |
| --tags <list> | Comma-separated tags |
| --stdin | Read code from piped input instead of editor |
snip find — Search your snippets
The most useful command. Searches everything — title, code, and description.
snip find "docker exec"This shows a list of matching snippets, then a picker where you can choose to copy, preview, or edit one.
Copy the top result immediately (no picker):
snip find "docker exec" --copyFilter by tag:
snip find --tag dockerFilter by language:
snip find --language bashCombine search and filter:
snip find "exec" --tag docker --language bashPipe directly to run:
snip find "deploy script" --copy | bashAvailable flags:
| Flag | What it does |
|---|---|
| --copy | Copies top result to clipboard, no picker |
| --tag <name> | Filter results by tag |
| --language <lang> | Filter results by language |
| --limit <n> | How many results to show (default: 10) |
snip list — See all your snippets
Shows every snippet in a table format.
snip listExample output:
#1 Docker exec into container bash [docker, devops] copied 12×
#2 JWT decode in Node.js js [auth, jwt] copied 8×
#3 Nginx restart command bash [nginx, devops] copied 5×Filter by tag:
snip list --tag devopssnip copy — Copy a snippet by its id
If you already know the id number, this is the fastest way to copy.
snip copy 3
# ✔ Copied "Nginx restart command" to clipboardYou can find id numbers by running snip list.
Run the snippet directly:
snip copy 3 | bashsnip edit — Edit an existing snippet
Opens a menu to choose which field to edit — code, title, tags, or description.
snip edit 3The terminal asks:
? What do you want to edit?
◉ Code (opens editor)
○ Title
○ Tags
○ DescriptionFor code — your editor opens with the current code pre-filled. Edit it, save, and close.
Edit only the title (skips the menu):
snip edit 3 --titleEdit only the tags:
snip edit 3 --tagsAvailable flags:
| Flag | What it does |
|---|---|
| --title | Edit title only |
| --tags | Edit tags only |
| --description | Edit description only |
snip delete — Delete a snippet
Permanently removes a snippet. Asks for confirmation first.
snip delete 3Delete "Nginx restart command"? (Y/n): Y
# ✔ Snippet #3 deleted.There is no undo. Run
snip exportfirst if you are unsure.
snip top — See your most-used snippets
Shows the top 10 snippets ranked by how many times you have copied them.
snip topExample output:
#1 Docker exec into container bash copied 24×
#7 Git force push safely bash copied 18×
#2 JWT decode in Node.js js copied 11×Useful for knowing what to put in your shell aliases.
snip export — Back up your snippets
Exports all snippets to a file. Use this to back up your library or move to a new machine.
Export as JSON (for importing back later):
snip export --format json
# ✔ Exported 42 snippets → snippets-2026-06-24.jsonExport as Markdown (human-readable, good for sharing):
snip export --format md
# ✔ Exported 42 snippets → snippets-2026-06-24.mdsnip import — Restore snippets from a file
Reads a JSON export file and adds snippets to your database. Skips duplicates automatically, so it is safe to run more than once.
snip import snippets-2026-06-24.json
# ✔ Imported 42 snippets.Moving to a new machine:
# On your old machine
snip export --format json
# Copy the file to the new machine, then
snip import snippets-2026-06-24.jsonReal-world examples
Save a git shortcut you always forget
snip add --title "Git undo last commit (keep changes)" --language bash --tags git
# Editor opens → type: git reset --soft HEAD~1
# Save and closeSave a curl command with JSON headers
snip add --title "curl POST with JSON" --language bash --tags curl,api
# Editor opens → type:
# curl -X POST https://api.example.com/endpoint \
# -H "Content-Type: application/json" \
# -H "Authorization: Bearer YOUR_TOKEN" \
# -d '{"key": "value"}'Save a multi-line bash script
cat cleanup.sh | snip add --stdin --title "Cleanup node_modules" --language bash --tags nodeFind and use it later
snip find "cleanup" --copy
# Paste and run wherever you need itSave a SQL query you run often
snip add --title "Find duplicate emails in users table" --language sql --tags sql,postgres
# Editor opens → paste your queryHow it stores your data
snip stores everything locally on your machine — no cloud, no server, no account.
| What | Where |
|---|---|
| Database file | ~/.config/snip/snip.db |
| Config | ~/.config/snip/config.json |
The database is a standard SQLite file. You can open it with any SQLite browser if you ever want to inspect it directly.
To delete everything and start fresh:
rm -rf ~/.config/snipSet your preferred editor
snip uses the $EDITOR environment variable to know which editor to open.
Check what is currently set:
echo $EDITORSet it in your shell config (~/.bashrc or ~/.zshrc):
# For VS Code
export EDITOR="code --wait"
# For vim
export EDITOR="vim"
# For nano
export EDITOR="nano"Then reload your shell:
source ~/.zshrcThe
--waitflag for VS Code is important. Without it, the editor opens and snip thinks you closed it immediately — your code will not be saved.
Tech stack
Built with:
- TypeScript — fully typed codebase
- Node.js — runtime
- SQLite (better-sqlite3) — local database with full-text search (FTS5)
- Commander.js — CLI command parsing
- Inquirer.js — interactive terminal prompts
- Chalk — terminal colors
- Clipboardy — cross-platform clipboard access
Contributing
Contributions are welcome. To run the project locally:
# Clone the repo
git clone https://github.com/satyamsinghs408/cli-snippet-manager.git
cd cli-snippet-manager
# Install dependencies
npm install
# Build
npm run build
# Link globally so you can test the snip command
npm link
# Run in dev mode (no build needed, uses tsx)
npm run devTo run the test suite:
npm testPlease open an issue before submitting a large pull request so we can discuss the approach first.
Licence
MIT — free to use, modify, and distribute.
Author
Built by Satyam Singh
If this saved you time, consider giving the repo a star on GitHub.
