npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

snip-manager

v0.3.0

Published

Fast, terminal-native CLI snippet manager with TUI and SQLite/Gist sync.

Readme


Why snip?

Most snippet managers only handle shell commands. snip handles code — deploy scripts, API calls, Docker commands, JS utilities — across any language, with safety rails, a real TUI, and unix pipeline integration.

| Feature | snip | pet | navi | tldr | dotfiles | |---------|------|-----|------|------|--------| | Run snippets directly | ✅ Any language | ✅ Shell only | ✅ Shell only | ❌ | ✅ Shell only | | Multi-language (JS, Python, Ruby…) | ✅ | ❌ | ❌ | ❌ | ❌ | | Unix pipeline integration | ✅ snip pipe | ❌ | ❌ | ❌ | ❌ | | Interactive TUI | ✅ Split-pane | ❌ | ✅ Basic | ❌ | ❌ | | Dangerous command detection | ✅ | ❌ | ❌ | ❌ | ❌ | | fzf integration | ✅ Native | ✅ | ✅ | ❌ | Manual | | SQLite backend | ✅ Optional | ❌ | ❌ | ❌ | ❌ | | Gist sync | ✅ | ✅ | ❌ | ❌ | Manual | | Zero config | ✅ | ✅ | Needs cheats | ✅ | Heavy |

Quick Start

# Install
npm install -g snip-manager

# Save a snippet
echo 'docker compose up -d --build' | snip add dc-up --lang sh --tags docker

# Find it
snip search docker

# Run it
snip exec dc-up

# Launch TUI
snip ui

Installation

Prerequisites: Node.js ≥ 18

# npm
npm install -g snip-manager

# yarn
yarn global add snip-manager

# pnpm
pnpm add -g snip-manager

# verify
snip --version
snip doctor          # validates storage, editor, fzf, shell, gist

Commands

Core

| Command | Description | |---------|-------------| | snip add <name> | Save a snippet from stdin or $EDITOR | | snip list | List all snippets (--json, --tag, --lang, --sort, --limit) | | snip search <query> | Fuzzy search (--json, --limit) | | snip show <name> | Display snippet (--json, --raw, --edit) | | snip run <name> | Preview + confirm + execute (with template prompts) | | snip exec <name> | Execute immediately, no modal (--dry-run, --force) | | snip pipe <name> | Pipeline mode — stdin→template→stdout (--json, --dry-run) | | snip edit <name> | Open in $EDITOR | | snip rm <name> | Delete (alias: delete) | | snip update <name> | Update metadata (--tags, --lang) |

Utilities

| Command | Description | |---------|-------------| | snip cp <src> <dest> | Duplicate a snippet | | snip mv <old> <new> | Rename a snippet | | snip cat <name> | Print raw content to stdout | | snip recent [n] | Show last n used snippets (default: 5) | | snip stats | Library statistics | | snip grab <url> | Import from URL or github:user/repo/path | | snip fzf | fzf search with live preview |

Integration

| Command | Description | |---------|-------------| | snip alias [shell] | Generate shell aliases (eval "$(snip alias)") | | snip widget [shell] | Ctrl+G hotkey widget for zsh/bash/fish | | snip completion [shell] | Tab-completion script | | snip sync push [query] | Push to GitHub Gist | | snip sync pull <id> | Pull from GitHub Gist | | snip doctor | Health check | | snip config <action> | Get / set configuration | | snip ui | Interactive TUI |

Features

Interactive TUI

snip ui

Split-pane interface with fuzzy search. Keyboard shortcuts:

| Key | Action | |-----|--------| | j / k | Navigate | | / | Live search | | Enter | Preview | | r | Run | | e | Edit | | a | Add new | | d | Delete (type name to confirm, z to undo within 5s) | | s | Cycle sort mode | | q | Quit |

Zero-Friction Execution

snip exec deploy-api            # run immediately
snip exec deploy-api --dry-run  # print only
snip exec deploy-api --force    # skip safety warning

Parameterized Snippets

Use {{variable}} or {{variable:default}} syntax:

echo 'docker run --rm -it {{image:ubuntu:24.04}} {{cmd:bash}}' \
  | snip add docker-dev --lang sh --tags docker

snip run docker-dev
#   image [ubuntu:24.04]: node:20
#   cmd [bash]: ↵

Variables are auto-detected at runtime — no extra flags needed.

Safety

Dangerous commands (rm -rf, sudo, system-level ops) are detected automatically. snip run shows a preview and requires explicit confirmation. snip exec warns but lets you --force past.

Shell Aliases

eval "$(snip alias)"        # every snippet becomes a command
deploy-api                  # → snip exec deploy-api

Ctrl+G Widget

# add to ~/.zshrc
eval "$(snip widget zsh)"
# press Ctrl+G anywhere → search → paste snippet inline

Gist Sync

snip sync push               # push all
snip sync push docker        # push matching
snip sync pull <gist-id>     # pull

fzf Integration

snip fzf                     # search + preview
snip fzf | pbcopy            # pipe to clipboard

Pipeline Mode

# Run a snippet, pipe output forward
snip pipe deploy-api | tee /tmp/deploy.log

# Pipe JSON as template values — no interactive prompts
echo '{"host":"prod.api.com","branch":"main"}' | snip pipe deploy --json

# Stdin passthrough to the snippet's process
curl -s https://api.example.com/data | snip pipe parse-json

# Dry-run: see resolved content without executing
echo '{"image":"node:20"}' | snip pipe docker-dev --json --dry-run

Also pipe-friendly: snip cat, snip show --raw, snip list --json, snip search --json.

Grab from URL

snip grab https://example.com/script.sh --tags ops
snip grab github:user/repo/scripts/backup.sh

Language auto-detected from extension and shebang.

Configuration

snip config set editor "code --wait"
snip config set useSqlite true       # for 100+ snippets
snip config list

| Option | Default | Description | |--------|---------|-------------| | editor | $EDITOR / vi | Snippet editor | | useSqlite | false | SQLite instead of JSON | | snippetDir | ~/.snip | Data directory |

SQLite uses better-sqlite3 (native) or falls back to sql.js (WASM).

Architecture

snip
├── bin/snip              # Entry point
├── lib/
│   ├── cli.js            # Command definitions (Commander.js)
│   ├── storage.js        # JSON + SQLite abstraction
│   ├── search.js         # Fuse.js fuzzy search
│   ├── exec.js           # Multi-language runner
│   ├── template.js       # {{var:default}} engine
│   ├── safety.js         # Dangerous command detection
│   ├── config.js         # Config loader
│   └── commands/         # One file per command
├── completions/          # Shell completions
├── __tests__/            # Jest test suite
├── scripts/              # Seed / smoke scripts
└── docs/                 # Website + demo

Design decisions:

  • Commander.js for CLI parsing — battle-tested, zero-config subcommands.
  • Fuse.js for fuzzy search — searches name, tags, and content simultaneously.
  • Dual storage — JSON for instant start, SQLite for scale. Same API, swap with one config.
  • No daemon — every invocation is stateless. Fast cold starts.
  • Blessed for TUI — raw terminal control, no React/Ink overhead.

Development

git clone https://github.com/Bharath-code/snip.git
cd snip
npm install

# Run locally
node bin/snip --help

# Seed example snippets
node bin/snip seed

# Run tests
npm test

# Lint
npm run lint

Testing

Tests use Jest and cover storage, search, template engine, exec, safety, and CLI integration.

npm test                   # run all tests
npx jest --verbose         # verbose output
npx jest __tests__/exec.test.js  # single file

Project Structure for Contributors

| Directory | Purpose | |-----------|---------| | lib/commands/ | Add a new command = add one file here + register in cli.js | | lib/storage.js | Storage abstraction — both backends | | __tests__/ | Mirror of lib/ — one test file per module | | completions/ | Shell completion scripts |

Troubleshooting

Ensure npm's global bin is in your PATH:

export PATH="$(npm prefix -g)/bin:$PATH"
snip config set editor "vim"     # or code, nvim, nano, subl

Use nvm to avoid sudo:

nvm install --lts
npm install -g snip-manager

Roadmap

  • [x] snip pipe — stdin pipeline integration
  • [ ] Snippet groups / namespaces (docker/cleanup, k8s/deploy)
  • [ ] Snippet versioning & history
  • [ ] snip share — single-snippet gist sharing
  • [ ] snip diff a b — diff two snippets
  • [ ] AI snippet generation
  • [ ] Team shared snippets

See CHANGELOG.md for release history.

FAQ

A CLI tool for saving and running code snippets from the terminal. Think of it as a personal, searchable library for commands and code blocks you run repeatedly.

Dotfiles store configuration. snip stores executable snippets — commands and code blocks you run. snip provides instant search, multi-language execution, and safety rails.

Yes. Use --lang to specify any language. snip resolves the interpreter (node, python3, ruby, etc.) automatically.

Snippets are stored locally in ~/.snip/. Nothing leaves your machine unless you explicitly snip sync push to GitHub Gist.

Contributing

Contributions welcome. See CONTRIBUTING.md for setup and guidelines.

# Good first issues
# https://github.com/Bharath-code/snip/labels/good%20first%20issue

Community

License

MIT © Bharath