Skip to content

jee599/contextzip

Repository files navigation


⚡ ContextZip

CLI output eats your AI context window. ContextZip compresses it 40-97% (61% avg across 102 tests).
npx contextzip

Release CI Tests Benchmarks License

🌐 Languages

한국어日本語中文EspañolPortuguêsहिन्दीFrançaisDeutschРусскийTürkçeTiếng Việt


ContextZip demo — before vs after


⬇️ Install

npx contextzip

Restart Claude Code. Every command is now compressed. Zero config. macOS · Linux · Windows

Tip

Need raw output? Use contextzip proxy <command> to bypass all filters. Missing jq? Install it: brew install jq (macOS) or apt install jq (Linux). Required for the Claude Code hook.

Other install methods
# macOS / Linux
curl -fsSL https://raw.githubusercontent.com/jee599/contextzip/main/install.sh | bash
brew install jee599/tap/contextzip

# Windows (PowerShell)
npx contextzip

# Rust developers
cargo install --git https://github.com/jee599/contextzip

👀 See the Difference

💥 Node.js Error — 30 lines → 3 lines (92% saved)

❌ Before

TypeError: Cannot read properties
  of undefined (reading 'id')
    at getUserProfile (users.ts:47)
    at processAuth (auth.ts:12)
    at Layer.handle (node_modules/
      express/lib/router/layer.js:95)
    ... 25 more node_modules lines

✅ After

TypeError: Cannot read properties
  of undefined (reading 'id')
  → users.ts:47    getUserProfile()
  → auth.ts:12     processAuth()
  (+ 27 framework frames hidden)
💾 saved 92%

📦 npm install — 150 lines → 3 lines (95% saved)

❌ Before

npm warn deprecated inflight@1.0.6
npm warn deprecated rimraf@3.0.2
... 45 more deprecated warnings
added 847 packages, audited 848
8 vulnerabilities (2 moderate, 6 high)
  ... 20 more lines

✅ After

✓ 847 packages (32s)
⚠ 8 vulnerabilities (6 high, 2 mod)
⚠ bcrypt@3.0.0: CVE-2023-31484
💾 saved 95%

🐳 Docker Build — 50 lines → 1 line (96% saved)

❌ Before

Step 1/12 : FROM node:20-alpine
 ---> abc123def456
Step 2/12 : WORKDIR /app
 ---> Using cache
... 8 more steps with hashes
Successfully tagged my-app:latest

✅ After

✓ built my-app:latest (12 steps, 8 cached)
💾 saved 96%

Note

Currently supports legacy Docker builder output (Step N/M format). Docker BuildKit format passes through uncompressed.

🔨 TypeScript Build — 40 errors grouped (81% saved)

❌ Before

src/api/users.ts:47:5 - error TS2322:
  Type 'string' not assignable to 'number'
... 36 more identical errors
Found 40 errors in 8 files.

✅ After

TS2322: 'string' → 'number' (×40)
  users.ts :47, :83
  orders.ts :12, :45
  ... +6 files
💾 saved 81%
More examples: Rust panic, Python, Web page, ANSI, Docker failure, Java/Go

🐍 Python Traceback (72% saved) — Framework frames (flask, importlib) hidden, your code + error message kept.

🦀 Rust Panic (2-7% saved)std::panicking, tokio::runtime frames hidden, your crate frames kept.

🌐 Web Page (73% saved) — Nav, footer, sidebar, cookie banner, social links stripped. <main>/<article> content kept.

🎨 ANSI/Spinners (83% saved) — Escape codes, spinner frames, intermediate progress bars removed. Final states kept.

🐳 Docker failure — Failed step + 2 prior steps + error message + exit code always preserved.

☕ Java — Removes java.lang.reflect, sun.reflect, org.springframework, org.apache frames.

🐹 Go — Removes runtime/, runtime.gopanic, runtime.main frames.


📊 The Numbers Don't Lie

102 real-world tests. No cherry-picking.

Category Tests Avg Savings 🏆 Best 💀 Worst
🐳 Docker build 10 88% 97% 77%
🎨 ANSI/spinners 15 83% 98% 0%
💥 Error traces 20 59% 97% -12%
🔨 Build errors 15 56% 90% -10%
🌐 Web pages 15 43% 64% 5%
💻 CLI commands 12 42% 99% -56%
📦 Package install 15 39% 99% 2%

Weighted total: 61% savings → 326K chars in, 127K chars out

Note

Negative = output grew. Happens on tiny inputs. We put the worst numbers in the table because hiding them would be dishonest. Full benchmark →

Star


🆚 Why Not Just RTK?

Built on RTK (28k⭐). All 34 RTK commands included. Plus:

RTK ContextZip
CLI compression (git, test, ls)
Error stacktraces (Node/Python/Rust/Go/Java)
Web page content extraction
ANSI / spinner / decoration removal 🟡
Build error grouping (tsc/eslint/cargo) 🟡
Package install noise (npm/pip/cargo)
Docker build compression 🟡
Per-command savings display

🛡️ Nothing Important Gets Lost

🔴 Error messages ALWAYS preserved
📍 File:line in build errors NEVER removed
🔒 Security warnings (CVE, GHSA) ALWAYS kept
🐳 Docker failure context ALWAYS preserved
⏎ Exit codes ALWAYS propagated

Important

ContextZip only removes confirmed noise. When in doubt → passthrough.

🏎️ How It Works
  ┌─────────────────────────────────────────────┐
  │  Claude Code runs: git status               │
  │                         ↓                   │
  │  Hook rewrites → contextzip git status      │
  │                         ↓                   │
  │  ┌──────────────────────────────────────┐   │
  │  │ [1] ANSI preprocessor    strip junk  │   │
  │  │ [2] Command router    40+ filters    │   │
  │  │ [3] Error post-proc   compress stack │   │
  │  │ [4] SQLite tracker    record savings │   │
  │  └──────────────────────────────────────┘   │
  │                         ↓                   │
  │  Compressed output → Claude's context       │
  │  💾 contextzip: 200 → 40 tokens (80%)       │
  └─────────────────────────────────────────────┘
🔧 Commands
# Automatic (hook rewrites — no prefix needed):
git status    npm install    cargo test    docker build .

# Manual:
contextzip web https://docs.example.com    # page → content only
contextzip err node server.js              # error-focused output

# Analytics:
contextzip gain                  # dashboard
contextzip gain --by-feature     # per-filter stats
contextzip gain --graph          # daily chart

# Manage:
contextzip init --show    contextzip update    contextzip uninstall
📈 Track Everything
$ contextzip gain
📊 ContextZip Token Savings
════════════════════════════════════════
Total commands:    2,927
Tokens saved:      10.3M (89.2%)

$ contextzip gain --by-feature
Feature        Commands  Saved     Avg%
cli (RTK)      2,100     6.8M     78%
error          89        1.2M     93%
web            43        0.9M     73%
build          112       0.4M     81%

🤝 Contribute

git clone https://github.com/jee599/contextzip.git && cd contextzip
cargo test         # 1,056 tests
cargo clippy       # lint

📡 Telemetry

ContextZip collects anonymous usage statistics (command count, savings percentage) to improve the tool. No personal data or command content is transmitted.

Disable: export CONTEXTZIP_TELEMETRY_DISABLED=1

📜 License

MIT — Fork of RTK by rtk-ai.


⚡ Less noise. More code. Ship faster.

Star History Chart

About

⚡ Compress Claude Code context by 60-90%. Six noise filters RTK doesn't have.

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages