---
name: self-arrest
description: Session-limit self-protection for long-running solo sessions — arm a silent usage watcher that fires only when the 5h session window is ≥80% used AND projected to run out before its rollover; then checkpoint cleanly, lie flat, and auto-wake when the window resets. Use at the start of any long solo session, or invoke mid-session when limit pressure is suspected. NOT needed under /coordinate (the coordinator's autothrottle owns slot pressure there).
argument-hint: [optional: path of the artifact file you update while working]
---

# /self-arrest — checkpoint, lie flat, wake at the session reset

The account's REAL limits are queryable (no self-counting):
`.claude/tools/coordination/Get-AccountUsage.ps1` hits the OAuth usage endpoint and
returns session (5h) + weekly utilization with reset times. This skill wraps it into a
self-protection loop for a session with no coordinator watching over it.

## Arm (once, at session start or on invocation)

1. Pick your **activity file** — a file you naturally keep updating while working (your
   plan/implementation artifact under `plans/`, or the file named in `$ARGUMENTS`). The
   watcher self-expires ~90 min after it goes stale, so it can never outlive your
   actual work.
2. Start the watcher as a persistent Monitor (silent until it matters):

   ```
   Monitor(command: "pwsh -NoProfile -File '.claude/tools/coordination/Watch-AccountUsage.ps1' -SelfArrestMode -ActivityFile '<your artifact>'",
           description: "self-arrest watch (session-limit projection)",
           persistent: true)
   ```

   It probes every 10 min and emits at most ONE line:
   `SELF-ARREST session=X% projected=Y% resets=HH:mm (in N min)` — only when usage is
   ≥80% AND the burn-rate projection says the window overshoots the account tier's
   landing target before its rollover (or usage hits the tier hard pause — landing
   target + 2, capped 97% — outright). Below 80% it never fires, whatever the burn
   rate. Landing targets are tier-resolved: 95% max_20x · 90% max_5x/premium team ·
   80% pro/normal team.

## On the SELF-ARREST event

Work TO A SAFE POINT, never past it — the arrest exists to avoid the mid-flight limit
hit and its rebuild cost:

1. **Checkpoint:** finish the current atomic step only. Commit WIP on your branch
   (`checkpoint: <state> — self-arrest at <pct>%`), then write `SELF_ARREST_RESUME.md`
   next to your plan artifact: what was in progress, exact next step, any volatile
   context a fresh read of the files would miss.
2. **Announce:** one short message to the user — arrested at X%, window resets HH:mm,
   auto-wake armed.
3. **Arm the wake** (single-notification background timer, +3 min buffer past reset):

   ```
   PowerShell(command: "$t=[DateTimeOffset]::Parse('<resets_at ISO from the event/state file>').AddMinutes(3); while([DateTimeOffset]::Now -lt $t){Start-Sleep 30}; 'SESSION WINDOW RESET — resume from SELF_ARREST_RESUME.md'",
              run_in_background: true)
   ```

4. **Lie flat:** no dispatches, no reads, no polling until the wake notification. The
   session limit fully resets at the rollover — waiting is free; hitting the wall is not.

## On wake

Re-probe once (`Get-AccountUsage.ps1`) to confirm the fresh window, delete/absorb
`SELF_ARREST_RESUME.md` into your normal artifact, re-arm the watcher, resume.

## Boundaries

- Under **/coordinate**, do NOT arm this — the coordinator runs the slot-throttling
  variant of the same watcher and owns pacing; wave drivers never self-arrest (they are
  short-lived and the coordinator budgets for them).
- Weekly-limit pressure is deliberately NOT handled here (it moves slowly; it is a
  user/coordinator decision — see the bands in `Get-ThrottleAdvice.ps1`).
- Stop the watcher (`TaskStop`) when your task completes before any arrest — don't rely
  solely on the idle self-expiry.
