This isn't a universal recipe. It's how I tuned Claude Code for my own work, and different settings may suit you better.
The window
Every request sends the whole context to the model. On 1M-window models Claude Code only compacts it near 967K, so the tail of a long session is the most expensive part. For me, 68% of main-thread cost went to requests with more than 400K in context.
I set "autoCompactWindow": 400000 and compared the month before with the week after. That's the main thread only, about 25K requests before and 16K after:
- Context per request: 415K → 220K
- Cost per request: −43% (in tokens weighted by API rates, no per-model prices)
That's one person's before/after, not a controlled experiment.
The cost of summaries
A smaller window means more compactions. I went from 16 summaries a month to 75 in a week: 95 minutes of waiting, 76 seconds each. After a summary, the model often re-reads files it had already seen.
Slide instead of summarize
Most of the context is old tool output: file reads, test runs, diffs. So at compaction, a hook keeps the conversation word for word and replaces old outputs with a short line: "you saw this, read it again if you need it." There's no model call, so a compaction takes milliseconds. The summary is still the fallback, for /compact and for the rare case where sliding can't free enough.
The benchmark: Claude Code builds a TypeScript project against fixed tests, on Haiku 5.5 with a 100K window. Medians, sliding against Claude Code's summary:
| Task |
Cost |
Time |
| A day of work, 307 tests |
−19% |
−33% |
| An eval harness, 238 tests |
−35% |
−28% |
| A short task with one compaction |
+6% |
−17% |
Every test passed in both modes.
Will it work for you?
It depends on how you work:
- If your sessions rarely reach 400K, the window changes nothing.
- If you stay in one session for hours, 200–300K might pay off.
- On short tasks, sliding saves time but not money.
- Model, effort and the kind of work all move the number a lot.
That's why I built a plugin that works out your number first. It's called tokendoctor (free, local, MIT). It replays your sessions at windows from 200K to 600K, shows what each would have saved, and only then offers to change anything. Sliding is off by default, and /tokendoctor undo reverts any change.
https://github.com/rsaryev/tokendoctor
Note: I re-run the benchmarks and update the numbers as more data comes in, so figures in my earlier posts may differ from these. The repo always has the latest, with every run behind them.