{
  "hooks": {
    "SubagentStop": [
      {
        "hooks": [
          {
            "type": "prompt",
            "prompt": "<subagent-stop-hook>\n## Workflow Enforcement - SubagentStop Hook\n\nA subagent has completed. Determine and execute the next workflow phase.\n\n<verification-gates>\n### Verification Gates\n\nBefore proceeding to any next phase, verify the required previous steps completed.\n\n---\n\n## Gate 1: Before Exploration (Phase 4)\n\n**Required**: Worktree must have been created via `next-task:worktree-manager` agent.\n\n```javascript\nconst state = workflowState.readState();\nif (!state.worktree || !state.worktree.path) {\n  console.error('[BLOCKED] Cannot proceed to exploration - worktree not created');\n  return { blocked: true, reason: 'worktree-missing' };\n}\nconsole.log(`[VERIFIED] Worktree exists: ${state.worktree.path}`);\n```\n\n**Forbidden**:\n- Using `git checkout -b` directly\n- Using `git branch` directly\n- Proceeding to exploration without worktree verification\n\n---\n\n## Gate 2: Before Delivery Validation (Phase 10)\n\n**Required**: Review loop must have run with proper iterations.\n\n```javascript\nconst state = workflowState.readState();\nconst reviewResult = state.phases?.reviewLoop;\nif (!reviewResult || reviewResult.iterations < 1) {\n  console.error('[BLOCKED] Review loop must run at least 1 iteration');\n  return { blocked: true, reason: 'review-iterations-zero' };\n}\nif (!reviewResult.approved && !reviewResult.orchestratorOverride) {\n  console.error('[BLOCKED] Review not approved');\n  return { blocked: true, reason: 'review-not-approved' };\n}\nconsole.log(`[VERIFIED] Review: ${reviewResult.iterations} iterations`);\n```\n\n**Forbidden**:\n- Skipping to delivery without running review loop\n- Running review with 0 iterations\n\n---\n\n## Gate 3: Before /ship Merge\n\n**Required**: All PR comments must be addressed.\n\nEnforced in /ship command:\n1. Phase 4 CI & Review Monitor Loop must run\n2. 3-minute wait for auto-reviewers must complete\n3. All comments must be addressed before merge\n</verification-gates>\n\n---\n\n<decision-tree>\n### Decision Tree\n\n1. **worktree-manager completed**: Verify worktree path, then run exploration-agent\n2. **implementation-agent completed**: Run deslop:deslop-agent + test-coverage-checker (parallel)\n3. **pre-review gates completed**: Run review loop (min 1 iteration), then delivery-validator\n4. **delivery-validator completed**: If approved, run sync-docs:sync-docs-agent. If not, return to implementation.\n5. **sync-docs:sync-docs-agent completed**: Invoke /ship command\n</decision-tree>\n\n---\n\n<enforcement>\n### Enforcement\n\nEvery step exists for a reason. Taking shortcuts defeats the purpose of automation.\n\n- Do not skip worktree-manager (enables parallel task isolation)\n- Do not skip review iterations (catches bugs humans miss)\n- Do not skip 3-minute wait in /ship (auto-reviewers need time)\n- Do not skip addressing PR comments (blocks merge)\n\nIf you think a step is unnecessary, you are wrong.\n</enforcement>\n\n---\n\n<workflow-sequence>\n### Workflow Sequence\n\n1. task-discoverer\n2. [GATE] worktree-manager (must use agent)\n3. [VERIFY] worktree exists\n4. exploration-agent\n5. planning-agent\n6. implementation-agent\n7. pre-review gates (deslop + test-coverage)\n8. review loop (1+ iterations)\n9. [GATE] delivery-validator\n10. sync-docs:sync-docs-agent\n11. /ship command (must run Phase 4 loop)\n</workflow-sequence>\n\nReturn: {\"ok\": true, \"nextPhase\": \"<phase-name>\", \"verified\": [\"<gate-name>\"]}\n</subagent-stop-hook>"
          }
        ]
      }
    ]
  }
}
