snip CLI
A Go CLI proxy that shrinks git, test and build output with YAML filters before it reaches the agent. The author estimates 60-90% token savings
- 472 ★ on the repository
- Last commit
- MIT
Broad access
Why this level
- The PreToolUse hook rewrites the shell commands the agent runs and replaces their output
- Filters from a project directory can change output, so they must be approved with `snip trust`
- Installation runs a `curl | sh` script, and savings statistics are stored in SQLite
Install
- Works in
Manual install
brew install edouard-claude/tap/snipThe recommended route. There is also a script, `curl -fsSL https://raw.githubusercontent.com/edouard-claude/snip/master/install.sh | sh`, for macOS and Linux.
Access and checks
How we reviewBroad accessThe tool can change data, run commands or handle secrets.
- The PreToolUse hook rewrites the shell commands the agent runs and replaces their output
- Filters from a project directory can change output, so they must be approved with `snip trust`
- Installation runs a `curl | sh` script, and savings statistics are stored in SQLite
This is third-party code. Review the repository files before installing.
What it does
snip sits between a coding agent and the shell and filters command output before it reaches the context window. A passing `go test ./...` prints hundreds of lines the model never uses, and snip reduces them to the line "1125 passed, 0 failed". `git log`, `git status` and `git diff` shrink the same way. If a command has no filter, it passes through unchanged and with no overhead. Filters are declarative, written in YAML files with no compilation. 132 filters ship built in, covering about 100 commands: git, go, cargo, npm, yarn, pnpm, docker, kubectl, terraform, aws, gh and dotnet. The pipeline has 20 actions. Your own filters go in `~/.config/snip/filters`, and filters from a project directory run only after `snip trust`, which pins the SHA-256 of each file. snip attaches to agents with `snip init`. For Claude Code and Codex it is a PreToolUse hook that rewrites the command, Cursor, Copilot and Antigravity get their own hooks, Gemini CLI, Windsurf, Cline and Kilo Code get instructions inserted into a rules file, and Aider uses shell aliases. `snip gain` prints a savings report, and `snip discover` scans Claude Code history for missed opportunities.
Who it is for. For developers who work a lot with Claude Code, Cursor or Codex and want to spend fewer tokens on verbose test, git and build output.
Good fit when
- The agent runs `go test ./...` or `cargo test` many times and each run floods the context with hundreds of lines
- You want `git log` and `git diff` output trimmed to what the agent uses
- You want to know how many tokens you saved per day, week and month: `snip gain --daily`
- A team's internal utility needs its own YAML filter instead of a tool fork
- You need one program attached to several agents at once: Claude Code, Cursor, Copilot and others
Not a fit when
- You need full unprocessed output: `snip proxy -- command` exists for that, but while the hook is on the agent gets the compressed version by default
- The agent works with commands that have no filters and you do not want to write your own
- You want a tool written in Rust: snip is written in Go, and its Rust counterpart has a separate entry
- The machine has no Go 1.25 or newer: building from source requires it
Example request
Hook snip into Claude Code and show how many tokens it saved todayLimitations
The hook rewrites the commands the agent runs, so it sees and can alter the output of every matching shell command. For Gemini CLI, Windsurf, Cline and Kilo Code it works by inserting instructions into a rules file, and it holds only while the agent follows the rules. Grok Build hooks cannot rewrite a command in place, so snip denies a matching command and asks for a rerun through `snip run`. Pi needs the community pi-hooks extension installed separately. Installation is via `curl | sh`. The savings figures in the README were measured by the author on his own repository and one session, and yours will differ. Filters outside `~/.config/snip/` are ignored until `snip trust` approves them.
How to disable. For Claude Code run `snip init --uninstall`, for other agents add `--agent name`, for example `snip init --agent cursor --uninstall`. Then remove the binary: `brew uninstall snip`.
FAQ
How do I connect snip to Claude Code?
Install snip with Homebrew (`brew install edouard-claude/tap/snip`) or `go install github.com/edouard-claude/snip/cmd/snip@latest`, then run `snip init`. The command installs a PreToolUse hook that transparently rewrites supported commands: the agent gets compressed output as if the command itself produced it.
Which agents does snip work with?
Claude Code, Cursor, GitHub Copilot, Gemini CLI, Codex, Pi, Grok Build, Windsurf, Cline and Roo Code, Kilo Code, Antigravity, OpenCode, OpenClaw and Aider. Each has its own `snip init --agent name` variant or plugin, and Aider uses shell aliases.
How do I write my own filter?
Create a YAML file with name, match (command and subcommand) and a pipeline of actions and put it in `~/.config/snip/filters`. The repository has a SKILL.md that teaches an agent to write such filters. Run the built-in filter tests with `snip verify`.
How do I get full output without compression?
With `snip proxy -- your-command`, which runs the command without filtering. If a command has no matching filter, it passes through unchanged anyway.
What does snip gain show?
A token savings report: the number of filtered commands, tokens saved, a 14-day chart and top commands. It has `--daily`, `--weekly` and `--monthly` breakdowns, JSON and CSV output, and `--quota` compares savings with subscription limits.
Discussion
No questions or reviews yet.
Related
CLI toolsA tool that cuts an agent's token bill on three axes: terser prose, less speculative code, compressed tool output
Claude Token Optimizer: fewer tokens at startup
Claude Token Optimizer
The cto utility counts the tokens Claude Code loads at session start and shrinks CLAUDE.md into a short cheat sheet.
Eleven skills for Claude Code and Codex: test audit, git worktree cleanup, plan pages, screen recording transcripts and 1Password sign-in
A Rust CLI proxy that compacts output from git, tests and other commands so the agent spends fewer tokens reading the terminal
A Claude Code plugin: 39 commands for PRs, review, commits and specs, nine expert roles and hooks, in eight language versions
agnix lints CLAUDE.md, AGENTS.md, SKILL.md, hooks and MCP configs with 702 rules, autofix and editor extensions for VS Code and JetBrains
Comparison with similar tools
Entries that share the main search query, and how they differ.
| Entry | Official | Authentication | Repository stars | Main difference |
|---|---|---|---|---|
| snip (this entry) | no | 472 | ||
| RTK | no | 84,978 | a similar output-compression proxy, written in Rust, while snip is Go with YAML filters | |
| Context Mode | no | not required | 32,835 | an MCP server that keeps large tool output out of context and stores session memory |
README in short
The README opens with the claim: a proxy filters shell output before the agent's context window. It then shows a before and after example on `go test`, the flow and a table of savings per command. Install routes follow, a table of supported agents with details for each, a command reference and a list of the 132 built-in filters and 20 pipeline actions. It ends with custom filters, trust handling and configuration.