Skip to content

Latest commit

 

History

History
638 lines (493 loc) · 15.9 KB

File metadata and controls

638 lines (493 loc) · 15.9 KB


⚡ ContextZip

Output của Claude đầy rác không cần thiết.
ContextZip nén 60-90%. npx contextzip → 5 giây (lần chạy đầu tải binary).

Release CI Tests Benchmarks License

Cài đặtBefore/AfterBenchmarkEnglish한국어日本語中文EspañolPortuguêsहिन्दीFrançaisDeutschРусскийTürkçe • Tiếng Việt


  30 dòng stacktrace node_modules           →    3 dòng
  150 dòng cảnh báo npm deprecated          →    3 dòng
  50 dòng hash Docker build                 →    1 dòng
  Màu ANSI, spinner, thanh tiến trình       →    xóa sạch

⬇️ Một dòng. Chỉ vậy thôi.

npx contextzip

Khởi động lại Claude Code. Mọi lệnh tự động được nén. Không cần cấu hình.
macOS · Linux · Windows

Các cách cài đặt khác
# macOS / Linux
curl -fsSL https://raw.githubusercontent.com/jee599/contextzip/main/install.sh | bash
brew install jee599/tap/contextzip

# Windows (PowerShell)
npx contextzip

# Lập trình viên Rust
cargo install --git https://github.com/jee599/contextzip

👀 Xem Sự Khác Biệt

💥 Lỗi Node.js — 30 dòng → 3 dòng (tiết kiệm 92%)

❌ 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)
    at next (node_modules/express/
      lib/router/route.js:144)
    at Route.dispatch (node_modules/
      express/lib/router/route.js:114)
    ... 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 dòng → 3 dòng (tiết kiệm 58-95%, tùy số lượng cảnh báo)

❌ Before

npm warn deprecated inflight@1.0.6
npm warn deprecated rimraf@3.0.2
npm warn deprecated glob@7.2.3
npm warn deprecated bcrypt@3.0.0:
  security vulnerability CVE-2023-31484
... 45 more deprecated warnings
added 847 packages, audited 848
143 packages looking for funding
  run `npm fund` for details
8 vulnerabilities (2 moderate, 6 high)
  To address issues: npm audit fix
  ... 20 more lines

✅ After

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




Bảo mật giữ nguyên. Rác đã dọn.

💾 saved 95%

🐳 Docker Build — 50 dòng → 1 dòng (tiết kiệm 96%)

❌ Before

Step 1/12 : FROM node:20-alpine
 ---> abc123def456
Step 2/12 : WORKDIR /app
 ---> Using cache
 ---> 789ghi012jkl
Step 3/12 : COPY package*.json ./
 ---> Using cache
... 8 more steps with hashes
Removing intermediate container xyz
Successfully built abc123final
Successfully tagged my-app:latest

✅ After

✓ built my-app:latest (12 steps, 8 cached)






Bảo mật giữ nguyên. Rác đã dọn.

💾 saved 96%

🐍 Python Traceback — ẩn frame framework (tiết kiệm 72%)

❌ Before

Traceback (most recent call last):
  File "/app/main.py", line 10,
    in handler
    process(data)
  File "/usr/lib/python3.11/
    importlib/__init__.py", line 126
  File "/app/venv/lib/site-packages/
    flask/app.py", line 1498
  File "/app/venv/lib/site-packages/
    flask/app.py", line 1476
ValueError: invalid literal for int()

✅ After

Traceback (most recent call last):
  → /app/main.py:10  process(data)
  (+ 3 framework frames hidden)
ValueError: invalid literal for int()




💾 saved 72%

🦀 Rust Panic — xóa std/tokio (tiết kiệm 2-7% qua bộ lọc err)

❌ Before

thread 'main' panicked at
  'index out of bounds',
  src/handler.rs:42:5
stack backtrace:
   0: std::panicking::begin_panic
   1: core::panicking::panic_fmt
   2: myapp::handler::process
        at ./src/handler.rs:42:5
   3: myapp::main
        at ./src/main.rs:15:3
   4: std::rt::lang_start
   5: tokio::runtime::enter

✅ After

thread 'main' panicked at
  'index out of bounds',
  src/handler.rs:42:5
  (+ 2 framework frames hidden)
  → handler.rs:42  process()
  → main.rs:15     main()
  (+ 2 framework frames hidden)


💾 saved 2-7% (bộ lọc err; định dạng Rust panic chưa được tối ưu)

🔨 TypeScript Build — gom nhóm 40 lỗi (tiết kiệm 81%)

❌ Before

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

✅ After

TS2322: Type 'string' not assignable
        to type 'number' (×40)
  src/api/users.ts    :47, :83
  src/api/orders.ts   :12, :45, :67
  src/api/products.ts :23, :89
  src/lib/helpers.ts  :156
  ... +4 files (28 occurrences)

All line numbers preserved.
💾 saved 81%

🌐 Trang web — xóa nav/footer/quảng cáo (tiết kiệm 73%)

❌ Before (output curl)

[Skip to content]
[Nav: Products, Pricing, Docs, Blog]
[Sidebar: Getting Started, Auth,
  Database, Storage, Functions]
# Email/Password Authentication
Use supabase.auth.signInWithPassword
  to sign in users...
[code example]
[code example]
[Footer: © 2026 Supabase Inc]
[Terms | Privacy | Status]
[Newsletter: Subscribe for updates]
[Social: Twitter GitHub Discord]

✅ After

# Email/Password Authentication
Use supabase.auth.signInWithPassword
  to sign in users...
[code example]
[code example]




Nav, footer, sidebar, newsletter,
liên kết mạng xã hội — tất cả đã xóa.
💾 saved 73%

🎨 ANSI / Spinner — xóa rác vô hình (tiết kiệm 83%)

❌ Before (raw terminal)

\033[32m✓ Success\033[0m
\033[31m✗ Error\033[0m
⠋ Installing dependencies...
⠙ Installing dependencies...
⠹ Installing dependencies...
⠸ Installing dependencies...
████░░░░░░ 40%
████████░░ 80%
██████████ 100%
═══════════════════════
Done.

✅ After

✓ Success
✗ Error
██████████ 100%
Done.




Chỉ giữ lại trạng thái cuối cùng.

💾 saved 83%
🐳 Docker thất bại — bối cảnh được giữ lại
✗ 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

Bước thất bại + 2 bước trước + thông báo lỗi + mã thoát. Luôn luôn.

☕ Java / 🐹 Go stacktrace

Java — xóa 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 — xóa 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)

📊 Con Số Không Nói Dối

102 bài test thực tế. Không cherry-picking.

Danh mục Bài test Tiết kiệm TB 🏆 Tốt nhất 💀 Tệ nhất
🐳 Docker build 10 88% 97% 77%
🎨 ANSI/spinner 15 83% 98% 0%
💥 Error trace 20 59% 97% -12%
🔨 Build error 15 56% 90% -10%
🌐 Trang web 15 43% 64% 5%
💻 Lệnh CLI 12 42% 99% -56%
📦 Cài đặt package 15 39% 99% 2%

Tổng có trọng số: tiết kiệm 61% → 326K chars in, 127K chars out

Note

Âm = output tăng lên. Xảy ra với input rất nhỏ. Chúng tôi đưa con số tệ nhất vào bảng vì giấu đi là không trung thực. Benchmark đầy đủ →


🏎️ Cách Hoạt Động

  ┌─────────────────────────────────────────────┐
  │  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%)       │
  └─────────────────────────────────────────────┘

🆚 Tại Sao Không Chỉ Dùng RTK?

Xây dựng trên RTK (28k⭐). Bao gồm toàn bộ 34 lệnh RTK. Thêm vào đó:

RTK ContextZip
Nén CLI (git, test, ls)
Stacktrace lỗi (Node/Python/Rust/Go/Java)
Trích xuất nội dung web
Xóa ANSI / spinner / trang trí 🟡
Gom nhóm lỗi build (tsc/eslint/cargo) 🟡
Rác cài đặt package (npm/pip/cargo)
Nén Docker build 🟡
Hiển thị tiết kiệm theo lệnh

📈 Theo Dõi Mọi Thứ

$ 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 biểu đồ hàng ngày  •  --history lệnh gần đây


🛡️ Không Mất Gì Quan Trọng

🔴 Thông báo lỗi LUÔN được giữ
📍 File:dòng trong lỗi build KHÔNG BAO GIỜ bị xóa
🔒 Cảnh báo bảo mật (CVE, GHSA) LUÔN được giữ
🐳 Bối cảnh Docker thất bại LUÔN được giữ
⏎ Mã thoát LUÔN được truyền

Important

ContextZip chỉ xóa rác đã xác nhận. Khi nghi ngờ → passthrough.


🔧 Lệnh

# Tự động (hook chuyển đổi — không cần tiền tố):
git status              npm install             cargo test
docker build .          pip install flask        go test ./...

# Thủ công:
contextzip web https://docs.example.com    # trang → chỉ nội dung
contextzip err node server.js              # output tập trung vào lỗi

# Phân tích:
contextzip gain                  # bảng điều khiển
contextzip gain --by-feature     # thống kê theo bộ lọc
contextzip gain --graph          # biểu đồ hàng ngày
contextzip gain --history        # lệnh gần đây

# Quản lý:
contextzip init --show           # kiểm tra cài đặt
contextzip update                # tự cập nhật
contextzip uninstall             # gỡ cài đặt sạch

🤝 Đóng Góp

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

📡 Telemetry

ContextZip thu thập thống kê sử dụng ẩn danh (số lệnh, phần trăm tiết kiệm) để cải thiện công cụ. Không truyền dữ liệu cá nhân hay nội dung lệnh.

Tắt:

export CONTEXTZIP_TELEMETRY_DISABLED=1
# hoặc trong ~/.config/contextzip/config.toml:
# [telemetry]
# enabled = false

📜 Giấy phép

MIT — Fork của RTK bởi rtk-ai.


⚡ Ít rác hơn. Nhiều code hơn. Deploy nhanh hơn.

Star

Star History Chart