{"data":{"slug":"discovered-c79ff3a0bbca80fef2e8cefcffd2b350d01b46aebbd27078","title":"Context Budget","summary":"Enforces model selection rules and provides a handoff recipe for subagent-driven workflows. Ensures only Haiku, Sonnet, or Opus models are used for subagents, with specific use cases for each, and guides when to hand off to a fresh session.","url":"https:\/\/skillshunter.net\/skills\/discovered-c79ff3a0bbca80fef2e8cefcffd2b350d01b46aebbd27078","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/discovered-c79ff3a0bbca80fef2e8cefcffd2b350d01b46aebbd27078","markdown_url":"https:\/\/skillshunter.net\/skills\/discovered-c79ff3a0bbca80fef2e8cefcffd2b350d01b46aebbd27078.md","download_url":"https:\/\/skillshunter.net\/skills\/discovered-c79ff3a0bbca80fef2e8cefcffd2b350d01b46aebbd27078\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Before dispatching a subagent, explicitly specify the `model` parameter. Ensure the project's `.claude\/context-budget.json` file is configured correctly, particularly the `allowFable` and `enforceDispatchModel` settings. When handing off, check if `docs\/planning\/STATE.md` exists to use `project-orchestration` `pause-work`, or create `.claude\/handoff.md` with the required headings if it does not.","instructions":"---\nname: context-budget\ndescription: Use when dispatching implementer or reviewer subagents, when choosing a model for a subagent, when a context-budget reminder appears in the conversation, or when handing off to a fresh session at a natural break. Holds the suite-wide model rule (Haiku, Sonnet or Opus, never Fable unless the project allows it) and the fresh-session handoff recipe. Skip for work that needs no subagent and no handoff.\n---\n\n# Context Budget Skill\n\n## Purpose\n\nLong sessions and heavyweight models are the two biggest cost drivers in a subagent-driven run. This plugin addresses both:\n\n- A `UserPromptSubmit` hook measures the session's context size and adds a reminder when it grows large.\n- A `PreToolUse` hook on the `Agent` and `Task` tools checks every dispatch for an explicit, allowed `model`.\n- This skill holds the rules those hooks enforce and the handoff recipe the reminder points to.\n\nHooks never fail a turn or stop work. On any error they exit silently.\n\n## Model Choice\n\nOnly Haiku, Sonnet and Opus are used for subagents. Never Fable, unless the project's `.claude\/context-budget.json` sets `allowFable` to `true`.\n\n- Implementers and reviewers default to Sonnet.\n- Opus is for a plan task marked `**Model:** opus`, a stuck-implementer retry (fix round 4 or later), and the final whole-branch review.\n- Haiku is only for lookups and searches.\n\nThis holds in every run, including plain `subagent-driven-development` and `executing-plans` runs, with or without a plan that names models. Where the upstream Model Selection guidance allows a cheap model for mechanical implementers, this rule wins: implementers never go below Sonnet.\n\nAlways pass `model` explicitly on a dispatch. The dispatch hook denies any Fable `model` for every agent type while `allowFable` is not `true`. It denies a missing `model` only when `subagent_type` is absent, empty or `general-purpose`, and only while `enforceDispatchModel` is not `false`. `fork` and every other agent type pass.\n\n## Fresh-Session Handoff\n\n### When to hand off\n\nHand off only at a natural break, and only when the next work needs nothing from the current context.\n\n- A natural break is a finished phase or PR, or a delivered result.\n- A finished plan task is not a natural break. A `subagent-driven-development` or `executing-plans` run goes on to the last task and its final review in this session; implementer subagents already keep this context small.\n- If the next work needs what is in the current context, carry on. A big context that the work needs is fine.\n- Never hand off while a `\/goal` is active. A goal belongs to its session: a new session starts without it, so the run stops until someone sets it again. Auto-compaction carries a long goal run instead. The same holds during an unattended run (see the `unattended` skill).\n- Outside a natural break, or when the next work depends on the current context, say nothing and carry on silently. A context-budget reminder is a prompt to check these conditions, not an instruction to stop.\n\n### Record the handoff\n\n- **When `docs\/planning\/STATE.md` exists:** use `project-orchestration` `pause-work`. It records the position in `STATE.md`, and the new session resumes with `resume-work`.\n- **Otherwise:** write `.claude\/handoff.md` with these headings: `## Goal`, `## Current state`, `## Decisions made`, `## Next step`, `## Files in play`.\n\n### Start the new session yourself\n\nIf the `create_session` tool is available in a cloud session (Claude Code Remote), start the new session and close this one without asking. The user does not open sessions by hand.\n\nFirst call `get_session` without a `session_id`. If `environment_kind` is `bridge`, this is a Remote Control session on the user's own machine. There `create_session` is refused with `MCP tool call requires approval`, even in bypass permissions mode and with the tool on the allow list, because the remote-session service asks for an approval this session cannot give. Skip the steps below and follow [Without `create_session`](#without-create_session).\n\n1. **Leave nothing behind.** Commit and push work in progress, including the handoff record, or say what is uncommitted. Archiving this session can remove its worktree.\n2. **Make the first message self-contained.** A new session may get its own worktree, where this one's uncommitted files do not exist. With `STATE.md`, the message says to run `resume-work` and names the branch and the first step. Otherwise it holds the full handoff with the five headings above, with absolute paths, and ends with `Continue from Next step.` When `retro` is installed and has not been offered in this session, it also names this session's transcript as an absolute path (`~\/.claude\/projects\/<slug>\/$CLAUDE_CODE_SESSION_ID.jsonl`, expanded) and adds `Offer retro on that transcript once, after resuming.` Ask nothing about the retro here; the handoff stays silent.\n3. **Start it.** Call `create_session` with `prompt` set to that message and a short `title` naming the next step. Leave `environment_id` and `permission_mode` unset, so it runs where this session runs, with the same permissions.\n4. **Check it is running.** Call `get_session` on the new id until `status_bucket` is `working`, and read its latest events with `list_events` (`kinds: [\"assistant\"]`) to see it picked up the handoff. If it is `failed`, or shows no assistant turn after a few checks, keep this session open and tell the user.\n5. **Close this one.** Tell the user the new session's title and id, then call `archive_session` with this session's own id, from `get_session` without a `session_id`. The final message names the new session; nothing runs after the archive.\n\n### Without `create_session`\n\nIf the tool is missing, this is a `bridge` session, or `create_session` is refused (for example at a session lineage limit, or with `requires approval`), give the user one line to paste into a new session, for example `Read .claude\/handoff.md and continue from Next step.` or `Run resume-work on branch <branch>.`, followed by the same retro line under the same condition, and leave this session open. Do not retry a refused `create_session`: the same call gets the same refusal.\n\n## Configuration\n\nOptional file `.claude\/context-budget.json` in the project:\n\n| Field | Default | Meaning |\n| --- | --- | --- |\n| `nudge` | `200000` | Context tokens at which the first reminder appears. |\n| `firm` | `400000` | Context tokens at which the reminder turns firm. Must exceed `nudge`. |\n| `enforceDispatchModel` | `true` | When `false`, a general-purpose dispatch without `model` is allowed. Fable stays denied unless `allowFable` is `true`. |\n| `allowFable` | `false` | When `true`, a Fable `model` is allowed on any dispatch. A general-purpose dispatch still needs a `model` while `enforceDispatchModel` is on. |\n\nA missing or invalid file means the defaults. After a reminder, the next one appears only once the context has grown by a further 50000 tokens, and the count resets only when the size drops by at least 50000 tokens, for example after a compaction. A smaller dip keeps the count.\n","use_cases":["Enforcing model selection rules for subagents","Handling context-budget reminders during long sessions","Providing a recipe for handoff to a fresh session at natural breaks","Validating model parameters during dispatch"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/MarcelRoozekrans\/superpowers-extensions\/blob\/6f6a27c176cbcabbb7ebc61fc7ea6b59db2d5558\/plugins\/context-budget\/skills\/context-budget\/SKILL.md","source_commit":"6f6a27c176cbcabbb7ebc61fc7ea6b59db2d5558","license":null,"version":null,"listing_approved_at":"2026-11-29","created_at":"2026-11-28T18:43:25.000000Z","updated_at":"2026-11-29T10:53:15.000000Z","seo_title":"Context Budget - Model Selection and Session Handoff Rules","seo_description":"Enforces model selection rules for subagents and provides a structured approach for session handoffs in subagent-driven workflows.","seo_keywords":["context budget","model selection","subagent dispatch","session handoff","Haiku model","Sonnet model","Opus model","Fable model restriction"]}}