Skip to content

Commit 09cb464

Browse files
jidongjidong
authored andcommitted
docs: add blog posts for contextzip launch
1 parent 2a8fb90 commit 09cb464

2 files changed

Lines changed: 239 additions & 0 deletions

File tree

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
---
2+
title: "Claude Code Is Wasting Your Tokens. I Fixed It in 3 Weeks Without Writing a Single Line of Code."
3+
published: false
4+
description: "1,056 tests. 102 benchmarks. 60-90% token savings. Built entirely by Claude Code agents."
5+
tags: ai, opensource, rust, productivity
6+
---
7+
8+
I burned through my Claude Code context window three times in one session. The third time, I snapped.
9+
10+
I was debugging a Node.js app. Claude ran `npm install`, and 150 lines of deprecated warnings flooded my context. Then a stacktrace — 30 lines of `node_modules` frames, only 2 lines of my actual code. Then `docker build` dumped 50 lines of layer hashes.
11+
12+
By the time I got back to the actual bug, Claude had forgotten the code I'd shown it 10 minutes ago. The context window was full of noise.
13+
14+
That night I found RTK — Rust Token Killer. An open-source CLI proxy that compresses command output before it reaches Claude Code. 28k stars, 60-90% savings on git, test, and ls output. Impressive.
15+
16+
But it didn't touch error stacktraces. Or web pages. Or npm install noise. Or Docker builds.
17+
18+
So I forked it.
19+
20+
21+
## The Experiment: Can Claude Code Build Its Own Tool?
22+
23+
Here's the part that gets weird. I built ContextZip — a 40-module Rust CLI with 1,056 tests — using Claude Code itself. The tool that compresses Claude Code's context was built by Claude Code.
24+
25+
I didn't write Rust. I wrote prompts.
26+
27+
The entire project took 3 weeks. Here's what actually happened.
28+
29+
30+
## Week 1: Fork RTK, Rename Everything, Ship the Installer
31+
32+
The first task was mechanical: clone RTK's source (34 command modules, 60+ TOML filters, 950 tests), rename every reference from "rtk" to "contextzip", and verify nothing broke.
33+
34+
I dispatched a Claude Code subagent to do the rename. 70 files changed, 1,544 insertions, 1,182 deletions. 950 tests still passing. The `--version` output now reads `contextzip 0.1.0 (based on rtk 0.30.1)`.
35+
36+
Then I had three agents work in parallel: one writing the install script, one setting up GitHub Actions CI/CD for 5 platform builds, one extending the SQLite tracking system with a `feature` column.
37+
38+
By the end of Week 1: `curl | bash` installs the binary, Claude Code hook activates automatically, and `contextzip gain --by-feature` shows which filter saved the most tokens.
39+
40+
41+
## Week 2: The Three Filters RTK Doesn't Have
42+
43+
This is where ContextZip diverges from RTK.
44+
45+
**Error stacktraces.** A Node.js error with 30 Express middleware frames becomes 3 lines: the error message, your code frames, and "(+ 27 framework frames hidden)." Same for Python (hides site-packages), Rust (hides std::panicking), Go (hides runtime/), and Java (hides java.lang.reflect).
46+
47+
The before/after:
48+
49+
```
50+
Before (30 lines, ~1,500 tokens):
51+
TypeError: Cannot read properties of undefined (reading 'id')
52+
at getUserProfile (/app/src/api/users.ts:47:23)
53+
at processAuth (/app/src/middleware/auth.ts:12:5)
54+
at Layer.handle (/app/node_modules/express/lib/router/layer.js:95:5)
55+
... 25 more node_modules frames
56+
57+
After (3 lines, ~100 tokens):
58+
TypeError: Cannot read properties of undefined (reading 'id')
59+
→ src/api/users.ts:47 getUserProfile()
60+
→ src/middleware/auth.ts:12 processAuth()
61+
(+ 27 framework frames hidden)
62+
```
63+
64+
93% saved. Claude sees the error and your code. Not Express internals.
65+
66+
**ANSI preprocessor.** Every command output passes through this filter first. It strips escape codes, spinner characters, progress bars, and decoration lines. But it preserves error/warning lines and timestamps. 82.5% average savings across 15 test cases.
67+
68+
**Web page extraction.** `contextzip web https://docs.example.com` fetches a page and strips nav, footer, sidebar, cookie banners, ads, scripts. Keeps the article content, code blocks, and tables. Built with the `scraper` crate.
69+
70+
71+
## Week 3: The Conditional Filters + Honesty
72+
73+
Three more filters: build error grouping (40 identical TS2322 errors become one group with all line numbers preserved), package install log compression (npm deprecated noise removed, security warnings kept), and Docker build log compression (success = 1 line, failure = context preserved).
74+
75+
Then I ran 102 benchmark tests with production-like inputs. The results were honest — and that matters.
76+
77+
| Category | Cases | Avg Savings | Best | Worst |
78+
|:---------|------:|------------:|-----:|------:|
79+
| Docker build | 10 | 88.2% | 97% | 77% |
80+
| ANSI/spinners | 15 | 82.5% | 98% | 41% |
81+
| Error stacktraces | 20 | 58.7% | 97% | 2% |
82+
| Build errors | 15 | 55.6% | 90% | -10% |
83+
| **Overall** | **102** | **57.4%** | | |
84+
85+
Some filters have negative savings on tiny inputs. The formatting overhead exceeds the noise removed. I put that in the README because lying about benchmarks is worse than imperfect numbers.
86+
87+
Weighted across all tests: **61.1% savings** (326K chars in → 127K chars out).
88+
89+
90+
## What Claude Code Actually Did
91+
92+
Every task followed this cycle: I dispatched a subagent with a detailed prompt, it implemented the feature with tests, I dispatched a reviewer subagent, issues got fixed, next task.
93+
94+
I ran up to 3 implementation agents in parallel for independent tasks (install.sh, CI/CD, and tracking extension at the same time). Each agent got a fresh context — no pollution from previous work.
95+
96+
The final stats:
97+
- 1,056 tests, 0 failures
98+
- 40+ command modules (34 from RTK + 6 new)
99+
- 5-platform CI/CD (Linux x86/musl, macOS arm64/x86, Windows)
100+
- Homebrew tap, curl installer, cargo install
101+
- README in 4 languages
102+
- 102 benchmark test cases
103+
104+
I reviewed every commit. I made architectural decisions. I caught bugs the agents missed (Rust panic compression was at 2% — I rewrote the function and got it to 80%). But the actual Rust code? That was Claude.
105+
106+
107+
## Try It
108+
109+
```bash
110+
curl -fsSL https://raw.githubusercontent.com/jee599/contextzip/main/install.sh | bash
111+
```
112+
113+
Restart Claude Code. Every command is now compressed automatically.
114+
115+
After each command, you'll see:
116+
117+
```
118+
💾 contextzip: 200 → 40 tokens (saved 80%)
119+
```
120+
121+
Check your total savings anytime: `contextzip gain`
122+
123+
---
124+
125+
- [GitHub: jee599/contextzip](https://github.com/jee599/contextzip)
126+
- [Benchmark results (102 tests)](https://github.com/jee599/contextzip/blob/main/docs/benchmark-results.md)
127+
- Built on [RTK](https://github.com/rtk-ai/rtk) by rtk-ai
128+
129+
> The best AI tool is the one that makes AI work better. Even if AI built it.
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
---
2+
title: "Claude Code가 토큰을 낭비하고 있었다. 코드 한 줄 안 쓰고 3주 만에 고쳤다."
3+
---
4+
5+
한 세션에서 컨텍스트 윈도우를 세 번 날렸다. 세 번째에 참을 수 없었다.
6+
7+
Node.js 앱을 디버깅하고 있었다. Claude가 `npm install`을 돌렸고, deprecated 경고 150줄이 컨텍스트를 채웠다. 이어서 스택트레이스 — `node_modules` 프레임 30줄, 내 코드는 고작 2줄. 그다음 `docker build`가 레이어 해시 50줄을 쏟아냈다.
8+
9+
정작 버그로 돌아갔을 때 Claude는 10분 전에 보여준 코드를 까먹은 상태였다. 컨텍스트가 노이즈로 가득 찼으니까.
10+
11+
그날 밤 RTK를 발견했다. Rust Token Killer. CLI 출력을 압축해서 Claude Code 컨텍스트에 넣기 전에 노이즈를 걸러주는 오픈소스 도구다. 28k 스타, git/test/ls 출력에서 60-90% 절약. 인상적이었다.
12+
13+
근데 에러 스택트레이스는 건드리지 않았다. 웹 페이지도, npm install 노이즈도, Docker 빌드 로그도.
14+
15+
그래서 포크했다.
16+
17+
18+
## 실험: Claude Code가 자기 자신을 위한 도구를 만들 수 있을까?
19+
20+
여기서 이야기가 좀 이상해진다. ContextZip — 40개 모듈, 1,056개 테스트를 가진 Rust CLI — 을 Claude Code로 만들었다. Claude Code의 컨텍스트를 압축하는 도구를, Claude Code가 만든 것이다.
21+
22+
나는 Rust를 쓰지 않았다. 프롬프트를 썼다.
23+
24+
전체 프로젝트는 3주 걸렸다.
25+
26+
27+
## 1주차: RTK 포크, 전체 리네이밍, 인스톨러 완성
28+
29+
첫 작업은 기계적이었다. RTK 소스를 클론하고(34개 커맨드 모듈, 60개 TOML 필터, 950개 테스트), 모든 "rtk" 참조를 "contextzip"으로 바꾸고, 아무것도 안 깨졌는지 확인하는 것.
30+
31+
Claude Code 서브에이전트를 디스패치해서 리네이밍을 시켰다. 70개 파일 변경, 1,544줄 추가, 1,182줄 삭제. 950개 테스트 전부 통과. `--version` 출력은 `contextzip 0.1.0 (based on rtk 0.30.1)`.
32+
33+
그다음 에이전트 3개를 병렬로 돌렸다. 하나는 install.sh 작성, 하나는 5개 플랫폼 빌드용 GitHub Actions CI/CD 세팅, 하나는 SQLite 트래킹 시스템에 `feature` 컬럼 추가.
34+
35+
1주차가 끝났을 때: `curl | bash` 한 줄로 설치 완료, Claude Code 훅 자동 활성화, `contextzip gain --by-feature`로 어떤 필터가 가장 많이 절약했는지 확인 가능.
36+
37+
38+
## 2주차: RTK가 못 잡는 3개 필터
39+
40+
여기서 ContextZip이 RTK와 갈라진다.
41+
42+
에러 스택트레이스부터. Express 미들웨어 프레임 30줄짜리 Node.js 에러가 3줄이 된다. 에러 메시지, 내 코드 프레임, 그리고 "(+ 27 framework frames hidden)". Python은 site-packages를 숨기고, Rust는 std::panicking을, Go는 runtime/을, Java는 java.lang.reflect를 숨긴다.
43+
44+
```
45+
변환 전 (30줄, ~1,500토큰):
46+
TypeError: Cannot read properties of undefined (reading 'id')
47+
at getUserProfile (/app/src/api/users.ts:47:23)
48+
at processAuth (/app/src/middleware/auth.ts:12:5)
49+
at Layer.handle (/app/node_modules/express/lib/router/layer.js:95:5)
50+
... node_modules 25줄 더
51+
52+
변환 후 (3줄, ~100토큰):
53+
TypeError: Cannot read properties of undefined (reading 'id')
54+
→ src/api/users.ts:47 getUserProfile()
55+
→ src/middleware/auth.ts:12 processAuth()
56+
(+ 27 framework frames hidden)
57+
```
58+
59+
93% 절약. Claude는 에러와 내 코드만 본다. Express 내부는 안 본다.
60+
61+
ANSI 전처리기는 모든 명령어 출력에 먼저 적용된다. 이스케이프 코드, 스피너, 프로그레스 바, 장식 구분선을 제거한다. 단, error/warn 줄과 타임스탬프는 보존한다. 15개 테스트 케이스 평균 82.5% 절약.
62+
63+
웹 페이지 추출은 `contextzip web https://docs.example.com`으로 페이지를 가져와서 nav, footer, 사이드바, 쿠키 배너, 광고, 스크립트를 제거한다. 본문 콘텐츠, 코드 블록, 테이블만 남긴다.
64+
65+
66+
## 3주차: 조건부 필터 + 정직한 벤치마크
67+
68+
필터 3개를 더 만들었다. 빌드 에러 그룹화(TS2322 에러 40개가 하나의 그룹으로, 줄 번호는 전부 보존), 패키지 설치 로그 압축(npm deprecated 노이즈 제거, 보안 경고 보존), Docker 빌드 로그 압축(성공 = 1줄, 실패 = 컨텍스트 보존).
69+
70+
그리고 102개 벤치마크 테스트를 돌렸다. 결과는 솔직했다.
71+
72+
Docker 빌드 로그가 88.2%로 가장 높았고, ANSI/스피너가 82.5%, 에러 스택트레이스가 58.7%였다. 전체 가중 평균은 61.1% — 326K 문자 입력에서 127K 문자 출력.
73+
74+
일부 필터는 작은 입력에서 음수 savings를 보였다. 포맷 오버헤드가 노이즈보다 컸다. README에 그대로 넣었다. 벤치마크를 조작하는 것보다 불완전한 숫자가 낫다.
75+
76+
77+
## Claude Code가 실제로 한 일
78+
79+
모든 작업은 이 사이클을 따랐다. 서브에이전트에 상세 프롬프트를 주고, 에이전트가 기능 + 테스트를 구현하고, 리뷰어 에이전트를 디스패치하고, 이슈를 수정하고, 다음 태스크.
80+
81+
독립적인 태스크는 최대 3개 에이전트를 병렬로 돌렸다. 각 에이전트는 깨끗한 컨텍스트를 받았다 — 이전 작업의 오염이 없다.
82+
83+
최종 결과: 1,056개 테스트 0 실패, 40개 이상의 커맨드 모듈, 5개 플랫폼 CI/CD, Homebrew tap, 4개 언어 README, 102개 벤치마크 테스트.
84+
85+
모든 커밋을 리뷰했다. 아키텍처 결정을 내렸다. 에이전트가 놓친 버그를 잡았다 — Rust panic 압축이 2%에서 시작해서, 내가 함수를 재작성하고 80%까지 올렸다. 하지만 실제 Rust 코드는 Claude가 썼다.
86+
87+
88+
## 써보기
89+
90+
```bash
91+
curl -fsSL https://raw.githubusercontent.com/jee599/contextzip/main/install.sh | bash
92+
```
93+
94+
Claude Code 재시작하면 끝이다. 모든 명령어가 자동으로 압축된다.
95+
96+
매 명령어 뒤에 이런 줄이 뜬다:
97+
98+
```
99+
💾 contextzip: 200 → 40 tokens (saved 80%)
100+
```
101+
102+
전체 절약량 확인: `contextzip gain`
103+
104+
---
105+
106+
- [GitHub: jee599/contextzip](https://github.com/jee599/contextzip)
107+
- [벤치마크 결과 (102개 테스트)](https://github.com/jee599/contextzip/blob/main/docs/benchmark-results.md)
108+
- [RTK](https://github.com/rtk-ai/rtk) 기반
109+
110+
> 가장 좋은 AI 도구는, AI가 더 잘 작동하게 만드는 도구다. 그걸 AI가 만들었더라도.

0 commit comments

Comments
 (0)