/cc-self:model-recoveryfrom cc-self
This skill should be used when a "[model-guard]" note reports the session is running below its declared baseline model (e.g. "This session runs as Opus 4.8 … Declared baseline: Fable 5"), when the user asks to "recover the model", "switch back to the baseline model", "restore Fable 5", or after a "[cc-self recover]" verification wake message arrives. Runs the deterministic compact-first recovery built into cc-self.
Ships in cc-self. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
The bundled model-guard hook injects a [model-guard] note on every run
while the session's actual runtime model (transcript truth) differs from the
declared baseline: CC_SELF_BASELINE in the session's environment, else
model in ~/.claude/settings.json (an alias such as sonnet, a dated
snapshot and the bare id all name the same model). With neither declared
there is no baseline — the guard then reports a model transition once and
instructs nothing (no built-in default). The note names its baseline's source and
states whether the guard ever saw the session on that baseline: a mid-session
move away from it is what a fallback looks like, while a session the guard
never saw on the baseline may have been launched on another model on
purpose — then the note's instruction is conditional, and the right fix is
for the user to declare that model (CC_SELF_BASELINE=<id> at launch, or pin
settings.json), not to "recover" and not to edit the declaration yourself.
Once a recovery has been armed for the session, the baseline counts as the
operator's stated intent. A live model that outranks the baseline is never
flagged (a fallback only goes down), though a downward move from a model the
session ran on is reported once, instructing nothing. A /model the user
types in this session, once the first assistant record after it confirms it,
is the newest declaration and becomes the session's baseline (over
CC_SELF_BASELINE when typed after this process launched; over settings.json
unless that was written later) — a later fallback then recovers to the chosen
model, and the note's command names it with --baseline. A /model that
cc-self typed (cc-self type, the recover driver) is a switch, never a
declaration: the session cannot declare its own baseline, so typing /model
on yourself is never a way around a recovery. A /model newer than the last
assistant record means the runtime is still settling: the note says so and
instructs nothing. Recover records older than a day are ignored, except a
CLOSED one, which stays the operator's decision. If the fallback happened during legitimate work — a broad
safeguard over-triggering — recover with the procedure below. The note itself
carries the attempt number to use.
A direct /model <baseline> switch does not hold while the context still
contains the content that triggered the fallback — the session switches back
and immediately re-falls. The durable fix: /compact first with an
instruction that PRESERVES all work context but ABSTRACTS the trigger content
into neutral terms, THEN switch. cc-self recover encodes exactly this
order, mechanically.
Everything else — submitting /compact, waiting out the compaction, switching
/model back, approving a confirm dialog if one appears, waking the session,
and verifying the live model from the transcript — is performed
deterministically by a detached driver. Do none of those steps by hand:
no cc-self type "/model …", no cc-self type "/compact …", no home-made
wakers or watchers. The CLI enforces the single-driver rule (a second
recover while a driver lives is refused with exit 2) and the guard tells you
when a driver is in flight; improvised keystrokes only race the driver on the
same input box.
Write a file (scratchpad is fine) containing instructions only — no
/compact prefix (the script adds it), and prefer no double quotes (they are
normalized to single quotes). The instructions must:
bash <plugin-root>/scripts/cc-self recover --compact-file <path> --attempt <N>
The guard's note already carries --baseline <model> (the baseline it
measured against — a confirmed in-session /model, else CC_SELF_BASELINE,
else settings.json); run the command as given. Without --baseline, recover
resolves CC_SELF_BASELINE (own session only), then model in
~/.claude/settings.json, and refuses with neither. Then end the
turn promptly — the queued /compact only drains when the turn ends (the
driver waits as long as the TUI is alive, up to 90 minutes, but every extra
tool call delays the recovery). cc-self recover --status shows the state
machine and whether the driver is alive.
State machine (per-session state in ~/.cc-self/state/recover-<sid>.json,
which also records the driver's pid):
ARMED → COMPACT_SUBMITTED → COMPACT_DONE → SWITCH_SUBMITTED → SWITCHED
→ VERIFY_WAKE → DONE (or FAILED-<phase>, never a blind keypress)
compact_boundary
record), with "Compacting…" on screen followed by idle as the fallback;
a "Not enough messages to compact." / "Compaction failed" line fails the
attempt with the reason recorded.Switch model? confirm dialog appears only when a warm prompt
cache would be invalidated; compaction acknowledges that, so post-compaction
switches are normally dialog-free and the TUI prints Set model to ….
The driver handles both: it approves the dialog only after seeing
Yes, switch to highlighted, accepts the direct-switch message, retries a
swallowed Enter once, and fails on an unrecognized dialog (Escape) or a
rejection message.editorMode: vim the absence of -- INSERT -- means NORMAL and an i is
sent first.FAILED-<phase> with the reason and
dumps the last 40 screen lines to ~/.cc-self/state/recover-<sid>-screen.txt.
Drivers always exit 0: tmux echoes a non-zero exit of a background job as a
view-mode overlay on whichever pane currently has focus, which is how
"stray text floating on an unrelated pane" used to happen.~/.cc-self.log.Post-switch verification reads the session transcript (message.model of
the first main-chain assistant message after the wake) — the same truth
source the guard hook uses. Statusline checks are advisory logging only:
statuslines are user-configurable and cannot be relied on. The DONE state's
note records the outcome: verified (live model = baseline), re-fell (guard
escalates with attempt+1 on the wake turn), or inconclusive (cross-checked
next turn).
Stale-read window: on the first hook firings of the post-switch wake turn, the newest transcript record still predates the switch, so a guard note there can be a false re-fall alarm. The guard detects this itself (record timestamp older than the recover state's last write → it says the reading is STALE and instructs no re-arm). Never start a new attempt from a note the guard marked stale — let a post-switch record settle it within a few tool calls.
cc-self recover --close writes the terminal CLOSED state: the guard keeps
stating the off-baseline fact but stops instructing re-arms, and a live driver
stops at its next step. The standing directive is never-settle, so this is
strictly the USER's call — only run it on explicit user instruction to stop
retrying.
After the switch, the driver types
[cc-self recover] attempt N: model switched, verify guard silence and report.
On that turn: if no [model-guard] note accompanies it, the recovery held —
report success. If the note reappears, the guard has already computed the next
attempt number and embedded the escalation instruction — follow it (never
settle for the fallback model; retry until baseline holds). If the guard says
a driver is still alive or the reading is stale, do nothing and end the turn.
A Stop hook that always blocks keeps the turn alive forever, so the queued
/compact never drains and recovery deadlocks. Contract: before waiting for
the turn to end, the driver touches ~/.cc-self/state/yield-<sid>. A
cooperating Stop hook lets ONE stop through when the flag exists and consumes
it:
# top of an always-blocking Stop hook
SID=$(python3 -c 'import json,sys; print(json.load(sys.stdin).get("session_id",""))' <<< "$INPUT")
YIELD="$HOME/.cc-self/state/yield-$SID"
if [ -f "$YIELD" ]; then rm -f "$YIELD"; exit 0; fi # yield once, then resume blocking
The driver removes any leftover flag on DONE/FAILED.
The bundled model-guard hook re-flags on every run while off-baseline. If an
external copy of the guard also runs (e.g. a personal ops script), keep only
ONE enabled or every run gets duplicate notes — disable the bundled one by
creating ~/.cc-self/state/guard-disabled, or retire the external one. A
single session can opt out by being launched with CC_SELF_GUARD_DISABLED=1
(used by cc-self's own scratch-session tests), and a session deliberately run
on another model than the machine-wide default declares it with
CC_SELF_BASELINE=<model> at launch (hooks inherit the environment; cc-self restart carries both variables onto the relaunch).
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub dev-jahn/cc-self --plugin cc-self3 skills in this plugin
/restartThis skill should be used when the user asks to "restart your session", "restart yourself", "reload your session", or when the session itself determines a restart is needed (e.g. after a plugin update or harness change that requires a fresh process). Restarts the current Claude Code session in place via /exit + claude --resume, preserving the full conversation./self-controlThis skill should be used when the session needs to perform a user-side action on its own Claude Code TUI — run a slash command on itself ("/reload-plugins", "/effort low", "/model", "/plugin install ..."), answer its own confirmation dialogs, observe its own screen, or when the user asks to "change your own effort", "reload plugins yourself", "install this plugin yourself", "control your own session", "type into your own TUI", or "restart your session" (for restart, prefer the cc-self:restart skill).