Session State Management
Your context window is unreliable storage: it compacts, truncates, and ends. Disk does not. Anything you'd be sorry to lose goes in a file, at the moment you'd be sorry to lose it.
Step 1: Create WORKING_NOTES.md at task start
Location: the session scratchpad directory, or the repo root if the user's workflow expects it (never commit it unless asked). Structure — create all sections immediately, even empty:
markdown# WORKING NOTES — <task title> ## Task (verbatim requirements) <paste the user's actual requirements and process instructions — not your paraphrase; paraphrases drift and the original message may scroll out of context> ## Plan <ordered steps, checked off as done> ## Decisions <one line each: what was decided, and why — "IDs are ULIDs not UUIDs: sortable, spec §3"> ## Status <done / in progress / blocked, per step> ## Next action <the exact next command or edit, written for a cold reader> ## Assumptions & open questions
Step 2: Update triggers (write at the moment, not "later")
Update the file when ANY of these occurs:
- A plan step completes or a milestone verifies → check it off, update Status.
- A decision is made that later work must honor (naming, format, interface shape) → Decisions.
- The plan changes direction → rewrite Plan, note why in Decisions.
- You're about to do anything risky or slow (migration, big refactor step, long build) → record Next action FIRST, so a crash mid-operation leaves a resume point.
- Roughly every 30–45 minutes of work with no other trigger → refresh Status and Next action.
Step 3: Re-read triggers
Re-read WORKING_NOTES.md — fully, not from memory — when:
- A context-compaction notice appears, or a session resumes.
- You're unsure what was already decided or already tried.
- You're about to start a new plan step (glance at Decisions so step 9 honors what step 2 chose).
- Before writing the final delivery message (the Task section is the requirements checklist).
Rule: after any suspected context loss, trust the file over your recollection wherever they disagree. The file was written at the moment of knowledge; your recollection is a reconstruction.
Step 4: Split across sessions instead of overextending one
End the session at a natural boundary (a checkpoint, a completed unit) rather than pushing on, when ANY of:
- Remaining work is clearly larger than what's been done and quality is already degrading — see the signs below.
- Verification has failed 3+ times on the same criterion (grinding, not progressing).
- Degradation signs: repeating searches you already ran, re-deriving established facts, contradicting the Decisions list, or instructions from the original request coming as a surprise on re-read.
To split: finish the current unit to a verified state, update WORKING_NOTES.md so the Next
action block is executable cold ("run pytest tests/test_sync.py, then implement step 5:
retry logic in sync.py:120 per Decision 4"), and tell the user where things stand and what
the next session picks up.
Worked example
Mid-task, a compaction notice appears during an 8-step API migration.
- Without this skill: you continue from a summarized memory, re-implement the error envelope you already built (differently), and step 7 contradicts the pagination decision from step 2.
- With it: you re-read WORKING_NOTES.md — Decisions says "error envelope:
{error: {code, message}}, pagination: cursor-based, decided step 2"; Status shows steps 1–5 verified, step 6 in progress with next action "wire cursor into/ordershandler". You resume in two minutes with zero re-derivation and no drift.
Done when
WORKING_NOTES.md exists from task start and its Status/Next-action sections would let a cold model resume correctly right now; every cross-cutting decision made this session appears in Decisions; and at delivery, the verbatim Task section was used as the final requirements checklist.


