Windows (PowerShell)
March 19, 2026 · View on GitHub
⚡ ContextZip
Claude 的输出充满了无用噪音。
ContextZip 压缩 60-90%。npx contextzip → 5 秒(首次运行下载二进制文件)。
安装 • Before/After • 基准测试 • English • 한국어 • 日本語 • 中文 • Español • Português • हिन्दी • Français • Deutsch • Русский • Türkçe • Tiếng Việt
30 行 node_modules 堆栈帧 → 3 行
150 行 npm deprecated 警告 → 3 行
50 行 Docker 构建哈希 → 1 行
ANSI 颜色、加载动画、进度条 → 删除
⬇️ 一行搞定。
npx contextzip
重启 Claude Code。所有命令自动压缩。零配置。
macOS · Linux · Windows
其他安装方式
# macOS / Linux
curl -fsSL https://raw.githubusercontent.com/jee599/contextzip/main/install.sh | bash
brew install jee599/tap/contextzip
# Windows (PowerShell)
npx contextzip
# Rust 开发者
cargo install --git https://github.com/jee599/contextzip
👀 看看区别
💥 Node.js 报错 — 30 行 → 3 行(节省 92%)
|
❌ Before
|
✅ After
|
📦 npm install — 150 行 → 3 行(节省 58-95%,因警告数量而异)
|
❌ Before
|
✅ After
|
🐳 Docker 构建 — 50 行 → 1 行(节省 96%)
|
❌ Before
|
✅ After
|
🐍 Python Traceback — 隐藏框架帧(节省 72%)
|
❌ Before
|
✅ After
|
🦀 Rust Panic — 移除 std/tokio(err 过滤器节省 2-7%)
|
❌ Before
|
✅ After
|
🔨 TypeScript 构建 — 40 个错误分组(节省 81%)
|
❌ Before
|
✅ After
|
🌐 网页 — 去除 nav/footer/广告(节省 73%)
|
❌ Before (curl 输出)
|
✅ After
|
🎨 ANSI / 加载动画 — 移除不可见噪音(节省 83%)
|
❌ Before (raw terminal)
|
✅ After
|
🐳 Docker 失败 — 保留上下文
✗ Docker build failed at step 7/12
Step 5/12 : COPY package*.json ./ (cached ✓)
Step 6/12 : RUN npm install (cached ✓)
Step 7/12 : RUN npm run build ← FAILED
error: Module not found: 'react-dom/client'
Exit code: 1
失败步骤 + 前 2 步 + 错误信息 + 退出码。始终保留。
☕ Java / 🐹 Go 堆栈
Java — 移除 java.lang.reflect、sun.reflect、org.springframework、org.apache、jdk.internal:
- java.lang.NullPointerException: Cannot invoke method on null
- at com.myapp.UserService.getUser(UserService.java:42)
- at com.myapp.Controller.handle(Controller.java:15)
- at java.lang.reflect.Method.invoke(Method.java:498)
- at sun.reflect.DelegatingMethodAccessorImpl.invoke(...)
- at org.springframework.web.servlet.FrameworkServlet.service(...)
- at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(...)
+ java.lang.NullPointerException: Cannot invoke method on null
+ at com.myapp.UserService.getUser(UserService.java:42)
+ at com.myapp.Controller.handle(Controller.java:15)
+ (+ 4 framework frames hidden)
Go — 移除 runtime/、runtime.gopanic、runtime.main:
- goroutine 1 [running]:
- runtime/debug.Stack()
- /usr/local/go/src/runtime/debug/stack.go:24
- runtime.gopanic({0x1234, 0x5678})
- /usr/local/go/src/runtime/panic.go:884
- main.handler()
- /app/handler.go:42 +0x1a4
- main.main()
- /app/main.go:15 +0x58
+ goroutine 1 [running]:
+ (+ 2 framework frames hidden)
+ → main.handler() /app/handler.go:42
+ → main.main() /app/main.go:15
+ (+ 1 framework frames hidden)
📊 数字说明一切
102 个实战测试。没有挑选。
| 类别 | 测试 | 平均节省 | 🏆 最高 | 💀 最低 |
|---|---|---|---|---|
| 🐳 Docker 构建 | 10 | 88% | 97% | 77% |
| 🎨 ANSI/加载动画 | 15 | 83% | 98% | 0% |
| 💥 错误堆栈 | 20 | 59% | 97% | -12% |
| 🔨 构建错误 | 15 | 56% | 90% | -10% |
| 🌐 网页 | 15 | 43% | 64% | 5% |
| 💻 CLI 命令 | 12 | 42% | 99% | -56% |
| 📦 包安装 | 15 | 39% | 99% | 2% |
加权平均: 61% 节省 → 326K chars in, 127K chars out
Note
负数 = 输出增大。极小输入时发生。最低值也如实公开,因为隐瞒是不诚实的。完整基准测试 →
🏎️ 工作原理
┌─────────────────────────────────────────────┐
│ 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%) │
└─────────────────────────────────────────────┘
🆚 为什么不只用 RTK?
基于 RTK(28k⭐)。包含 RTK 全部 34 个命令。额外功能:
| RTK | ContextZip | |
|---|---|---|
| CLI 压缩 (git, test, ls) | ✅ | ✅ |
| 错误堆栈 (Node/Python/Rust/Go/Java) | ❌ | ✅ |
| 网页内容提取 | ❌ | ✅ |
| ANSI / 加载动画 / 装饰移除 | 🟡 | ✅ |
| 构建错误分组 (tsc/eslint/cargo) | 🟡 | ✅ |
| 包安装噪音 (npm/pip/cargo) | ❌ | ✅ |
| Docker 构建压缩 | 🟡 | ✅ |
| 逐命令节省量显示 | ❌ | ✅ |
📈 追踪一切
$ contextzip gain
📊 ContextZip Token Savings
════════════════════════════════════════
Total commands: 2,927
Tokens saved: 10.3M (89.2%)
Efficiency meter: █████████████████████░░░ 89%
$ 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%
pkg 34 0.3M 95%
docker 22 0.2M 85%
--graph 每日图表 • --history 最近命令
🛡️ 重要信息绝不丢失
| 🔴 错误信息 | 始终保留 |
| 📍 构建错误的文件:行号 | 绝不移除 |
| 🔒 安全警告 (CVE, GHSA) | 始终保留 |
| 🐳 Docker 失败上下文 | 始终保留 |
| ⏎ 退出码 | 始终传播 |
Important
ContextZip 只移除已确认的噪音。不确定时,原始输出原样通过。
🔧 命令
# 自动(hook 转换 — 无需前缀):
git status npm install cargo test
docker build . pip install flask go test ./...
# 手动:
contextzip web https://docs.example.com # 页面 → 仅内容
contextzip err node server.js # 错误聚焦输出
# 分析:
contextzip gain # 仪表盘
contextzip gain --by-feature # 按过滤器统计
contextzip gain --graph # 每日图表
contextzip gain --history # 最近命令
# 管理:
contextzip init --show # 检查安装状态
contextzip update # 自更新
contextzip uninstall # 干净卸载
🤝 贡献
git clone https://github.com/jee599/contextzip.git && cd contextzip
cargo test # 1,056 tests
cargo clippy # lint
📡 遥测
ContextZip 收集匿名使用统计(命令数、节省率)以改进工具。不传输个人信息或命令内容。
禁用:
export CONTEXTZIP_TELEMETRY_DISABLED=1
# 或在 ~/.config/contextzip/config.toml:
# [telemetry]
# enabled = false
📜 许可证
MIT — RTK by rtk-ai 的 fork。
⚡ 减少噪音,专注代码,更快交付。