when-to-clear: Claude Code token usage report and /clear reminder
Find out how much of your Claude Code usage goes to re-reading long conversations, and get told when it's time to /clear.
中文说明 · MIT · Python 3.9+, no dependencies · reads local files only · by Balance Zhao

This is a local report, a Claude Code Stop hook, and a handoff skill for people whose Claude Code usage gets eaten by long conversations. It reads the token counts already saved in your sessions, shows how much of the work happened after the context got large, reminds you when it's time to /clear, and can write a handoff note so a new session can pick up where you left off. Nothing is sent anywhere.
Install in Claude Code:
/plugin marketplace add Balance0014/claude-code-when-to-clear
/plugin install when-to-clear@when-to-clear
That adds the /clear reminder and the handoff skill. The usage report runs from a clone: python3 when_to_clear.py.
Every reply re-sends the whole conversation. Caching cuts the price of that to a tenth, but at 400k tokens even "ok, go on" re-reads 400k tokens before the model writes a word.
I ran the report on my own sessions on October 28, 2026. Over the last 7 days (93 transcripts, including subagents, and 9,981 replies):
- 81% of the work happened while a conversation was over 200k tokens. ("Work" means tokens weighted by API price; details below.)
- Starting fresh at 200k with a short handoff note would have saved about a quarter (27%), after paying for the note and for the files the agent reads again.
- A long conversation missed the cache and was re-sent in full 90 times, every one of them after a break of five minutes or more.
- A new session already holds about 71k tokens by its first reply: system prompt, tools, MCP servers, CLAUDE.md, memory, and your first message.
Over 30 days, 90% of the work was past 200k, and restarting there would have saved 37%.
Three parts
1. The report. Clone the repo (or download when_to_clear.py) and run:
python3 when_to_clear.py
when-to-clear · last 7 days · 93 transcripts · 9,981 replies
Tokens re-read as context: 2.9B
81% of the work happened while a conversation was over 200k tokens.
Starting fresh at 200k with a short handoff note would have saved about 27% (119 restarts).
Long conversations were re-sent from scratch 90 times, 90 of them after a break of 5+ minutes (9% of the work).
A new session holds about 71k tokens by its first reply (system prompt, tools, MCP servers, CLAUDE.md, memory, your first message).
Heaviest sessions:
...
Options: --days 30, --at 150k to try a different restart size, --dir for another transcripts folder, --json for raw numbers.
2. The reminder. A Stop hook. When a conversation passes 200k tokens, you get a short note:
when-to-clear: this conversation is at 348k tokens, and every reply re-reads all of it.
At your next stopping point, ask Claude to write a handoff note, then /clear and paste it.
With the default 200k, it reminds you again every 100k (300k, 400k and so on), once per level. It never blocks anything.
3. The handoff skill. Say "write a handoff." The agent writes HANDOFF.md: what's done (with proof), what's in progress, what's not started, the next step, what it's blocked on, the branch, and uncommitted changes, plus a few lines of context the code can't tell you. Then:
/clear
Read HANDOFF.md and continue from Next step.
Install
Claude Code, as a plugin (reminder and handoff skill):
/plugin marketplace add Balance0014/claude-code-when-to-clear
/plugin install when-to-clear@when-to-clear
Then start a new session. The report isn't part of the plugin; run it from a clone as shown above.
Without the plugin system: add the reminder to ~/.claude/settings.json, with --at set to the size you want:
{
"hooks": {
"Stop": [{ "hooks": [{ "type": "command", "command": "python3 /path/to/when_to_clear.py hook --at 200k" }] }]
}
}
Codex: npx skills add Balance0014/claude-code-when-to-clear -g -a codex -y puts the handoff skill in ~/.agents/skills, where Codex looks for skills. Then say "write a handoff" or type $handoff. The skill ends by telling you to /clear; in Codex, start a new chat instead.
Other agents: npx skills add Balance0014/claude-code-when-to-clear installs the handoff skill.
How the numbers work