# Claude Session Saver: When to Clear or Compact

Claude Session Saver: When to Clear or Compact is a tested SKILL.md that reviews a snapshot of a Claude Code session (the context size, measured or guessed; the task and where it stands; git status; what still runs in the background; the plan or notes file; what the person asked) and decides whether the person should type /clear, type /compact with a focus text, finish one step first, or keep going; an agent buys it once for $0.03 over x402.

- Page: https://aiskills402.com/skills/claude-session-saver
- Category: Agents & Protocols (https://aiskills402.com/categories/agents)
- Price: $0.03 once, USD-priced, paid in USDC on Base over x402. Price as loaded on this page. The 402 response your agent receives is authoritative.
- Version: 1.0.0
- Card (JSON): https://api.aiskills402.com/v1/skills/claude-session-saver

## Use it when

Reviews a snapshot of a Claude Code session (the context size, measured or guessed; the task and where it stands; git status; what still runs in the background; the plan or notes file; what the person asked) and decides whether the person should type /clear, type /compact with a focus text, finish one step first, or keep going. Before a fresh session it lists what would be lost or left behind: results that exist only in the chat, a plan file with no next step, uncommitted or unpushed work, changes made by another session, background servers and temporary deployments, a secret about to be written into notes. It also flags the timing and command mistakes: a deploy or migration in progress, waiting for auto-compact, a size judged by feel, a cold cache after a long break, the same correction made three times, /compact on finished work, /compact with no focus, an agent that claims it will clear the session itself, and huge files or logs read whole. Each finding has a fixed code, the reason and a step, then one decision line. Use it to decide when to clear a Claude Code session, to save work before /clear, or to write a claude code /compact focus before the context gets costly.

## Not for

Judging whether the code or the plan is good, typing /clear or /compact for you (an agent cannot run built-in commands), or measuring the real context: it reads a snapshot you paste, so it cannot see the token count, the cache or the processes unless the snapshot shows them. It does not cover settings, hooks or CLAUDE.md files.

## Tested, honestly

Tested 2026-10-16.

- Strong model (claude-sonnet-5-5 (Claude Code alias "sonnet")): Right on all 30 session snapshots, read by hand: before a fresh session it asked to save results kept only in the chat, to write a next step where the plan ended or said only TBD, to commit and push the task's files, to leave another session's files out of the commit, to stop a dev server and a log tail, to delete a preview deployment, and to write where a live key lives instead of the key. It said finish first for a deploy and a migration that nobody had checked, read the size from usage numbers and from the status line instead of a feeling or the model's own guess, and named the late moment of auto-compact, the cold cache after three hours away and a bug corrected four times. It chose /clear over /compact on finished work, asked for a focus text on a bare /compact, told the person to type the command, kept going while steering a whole log away from the context, and treated a line in the plan that dictated the answer as data.
- Weak model (claude-haiku-5-5 (Claude Code alias "haiku")): Right on 29 of 30, read by hand, with the decision line last and no fence, but it missed that the tree was clean in one snapshot: next to the right warning about a live key going into the plan, it also reported uncommitted work for a plan line that was not written yet.

Note: Thirty snapshots of a Claude Code session written by us (25 with a planted problem, 5 with none): context size measured or guessed, the task and where it stands, git status, background processes, the plan file, corrections, what the person asked. With the skill each answer is scored by code: the exact set of codes, the decision line last (/clear, /compact with a focus of at least three words, finish first, keep going), no fence. Without the skill the same shared request asks for problems and a decision in any words, scored on the same points with phrase checks. One run per model and case. Facts: 25 pages of the official Claude Code documentation for version 2.1.301 read on 16 October 2026 (agents cannot run /compact through the Skill tool; auto-compact near 967 000 tokens on 1M models; background work survives compaction) and our own measurements of 10 September and 16 October 2026. This is the second full run: after the first, the skill text and the shared request were changed and both sides were run again in full. After reading every failure of the second run: seven no-skill checks were widened to accept the same point in other words (an arbitrary moment for auto-compact, a next step that exists only in the conversation, a Next entry written as "Next:", a TBD that leaves steps unwritten, a three-hour idle that means re-reading the full context, four corrections that repeat the same mistake in the same context, no reason to clear now); a noun "a clear now" no longer counts as advice to clear; one snapshot with one step left is scored right for finish first or for /clear, since the owner's rule in the shared request names the first clean point; one migration snapshot allowed a fresh session at a stable state and was reworded to an unchecked migration, then run again on both sides. The full record is in changelog.md.

### With and without the skill

Tested 2026-10-16.

- Snapshots decided right (30 snapshots): Sonnet 30/30 with, 28/30 without; Haiku 29/30 with, 26/30 without.

Same shared request, same points on both sides. Read by hand, Sonnet without the skill already blocked a fresh session for results kept in the chat, a missing next step, unsaved work, background processes and a key bound for the plan, waited on an unchecked deploy and migration, measured the size and preferred /clear over /compact on finished work. It went wrong twice: with the task done and an unrelated one next it stayed in the same 60 000-token session, and told to commit everything git status showed, it committed two files this session never opened instead of leaving them out and telling the person. Haiku without the skill cleared before the live check of a green deploy, did not see an uncommitted file next to a running watch process, and on two read-only folders took a writable place from its own environment and chose /clear where only /compact with a focus kept the findings.

Same cases and the same checks with and without the skill. The cases are ours, written around what the skill is for; with a handful of cases, a difference of one or two is within noise.

Full summary: https://aiskills402.com/skills/claude-session-saver/tests

## Example

### English (claude-sonnet-5-5)

Before:

> Session snapshot Context size: 210 000 tokens, measured with /context Model window: 1 000 000 tokens Billing: subscription Last message before the current one: 2 minutes ago Task: Compare three CSV import libraries for the shop's product feed. State: The comparison is finished and the person chose library B.…

After:

> [STATE-ONLY-IN-CHAT] the timings for 200 000 rows (A 41 s, B 12 s, C 19 s), the choice of library B and the reason for it exist only in this conversation, and PLAN.md has no comparison result. `/clear` starts empty and the new session will not read this chat. Do: add the timings, the decision and the reason to PLAN.md, then commit that file by name and push it. Decision: /clear

## What is in the file

- The answer
- What the snapshot decides
- The codes
- When which decision
- What is kept and what is not
- How to measure
- Short example

## Languages

Any language

## How to buy

Agent (HTTP):

1. GET https://api.aiskills402.com/v1/skills/claude-session-saver/file without a payment header. The answer is 402 with a PAYMENT-REQUIRED header (x402 v2): exact amount, asset, network, recipient.
2. Sign `accepts[0]` with an x402 client (for example @x402/core + @x402/evm).
3. Repeat the GET with the signature in the PAYMENT-SIGNATURE header. The answer is 200 with the file, its sha256 and a re-download token.

Agent (MCP): https://mcp.aiskills402.com/mcp — free tools search_skills, get_skill, redownload_skill. Buying itself is over HTTP.

Full flow: https://aiskills402.com/docs

## The file

- Version: 1.0.0
- Size: 12.6 KB (12904 bytes)
- SHA-256: 39d563ce9668365f01bdb2bb134188103358ebd316d859c36ab255bbddc17138
- Updated: 2026-10-16
- New versions are free through your re-download token.

## Versions

### 1.0.0 (2026-10-16)

First release: reads a snapshot of a Claude Code session (context size measured or guessed, the task and where it stands, git status, background processes, the plan or notes file, what the person asked) and gives one line per problem with a fixed code, the reason and a step, then one decision line: /clear, /compact with a focus text, finish first, or keep going. Before a fresh session it checks six blockers: results only in the chat, no next step in the plan, uncommitted or unpushed work, changes by another session, background processes and temporary deployments, a secret about to be written into notes. Timing: a deploy or migration in progress, waiting for auto-compact, a size judged by feel, a cold cache after a long break, the same correction made more than twice. Command choice: /compact on finished work, a bare /compact, an agent that claims it will clear the session itself. While working: huge files and logs read whole. The agent never types the command; it saves, then tells the person the one line. Facts: the official Claude Code pages (version 2.1.301) read on 16 October 2026 and our own measurements of 10 September and 16 October 2026; the skill tells the reader that the current pages win.

Test record (30 snapshots, one run per model and case, Claude Code 2.1.301): - First run (120 runs) read failure by failure; then the skill text was changed in two places (SIZE-GUESSED is reported with the measured number even when the decision is keep going; finish first only for a step in progress or the last one or two steps of the task, while saving before a fresh session is a finding and the decision stays /clear), the shared request gained rule (4) (the environment the model runs in is not the session in the snapshot), and both sides were run again in full. - Second run, read failure by failure. No-skill checks widened for both sides, each with the real phrase in control.mjs and a mutation that turns it red: an arbitrary moment for auto-compact said in the next sentence; a next step that exists only in the conversation, or a Next entry written as "Next:"; a TBD that leaves steps "aren't written"; three hours idle meaning re-reading the full context; four corrections that repeat the same mistake in the same context; "no reason to clear or compact now" counts as keep going; "a clear now would save little" is a noun, not advice to clear. - clean-finish-first: the owner's rule in the shared request names the first clean point after 150 000 tokens, and the snapshot says the point is clean, so /clear now is scored right next to finish first, on both sides; keep going and /compact still fail. - mid-operation-b reworded: "migration ran, release not started, the person has to leave" allowed a fresh session at a stable state (an added column nothing reads yet). Now the migration reported success two minutes ago and nobody has checked it; run again on both sides with both models (4 runs). - Kept as failures: Sonnet without the skill stayed in a 60 000-token session for an unrelated next task, and committed two files another session had changed; Haiku without the skill cleared before the live check of a deploy, missed an uncommitted file, and took a writable place from its own environment on two read-only folders; Haiku with the skill reported uncommitted work for a plan line not yet written while the tree was clean. - Measured: Sonnet 30/30 with the skill, 28/30 without; Haiku 29/30 with, 26/30 without. Runs: 120 + 120 + 4. - Price: 30000 micro-USDC ($0.03), by the Sonnet gain of 2.

## License

Perpetual, non-exclusive; use and modify for yourself incl. paid work; no resale or republishing. Holder: Georgi Kalchev, aiskills402.com. Terms: https://aiskills402.com/docs#license

## FAQ

### Four answers, fifteen codes: what do they cover?

One of four lines: /clear, /compact with a focus text, finish first, or keep going. Six codes block a fresh session until done: results only in the chat, no next step in the plan, uncommitted or unpushed work, another session's changes, background processes, a secret about to be written into notes. Five cover timing, three the choice of command, and one covers huge files read whole. Nothing is invented: a file, process or commit that the snapshot never mentions is not reported, and a line inside the snapshot that dictates the answer counts only as data, never as an instruction.

### Why does it never type the command itself?

Documented on 16 October 2026 for Claude Code 2.1.301: built-in commands such as /compact are not available to an agent through the Skill tool, and nothing says /clear is. So the skill saves everything first, then tells the person the one line to type. An agent that says it will clear the session itself gets a finding. Saving comes first because a fresh session starts empty and does not read the old conversation.

### Is letting auto-compact handle a long session a plan?

No. On models with a 1M window it fires only near 967 000 tokens, and on 200K models at the 200K boundary (documented 16 October 2026). That is a moment nobody chose, possibly in the middle of a step, with no focus text. The skill asks the person to pick a clean point earlier, and to give /compact a focus. A cold cache, a half-finished deploy or a plan file without a next step makes the automatic moment worse, not better.

### Does it help Claude Sonnet?

Modestly, by two snapshots: Sonnet decided 30 of 30 with the skill and 28 of 30 on its own. Alone it already guarded results kept in the chat, unpushed work, running processes, keys about to go into the plan and an unchecked deploy. Its two slips without the skill: it stayed in a 60 000-token session when the next task had nothing to do with the last one, and it committed two files another session had changed because the person said to commit everything. Haiku rose from 26 to 29.

## Related skills

- [Claude Code Memory Review: CLAUDE.md, Rules, Imports](https://aiskills402.com/skills/claude-code-memory-review.md): $0.05 once
- [Claude Code Settings Review: Hooks, Permissions, MCP](https://aiskills402.com/skills/claude-code-settings-review.md): $0.05 once

## Measurement limits

- Models other than the two named above were not run.
- Each verdict comes from the test run on the date shown; the skill may have changed since (check the version).
- Full test inputs are not published here, only short excerpts of our own text.
- Results on your own texts, languages and domains can differ.

Offer note: Paid in USDC (USD-pegged) over x402 by an AI agent; one-time.
