--- name: switch-mode description: > Change engagement mode mid-session. Updates active-mode.env and last-mode so the next session launches in the new mode. Injects the new mode's workflow stance into the current conversation so it takes effect immediately (driver model cannot change without a relaunch). allowed-tools: Read, Write, Glob, Bash(ls *), Bash(cat *) --- # Switch Mode Skill You are helping the user change their engagement mode. ## Pre-gathered context ### Available modes !`ls ~/dev/claude/small-scripts/data/claude-profile/modes/` ### Current active-mode.env !`cat ~/.claude-oreillyit/active-mode.env` ### Current last-mode !`cat ~/.claude-oreillyit/last-mode` ## Instructions The user wants to switch engagement mode. Follow these steps exactly. ### Step 1: Build the mode menu Read each `.md` file in `/home/paul/dev/claude/small-scripts/data/claude-profile/modes/` using the Read tool. From each file's frontmatter, extract: - `name` — the mode identifier - `tag` — display tag (same as name usually) - `driver` — the driver model - `escalates_to` — escalation model (or "none") From the body, read the `## Purpose` section to get a one-line description. Present a numbered menu like this (order: quick, deep, hybrid, orch, chat): ``` Available modes: 1. quick [Sonnet] One small focused job — get in, get out 2. deep [Sonnet -> Opus] Hard design/debug, plan-first, spec-driven 3. hybrid [Haiku -> Opus] Long sessions, cheap driver, escalate on demand 4. orch [Sonnet] Parallel container agents, orchestration focus 5. chat [Haiku] No project, just conversation ``` Mark the current mode (from `active-mode.env`'s `CLAUDE_MODE`) with `(current)`. If `$ARGUMENTS` is non-empty and matches a mode name, skip the menu and go directly to Step 2 with that mode. ### Step 2: Confirm selection Ask the user which mode number (or name) they want to switch to. Wait for their response. If they already specified a mode in `$ARGUMENTS` or the menu was skipped, confirm it: "Switching to `` mode — confirm? (y/n)" ### Step 3: Read the target mode file Use the Read tool to read the full content of `/home/paul/dev/claude/small-scripts/data/claude-profile/modes/.md`. Extract all frontmatter fields: - `name` - `tag` - `driver` - `async_ok` - `autoloop` - `plan_mode_auto` - `spec_driven` - `escalates_to` Compute the full mode file path: `/home/paul/dev/claude/small-scripts/data/claude-profile/modes/.md` ### Step 4: Write active-mode.env Write `/home/paul/.claude-oreillyit/active-mode.env` with this exact format (substitute the values from the frontmatter): ``` CLAUDE_MODE= CLAUDE_MODE_TAG= CLAUDE_DRIVER= CLAUDE_ESCALATES_TO= CLAUDE_PROJECT= CLAUDE_TIME_HORIZON=2 CLAUDE_ASYNC_OK= CLAUDE_AUTOLOOP= CLAUDE_PLAN_MODE_AUTO= CLAUDE_SPEC_DRIVEN= CLAUDE_MODE_FILE=/home/paul/dev/claude/small-scripts/data/claude-profile/modes/.md ``` For `CLAUDE_PROJECT=` — leave the value empty (no project context is carried across a mode switch initiated mid-session; the user will set it at relaunch). ### Step 5: Write last-mode Write `/home/paul/.claude-oreillyit/last-mode` with just the mode name and a trailing newline: ``` ``` ### Step 6: Adopt the new workflow stance Read the full body of the new mode's `.md` file (everything after the closing `---` of the frontmatter). This is the mode's instructions to Claude. Tell the user: > Mode updated to ``. The new mode will be fully active after `/clear` + relaunch (driver model `` cannot change mid-session). > > In this session, the following changes are active immediately: > - **Workflow stance**: [summarise the key stance change in 1-2 sentences based on the mode body] > - **Subagent policy**: [summarise from the Subagent policy section] > - **Async policy**: [enabled / disabled based on async_ok] > - **Plan mode**: [auto / manual / never, from plan_mode_auto] > > Adopting new stance now. Then behave according to the new mode's body prose for the remainder of the session. The driver model (``) is fixed — acknowledge this if the new mode's driver differs. ### Error handling - If `$ARGUMENTS` is set but does not match any mode name: say "Unknown mode: ``. Available modes: quick, deep, hybrid, orch, chat." and show the menu. - If the user picks their current mode: say "You are already in `` mode. No change made." and stop. - If a file write fails: report the error and tell the user to check permissions on `/home/paul/.claude-oreillyit/`.