Session State vs Claude Code --resume
What .meowkit/state/ holds, how it differs from the conversation that Claude Code --resume restores, and which of the two to look at for a given question.
Claude Code's --resume restores a conversation. MeowKit's .meowkit/state/ holds what the hooks recorded while the session ran: counters, caches, the detected model and checkpoints. The two answer different questions and neither replaces the other.
Claude Code --resume | MeowKit .meowkit/state/ | |
|---|---|---|
| Restores | The transcript: messages and tool calls | Hook-layer records |
| Knows about | What was said | What the process did: edits, builds, spend, model |
| Cannot restore | Hook counters, build caches, git drift | The conversation |
What the hooks keep in state
State files are written and read by hook handlers. Each handler is a separate process with no shared memory, so the files are how handlers pass data to each other.
| File | Written by | Read by | Purpose |
|---|---|---|---|
detected-model.json | model-detector.cjs (SessionStart) | budget-tracker, auto-checkpoint, checkpoint-writer | Model tier and density, from the SessionStart model field |
budget-state.json | budget-tracker.cjs (PostToolUse) | The same handler, auto-checkpoint, checkpoint-writer, post-session | Running token and cost estimate. Advisory: over the cap it prints a notice and stops nothing |
edit-counts.json | loop-detection.cjs (PostToolUse) | The same handler | Edits per file, keyed by session and real path |
build-verify-cache.json | build-verify.cjs (PostToolUse) | The same handler | File hash, so an unchanged file skips the compile and lint check |
learning-observer.jsonl | learning-observer.cjs (PostToolUse) | post-session.cjs (Stop) | Per-file edit ledger |
last-session-id | project-context-loader.cjs (SessionStart) | The same hook | Detects a new session id |
checkpoints/checkpoint-latest.json | checkpoint-writer.cjs (Stop), auto-checkpoint.cjs (phase changes) | orientation-ritual.cjs (SessionStart), as a fallback when mewkit orient cannot run | One file of resume context: model tier, density, plan path, git state, budget |
When project-context-loader.cjs sees a new session id, it resets the edit counts, the build cache and the budget estimate, and clears the TDD sentinel. Inside one session they accumulate. The cost history is kept separately in .meowkit/telemetry/cost-log.json.
What this enables
- Loop detection. After 4 edits to one file,
loop-detection.cjsadds a reminder to re-read the plan and the failing output. At 8 edits it tells the model to stop editing that file and re-plan. It repeats at every further multiple of 4. These are messages to the model, not blocks. - Cheap verification.
build-verify.cjshashes the edited file and skips the compile and lint check when the hash is unchanged. A failure is reported to the model. - Density and pricing. The detected model drives the autobuild density (see Adaptive density) and the per-tier cost estimate.
- Resume context. The checkpoint carries the plan path and git state, so a new session can see whether the working tree changed since the last checkpoint.
What survives a resume
Some behavior survives --resume because it lives in project files Claude Code reads again at session start.
| Survives | What | Where |
|---|---|---|
| Yes | Always-on rules | .claude/rules/*.md |
| Yes | Skills and agents | .claude/skills/, .claude/agents/ |
| Yes | Project context | docs/project-context.md |
| Yes | Team memory | .meowkit/memory/ |
| Yes, read on demand | The durable task record | tasks/active/<id>.json, shown with mewkit task-state show |
| No | Edit counters, build cache, budget, model tier, checkpoint | .meowkit/state/ |
The task record is a project file, but it is not injected into every session. A fresh session reads it when it asks for the active task, so resume state costs no context until it is needed.
Which layer answers which question
| Question | Look at |
|---|---|
| What was said in the last conversation? | --resume |
| What was the agent doing when the session ended? | .meowkit/state/checkpoints/ |
| Has the agent edited one file too many times? | .meowkit/state/edit-counts.json |
| Did this session go over budget? | budget-state.json now, .meowkit/telemetry/cost-log.json for history |
| Which model tier is this session on? | .meowkit/state/detected-model.json |
| Has the working tree changed since the last checkpoint? | checkpoint-latest.json (git hash comparison) |
| What did the last bug fix teach? | .meowkit/memory/gotchas.md, which mk:fix greps on demand |
Related
- Memory system for the durable, reviewed lessons that are separate from state
- The workflow for where each phase reads and writes state
- Hooks for the handlers
Adaptive Density
How /mk:autobuild scales its scaffolding to the model: the dead-weight thesis, the three density modes and how the mode is chosen.
Customising and Upgrading Skills
Keep your own version of a kit skill across upgrades with an overlay, copy one under your own name with a fork, and put a skill back with rollback. What the skill store records and what an older mewkit does with it.