{"id":46635249,"url":"https://github.com/agusrdz/chop","last_synced_at":"2026-04-03T00:00:14.463Z","repository":{"id":342625585,"uuid":"1174564543","full_name":"AgusRdz/chop","owner":"AgusRdz","description":"CLI output compressor for Claude Code. Reduces token consumption by 50–90% by compressing verbose    command output before it enters the context window. Supports 52+ commands — git, docker,   kubectl, npm, terraform, and more.","archived":false,"fork":false,"pushed_at":"2026-03-28T16:48:01.000Z","size":587,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-28T17:56:23.029Z","etag":null,"topics":["claude","claude-ai","claude-code","cli","context-window","developer-tools","golang","llm","productivity","token-optimization"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AgusRdz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-06T15:32:57.000Z","updated_at":"2026-03-28T16:46:54.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/AgusRdz/chop","commit_stats":null,"previous_names":["agusrdz/chop"],"tags_count":87,"template":false,"template_full_name":null,"purl":"pkg:github/AgusRdz/chop","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgusRdz%2Fchop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgusRdz%2Fchop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgusRdz%2Fchop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgusRdz%2Fchop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AgusRdz","download_url":"https://codeload.github.com/AgusRdz/chop/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgusRdz%2Fchop/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31319714,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T23:57:25.032Z","status":"ssl_error","status_checked_at":"2026-04-02T23:57:06.281Z","response_time":89,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["claude","claude-ai","claude-code","cli","context-window","developer-tools","golang","llm","productivity","token-optimization"],"created_at":"2026-03-08T01:26:04.823Z","updated_at":"2026-04-03T00:00:14.456Z","avatar_url":"https://github.com/AgusRdz.png","language":"Go","readme":"# chop\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"logo.png?v=2\" alt=\"chop logo\" width=\"200\" /\u003e\n\u003c/p\u003e\n\n**CLI output compressor for Claude Code, Gemini CLI, Codex CLI, and Antigravity IDE.**\n\nClaude Code and other AI agents waste 50-90% of their context window on verbose CLI output —\nbuild logs, test results, container listings, git diffs. **chop** compresses\nthat output before Claude sees it, saving tokens and keeping conversations\nfocused.\n\nThe name comes from _chop chop_: the sound of something eating through all that verbosity before it ever reaches the context window.\n\n---\n\n## How It Works\n\nWhen Claude Code runs a Bash command, the raw output is fed back into the\nconversation as a `tool_result` — part of the **input** of the next API call.\n`chop` intercepts that result and compresses it before it enters the context.\n\n```mermaid\nsequenceDiagram\n    participant CC as Claude Code\n    participant H as PreToolUse Hook\n    participant CH as chop\n    participant API as Claude API\n\n    CC-\u003e\u003eH: bash(\"docker ps\")\n    H-\u003e\u003eCH: raw output (850 tokens)\n    CH--\u003e\u003eH: compressed output (250 tokens)\n    H-\u003e\u003eAPI: tool_result (250 tokens)\n    API--\u003e\u003eCC: response\n```\n\n### The Cascade Effect\n\nThe savings aren't one-time. Every `tool_result` that enters the context\n**stays there** for the rest of the session — included in the input of every\nsubsequent API call. A bloated command result compounds across turns.\n\n```mermaid\ngraph TD\n    T1[\"Turn 1: docker ps → 850 tokens added\"]\n    T2[\"Turn 2: +850 tokens carried forward\"]\n    T3[\"Turn 3: +850 tokens carried forward\"]\n    TN[\"Turn N: +850 tokens carried forward\"]\n    COMPACT[\"Compaction triggered early ⚠️\"]\n\n    T1 --\u003e T2 --\u003e T3 --\u003e TN --\u003e COMPACT\n\n    style COMPACT fill:#f66,color:#fff\n```\n\n```mermaid\ngraph TD\n    T1C[\"Turn 1: chop docker ps → 250 tokens added\"]\n    T2C[\"Turn 2: +250 tokens carried forward\"]\n    T3C[\"Turn 3: +250 tokens carried forward\"]\n    TNC[\"Turn N: +250 tokens carried forward\"]\n    SESSION[\"Longer session, more context budget ✅\"]\n\n    T1C --\u003e T2C --\u003e T3C --\u003e TNC --\u003e SESSION\n\n    style SESSION fill:#2a2,color:#fff\n```\n\n### Why Output Tokens Also Benefit\n\nAPI output tokens cost **5× more** than input tokens and are slower to\ngenerate (higher TTFB). A larger, noisier context causes the model to produce\nlonger, more verbose responses — more recapitulation, more hedging. Keeping\nthe context lean produces tighter, faster output naturally.\n\n```\nInput token price:   $3.00 / MTok  (Sonnet 4.6)\nOutput token price: $15.00 / MTok  (Sonnet 4.6)\n```\n\n\u003e ⚠️ **200K threshold**: Once input exceeds 200K tokens, pricing jumps to\n\u003e $6.00 input / $22.50 output — applied to the *entire* request, not just\n\u003e the excess. Staying compressed avoids crossing that threshold.\n\n---\n\n## Before \u0026 After\n\n```\n# Without chop (247 tokens)\n$ git status\nOn branch main\nYour branch is up to date with 'origin/main'.\n\nChanges not staged for commit:\n  (use \"git add \u003cfile\u003e...\" to update what will be committed)\n  (use \"git restore \u003cfile\u003e...\" to discard changes in working directory)\n        modified:   src/app.ts\n        modified:   src/auth/login.ts\n        modified:   config.json\n\nUntracked files:\n  (use \"git add \u003cfile\u003e...\" to include in what will be committed)\n        src/utils/helpers.ts\n\nno changes added to commit (use \"git add\" and/or \"git commit\")\n\n# With chop (12 tokens — 95% savings)\n$ chop git status\nmodified(3): src/app.ts, src/auth/login.ts, config.json\nuntracked(1): src/utils/helpers.ts\n```\n\n```\n# Without chop (850+ tokens)\n$ docker ps\nCONTAINER ID   IMAGE                  COMMAND                  CREATED        STATUS        PORTS                    NAMES\na1b2c3d4e5f6   nginx:1.25-alpine      \"/docker-entrypoint.…\"   2 hours ago    Up 2 hours    0.0.0.0:80-\u003e80/tcp       web\nf6e5d4c3b2a1   postgres:16-alpine     \"docker-entrypoint.s…\"   2 hours ago    Up 2 hours    0.0.0.0:5432-\u003e5432/tcp   db\n...\n\n# With chop (compact table — 70% savings)\n$ chop docker ps\nweb        nginx:1.25-alpine     Up 2h    :80-\u003e80\ndb         postgres:16-alpine    Up 2h    :5432-\u003e5432\n```\n\n```\n# Without chop (1,200+ tokens)\n$npm test\n\n\u003e @acme/ui@1.0.0 test\n\u003e jest\n\n PASS  src/lib/button/button.component.spec.ts\n PASS  src/lib/modal/modal.component.spec.ts\n...58 more passing suites...\n\nTest Suites: 59 passed, 59 total\nTests:       2 skipped, 1679 passed, 1681 total\nTime:        12.296 s\n\n# With chop (5 tokens — 99% savings)\n$chop npm test\nall 1681 tests passed\n```\n\n---\n\n## Install\n\n**macOS / Linux:**\n\n```bash\ncurl -fsSL https://raw.githubusercontent.com/AgusRdz/chop/main/install.sh | sh\n```\n\nSpecific version or custom directory:\n\n```bash\ncurl -fsSL https://raw.githubusercontent.com/AgusRdz/chop/main/install.sh | CHOP_VERSION=v1.0.0 sh\ncurl -fsSL https://raw.githubusercontent.com/AgusRdz/chop/main/install.sh | CHOP_INSTALL_DIR=/usr/local/bin sh\n```\n\nThe installer places the binary in `~/.local/bin` by default. If it is not in your PATH, it is added automatically to `~/.zshrc` or `~/.bashrc`. Reload your shell after installing:\n\n```bash\nsource ~/.zshrc  # or ~/.bashrc\n```\n\n**Windows (PowerShell):**\n\n```powershell\nirm https://raw.githubusercontent.com/AgusRdz/chop/main/install.ps1 | iex\n```\n\nThe installer places the binary in `%LOCALAPPDATA%\\Programs\\chop` by default and adds it to your user PATH automatically. Restart your terminal after installing.\n\n**With Homebrew (macOS / Linux):**\n\n```bash\nbrew install AgusRdz/tap/chop\n```\n\n**With Go:**\n\n```bash\ngo install github.com/AgusRdz/chop@latest\n```\n\nUpdate to latest:\n\n```bash\nchop update\n```\n\n## Verification\n\nAll release binaries are signed with [GitHub Artifact Attestations](https://docs.github.com/en/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds),\nproviding cryptographic proof that a given binary was built from this repository at a specific commit.\n\nRequires the [GitHub CLI](https://cli.github.com/).\n\n```bash\ngh attestation verify chop-darwin-arm64 --repo AgusRdz/chop\n```\n\n\u003e **macOS note:** If downloaded manually (not via Homebrew), macOS may block the binary on first run.\n\u003e Remove the quarantine flag before running:\n\u003e ```bash\n\u003e xattr -d com.apple.quarantine ./chop\n\u003e ```\n\u003e Installing via Homebrew avoids this entirely.\n\n---\n\n## Quick Start\n\n```bash\nchop git status          # compressed git status\nchop docker ps           # compact container list\nchop npm test            # just failures and summary\nchop kubectl get pods    # essential columns only\nchop terraform plan      # resource changes, no attribute noise\nchop curl https://api.io # JSON compressed to structure + types\nchop anything            # auto-detects and compresses any output\n```\n\n---\n\n## Agent Integration\n\n### Claude Code\n\nRegister a `PreToolUse` hook that automatically wraps every Bash command:\n\n```bash\nchop init --global       # install hook\nchop init --uninstall    # remove hook\nchop init --status       # check if installed\n```\n\nAfter this, every command Claude Code runs gets compressed transparently.\nYou'll see `chop git status` in the tool calls — that's the hook working.\n\n### Gemini CLI\n\n```bash\nchop init --gemini             # install hook\nchop init --gemini --uninstall # remove hook\nchop init --gemini --status    # check if installed\n```\n\n### Codex CLI\n\n```bash\nchop init --codex              # install hook\nchop init --codex --uninstall  # remove hook\nchop init --codex --status     # check if installed\n```\n\n### Antigravity IDE\n\n```bash\nchop init --antigravity              # install hook\nchop init --antigravity --uninstall  # remove hook\nchop init --antigravity --status     # check if installed\n```\n\n### AI Agent Discovery\n\nchop writes a discovery file at `~/.chop/path.json` on every install, update, or hook registration, so AI agents can always locate the binary without searching:\n\n```json\n{\n  \"version\": \"v1.15.0\",\n  \"path\": \"/home/user/.local/bin/chop\"\n}\n```\n\nTwo commands support agent-first workflows:\n\n```bash\nchop agent-info               # output JSON metadata (path, version, installed hooks)\nchop init --agent-handshake   # print a high-signal discovery message agents recognize\n```\n\n`setup` is also available as an alias for `init`, useful when working with Gemini CLI where `/init` conflicts with a built-in command:\n\n```bash\nchop setup --global           # same as chop init --global\n```\n\n---\n\n## Supported Commands (60+)\n\n| Category | Commands | Savings |\n|----------|----------|---------|\n| **Git** | `git` status/log/diff/branch/push, `gh` pr/issue/run | 50-90% |\n| **JavaScript** | `npm` install/list/test/view, `pnpm`, `yarn`, `bun`, `npx`, `tsc`, `eslint`, `biome` | 70-95% |\n| **Angular/Nx** | `ng` build/test/serve, `nx` build/test, `npx nx` | 70-90% |\n| **.NET** | `dotnet` build/test | 70-90% |\n| **Rust** | `cargo` test/build/check/clippy | 70-90% |\n| **Go** | `go` test/build/vet | 75-90% |\n| **Python** | `pytest`, `pip`, `uv`, `mypy`, `ruff`, `flake8`, `pylint` | 70-90% |\n| **Java** | `mvn`, `gradle`/`gradlew` | 70-85% |\n| **Ruby** | `bundle`, `rspec`, `rubocop` | 70-90% |\n| **PHP** | `composer` install/update | 70-85% |\n| **Containers** | `docker` ps/build/images/logs/inspect/stats/rmi/etc., `docker compose` | 60-85% |\n| **Kubernetes** | `kubectl` get/describe/logs/top, `helm` | 60-85% |\n| **Infrastructure** | `terraform` plan/apply/init | 70-90% |\n| **Build** | `make`, `cmake`, `gcc`/`g++`/`clang` | 60-80% |\n| **Cloud** | `aws`, `az`, `gcloud` | 60-85% |\n| **HTTP** | `curl`, `http` (HTTPie) | 50-80% |\n| **Search** | `grep`, `rg` | 50-70% |\n| **System** | `ping`, `ps`, `ss`/`netstat`, `df`/`du`, `systemctl` | 50-80% |\n| **Files/Logs** | `cat`, `tail`, `less`, `more`, `ls`, `find` | 60-95% |\n| **Atlassian** | `acli` jira list/get-issue | 60-80% |\n\nAny command not listed above still gets compressed via auto-detection (JSON, CSV, tables, log lines).\n\n### Log Pattern Compression\n\nWhen reading log files with `cat`, `tail`, or any log-producing command, chop groups\nstructurally similar lines by replacing variable parts (UUIDs, IPs, timestamps, numbers,\n`key=value` pairs) with a fingerprint, then shows a representative line with a repeat count:\n\n```bash\n# Before (51 lines)\n2024-03-11 10:00:00 INFO Processing request id=req0001 duration=31ms status=200\n2024-03-11 10:00:01 INFO Processing request id=req0002 duration=32ms status=200\n... (48 more identical-structure lines)\n2024-03-11 11:00:00 ERROR Connection timeout to 10.0.0.5:3306\n\n# After (2 lines)\n2024-03-11 11:00:00 ERROR Connection timeout to 10.0.0.5:3306\n2024-03-11 10:00:49 INFO Processing request id=req0049 duration=79ms status=200 (x50)\n```\n\nErrors and warnings are always shown in full and floated to the top.\n\n---\n\n## Configuration\n\n### Global config\n\n`~/.config/chop/config.yml` — configure editor preference and disable built-in filters globally:\n\n```bash\nchop config                        # show current config\nchop config init                   # create a starter config.yml\nchop config set editor \u003cvim|code|nano|...\u003e  # set preferred editor\nchop config edit                   # open config.yml in your editor\nchop config export                 # export config + filters to stdout (for syncing)\nchop config import \u003cfile\u003e          # import a previously exported config\n```\n\n```yaml\n# ~/.config/chop/config.yml\n\n# Preferred editor for all \"chop * edit\" commands.\n# Falls back to $VISUAL, $EDITOR, then auto-detects (code, vim, nano, notepad).\n# Set without opening a file: chop config set editor vim\neditor: vim\n\n# Disable built-in filters for specific commands.\n# Matching is prefix-based: \"git diff\" disables all git diff variants.\n# Both formats are supported:\ndisabled:\n  - git diff            # disables git diff, git diff HEAD, git diff --cached, etc.\n  - curl                # disables all curl commands\n```\n\n\u003e **Why disable `git diff`?** chop compresses diff output by default, which is useful for AI agents but breaks interactive use. Adding `git diff` to disabled ensures you always see the full diff when running it yourself.\n\n### Local config (per-project)\n\nOverride the global disabled list for the current project:\n\n```bash\nchop local                      # show current local config\nchop local add \"git diff\"       # disable git diff in this project\nchop local remove \"git diff\"    # re-enable git diff\nchop local clear                # remove local config entirely\nchop local edit                 # open .chop.yml in your editor\n```\n\nThe first `chop local add` creates `.chop.yml` and adds it to `.gitignore` automatically.\n\n### Custom Filters\n\nDefine your own compression rules for any command — keep/drop regex, head/tail truncation, or pipe through an external script.\n\n```bash\nchop filter new \"myctl deploy\"                          # scaffold + guided workflow (recommended)\nchop filter add \"myctl deploy\" --keep \"ERROR,WARN\" --drop \"DEBUG\"  # add directly\nchop filter test \"myctl deploy\"                         # test against stdin\n```\n\n→ Full reference: [docs/custom-filters.md](docs/custom-filters.md)\n\n---\n\n## Token Tracking\n\nEvery command is tracked locally. See how many tokens you're saving:\n\n```bash\nchop gain                  # overall savings summary\nchop gain --history        # last 20 commands with per-command savings\nchop gain --summary        # per-command breakdown\nchop gain --projects       # per-project breakdown\nchop gain --unchopped      # commands with no filter — new candidates\nchop gain --export json    # export history as JSON or CSV\n```\n\n→ Full reference: [docs/token-tracking.md](docs/token-tracking.md)\n\n---\n\n## Shell Completions\n\nEnable tab-completion for all chop commands and flags:\n\n```bash\nsource \u003c(chop completion bash)        # bash — add to ~/.bashrc\nsource \u003c(chop completion zsh)         # zsh  — add to ~/.zshrc\nchop completion fish | source         # fish\nchop completion powershell | Invoke-Expression  # PowerShell\n```\n\n→ Setup instructions: [docs/shell-completions.md](docs/shell-completions.md)\n\n---\n\n## Maintenance\n\n```bash\nchop doctor            # check and auto-fix common issues\nchop update            # update to the latest version\nchop auto-update on    # enable background auto-updates\nchop enable / disable  # resume or bypass chop globally\nchop uninstall         # remove everything\nchop reset             # clear tracking data, keep installation\n```\n\n→ Full reference: [docs/maintenance.md](docs/maintenance.md)\n\n---\n\n## Development\n\n```bash\nmake test              # run tests\nmake coverage          # run tests and show coverage\nmake build             # build (linux, in container)\nmake install           # build for your platform + install to ~/bin/\nmake cross             # build all platforms (linux/darwin/windows × amd64/arm64)\nmake release-patch     # tag + push next patch version\nmake release-minor     # tag + push next minor version\n```\n\n## Contributors\n\nchop started as a Claude Code-focused tool and has grown through community contributions.\n\n- **[@giankpetrov](https://github.com/giankpetrov)** — Codex CLI integration, Antigravity IDE integration, systemctl filter, Windows native path support, security hardening, and AI agent discovery\n- **[@aeanez](https://github.com/aeanez)** — log compaction, unchopped report, custom filters, changelog command, enable/disable toggle, auto-update toggle, and Gemini CLI integration\n\n## License\n\nMIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagusrdz%2Fchop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagusrdz%2Fchop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagusrdz%2Fchop/lists"}