|
5 | 5 | [](LICENSE) |
6 | 6 | [](https://ancc.dev) |
7 | 7 |
|
8 | | -Reasoning hygiene layer for Claude Code. Not a cleanup utility - a tool you open at every decision boundary, not just when context is full. See what fills your context, what it costs, cut what no longer matters, and carry forward what does. |
| 8 | +Reasoning hygiene layer for Claude Code. Sits between your agent and the API as an inline proxy, stripping noise before it's billed. Also diagnoses, cleans, and repairs session files post-hoc. |
9 | 9 |
|
10 | | -## Before and after |
| 10 | +## Proxy mode — strip noise before billing |
| 11 | + |
| 12 | +```bash |
| 13 | +contextspectre proxy --port 9120 |
| 14 | +# then: ANTHROPIC_BASE_URL=http://localhost:9120 claude |
| 15 | +``` |
| 16 | + |
| 17 | +Real session, OPS 90.6% — 34KB of noise stripped per request: |
| 18 | + |
| 19 | +``` |
| 20 | +ops:90.6% saved:34265 (think:5 stale:22 pruned:11) |
| 21 | +ops:90.5% saved:34738 (think:6 stale:22 pruned:11) |
| 22 | +ops:90.6% saved:34683 (think:6 stale:22 pruned:11) |
| 23 | +``` |
| 24 | + |
| 25 | +Six filters run on every API request: thinking blocks, stale file reads, orphaned tool_results, failed retries, duplicate system reminders, oversized blocks. Empty messages are pruned after filtering. Nothing reaches the API that doesn't need to. |
| 26 | + |
| 27 | +Chain with [pastewatch](https://github.com/ppiankov/pastewatch) for secret + noise protection: |
| 28 | + |
| 29 | +```bash |
| 30 | +pastewatch-cli proxy # :8443 |
| 31 | +contextspectre proxy --port 9120 --upstream http://localhost:8443 # :9120 |
| 32 | +ANTHROPIC_BASE_URL=http://localhost:9120 claude |
| 33 | +``` |
| 34 | + |
| 35 | +Or one command: `contextspectre launch --cwd --proxy` (auto-detects pastewatch). |
| 36 | + |
| 37 | +## Before and after (post-hoc cleanup) |
11 | 38 |
|
12 | 39 | A real $1,072 session — 7,701 messages, 46.8 MB, Signal F with 159K cleanable tokens. One `clean --all` later: Signal A, 3K cleanable, 1.5M tokens stripped. Same decisions, no scaffolding. |
13 | 40 |
|
|
0 commit comments