[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M736SVC70158J0SNN1VJ8Y6H":3,"skill-same:01M736SVC70158J0SNN1VJ8Y6H":50},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":23,"commitSha":24,"skillDirectory":25,"forksCount":13,"repositoryHtmlUrl":26,"repositoryHomepageUrl":6,"ownerHtmlUrl":27,"ownerBlogUrl":6,"ownerDescription":28,"updatedAt":29,"install":30,"resources":43},"01M736SVC70158J0SNN1VJ8Y6H","main-agent-mode",null,"Run an explicit opt-in delivery workflow where one main agent owns the user conversation and acceptance while managed workers implement isolated lanes.","graysurf\u002Fagent-runtime-kit","graysurf","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F10785178?v=4","01M736PQHYKHFMNBYF8BT93NM4","01M736PQJWYH7G046WAN7EQCHD",0,"MIT","https:\u002F\u002Fgithub.com\u002Fgraysurf\u002Fagent-runtime-kit\u002Fblob\u002Fmain\u002Ftests\u002Fgolden\u002Fcodex\u002Fplugins\u002Fconversation\u002Fskills\u002Fmain-agent-mode\u002Fexpected\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: main-agent-mode\ndescription: >\n  Run an explicit opt-in delivery workflow where one main agent owns the user\n  conversation and acceptance while managed workers implement isolated lanes.\n---\n\n# Main Agent Mode\n\n## Contract\n\nPrereqs:\n\n- The user explicitly asks to enable or use Main Agent Mode for the bounded\n  workflow. Ordinary implementation requests never activate this mode.\n- `agent-session >=1.25.11` is installed from a trusted compatible surface.\n- The trusted `main-agent` facade from the compatible nils-cli surface is\n  executable and advertises the exact runtime-checkpoint and run-wide closeout\n  capabilities below.\n  The semantic-version floor alone is not sufficient. Until that surface is\n  available, report Main Agent Mode as unavailable without repairing or\n  restricting ordinary agent work.\n- A supported worker provider and executable provider helper pass the doctor\n  gate below before mode activation or worker launch.\n- The active project intent, work-tier, test-first, validation, review, and\n  delivery policies remain authoritative.\n- The detailed role, handoff, evidence, acceptance, and recovery protocol is\n  available at `references\u002FMAIN_AGENT_MODE_PROTOCOL.md`.\n\nInputs:\n\n- The accepted request, done criteria, constraints, repository, base ref, and\n  work tier.\n- The literal worker provider name, `codex` or `claude`, chosen from the\n  providers reported as supported by the installed `agent-session` doctor.\n- Existing plan, issue, run-state, PR, and worktree references when the tier\n  already owns them.\n- One private mode-0600 objective packet for a new run, or an authenticated\n  durable run relationship that `main-agent rehydrate` can recover.\n- An optional explicit `delegate-all` preference for L0\u002FL1 work.\n\nOutputs:\n\n- One main-agent-owned execution and acceptance result for the user.\n- One revisioned orchestration run whose assignments, relationships,\n  checkpoints, and privacy-safe projections survive compaction and resume.\n- Exact task packets and isolated managed worktree assignments for workers.\n- Bounded worker completion or blocker packets grounded in diff, validation,\n  and durable lifecycle evidence.\n- Independent main-agent inspection, validation, code-review synthesis,\n  acceptance decisions, and final reporting.\n\nFailure modes:\n\n- Activation was not explicit, or the requested scope\u002Fdone criteria are not\n  sufficiently bounded to delegate safely.\n- The installed `agent-session` is missing or older than `1.25.11`.\n- The trusted `main-agent` facade is absent, incompatible, untrusted, does not\n  advertise `main-agent.runtime-checkpoint-file.v1` and\n  `main-agent.run-wide-closeout.v1`, or cannot authenticate the current\n  managed-session incarnation.\n- Doctor output is unhealthy, unsupported, unavailable, malformed, or reports\n  a missing provider helper.\n- The bounded compatibility preview is not converged, would change state, or\n  exposes a representation conflict.\n- Provider readiness, prompt delivery, worker ownership, durable evidence,\n  scope, validation, review, or recovery cannot be established.\n\n## Explicit Activation\n\nActivate only after the user says to enable or use Main Agent Mode for the\ncurrent workflow. State that the mode is active, its bounded outcome, the\nselected worker provider, and whether L0\u002FL1 work is also delegated. Do not infer\nactivation from an ordinary request to implement, use subagents, work in\nparallel, or keep going. Activation does not persist into a later unrelated\nrequest, and an explicit user request to disable the mode takes effect before\nany new worker launch.\n\n## Entrypoint\n\nRun the installed version and doctor checks before activating the mode or\nlaunching any worker:\n\nFor a Codex worker, run these literal commands:\n\n```bash\nagent-session --version\nmain-agent capabilities --provider codex --format json\nmain-agent self readiness --format json\nagent-session activity doctor --agent codex --format json\n```\n\n\nRequire `agent-session >=1.25.11`, a valid\n`cli.main-agent.capabilities.v1` envelope with `ok:true`, whose\n`data.schema_version` is `main-agent.capabilities.v1` and whose\n`data.capabilities.runtime_checkpoint_file` is exactly\n`\"main-agent.runtime-checkpoint-file.v1\"`, whose\n`data.capabilities.runtime_hook_checkpoint_write` is exactly\n`\"runtime-kit.checkpoint-write-admission.v1\"`, and whose\n`data.capabilities.run_wide_closeout` is exactly\n`\"main-agent.run-wide-closeout.v1\"`, and whose\n`data.provider` matches the selected worker provider, and whose\n`data.compatible` is `true`. This provider-aware probe reads the deployed `agent-hook`\ninventory, requiring bundle version `2026.07.28.1` or newer plus the locked\ncoordination rules for the selected provider. It also requires that provider's\nconverged `agent-hook doctor` record and executes its installed\n`session-coordination-guard.py` capability self-probe, so a stale or missing\nselected-provider handler fails closed without coupling activation to another\nprovider installation. It therefore rejects either mixed deployment (new CLI\nwith old policy\u002Fhandler surfaces, or old CLI with the new runtime surfaces).\n\nRequire `main-agent self readiness` to return a valid\n`cli.main-agent.self-readiness.v1` envelope with `ok:true`, whose\n`data.schema_version` is `main-agent.runtime-readiness.v1`, whose `data.ready`\nis `true`, and whose `data.checkpoint_file` is an absolute path. This\nper-incarnation gate proves the current managed session received the exact\nruntime-issued environment path and still owns a private regular checkpoint\nfile. `runtime-checkpoint-unavailable` stops activation; resume or restart the\nmanaged session after the compatible surfaces are deployed. Do not run `init`\nor any Main Agent mutation from that incarnation.\n\nAlso require a valid\n`cli.agent-session.activity-doctor.v1` envelope with `ok:true`, exactly one\nmatching provider record, and `helper_executable:true`.\nRequire `classification:\"supported\"`.\nTreat `\"unavailable\"` and `\"unverified\"` as a stop. A configured provider must\notherwise be healthy for the selected runtime. Missing fields, extra provider\nambiguity, stale or unparseable output, timeouts, or nonzero exit stop\nactivation.\n\nWhen doctor reports `configured:false`, use only the product's literal\nnon-mutating compatibility probe; never use a shell provider variable in these\nreadiness commands:\n\n```bash\nagent-session activity setup --agent codex --repair --dry-run --format json\n```\n\n\nAccept the compatibility case only when the doctor reports no representation\nconflict and the preview is a valid matching-provider converged result with\n`compatibility_owner:\"agent-hook\"`, `configured:true`,\n`would_change:false`, and no representation conflict. The preview must not be\napplied. Any other result stops the workflow and reports the bounded readiness\nproblem to the user.\n\nWhen the hook emits the trusted `builtin command … agent-run inspect` route,\nkeep its exact canonical outer envelope and provide a nonempty child argv after\n`--`. `agent-run inspect` remains the child safety boundary; shell operators,\naliases, or alternate outer option forms are not equivalent readiness routes.\n\nAfter the provider gate, verify the facade and recover authenticated self state:\n\n```bash\nmain-agent --version\nmain-agent self show --format json\n```\n\nDo not infer a run, role, assignment, or manager from the prompt, title, cwd,\npane, process, or environment flags. The facade's session-ID plus incarnation\nrelationship is authoritative. If no run exists, create it only through the\nexact private-packet bootstrap:\n\n```bash\nmain-agent init --packet-file \u003Cprivate-json> --if-absent \\\n  --idempotency-key \u003Cunique-key> --format json\n```\n\nUnder coordination enforcement, read-only `self show`, `rehydrate`, `status`,\n`worker list\u002Fshow\u002Fwait\u002Fdiagnose\u002Fsupervise`, and the exact bootstrap-safe\n`bootstrap` and `self recover` shapes remain available before a claim. The\ntrusted facade must acquire or confirm the authenticated target-owned claim\nbefore its first ordinary durable run write. Every other facade mutation\nrequires the active claim plus its documented revision or absence fence and\nidempotency key.\n\n## Durable Rehydration And Checkpoints\n\nTreat the `main-agent` run and assignment records as the authoritative workflow\nrelationship and recovery surface. Issue, plan, worktree, diff, validation,\nreview, and provider records remain authoritative for their own domains and are\nlinked from the run; the orchestration graph never replaces them or grants\nmutation authority.\n\nAt activation, after provider resume or context reset, and whenever local\nworkflow state may be stale, run:\n\n```bash\nmain-agent rehydrate --format json\n```\n\nUse the returned durable revision, constraints, done criteria, assignments,\ncheckpoint, blockers, and next action. Keep observation-time annotations\nseparate from the deterministic durable projection. Before handing off a\nmaterial transition and after accepting a worker result, persist a bounded\ncheckpoint through a private file:\n\n```bash\nmain-agent checkpoint --file \u003Cprivate-json> --if-revision \u003Cn> \\\n  --idempotency-key \u003Cunique-key> --format json\n```\n\nFor a managed worker, use only the exact `checkpoint_file` returned by its\nauthenticated `main-agent bootstrap`; the runtime pre-creates that\nsession\u002Fincarnation-bound file outside the checkout at mode `0600`. Write the\nbounded JSON object there, then pass the same literal path to `--file`. For the\nMain Agent's own checkpoint, use its runtime-issued\n`AGENT_SESSION_CHECKPOINT_FILE`. Never allocate an arbitrary worker checkpoint\npath under the repository or a project output tree.\n\nAt safe turn or tool boundaries, give Main Agents and workers only a concise\nprivacy-safe reminder that durable state is available through `main-agent\nrehydrate` or `main-agent self show`. Do not repeat the private task packet,\nblock unrelated safe work, detect compaction heuristically, or expose private\npaths, capabilities, prompts, transcripts, or mailbox bodies.\n\n## Outcome Routing\n\nClassify the request before choosing workers. Main Agent Mode changes\nimplementation ownership, not the tier:\n\n- L0\u002FL1 remain inline unless the user requests `delegate-all`; when delegated,\n  use one isolated managed worker and keep the same parent outcome.\n- L2 retains the plan-tracking parent, but the main agent does not implement or\n  repair production or test code. One interactive managed worker owns the\n  implementation in an isolated managed worktree launched with\n  `--coordination-mode enforce`.\n- L3 retains exact independent lane workers and the dispatch orchestrator\n  acceptance boundary. The mode does not merge lanes or collapse their\n  worktrees, PRs, reviews, validation, or closeout.\n\nFor L2\u002FL3, main-agent writes are limited to orchestration, plan\u002Frun-state,\nevidence, review synthesis, and authorized provider lifecycle actions. Return\ncode findings to the same worker and lane unless the main agent records an\nexplicit reassignment under the recovery protocol.\n\n## Workflow\n\n1. Confirm explicit activation, bounded done criteria, worker provider, tier,\n   and any L0\u002FL1 `delegate-all` preference.\n2. Pass the version, doctor, and conditional dry-run compatibility gates. Do\n   not launch a worker while readiness is uncertain.\n3. Run authenticated `main-agent self show`. Rehydrate an existing run or use\n   the exact `init` bootstrap with a private packet. Reconcile the returned run\n   with durable issue\u002Fplan\u002Frun-state\u002Fworktree evidence; never create a second\n   run merely because local conversation context is missing.\n4. Create one revision-fenced assignment per implementation owner through the\n   facade. Each private packet names a repository, non-overlapping scope,\n   invariants, exclusions, base, isolated managed worktree, test-first and\n   validation duties, delivery artifact duties, and the exact\n   completion\u002Fblocker packet. The Main Agent claim must not overlap a worker\n   scope. For a mutating worker, the packet `worktree`, `launch.cwd`, durable\n   assignment worktree, and authenticated worker cwd must resolve to the same\n   canonical checkout root before bootstrap can mint its shell grant. Keep\n   worker path scopes narrow; do not add repository scope merely so\n   the worker can run tests, validation, delivery, or checkpoint commands.\n   Authenticated worker bootstrap mints a private checkout-shell grant on the\n   exact assignment-derived claim; admission also requires the matching\n   repository and worktree fingerprint. This grant is checkout-level\n   coordination, not a path sandbox: reject final diffs outside the assigned\n   scopes. The assignment relationship is routing metadata and\n   transfers no repository or provider authority. When a packet declares `depends_on`, every\n   named assignment must belong to the same run and already be `accepted` or\n   `released` before launch. On `dependency-not-satisfied`, no dependent\n   assignment was created: wait boundedly for each upstream assignment's\n   terminal transition, re-read it, and retry the unchanged launch only after\n   every dependency is accepted or released. Missing, cross-run, cancelled, or\n   other pre-terminal dependencies remain blocking.\n5. Run the candidate conflict check, then launch through the folded readiness\n   boundary:\n\n   ```bash\n   main-agent worker start --assignment-file \u003Cprivate-json> --await-ready 5m \\\n     --idempotency-key \u003Cunique-key> --format json\n   ```\n\n   The assignment itself must request the isolated worktree and\n   `--coordination-mode enforce`.\n6. Branch only on the returned typed readiness. Continue immediately only for\n   `state:\"ready\"`, `delivery.state:\"confirmed\"`, and\n   `delivery.proof:\"authenticated-worker-checkpoint\"`. For a fresh supported\n   worker whose assignment remains `starting`, the folded runtime may submit\n   exactly one recovery Enter within the original wait deadline after rechecking\n   the exact session incarnation and live runtime. The prompt is never resent.\n   The runtime owns this recovery decision and keypress; the Main Agent only\n   verifies the `submit_key_recovery` projection and accepts either the initial\n   `submit-command-succeeded` transport or the recovered\n   `submit-key-recovery-succeeded` transport when the authenticated checkpoint\n   also succeeds. A\n   `state:\"readiness_failed\"` result has `delivery.state:\"unverified\"` and\n   `automatic_retry_safe:false`: runtime recovery is then exhausted or\n   ineligible, so do not resend the prompt, inject another Enter, or inspect a\n   pane\u002Ftranscript to overrule it. Retain the exact worker and typed safe state\n   for diagnostics. A folded start result with a non-authoritative starting\n   failure is only a provisional snapshot: if the same bound incarnation later\n   completes authenticated bootstrap, supervise that incarnation and continue\n   it instead of launching a duplicate.\n   A folded `readiness_failed` snapshot can be superseded by that newer authoritative evidence from the same\n   incarnation; it never authorizes a second prompt, Enter, assignment, or\n   worker.\n7. The generated worker prompt invokes the exact compatible executable's\n   `main-agent bootstrap` command. The authenticated worker alone resolves its\n   private assignment, acquires the assignment-derived claim, and records the\n   revision-fenced `working` checkpoint that proves readiness. A released or\n   expired claim must be reacquired and verified before a later mutation turn.\n   The launcher never uses the target capability or claims on its behalf, and\n   interference or deletion before this handoff fails the ownership proof.\n8. Monitor actively through the repeatable bounded macro:\n\n   ```bash\n   main-agent worker supervise \u003Cassignment-id> --format json\n   ```\n\n   Run it after every bounded wait timeout or contradictory snapshot and branch\n   on `classification` and `recovery_action.kind`, not prose. Execute\n   `recovery_action.argv` only when `recovery_action.executable:true` and its\n   declared owner and capability delivery still match. When it is false, supply\n   every `recovery_action.required_inputs` value through that owner and use the\n   returned `argv_template`; never execute placeholders or copy another\n   session's capability. Use\n   `main-agent worker diagnose \u003Cassignment-id> --format json` for the same\n   evidence without the supervisor wrapper. Provider working text or a fresh\n   broker heartbeat alone is not progress: require the combined assignment,\n   provider activity, worktree material, claim\u002Fedit authority, authenticated\n   mailbox, and active\u002Funcertain-operation evidence.\n   `last_proven_safe_state` is the evidence boundary, while `recovery_action`\n   is the executable routing contract. When a macro stops, continue only from\n   both of those typed fields; never repeat the whole macro blindly. If a\n   facade action returns\n   `coordination-unauthorized`, diagnose the coordination state first with\n   `agent-session work-context status --format json` and `agent-session broker\n   status --session \"$AGENT_SESSION_ID\" --format json`. When those prove a stale\n   or lost broker for the still-authoritative controller incarnation and no\n   active or uncertain operation, run exact-controller `main-agent self recover` before attempting rebind.\n   `rebind` is reserved for a proven controller-incarnation mismatch;\n   it is not a stale-broker recovery and can\n   be rejected by the same authorization gate.\n   If ordinary hook capability validation fails, use only the finite\n   capability-failure-closed recovery lane: trusted version\u002Fstatus,\n   `self show`, `self recover`, `rehydrate`, and revision-fenced `rebind`\n   shapes. Arbitrary Bash, raw input, trust\u002Fauth\u002Fpermission\u002Faccount actions,\n   worker start, and repository mutation remain denied.\n   Service health, provider process health, provider session binding, and the Main relationship are four distinct states.\n   A healthy service restart does not repair a stale provider binding. With\n   explicit user authorization, use the typed provider restart-resume action\n   when available; otherwise gracefully stop the provider, run\n   `agent-session resume \u003Csession-id> --format json`, prove a new generation\n   and incarnation, revision-fence `rebind`, then re-read `self show`. Preserve\n   thread, account binding, repository\u002Fworktrees, workers, and the durable run.\n   Verify post-rebind assignment ownership before worker actions. Use a folded\n   rebind-and-adopt result when exposed; otherwise revision-fence `adopt` only\n   for assignments still bound to the exact prior run controller.\n   Stable dirty material, a renewed claim, a heartbeat, or provider `working`\n   text is not progress. When material fingerprints, provider\n   `last_progress_at`, assignment\u002Fcheckpoint revision time, mailbox state, and\n   operation state do not advance, stable dirty material plus stale provider progress is stalled\n   or attention-required, including capacity failures. Do not classify it as\n   healthy progress, and do not renew edit authority indefinitely without new\n   authoritative progress.\n   When supervision proves that an assignment completed authenticated\n   bootstrap into `working`, the exact bound worker runtime is stopped, the\n   worker session and incarnation are unchanged, and no admitted operation is\n   active or uncertain, require `classification:\"post_claim_failure\"`,\n   `last_proven_safe_state.post_claim_terminalization_safe:true`,\n   `automatic_retry_safe:false`, and\n   `recovery_action.kind:\"stopped_worker_terminalization\"`.\n   Require the public `main-agent.worker-diagnose-result.v2`,\n   `main-agent.worker-supervise-result.v2`, and\n   `main-agent.worker-recovery-action.v2` schemas; v1 projections are stale.\n   Require exactly\n   `recovery_action.required_inputs:[\"terminalization_reason\",\"idempotency_key\"]`;\n   a third input fails closed. Resolve both values through the declared Main\n   owner and use the returned `recovery_action.argv_template`.\n   A live or unknown runtime, or any active or uncertain operation must fail closed.\n   Run only the revision-fenced, idempotent typed action:\n\n   ```bash\n   main-agent worker reconcile-stopped \u003Cassignment-id> \\\n     --if-revision \u003Cassignment-revision> \\\n     --reason \u003Cbounded-terminalization-reason> \\\n     --idempotency-key \u003Cunique-key> --format json\n   ```\n\n   Require a `main-agent.worker-reconcile-stopped-result.v2` result with\n   `terminalized:true`, top-level `worker_claim_active_after:false`,\n   `input_sent:false`, `worktree_preserved:true`, and\n   `proof.worker_claim:{active_disposition:\"absent\",release_provenance:\"not_attributed_to_attempt\",observed_at_stage1:\u003Cbool>}`.\n   Claim absence is stable observed truth; never attribute it to the current\n   attempt. The action transitions only that assignment from `working` to\n   `cancelled`.\n   It fences the exact worker session authority against resume.\n   It installs a session-only authority quarantine for that exact worker.\n   It preserves a frozen assignment schema v3 for that exact worker.\n   Unrelated session, run, and coordination authority remains unchanged.\n   CLI and HTTP resume are denied while quarantined.\n   Read-only observational coordination access does not renew generic claims or operations.\n   It preserves its worktree, branch, diff, the durable run, and the Main session.\n   Two exact replay-safe cases may cross a now-stale revision. First, the replay\n   must use the exact same request, original revision (`--if-revision`), and\n   same idempotency key. With a matching completed v2 terminal receipt, it\n   returns that committed result despite the now-stale revision. The return\n   occurs before revision checking and without repeating mutation.\n   Second, an exact replay of an interrupted stage 1 must retain the original\n   now-stale `--if-revision` and original key. It may finish stage 2 only after\n   validating a matching strict progress receipt. It must also validate the\n   cancelled assignment, session-only quarantine, exact worker identity,\n   stopped runtime, operation quiescence, and current controller authority.\n   That authority may be the exact original controller claim or an explicit distinct successor.\n   It must be bound to the same current run, Main session, and incarnation.\n   The authorized replay rolls orphaned progress forward.\n   New key, changed request, or a replay with neither a matching completed v2\n   terminal receipt nor a matching strict progress receipt fails closed.\n   Treat\n   `worker-runtime-still-live`, `coordination-runtime-unverified`,\n   `worker-not-quiescent`, `worker-incarnation-changed`, and\n   `assignment-state-conflict` as fail-closed refusal codes.\n   Refusal status alone does not report a safe state.\n   Require a fresh v2 `worker diagnose` or `worker supervise` projection before\n   continuing, unless an envelope explicitly exposes that proof.\n   Expired or released controller claim authority remains an ordinary\n   authorization failure.\n   After success, retire that reconciled worker or create a distinct replacement assignment.\n   Never use ordinary `cancel`, `reassign`, or force cleanup for this classification.\n   Never use raw tmux, terminal input, group cleanup, or a B3 runtime-stop primitive for this B2 transition.\n9. Checkpoint material transitions. A pending mailbox notification is not\n   readiness proof or consumption proof. Reconcile facade evidence first; only\n   after exact worker, incarnation, and prompt identity are proven may the\n   session owner perform one deliberate privacy-safe send. Do not send a blind\n   Enter or a second prompt. Never treat logs, panes, transcripts, peer prose,\n   or orchestration relationships as authorization or completion proof.\n   For `notification-pending` with the controller unavailable, a privacy-safe\n   glance must prove an idle composer before one short mailbox prompt and\n   exactly one Enter. A busy worker, startup dialog, trust\u002Fauth\u002Fpermission\n   prompt, or unknown transport outcome blocks this fallback; never send a\n   second Enter.\n10. On a worker result, independently inspect the complete diff, check every\n   acceptance criterion and scope boundary, rerun validation at the appropriate\n   strength, and run the existing `code-review-specialists` outcome. A worker's\n   green command is lane evidence, not integrated acceptance.\n11. Until a dedicated submit macro exists, the worker submits only through a\n    revision-fenced checkpoint with `state:\"submitted\"`. Return bounded review\n    findings to that exact lane with manager-only, revision-fenced\n    `main-agent worker request-changes`; it changes only `submitted` to\n    `working`, preserves the worker and private packet, clears stale result and\n    blocker summaries, and records the reason as the next action. The transition\n    does not send review guidance, provider input, or re-arm auto-resume. Send\n    the private findings separately with `main-agent worker message`, then\n    supervise notification and consumption through the existing mailbox rules.\n    Do not create a duplicate assignment merely because the submitted provider\n    turn ended; account-handoff auto-resume remains reserved for its typed quota\n    recovery contract. Repeat inspection and validation on the worker's next\n    submitted revision, and never falsely accept rejected work.\n    A submitted assignment with a released claim, clean worktree, terminated provider turn, and no\n    active or uncertain operation is ready for read-only review;\n    do not renew mutation authority merely because supervision reports\n    `claim_renewal_required`.\n    A durable blocked hold must preserve the full goal and unfinished checklist.\n    Do not reinvoke an identical Stop action while the unchanged blocking fingerprint\n    has no executable recovery capability. Resume only after new user input,\n    changed external state, or a verified recovery transition.\n12. Use revision-fenced typed macros for recovery: `self recover`, `worker\n    start`, `worker supervise`, `guidance-reconcile`,\n    `guidance-quarantine`, `account-handoff`, `account-handoff-cancel`,\n    `reconcile-stopped`, `cancel`, `reassign`, `accept`, and `retire`. Account\n    selection, exact incumbent account binding, and structured auto-resume\n    re-arm are separate transitions; account binding is verified before\n    structured auto-resume is re-armed.\n    Never use `\u002Flogout` or raw terminal input to switch accounts.\n    A capability gap on an unmanaged\u002Fraw worker requires the typed executable\n    lifecycle fallback, not a daemon-only recovery claim.\n13. Retire an accepted terminal worker only after the facade and\n    session-management owner prove no active or uncertain operation remains,\n    the exact worker releases its claim, the durable logical-delete boundary\n    commits, and a fresh default list proves exact-incarnation absence. Keep\n    physical cleanup failures in the maintenance projection rather than the live\n    worker list. A stopped or rejected session whose assignment was never\n    accepted is not directly deletable: preserve its work and use typed\n    recovery for its proven classification. In particular,\n    `post_claim_failure` must pass through `reconcile-stopped` before retirement\n    or a distinct replacement.\n14. Checkpoint and close the run only when assignments are terminal or carry an\n    explicit retained exception and the active tier's durable gates pass.\n    Accept, merge, archive, and report only when provider delivery is available;\n    otherwise retain the bounded local result and state exactly what remains.\n\n## Run Closeout And Handoff\n\nThe Main Agent owns run closeout; a user-facing result does not by itself close\nthe durable run or release its coordination authority. Before ending or handing\noff a Main Agent Mode workflow:\n\n1. Reconcile any worker that still needs an explicit typed recovery decision.\n   When the run is terminal-ready, retain its current revision, write one\n   private final checkpoint file, choose one stable parent idempotency key, and\n   invoke the run-wide macro:\n\n   ```bash\n   main-agent closeout \\\n     --if-run-revision \u003Cinitial-run-revision> \\\n     --checkpoint-file \u003Cprivate-final-checkpoint-json> \\\n     --idempotency-key \u003Cstable-closeout-key> \\\n     --format json\n   ```\n\n2. Require `main-agent.closeout-result.v1` with `handoff_ready:true`,\n   `run_closed:true`, `workers_absent:true`, `cleanup_pending:false`,\n   `provider_session_preserved:true`, an empty `retained_exceptions`, and\n   `controller_claim.run_owned_claim_absent:true`. Retain\n   `expected_run_revision`, `checkpoint_revision`, `final_run_revision`,\n   `worker_dispositions`, and `progress_receipt.completed_stages` as the\n   bounded closeout proof.\n3. `handoff_ready:false` is a resumable partial result, not permission to\n   improvise cleanup. Inspect only its typed `retained_exceptions`,\n   `cleanup_pending`, worker dispositions, controller-claim disposition, and\n   completed stages. Resolve the named worker, operation, or maintenance\n   condition through its owner, then replay the identical checkpoint content,\n   original run revision, request, and parent idempotency key. Do not choose a\n   new key after a stage commits. A pre-provenance run that returns\n   `controller-claim-provenance-required` remains incomplete; never infer claim\n   ownership from matching context.\n4. Keep the Main provider session live until the user-facing result or handoff\n   prompt is delivered.\n   Physical provider-session stop or deletion is a later session-owner action;\n   the Main Agent must not terminate the transport that still owes the user its\n   final response.\n\n`worker retire`, `main-agent close`, and `work-context release` remain\ndiagnostic and intentional recovery primitives. They are not the normal\ncloseout path and must not replace exact replay of an admitted closeout macro.\n\n## Boundary\n\n- This skill exists only on supported managed runtimes with the required hook\n  runner and enforced interactive-session and acceptance boundary; unsupported\n  runtimes have no managed Main Agent Mode surface.\n- It consumes compatible deterministic `agent-session` primitives and existing\n  tier\u002Freview\u002Fdelivery outcomes. It adds no runtime graph, provider-specific\n  orchestration engine, or provider transport command.\n- Concrete provider transport mechanics remain runtime-owned. Main Agent Mode\n  consumes only `worker start --await-ready` and its typed authenticated\n  checkpoint proof, including the bounded `submit_key_recovery` result; it never\n  implements provider-specific paste, keypress, or pane heuristics.\n- Main Agent Mode never repairs trust, authentication, configuration, hooks,\n  updates, permissions, or services. The dry-run compatibility probe is the\n  only readiness fallback, and it never authorizes apply.\n","# Main Agent Mode\n\n## Contract\n\nPrereqs:\n\n- The user explicitly asks to enable or use Main Agent Mode for the bounded\n  workflow. Ordinary implementation requests never activate this mode.\n- `agent-session >=1.25.11` is installed from a trusted compatible surface.\n- The trusted `main-agent` facade from the compatible nils-cli surface is\n  executable and advertises the exact runtime-checkpoint and run-wide closeout\n  capabilities below.\n  The semantic-version floor alone is not sufficient. Until that surface is\n  available, report Main Agent Mode as unavailable without repairing or\n  restricting ordinary agent work.\n- A supported worker provider and executable provider helper pass the doctor\n  gate below before mode activation or worker launch.\n- The active project intent, work-tier, test-first, validation, review, and\n  delivery policies remain authoritative.\n- The detailed role, handoff, evidence, acceptance, and recovery protocol is\n  available at `references\u002FMAIN_AGENT_MODE_PROTOCOL.md`.\n\nInputs:\n\n- The accepted request, done criteria, constraints, repository, base ref, and\n  work tier.\n- The literal worker provider name, `codex` or `claude`, chosen from the\n  providers reported as supported by the installed `agent-session` doctor.\n- Existing plan, issue, run-state, PR, and worktree references when the tier\n  already owns them.\n- One private mode-0600 objective packet for a new run, or an authenticated\n  durable run relationship that `main-agent rehydrate` can recover.\n- An optional explicit `delegate-all` preference for L0\u002FL1 work.\n\nOutputs:\n\n- One main-agent-owned execution and acceptance result for the user.\n- One revisioned orchestration run whose assignments, relationships,\n  checkpoints, and privacy-safe projections survive compaction and resume.\n- Exact task packets and isolated managed worktree assignments for workers.\n- Bounded worker completion or blocker packets grounded in diff, validation,\n  and durable lifecycle evidence.\n- Independent main-agent inspection, validation, code-review synthesis,\n  acceptance decisions, and final reporting.\n\nFailure modes:\n\n- Activation was not explicit, or the requested scope\u002Fdone criteria are not\n  sufficiently bounded to delegate safely.\n- The installed `agent-session` is missing or older than `1.25.11`.\n- The trusted `main-agent` facade is absent, incompatible, untrusted, does not\n  advertise `main-agent.runtime-checkpoint-file.v1` and\n  `main-agent.run-wide-closeout.v1`, or cannot authenticate the current\n  managed-session incarnation.\n- Doctor output is unhealthy, unsupported, unavailable, malformed, or reports\n  a missing provider helper.\n- The bounded compatibility preview is not converged, would change state, or\n  exposes a representation conflict.\n- Provider readiness, prompt delivery, worker ownership, durable evidence,\n  scope, validation, review, or recovery cannot be established.\n\n## Explicit Activation\n\nActivate only after the user says to enable or use Main Agent Mode for the\ncurrent workflow. State that the mode is active, its bounded outcome, the\nselected worker provider, and whether L0\u002FL1 work is also delegated. Do not infer\nactivation from an ordinary request to implement, use subagents, work in\nparallel, or keep going. Activation does not persist into a later unrelated\nrequest, and an explicit user request to disable the mode takes effect before\nany new worker launch.\n\n## Entrypoint\n\nRun the installed version and doctor checks before activating the mode or\nlaunching any worker:\n\nFor a Codex worker, run these literal commands:\n\n```bash\nagent-session --version\nmain-agent capabilities --provider codex --format json\nmain-agent self readiness --format json\nagent-session activity doctor --agent codex --format json\n```\n\n\nRequire `agent-session >=1.25.11`, a valid\n`cli.main-agent.capabilities.v1` envelope with `ok:true`, whose\n`data.schema_version` is `main-agent.capabilities.v1` and whose\n`data.capabilities.runtime_checkpoint_file` is exactly\n`\"main-agent.runtime-checkpoint-file.v1\"`, whose\n`data.capabilities.runtime_hook_checkpoint_write` is exactly\n`\"runtime-kit.checkpoint-write-admission.v1\"`, and whose\n`data.capabilities.run_wide_closeout` is exactly\n`\"main-agent.run-wide-closeout.v1\"`, and whose\n`data.provider` matches the selected worker provider, and whose\n`data.compatible` is `true`. This provider-aware probe reads the deployed `agent-hook`\ninventory, requiring bundle version `2026.07.28.1` or newer plus the locked\ncoordination rules for the selected provider. It also requires that provider's\nconverged `agent-hook doctor` record and executes its installed\n`session-coordination-guard.py` capability self-probe, so a stale or missing\nselected-provider handler fails closed without coupling activation to another\nprovider installation. It therefore rejects either mixed deployment (new CLI\nwith old policy\u002Fhandler surfaces, or old CLI with the new runtime surfaces).\n\nRequire `main-agent self readiness` to return a valid\n`cli.main-agent.self-readiness.v1` envelope with `ok:true`, whose\n`data.schema_version` is `main-agent.runtime-readiness.v1`, whose `data.ready`\nis `true`, and whose `data.checkpoint_file` is an absolute path. This\nper-incarnation gate proves the current managed session received the exact\nruntime-issued environment path and still owns a private regular checkpoint\nfile. `runtime-checkpoint-unavailable` stops activation; resume or restart the\nmanaged session after the compatible surfaces are deployed. Do not run `init`\nor any Main Agent mutation from that incarnation.\n\nAlso require a valid\n`cli.agent-session.activity-doctor.v1` envelope with `ok:true`, exactly one\nmatching provider record, and `helper_executable:true`.\nRequire `classification:\"supported\"`.\nTreat `\"unavailable\"` and `\"unverified\"` as a stop. A configured provider must\notherwise be healthy for the selected runtime. Missing fields, extra provider\nambiguity, stale or unparseable output, timeouts, or nonzero exit stop\nactivation.\n\nWhen doctor reports `configured:false`, use only the product's literal\nnon-mutating compatibility probe; never use a shell provider variable in these\nreadiness commands:\n\n```bash\nagent-session activity setup --agent codex --repair --dry-run --format json\n```\n\n\nAccept the compatibility case only when the doctor reports no representation\nconflict and the preview is a valid matching-provider converged result with\n`compatibility_owner:\"agent-hook\"`, `configured:true`,\n`would_change:false`, and no representation conflict. The preview must not be\napplied. Any other result stops the workflow and reports the bounded readiness\nproblem to the user.\n\nWhen the hook emits the trusted `builtin command … agent-run inspect` route,\nkeep its exact canonical outer envelope and provide a nonempty child argv after\n`--`. `agent-run inspect` remains the child safety boundary; shell operators,\naliases, or alternate outer option forms are not equivalent readiness routes.\n\nAfter the provider gate, verify the facade and recover authenticated self state:\n\n```bash\nmain-agent --version\nmain-agent self show --format json\n```\n\nDo not infer a run, role, assignment, or manager from the prompt, title, cwd,\npane, process, or environment flags. The facade's session-ID plus incarnation\nrelationship is authoritative. If no run exists, create it only through the\nexact private-packet bootstrap:\n\n```bash\nmain-agent init --packet-file \u003Cprivate-json> --if-absent \\\n  --idempotency-key \u003Cunique-key> --format json\n```\n\nUnder coordination enforcement, read-only `self show`, `rehydrate`, `status`,\n`worker list\u002Fshow\u002Fwait\u002Fdiagnose\u002Fsupervise`, and the exact bootstrap-safe\n`bootstrap` and `self recover` shapes remain available before a claim. The\ntrusted facade must acquire or confirm the authenticated target-owned claim\nbefore its first ordinary durable run write. Every other facade mutation\nrequires the active claim plus its documented revision or absence fence and\nidempotency key.\n\n## Durable Rehydration And Checkpoints\n\nTreat the `main-agent` run and assignment records as the authoritative workflow\nrelationship and recovery surface. Issue, plan, worktree, diff, validation,\nreview, and provider records remain authoritative for their own domains and are\nlinked from the run; the orchestration graph never replaces them or grants\nmutation authority.\n\nAt activation, after provider resume or context reset, and whenever local\nworkflow state may be stale, run:\n\n```bash\nmain-agent rehydrate --format json\n```\n\nUse the returned durable revision, constraints, done criteria, assignments,\ncheckpoint, blockers, and next action. Keep observation-time annotations\nseparate from the deterministic durable projection. Before handing off a\nmaterial transition and after accepting a worker result, persist a bounded\ncheckpoint through a private file:\n\n```bash\nmain-agent checkpoint --file \u003Cprivate-json> --if-revision \u003Cn> \\\n  --idempotency-key \u003Cunique-key> --format json\n```\n\nFor a managed worker, use only the exact `checkpoint_file` returned by its\nauthenticated `main-agent bootstrap`; the runtime pre-creates that\nsession\u002Fincarnation-bound file outside the checkout at mode `0600`. Write the\nbounded JSON object there, then pass the same literal path to `--file`. For the\nMain Agent's own checkpoint, use its runtime-issued\n`AGENT_SESSION_CHECKPOINT_FILE`. Never allocate an arbitrary worker checkpoint\npath under the repository or a project output tree.\n\nAt safe turn or tool boundaries, give Main Agents and workers only a concise\nprivacy-safe reminder that durable state is available through `main-agent\nrehydrate` or `main-agent self show`. Do not repeat the private task packet,\nblock unrelated safe work, detect compaction heuristically, or expose private\npaths, capabilities, prompts, transcripts, or mailbox bodies.\n\n## Outcome Routing\n\nClassify the request before choosing workers. Main Agent Mode changes\nimplementation ownership, not the tier:\n\n- L0\u002FL1 remain inline unless the user requests `delegate-all`; when delegated,\n  use one isolated managed worker and keep the same parent outcome.\n- L2 retains the plan-tracking parent, but the main agent does not implement or\n  repair production or test code. One interactive managed worker owns the\n  implementation in an isolated managed worktree launched with\n  `--coordination-mode enforce`.\n- L3 retains exact independent lane workers and the dispatch orchestrator\n  acceptance boundary. The mode does not merge lanes or collapse their\n  worktrees, PRs, reviews, validation, or closeout.\n\nFor L2\u002FL3, main-agent writes are limited to orchestration, plan\u002Frun-state,\nevidence, review synthesis, and authorized provider lifecycle actions. Return\ncode findings to the same worker and lane unless the main agent records an\nexplicit reassignment under the recovery protocol.\n\n## Workflow\n\n1. Confirm explicit activation, bounded done criteria, worker provider, tier,\n   and any L0\u002FL1 `delegate-all` preference.\n2. Pass the version, doctor, and conditional dry-run compatibility gates. Do\n   not launch a worker while readiness is uncertain.\n3. Run authenticated `main-agent self show`. Rehydrate an existing run or use\n   the exact `init` bootstrap with a private packet. Reconcile the returned run\n   with durable issue\u002Fplan\u002Frun-state\u002Fworktree evidence; never create a second\n   run merely because local conversation context is missing.\n4. Create one revision-fenced assignment per implementation owner through the\n   facade. Each private packet names a repository, non-overlapping scope,\n   invariants, exclusions, base, isolated managed worktree, test-first and\n   validation duties, delivery artifact duties, and the exact\n   completion\u002Fblocker packet. The Main Agent claim must not overlap a worker\n   scope. For a mutating worker, the packet `worktree`, `launch.cwd`, durable\n   assignment worktree, and authenticated worker cwd must resolve to the same\n   canonical checkout root before bootstrap can mint its shell grant. Keep\n   worker path scopes narrow; do not add repository scope merely so\n   the worker can run tests, validation, delivery, or checkpoint commands.\n   Authenticated worker bootstrap mints a private checkout-shell grant on the\n   exact assignment-derived claim; admission also requires the matching\n   repository and worktree fingerprint. This grant is checkout-level\n   coordination, not a path sandbox: reject final diffs outside the assigned\n   scopes. The assignment relationship is routing metadata and\n   transfers no repository or provider authority. When a packet declares `depends_on`, every\n   named assignment must belong to the same run and already be `accepted` or\n   `released` before launch. On `dependency-not-satisfied`, no dependent\n   assignment was created: wait boundedly for each upstream assignment's\n   terminal transition, re-read it, and retry the unchanged launch only after\n   every dependency is accepted or released. Missing, cross-run, cancelled, or\n   other pre-terminal dependencies remain blocking.\n5. Run the candidate conflict check, then launch through the folded readiness\n   boundary:\n\n   ```bash\n   main-agent worker start --assignment-file \u003Cprivate-json> --await-ready 5m \\\n     --idempotency-key \u003Cunique-key> --format json\n   ```\n\n   The assignment itself must request the isolated worktree and\n   `--coordination-mode enforce`.\n6. Branch only on the returned typed readiness. Continue immediately only for\n   `state:\"ready\"`, `delivery.state:\"confirmed\"`, and\n   `delivery.proof:\"authenticated-worker-checkpoint\"`. For a fresh supported\n   worker whose assignment remains `starting`, the folded runtime may submit\n   exactly one recovery Enter within the original wait deadline after rechecking\n   the exact session incarnation and live runtime. The prompt is never resent.\n   The runtime owns this recovery decision and keypress; the Main Agent only\n   verifies the `submit_key_recovery` projection and accepts either the initial\n   `submit-command-succeeded` transport or the recovered\n   `submit-key-recovery-succeeded` transport when the authenticated checkpoint\n   also succeeds. A\n   `state:\"readiness_failed\"` result has `delivery.state:\"unverified\"` and\n   `automatic_retry_safe:false`: runtime recovery is then exhausted or\n   ineligible, so do not resend the prompt, inject another Enter, or inspect a\n   pane\u002Ftranscript to overrule it. Retain the exact worker and typed safe state\n   for diagnostics. A folded start result with a non-authoritative starting\n   failure is only a provisional snapshot: if the same bound incarnation later\n   completes authenticated bootstrap, supervise that incarnation and continue\n   it instead of launching a duplicate.\n   A folded `readiness_failed` snapshot can be superseded by that newer authoritative evidence from the same\n   incarnation; it never authorizes a second prompt, Enter, assignment, or\n   worker.\n7. The generated worker prompt invokes the exact compatible executable's\n   `main-agent bootstrap` command. The authenticated worker alone resolves its\n   private assignment, acquires the assignment-derived claim, and records the\n   revision-fenced `working` checkpoint that proves readiness. A released or\n   expired claim must be reacquired and verified before a later mutation turn.\n   The launcher never uses the target capability or claims on its behalf, and\n   interference or deletion before this handoff fails the ownership proof.\n8. Monitor actively through the repeatable bounded macro:\n\n   ```bash\n   main-agent worker supervise \u003Cassignment-id> --format json\n   ```\n\n   Run it after every bounded wait timeout or contradictory snapshot and branch\n   on `classification` and `recovery_action.kind`, not prose. Execute\n   `recovery_action.argv` only when `recovery_action.executable:true` and its\n   declared owner and capability delivery still match. When it is false, supply\n   every `recovery_action.required_inputs` value through that owner and use the\n   returned `argv_template`; never execute placeholders or copy another\n   session's capability. Use\n   `main-agent worker diagnose \u003Cassignment-id> --format json` for the same\n   evidence without the supervisor wrapper. Provider working text or a fresh\n   broker heartbeat alone is not progress: require the combined assignment,\n   provider activity, worktree material, claim\u002Fedit authority, authenticated\n   mailbox, and active\u002Funcertain-operation evidence.\n   `last_proven_safe_state` is the evidence boundary, while `recovery_action`\n   is the executable routing contract. When a macro stops, continue only from\n   both of those typed fields; never repeat the whole macro blindly. If a\n   facade action returns\n   `coordination-unauthorized`, diagnose the coordination state first with\n   `agent-session work-context status --format json` and `agent-session broker\n   status --session \"$AGENT_SESSION_ID\" --format json`. When those prove a stale\n   or lost broker for the still-authoritative controller incarnation and no\n   active or uncertain operation, run exact-controller `main-agent self recover` before attempting rebind.\n   `rebind` is reserved for a proven controller-incarnation mismatch;\n   it is not a stale-broker recovery and can\n   be rejected by the same authorization gate.\n   If ordinary hook capability validation fails, use only the finite\n   capability-failure-closed recovery lane: trusted version\u002Fstatus,\n   `self show`, `self recover`, `rehydrate`, and revision-fenced `rebind`\n   shapes. Arbitrary Bash, raw input, trust\u002Fauth\u002Fpermission\u002Faccount actions,\n   worker start, and repository mutation remain denied.\n   Service health, provider process health, provider session binding, and the Main relationship are four distinct states.\n   A healthy service restart does not repair a stale provider binding. With\n   explicit user authorization, use the typed provider restart-resume action\n   when available; otherwise gracefully stop the provider, run\n   `agent-session resume \u003Csession-id> --format json`, prove a new generation\n   and incarnation, revision-fence `rebind`, then re-read `self show`. Preserve\n   thread, account binding, repository\u002Fworktrees, workers, and the durable run.\n   Verify post-rebind assignment ownership before worker actions. Use a folded\n   rebind-and-adopt result when exposed; otherwise revision-fence `adopt` only\n   for assignments still bound to the exact prior run controller.\n   Stable dirty material, a renewed claim, a heartbeat, or provider `working`\n   text is not progress. When material fingerprints, provider\n   `last_progress_at`, assignment\u002Fcheckpoint revision time, mailbox state, and\n   operation state do not advance, stable dirty material plus stale provider progress is stalled\n   or attention-required, including capacity failures. Do not classify it as\n   healthy progress, and do not renew edit authority indefinitely without new\n   authoritative progress.\n   When supervision proves that an assignment completed authenticated\n   bootstrap into `working`, the exact bound worker runtime is stopped, the\n   worker session and incarnation are unchanged, and no admitted operation is\n   active or uncertain, require `classification:\"post_claim_failure\"`,\n   `last_proven_safe_state.post_claim_terminalization_safe:true`,\n   `automatic_retry_safe:false`, and\n   `recovery_action.kind:\"stopped_worker_terminalization\"`.\n   Require the public `main-agent.worker-diagnose-result.v2`,\n   `main-agent.worker-supervise-result.v2`, and\n   `main-agent.worker-recovery-action.v2` schemas; v1 projections are stale.\n   Require exactly\n   `recovery_action.required_inputs:[\"terminalization_reason\",\"idempotency_key\"]`;\n   a third input fails closed. Resolve both values through the declared Main\n   owner and use the returned `recovery_action.argv_template`.\n   A live or unknown runtime, or any active or uncertain operation must fail closed.\n   Run only the revision-fenced, idempotent typed action:\n\n   ```bash\n   main-agent worker reconcile-stopped \u003Cassignment-id> \\\n     --if-revision \u003Cassignment-revision> \\\n     --reason \u003Cbounded-terminalization-reason> \\\n     --idempotency-key \u003Cunique-key> --format json\n   ```\n\n   Require a `main-agent.worker-reconcile-stopped-result.v2` result with\n   `terminalized:true`, top-level `worker_claim_active_after:false`,\n   `input_sent:false`, `worktree_preserved:true`, and\n   `proof.worker_claim:{active_disposition:\"absent\",release_provenance:\"not_attributed_to_attempt\",observed_at_stage1:\u003Cbool>}`.\n   Claim absence is stable observed truth; never attribute it to the current\n   attempt. The action transitions only that assignment from `working` to\n   `cancelled`.\n   It fences the exact worker session authority against resume.\n   It installs a session-only authority quarantine for that exact worker.\n   It preserves a frozen assignment schema v3 for that exact worker.\n   Unrelated session, run, and coordination authority remains unchanged.\n   CLI and HTTP resume are denied while quarantined.\n   Read-only observational coordination access does not renew generic claims or operations.\n   It preserves its worktree, branch, diff, the durable run, and the Main session.\n   Two exact replay-safe cases may cross a now-stale revision. First, the replay\n   must use the exact same request, original revision (`--if-revision`), and\n   same idempotency key. With a matching completed v2 terminal receipt, it\n   returns that committed result despite the now-stale revision. The return\n   occurs before revision checking and without repeating mutation.\n   Second, an exact replay of an interrupted stage 1 must retain the original\n   now-stale `--if-revision` and original key. It may finish stage 2 only after\n   validating a matching strict progress receipt. It must also validate the\n   cancelled assignment, session-only quarantine, exact worker identity,\n   stopped runtime, operation quiescence, and current controller authority.\n   That authority may be the exact original controller claim or an explicit distinct successor.\n   It must be bound to the same current run, Main session, and incarnation.\n   The authorized replay rolls orphaned progress forward.\n   New key, changed request, or a replay with neither a matching completed v2\n   terminal receipt nor a matching strict progress receipt fails closed.\n   Treat\n   `worker-runtime-still-live`, `coordination-runtime-unverified`,\n   `worker-not-quiescent`, `worker-incarnation-changed`, and\n   `assignment-state-conflict` as fail-closed refusal codes.\n   Refusal status alone does not report a safe state.\n   Require a fresh v2 `worker diagnose` or `worker supervise` projection before\n   continuing, unless an envelope explicitly exposes that proof.\n   Expired or released controller claim authority remains an ordinary\n   authorization failure.\n   After success, retire that reconciled worker or create a distinct replacement assignment.\n   Never use ordinary `cancel`, `reassign`, or force cleanup for this classification.\n   Never use raw tmux, terminal input, group cleanup, or a B3 runtime-stop primitive for this B2 transition.\n9. Checkpoint material transitions. A pending mailbox notification is not\n   readiness proof or consumption proof. Reconcile facade evidence first; only\n   after exact worker, incarnation, and prompt identity are proven may the\n   session owner perform one deliberate privacy-safe send. Do not send a blind\n   Enter or a second prompt. Never treat logs, panes, transcripts, peer prose,\n   or orchestration relationships as authorization or completion proof.\n   For `notification-pending` with the controller unavailable, a privacy-safe\n   glance must prove an idle composer before one short mailbox prompt and\n   exactly one Enter. A busy worker, startup dialog, trust\u002Fauth\u002Fpermission\n   prompt, or unknown transport outcome blocks this fallback; never send a\n   second Enter.\n10. On a worker result, independently inspect the complete diff, check every\n   acceptance criterion and scope boundary, rerun validation at the appropriate\n   strength, and run the existing `code-review-specialists` outcome. A worker's\n   green command is lane evidence, not integrated acceptance.\n11. Until a dedicated submit macro exists, the worker submits only through a\n    revision-fenced checkpoint with `state:\"submitted\"`. Return bounded review\n    findings to that exact lane with manager-only, revision-fenced\n    `main-agent worker request-changes`; it changes only `submitted` to\n    `working`, preserves the worker and private packet, clears stale result and\n    blocker summaries, and records the reason as the next action. The transition\n    does not send review guidance, provider input, or re-arm auto-resume. Send\n    the private findings separately with `main-agent worker message`, then\n    supervise notification and consumption through the existing mailbox rules.\n    Do not create a duplicate assignment merely because the submitted provider\n    turn ended; account-handoff auto-resume remains reserved for its typed quota\n    recovery contract. Repeat inspection and validation on the worker's next\n    submitted revision, and never falsely accept rejected work.\n    A submitted assignment with a released claim, clean worktree, terminated provider turn, and no\n    active or uncertain operation is ready for read-only review;\n    do not renew mutation authority merely because supervision reports\n    `claim_renewal_required`.\n    A durable blocked hold must preserve the full goal and unfinished checklist.\n    Do not reinvoke an identical Stop action while the unchanged blocking fingerprint\n    has no executable recovery capability. Resume only after new user input,\n    changed external state, or a verified recovery transition.\n12. Use revision-fenced typed macros for recovery: `self recover`, `worker\n    start`, `worker supervise`, `guidance-reconcile`,\n    `guidance-quarantine`, `account-handoff`, `account-handoff-cancel`,\n    `reconcile-stopped`, `cancel`, `reassign`, `accept`, and `retire`. Account\n    selection, exact incumbent account binding, and structured auto-resume\n    re-arm are separate transitions; account binding is verified before\n    structured auto-resume is re-armed.\n    Never use `\u002Flogout` or raw terminal input to switch accounts.\n    A capability gap on an unmanaged\u002Fraw worker requires the typed executable\n    lifecycle fallback, not a daemon-only recovery claim.\n13. Retire an accepted terminal worker only after the facade and\n    session-management owner prove no active or uncertain operation remains,\n    the exact worker releases its claim, the durable logical-delete boundary\n    commits, and a fresh default list proves exact-incarnation absence. Keep\n    physical cleanup failures in the maintenance projection rather than the live\n    worker list. A stopped or rejected session whose assignment was never\n    accepted is not directly deletable: preserve its work and use typed\n    recovery for its proven classification. In particular,\n    `post_claim_failure` must pass through `reconcile-stopped` before retirement\n    or a distinct replacement.\n14. Checkpoint and close the run only when assignments are terminal or carry an\n    explicit retained exception and the active tier's durable gates pass.\n    Accept, merge, archive, and report only when provider delivery is available;\n    otherwise retain the bounded local result and state exactly what remains.\n\n## Run Closeout And Handoff\n\nThe Main Agent owns run closeout; a user-facing result does not by itself close\nthe durable run or release its coordination authority. Before ending or handing\noff a Main Agent Mode workflow:\n\n1. Reconcile any worker that still needs an explicit typed recovery decision.\n   When the run is terminal-ready, retain its current revision, write one\n   private final checkpoint file, choose one stable parent idempotency key, and\n   invoke the run-wide macro:\n\n   ```bash\n   main-agent closeout \\\n     --if-run-revision \u003Cinitial-run-revision> \\\n     --checkpoint-file \u003Cprivate-final-checkpoint-json> \\\n     --idempotency-key \u003Cstable-closeout-key> \\\n     --format json\n   ```\n\n2. Require `main-agent.closeout-result.v1` with `handoff_ready:true`,\n   `run_closed:true`, `workers_absent:true`, `cleanup_pending:false`,\n   `provider_session_preserved:true`, an empty `retained_exceptions`, and\n   `controller_claim.run_owned_claim_absent:true`. Retain\n   `expected_run_revision`, `checkpoint_revision`, `final_run_revision`,\n   `worker_dispositions`, and `progress_receipt.completed_stages` as the\n   bounded closeout proof.\n3. `handoff_ready:false` is a resumable partial result, not permission to\n   improvise cleanup. Inspect only its typed `retained_exceptions`,\n   `cleanup_pending`, worker dispositions, controller-claim disposition, and\n   completed stages. Resolve the named worker, operation, or maintenance\n   condition through its owner, then replay the identical checkpoint content,\n   original run revision, request, and parent idempotency key. Do not choose a\n   new key after a stage commits. A pre-provenance run that returns\n   `controller-claim-provenance-required` remains incomplete; never infer claim\n   ownership from matching context.\n4. Keep the Main provider session live until the user-facing result or handoff\n   prompt is delivered.\n   Physical provider-session stop or deletion is a later session-owner action;\n   the Main Agent must not terminate the transport that still owes the user its\n   final response.\n\n`worker retire`, `main-agent close`, and `work-context release` remain\ndiagnostic and intentional recovery primitives. They are not the normal\ncloseout path and must not replace exact replay of an admitted closeout macro.\n\n## Boundary\n\n- This skill exists only on supported managed runtimes with the required hook\n  runner and enforced interactive-session and acceptance boundary; unsupported\n  runtimes have no managed Main Agent Mode surface.\n- It consumes compatible deterministic `agent-session` primitives and existing\n  tier\u002Freview\u002Fdelivery outcomes. It adds no runtime graph, provider-specific\n  orchestration engine, or provider transport command.\n- Concrete provider transport mechanics remain runtime-owned. Main Agent Mode\n  consumes only `worker start --await-ready` and its typed authenticated\n  checkpoint proof, including the bounded `submit_key_recovery` result; it never\n  implements provider-specific paste, keypress, or pane heuristics.\n- Main Agent Mode never repairs trust, authentication, configuration, hooks,\n  updates, permissions, or services. The dry-run compatibility probe is the\n  only readiness fallback, and it never authorizes apply.\n",{"name":5,"description":7},"main","da7119f2ebece510d6955cea72743069f5496c73","tests\u002Fgolden\u002Fcodex\u002Fplugins\u002Fconversation\u002Fskills\u002Fmain-agent-mode\u002Fexpected","https:\u002F\u002Fgithub.com\u002Fgraysurf\u002Fagent-runtime-kit","https:\u002F\u002Fgithub.com\u002Fgraysurf","Building reliable tools for teams of AI coding agents · Rust \u002F TypeScript · @sympoies","2026-08-29 05:27:47",{"source":8,"skillName":5,"commands":31,"prompt":41,"zipAvailable":42},[32,35,38],{"tool":33,"command":34},"npx","npx skills add graysurf\u002Fagent-runtime-kit --skill main-agent-mode",{"tool":36,"command":37},"bunx","bunx skills add graysurf\u002Fagent-runtime-kit --skill main-agent-mode",{"tool":39,"command":40},"pnpm","pnpm dlx skills add graysurf\u002Fagent-runtime-kit --skill main-agent-mode","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fgraysurf\u002Fagent-runtime-kit\u002Fblob\u002Fmain\u002Ftests\u002Fgolden\u002Fcodex\u002Fplugins\u002Fconversation\u002Fskills\u002Fmain-agent-mode\u002Fexpected\u002FSKILL.md",true,[44],{"path":45,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":48,"sourceHtmlUrl":49},"references\u002FMAIN_AGENT_MODE_PROTOCOL.md","REFERENCE","参考文档",39624,"https:\u002F\u002Fgithub.com\u002Fgraysurf\u002Fagent-runtime-kit\u002Fblob\u002Fmain\u002Ftests\u002Fgolden\u002Fcodex\u002Fplugins\u002Fconversation\u002Fskills\u002Fmain-agent-mode\u002Fexpected\u002Freferences\u002FMAIN_AGENT_MODE_PROTOCOL.md",[51,57,62,69,76,83],{"skillNo":52,"name":53,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":54,"categories":55,"keywords":56,"publishedAt":18},"01M736XWK14DFRERMQ8RT3HS0Z","removable-skill","https:\u002F\u002Fgithub.com\u002Fgraysurf\u002Fagent-runtime-kit\u002Fblob\u002Fmain\u002Ftests\u002Fruntime-smoke\u002Ffixtures\u002Fskill-lifecycle\u002Fremove-skill\u002Ftests\u002Fgolden\u002Fcodex\u002Fplugins\u002Ffixture\u002Fskills\u002Fremovable-skill\u002FSKILL.md",[],[],{"skillNo":58,"name":53,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":18},"01M736XTPQEKAYESDM1REN2KAN","https:\u002F\u002Fgithub.com\u002Fgraysurf\u002Fagent-runtime-kit\u002Fblob\u002Fmain\u002Ftests\u002Fruntime-smoke\u002Ffixtures\u002Fskill-lifecycle\u002Fremove-skill\u002Ftests\u002Fgolden\u002Fclaude\u002Fplugins\u002Ffixture\u002Fskills\u002Fremovable-skill\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":18},"01M736XRMWHMJB4X563G9J6QYY","removable-project-skill","Fixture project-local skill used to prove remove-project-skill dry-run coverage.","https:\u002F\u002Fgithub.com\u002Fgraysurf\u002Fagent-runtime-kit\u002Fblob\u002Fmain\u002Ftests\u002Fruntime-smoke\u002Ffixtures\u002Fskill-lifecycle\u002Fremove-project-skill\u002F.agents\u002Fskills\u002Fremovable-project-skill\u002FSKILL.md",[],[],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":18},"01M736XPT65YZMPCBD4K3RHV4P","project-sample-skill","Fixture project-local skill used to prove create-project-skill governance coverage.","https:\u002F\u002Fgithub.com\u002Fgraysurf\u002Fagent-runtime-kit\u002Fblob\u002Fmain\u002Ftests\u002Fruntime-smoke\u002Ffixtures\u002Fskill-lifecycle\u002Fcreate-project-skill\u002F.agents\u002Fskills\u002Fproject-sample-skill\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":18},"01M736XKZVYWVQA1YB0P459WND","project-local-skill","Fixture project-local skill used by runtime-kit project-local smoke checks.","https:\u002F\u002Fgithub.com\u002Fgraysurf\u002Fagent-runtime-kit\u002Fblob\u002Fmain\u002Ftests\u002Fprojects\u002Fproject-local-smoke\u002F.agents\u002Fskills\u002Fproject-local-skill\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":18},"01M736XHA73KZ5G2TKWSED5P1B","topic-radar","Aggregate read-only AI and technology trend signals (Polymarket, Hacker News, GitHub, arXiv, Hugging Face, news search) into source-grounded Markdown or JSON; the lower-level data engine behind `daily-brief`.","https:\u002F\u002Fgithub.com\u002Fgraysurf\u002Fagent-runtime-kit\u002Fblob\u002Fmain\u002Ftests\u002Fgolden\u002Fhermes\u002Fplugins\u002Freporting\u002Fskills\u002Ftopic-radar\u002Fexpected\u002FSKILL.md",[],[]]