[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71J30MNXE7C8QCMXBR1RGDN":3,"skill-same:01M71J30MNXE7C8QCMXBR1RGDN":82},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":37,"linkOnly":38,"markdownContent":39,"markdownBody":40,"frontMatter":41,"refName":42,"commitSha":43,"skillDirectory":44,"forksCount":13,"repositoryHtmlUrl":45,"repositoryHomepageUrl":6,"ownerHtmlUrl":46,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":47,"install":48,"resources":61},"01M71J30MNXE7C8QCMXBR1RGDN","drive",null,"Automatically cycles through implementation, PR creation, self-review, and fixes from an Issue or an instruction to produce a merge-ready PR. Supports single\u002Fmultiple Issues\u002FPRs and explicit dependency notation. Can optionally run through to merge. In orchestration, detects and self-resolves cross-cutting concerns before merge, leaving no follow-up within a single run.","ozzy-labs\u002Fskills","ozzy-labs","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F246109093?v=4","01M6H0M2K2PZXHWNHJJTWY20FY","01M71J2B6FZ5KPEXPR5VS1TX7Z",0,"MIT","https:\u002F\u002Fgithub.com\u002Fozzy-labs\u002Fskills\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fdrive\u002FSKILL.md",[],[5,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36],"merge","can","produce","single","prs","fixes","pr","follow-up","issue","pr creation","run","dependency","self","review","orchestration","issues","up","creation","ready","2026-11-10 10:12:30",false,"---\nname: drive\ndescription: Automatically cycles through implementation, PR creation, self-review, and fixes from an Issue or an instruction to produce a merge-ready PR. Supports single\u002Fmultiple Issues\u002FPRs and explicit dependency notation. Can optionally run through to merge. In orchestration, detects and self-resolves cross-cutting concerns before merge, leaving no follow-up within a single run.\n---\n\n# drive - Autonomously driving from an Issue to a merge-ready PR\n\nTakes an Issue or an instruction and automatically repeats implement → ship → self-review → fix to produce a merge-ready PR. Supports parallel driving of multiple Issues\u002FPRs, and can optionally complete all the way through to merge.\n\nDeterminism (argument parsing, target expansion, DAG\u002Fwave construction, cycle detection, concurrency\u002Freview-mode resolution, aggregating worker return values, and report formatting) is handled by the two bundled engines ([ADR-0028](https:\u002F\u002Fgithub.com\u002Fozzy-labs\u002Fhandbook\u002Fblob\u002Fmain\u002Fadr\u002F0028-skills-architecture-engine-judgment-policy-catalog.md) R1, following the precedent of `health-check.mjs` \u002F `topics.mjs` \u002F `review.mjs`):\n\n- **`drive-plan.mjs`**: Input (argument string + optional target meta) → wave configuration JSON. Handles target expansion, `->` dependency parsing, DAG construction, topological wave splitting, circular dependency detection, mode branching, and concurrency\u002Freview mode resolution.\n- **`drive-report.mjs`**: Aggregates worker return-value JSON → formats the single-mode Phase 5 completion report \u002F the orchestration Phase Final-6 aggregate report. Handles review aggregation (by_axis \u002F total), cross-cutting gaps display, and the output decision for the `再開: \u002Fdrive \u003C元の引数>` line.\n\nThis SKILL.md is confined to the judgment layer — when to call the engine, the meaning of each Phase, the per-axis exit determination for the review loop, the folding decision for cross-cutting concerns, and where to confirm with a human. This file is the SSOT for the behavioral contract (the semantics of Phase 1-5 \u002F Phase Final-1–6, failure semantics, and the meaning of `--merge` \u002F `--review` \u002F `--concurrency`).\n\n## Input parsing\n\nArgument parsing is handled by `drive-plan.mjs` (in the same directory as this SKILL.md; on Claude Code it's `~\u002F.claude\u002Fskills\u002Fdrive\u002Fdrive-plan.mjs`, and for dogfooding it's `\u003Crepo>\u002F.claude\u002Fskills\u002Fdrive\u002Fdrive-plan.mjs`):\n\n```bash\nnode \u003Cこの skill のディレクトリ>\u002Fdrive-plan.mjs \"\u003C元の引数>\" [--meta-file \u003Cpath>] [--json]\n```\n\nContent resolved by the engine (behavioral contract):\n\n- **Target expansion:** single `#42` \u002F `42`, comma-separated `#1,#2`, range `#3-5` → `#3,#4,#5`, whitespace-separated `#1 #2`, mixed `#1,#3-5`. An argument matching none of these is treated as a text instruction (single target).\n- **Explicit dependency notation `->`:** `#1,#2 -> #3` (#1 and #2 run in parallel → #3 runs after both complete), `#1 -> #2 -> #3` (fully sequential).\n- **DAG construction:** explicit dependencies (highest priority) + PR base↔head matching (stacked) + best-effort detection of \"depends on #X\" in the issue body (when issue\u002FPR meta is passed via `--meta-file`).\n- **Wave splitting \u002F cycle detection:** splits into topological levels. If a circular dependency exists, returns `error` + `cycle` (→ report and abort).\n- **Mode branching:** 1 target with no dependencies → single mode; 2 or more targets, or dependencies present → orchestration mode.\n- **Concurrency \u002F review mode:** default `min(4, task count)`, overridable via `--concurrency` (>8 only warns). Orchestration forces `--review=quick` (`final-deep`\u002F`deep` are downgraded with a warning).\n\nThe `resume_command` in the engine output (`--json`) is already assembled according to the \"Argument restoration (resume command)\" convention.\n\n### Options\n\n- `--merge`: Attempts an automatic merge. The merge follows the central autonomy policy's `irreversible` gate (see \"Merge and the autonomy policy\" below). **The `--merge` flag itself is an explicit opt-in** — it treats the user as having already delegated autonomous merging, overriding the gate to `proceed` (merge without confirmation)\n- `--concurrency N`: Overrides the concurrency level (default `min(4, task count)`, N > 8 only warns)\n- `--review=\u003Cmode>`: review mode (default `quick`). The value is one of the following:\n  - `quick` (default): quick mode for every review pass (up to 3 iterations)\n  - `final-deep`: loops in quick mode up to 2 times, then upgrades only the final pass to deep (quick 2 + deep 1)\n  - `deep`: deep mode for every pass (up to 1 iteration; prevents cost blowup)\n\n  In orchestration mode, `--review=quick` is forced; if `final-deep` \u002F `deep` is specified, a warning is shown and it falls back to `quick`.\n\n- usage-guard: pauses work just before the Claude Code Usage Limit is exceeded, and automatically resumes once the budget recovers. **Enabled by default (opt-out)**. Add `--no-usage-guard` to disable it. Takes effect **only in the Claude Code environment** (same treatment as `review --deep`; it depends on the OAuth usage-rate endpoint + `ScheduleWakeup`, so it's a no-op on other adapters). It's ON by default, but only takes effect on the claude-code adapter — other adapters (codex\u002Fgemini\u002Fcopilot) do nothing, as before. Since the pause\u002Fresume wiring is host-dependent, it is absorbed into \"usage-guard wiring (default ON, disabled via `--no-usage-guard`)\" in `SKILL.claude-code.md`.\n  - `--no-usage-guard`: disables usage-guard and runs a plain drive with no checkpoints inserted at all.\n  - `--usage-guard`: a **deprecated no-op alias** kept for backward compatibility (no longer needs to be explicit since it's now enabled by default). Accepted, but behaves identically to the default ON state.\n  - Pauses occur only at the **entry to a resumable unit** (single mode: before Phase 1 begins \u002F before each review-loop iteration; orchestration: before each wave begins \u002F before worker dispatch). It does not pause mid-implement (before PR creation).\n  - The pause granularity for orchestration is the **wave boundary**. A mid-unit overage in an already-running worker cannot be stopped by this flag; the PreToolUse hook (#123) serves as the ceiling.\n  - On overage, it waits until the budget resets, then re-enters via the continuation command `\u002Fdrive \u003C元の引数>` (continuing via drive's idempotent resume). `--no-usage-guard` is carried over to the continuation command only if the user specified it explicitly (`--usage-guard` is never force-added).\n  - Even in environments where the usage-guard skill \u002F `usage-check.mjs` is not installed, drive is not stopped with an error. If the skill's absence is detected, a one-line warning is shown and it proceeds normally (treated as fail-open).\n\n### Merge and the autonomy policy (irreversible gate)\n\nMerging (single-mode Phase 4 \u002F orchestration Phase Final-4) is an **irreversible, destructive action**. Rather than hardcoding an individual approval gate in prose, it follows the central autonomy policy (the SSOT for the 3 action classes and gate vocabulary, defined by the `policy` skill. [ADR-0028](https:\u002F\u002Fgithub.com\u002Fozzy-labs\u002Fhandbook\u002Fblob\u002Fmain\u002Fadr\u002F0028-skills-architecture-engine-judgment-policy-catalog.md) R3, [#181](https:\u002F\u002Fgithub.com\u002Fozzy-labs\u002Fskills\u002Fissues\u002F181)). Classification and zero-config default:\n\n| Action in this skill | Class | policy reference | zero-config default gate |\n|---|---|---|---|\n| PR merge (`gh pr merge`) | `irreversible` | `--action=merge` | `ask` (explicit approval before merging) |\n\nThe effective gate is looked up via `policy-read.mjs` in the sibling `policy` skill (in Claude Code's user-scope it's `~\u002F.claude\u002Fskills\u002Fpolicy\u002Fpolicy-read.mjs`, for dogfooding it's `\u003Crepo>\u002F.claude\u002Fskills\u002Fpolicy\u002Fpolicy-read.mjs`, and on Codex\u002FGemini it's `.agents\u002Fskills\u002Fpolicy\u002Fpolicy-read.mjs`):\n\n```bash\nnode \u003Cpolicy skill のディレクトリ>\u002Fpolicy-read.mjs --action=merge --repo-root=\"$PWD\"\n# => .resolved.gate（既定 ask）\n```\n\n- **Default is `ask`:** when `--merge` is not specified, the merge follows gate=`ask` and executes only after **confirming with a human** (single mode: Phase 4; orchestration: the \"After completion\" confirmation in Phase Final-4).\n- **`--merge` is an explicit opt-in that overrides to `proceed`:** the moment the user adds `--merge`, it is treated as having delegated autonomous merging, overriding the gate to `proceed` (merge without confirmation + audit trail). This is an extension of the same \"drive has been delegated autonomous execution\" principle as implement's `reversible-local`=`proceed` (plan approval is skipped under drive).\n- **Doesn't break even without a policy present (fail-safe):** `policy-read.mjs` is fail-safe by design — unreadable or invalid values always fall to the stricter side (`ask`). In environments where the `policy` skill isn't installed, the default gate (`irreversible`=`ask`) is applied directly. The explicit opt-in of `--merge` remains effective in this case too.\n- **Architectural enforcement (Claude Code) and how `--merge` gets through:** in environments where the execution-engine-side gate for `gh pr merge` (the PreToolUse `policy-hook.mjs`, wired via `npx @ozzylabs\u002Fskills hooks add policy`) is in place, a merge with gate=`ask` (the default) is denied (exit 2) by the hook. **Since `--merge` is an explicit opt-in that overrides the merge to `proceed` at the prose layer, when actually running `gh pr merge`, export `POLICY_GUARD_PROCEED=merge` before running it** (the hook allows this pre-authorized action without re-gating it; resolves the [#195](https:\u002F\u002Fgithub.com\u002Fozzy-labs\u002Fskills\u002Fissues\u002F195) gap). This ensures that even in environments with the hook wired up, drive's own legitimate merges aren't blocked by the enforcement net. In environments without the hook wired, this is just a harmless env prefix. Likewise, when a human approves the merge during the \"After completion\" confirmation when `--merge` is not specified, that one command is also run with `POLICY_GUARD_PROCEED=merge` prefixed (since the explicit approval via AskUserQuestion satisfies the `ask` gate's requirement).\n\n### Argument restoration (resume command)\n\n**The original argument list is saved** at parse time. The resume line in the failure-time report (single-mode Phase 5 \u002F orchestration Phase Final-6) and usage-guard's continuation command both assemble `\u002Fdrive \u003C元の引数>` from these saved arguments. The restoration convention is identical to usage-guard's continuation-command convention:\n\n- Restates the original arguments as-is. drive's idempotent resume (detecting an existing PR \u002F branch \u002F already-merged PR) resumes from where it left off\n- `--no-usage-guard` is carried over only if the user specified it\n- `--usage-guard` is a deprecated no-op alias, so it is neither saved nor added (nor force-added)\n\n### Mode branching\n\nFollows the `mode` output from `drive-plan.mjs`:\n\n- 1 target with no dependency notation → **single mode**\n- 2 or more targets, or dependency notation present → **orchestration mode**\n\n## Single mode\n\n### Phase 1: implement\n\nRuns the implement skill's workflow. However, the following points differ:\n\n- **Skip plan approval:** since the user has already delegated autonomous execution by running drive, the plan is self-approved and implementation proceeds\n- **Ignore the completion report and next-action confirmation:** transitions between phases are controlled by this skill\n\n**Abort condition:** if behavior verification repeatedly fails → report the error and abort\n\n### Phase 2: ship\n\nRuns the ship skill's workflow (verify → commit → create PR). Ignores the completion report and next-action confirmation.\n\n- Records the PR number (used in Phase 3)\n- **Idempotency:** if an existing PR is detected, it's treated as a resume — instead of creating a new one, it resumes from Phase 3. Criteria:\n  - target is a PR number → adopt that PR\n  - target is an issue number → adopt the latest single result from `gh pr list --search \"in:body #\u003CN>\" --state open`, or the PR matching the current branch name\n\n**Abort condition:** if verify (validation) fails and can't be fixed → report the error and abort\n\n### Phase 3: review loop (determined by per-axis exit criteria)\n\nAggregates the review skill's per-axis `exit_criteria.drive_loop` to determine when to exit. The loop cap switches based on the `--review` mode:\n\n| `--review` | max quick iterations | max deep iterations | notes |\n| --- | --- | --- | --- |\n| `quick` (default) | 3 | 0 | quick for every review pass |\n| `final-deep` | 2 | 1 (final pass only) | loops in quick, then only the final pass is deep |\n| `deep` | 0 | 1 | deep for every pass. Capped at 1 to prevent cost blowup |\n\nSteps for each pass:\n\n1. **Run the review:** review the PR with the review skill and post the result as a PR comment. At this point, embed JSON in the HTML comment `\u003C!-- review-json:v\u003CN> ... -->` at the end of the PR comment ([ADR-0025](https:\u002F\u002Fgithub.com\u002Fozzy-labs\u002Fhandbook\u002Fblob\u002Fmain\u002Fadr\u002F0025-skills-review-multi-perspective.md) Schema v1)\n2. **Determination:**\n   - If the JSON can be parsed → determine whether **all** per-axis `exit_criteria.drive_loop` are satisfied. `exit_criteria` refers to the `exit_criteria.drive_loop` of the corresponding `perspectives\u002F\u003Caxis>.md` (the acceptable critical\u002Fwarning thresholds differ per axis)\n   - If all applicable axes satisfy `exit_criteria` → end the loop (merge-ready)\n   - If even one axis is unmet → proceed to fixing\n   - If JSON parsing fails \u002F `unknown_review_version` → fail-soft, handling only the human-readable portion, determined by whether Critical or Warning counts are 0 (legacy-behavior compatible)\n   - If the loop cap is reached → end the loop (include remaining findings in the report)\n3. **Fix:** fix only the Critical and Warning findings for unmet axes. Info is not fixed (reported only). After fixing, run verify → commit → push, and return to step 1\n\nFor `--review=final-deep`, only the last pass (either right before the quick cap is reached, or the final single iteration) is re-reviewed in deep mode.\n\nIf `unknown_review_version` is detected, the JSON is ignored and the determination uses only the human-readable portion, with the loop continuing as-is (maintaining compatibility after a schema bump).\n\n#### Resume compatibility with existing PR comments\n\n- If a past PR comment doesn't include `\u003C!-- review-json:v\u003CN> -->`, that PR is treated as a **legacy comment**, and a new review pass is run (the old comment isn't deleted)\n- The same applies for `\u003C!-- review-json:v\u003Cunknown> -->` — a new pass is run\n\n### Phase 4: merge (optional)\n\n**When single mode is executed as an orchestration worker, Phase 4 is not run.** The worker stops at `merge-ready` (review passed, not yet merged) and returns `status` capped at `merge-ready`. Merging is centrally managed by the parent in Phase Final-4 (to secure a window for folding in cross-cutting concerns before merge — if a worker were to self-merge, it would already be merged and unfoldable, leaving follow-up behind).\n\nThe merge follows the central policy's `irreversible` gate (see \"Merge and the autonomy policy\"; default `ask`). The following runs only when **single mode is executed directly (not as a worker) and `--merge` is specified** (`--merge` is an explicit opt-in that overrides the gate to `proceed`):\n\n1. **Enable auto-merge:** run `POLICY_GUARD_PROCEED=merge gh pr merge --auto --squash --delete-branch` (`POLICY_GUARD_PROCEED=merge` conveys `--merge`'s proceed override to the PreToolUse `policy-hook.mjs`; see \"Merge and the autonomy policy\")\n2. **Check success\u002Ffailure:**\n   - Success (auto-merge was set, or it was merged immediately) → proceed\n   - Failure (e.g., auto-merge disabled on the repository) → notify the user and prompt for a manual merge (set the state to `merge-ready`)\n3. **Cleanup (if merged immediately):**\n   - Confirm the local branch has been deleted and it's switched to the base branch (e.g., main)\n   - Run `git pull` on the base branch to sync to the latest state\n\n### Phase 5: completion report\n\nFormatting the completion report is handled by `drive-report.mjs single`. Passing the worker\u002Fsingle-mode return-value JSON (`target` \u002F `title` \u002F `branch` \u002F `pr_url` \u002F `status` \u002F `review` \u002F `original_args`) via stdin or `--input` returns the following formatting (including by_axis aggregation and the output decision for the resume line):\n\n```bash\necho '\u003Cresult-json>' | node \u003Cこの skill のディレクトリ>\u002Fdrive-report.mjs single\n```\n\n```text\ndrive 完了:\n  Issue:    #\u003Cnumber> \u003Ctitle>\n  ブランチ: \u003Cbranch-name>\n  PR:       \u003CPR URL>\n  レビュー: N 回実施 (mode: \u003Cquick|final-deep|deep>)\n            総計 Critical: 0, Warning: 0, Info: N\n            by_axis: correctness:C0W0I0 security:C0W0I0 ...\n  状態:     \u003Cmerged | merge-ready | auto-merge enabled | failed>\n  再開:     \u002Fdrive \u003C元の引数>\n```\n\nThe `再開:` line is **always** output when the status is `failed` or `merge-ready` (for discoverability — so it's known that resume works without having to read the SKILL.md). The arguments are restored following the \"Argument restoration (resume command)\" convention, and shown as a single `再開: \u002Fdrive \u003C元の引数>` line. Re-running triggers idempotent resume, which detects the existing PR \u002F branch and resumes from Phase 3. It's not shown when the status completes as `merged` \u002F `auto-merge enabled`. This output decision and argument restoration are implemented by `drive-report.mjs`.\n\n## Orchestration mode\n\n### Phase 0: input expansion and DAG construction\n\nTarget expansion, DAG construction, wave splitting, and cycle detection are handled by `drive-plan.mjs` (the judgment layer only fetches meta from GitHub and calls the engine):\n\n1. For each target, fetch meta from GitHub (used for the DAG's PR-base matching \u002F issue-body detection):\n   - issue: `gh issue view \u003CN> --json number,title,body`\n   - PR: `gh pr view \u003CN> --json number,title,body,baseRefName,headRefName`\n   - If it's ambiguous whether it's an issue or a PR, try both and adopt whichever hits\n   - Assemble the fetched meta into JSON of the form `{\"#N\": {kind,title,body,baseRefName,headRefName}, ...}` and write it to a temp file\n2. Run `drive-plan.mjs \"\u003C元の引数>\" --meta-file \u003Cpath> --json`. Adopt the `waves` \u002F `deps` \u002F `mode` \u002F `concurrency` \u002F `review` \u002F `cycle` returned by the engine:\n   - **DAG:** explicit dependency `->` (highest priority) + PR base↔head matching (stacked) + best-effort detection of \"depends on #X\" \u002F \"blocked by #X\" \u002F \"after #X\" in the issue body (misses fall back to parallel treatment rather than being an error)\n   - **Circular dependency:** if the engine returns `error: \"circular dependency detected\"` + `cycle`, report the error and abort\n3. Present the output of `drive-plan.mjs` (without `--json`) as-is. Formatting is handled by the engine (do not reformat it):\n\n```text\ndrive 開始:\n  Targets:  #1, #2, #3, #4, #5\n  並列度:    4 (既定: min(4, タスク数))\n  --merge:  有効\n  Waves:\n    Wave 1: #1, #2 (並列)\n    Wave 2: #3 (← #1, #2)\n    Wave 3: #4, #5 (並列, ← #3)\n```\n\n### Phase 1..N: wave parallel execution\n\nRuns the waves in order.\n\n#### Concurrency\n\n- Default: `min(4, tasks in wave)`\n- Overridable with `--concurrency N`\n- If N > 8, show a warning and continue (no hard cap)\n\n#### worker dispatch\n\nFor each target, launch a worker (a unit of parallel execution). Launches proceed up to the concurrency level at a time, dispatching the next as slots free up. The worker launch mechanism, and the prohibitions\u002Ftool constraints for protecting the parent repository's git state, **depend on the parallel-execution mechanism**, so follow the host-specific procedure (Claude Code: \"subagent dispatch\" in `SKILL.claude-code.md`).\n\n- **Isolation:** workers must always be launched in an isolated working copy (mandatory — prevents working-directory collisions during parallel execution). A worker stays self-contained within its own working copy and branch, and never writes to the parent's base branch, refs, or working copy\n- **Delegation granularity:** have the worker read this SKILL.md and run the single-mode workflow (Phase 1-3) for target #N. **The worker does not run Phase 4 (merge)** — it stops at `merge-ready`, and merging is centrally managed by the parent in Phase Final-4 (to secure a window for folding in cross-cutting concerns before merge)\n- **Merge prohibition:** the worker never calls `gh pr merge` at all (neither `--auto` nor `--delete-branch`). If it were to self-merge, it would already be merged and the gap couldn't be folded in, leaving follow-up behind. Cleanup of local branches \u002F working copies is also handled in bulk by the parent in Phase Final-5\n- **Minimal cross-scope-impact check:** if a schema enum \u002F field \u002F CLI flag was added within its own issue's scope, grep the whole repo for the corresponding help strings \u002F error messages \u002F samples\u002Fdocs and check whether they're in sync (e.g., `rg -n '\u003Cold-enum-list>' src\u002F docs\u002F`). If not in sync, **include the fix in its own PR if feasible** (as a natural extension of its own scope). If it's a judgment call or clearly beyond its own scope, don't fix it — instead record it in the return value's `cross_cutting_gaps` in the form `\u003Cfile>:\u003Cline> — \u003Csymbol> not synced`, to be aggregated into the parent's Phase Final-2 audit ([Issue #70](https:\u002F\u002Fgithub.com\u002Fozzy-labs\u002Fskills\u002Fissues\u002F70))\n- **Base branch:**\n  - target with no upstream wave dependency → branch from main\n  - target with an upstream wave dependency → branch based on the upstream PR's `headRefName` (stacked PR). Since the worker doesn't self-merge, the upstream remains unmerged during the run. So regardless of `--merge`, **stacked structure is the default** (the parent reassigns the base to main when merging in dependency order in Phase Final-4)\n- **Return value:** each worker returns the following JSON on completion\n\n```json\n{\n  \"target\": \"#\u003CN>\",\n  \"title\": \"\u003Cissue\u002FPR title>\",\n  \"branch\": \"\u003Cbranch-name>\",\n  \"pr_url\": \"\u003CURL>\",\n  \"pr_number\": \u003CN>,\n  \"status\": \"merge-ready\" | \"failed\",\n  \"review\": {\n    \"mode\": \"quick\" | \"final-deep\" | \"deep\",\n    \"axes_applied\": [\"security\", \"...\"],\n    \"by_axis\": {\"security\": {\"critical\": 0, \"warning\": 0, \"info\": 0}, ...},\n    \"total\": {\"critical\": 0, \"warning\": 0, \"info\": 0},\n    \"iterations\": \u003CN>\n  },\n  \"cross_cutting_gaps\": [\n    \"src\u002Fcli\u002Ffoo.ts:213 — help text missing new kind 'html-js'\",\n    \"src\u002Fcli\u002Ffoo.ts:299 — validation error message lists old enum set\"\n  ],\n  \"final_head_state\": {\n    \"symbolic_ref\": \"\u003Cgit symbolic-ref HEAD 出力、例: refs\u002Fheads\u002Ffeat\u002Ffoo>\",\n    \"rev_parse_HEAD\": \"\u003Cgit rev-parse HEAD 出力>\",\n    \"status_short\": \"\u003Cgit status --short 出力、clean なら空文字列>\"\n  },\n  \"error\": \"\u003Cmessage if failed>\"\n}\n```\n\n`status` is capped at `merge-ready` for workers (review passed, unmerged). `merged` is only confirmed by the parent in Phase Final-4 (immediate squash merge), and `auto-merge enabled` only appears in Phase 4 (`--auto`) when single mode is run directly. Neither appears in a worker's return value (the parent accepts them anyway, for backward compatibility).\n\n`cross_cutting_gaps` is an optional field recording items the worker noticed during its \"minimal cross-scope-impact check\" but did not fix in its own PR (an empty array is fine). A return value missing this field is treated as `[]`, not an error, for backward compatibility. The parent aggregates these as a starting point in Phase Final-2's **pre-merge** audit, combining them with its own independently detected gaps, and folds them into the originating PR in Phase Final-3 reconciliation.\n\n`final_head_state` is a field that always reports the git HEAD state of the worker's own working copy at completion. Since discrepancies between self-reported state and actual state have been observed, the actual measured values are submitted in the return value for cross-checking on the parent side in Phase Final-1. If the field is missing, it's treated as `null` for backward compatibility and the cross-check is skipped (see the host-specific procedure for the discrepancy criteria).\n\n#### Observability and interrupt\u002Fresume\n\nThe **execution mechanism** for progress observation and interrupt\u002Fresume **is host-dependent** (since it's integrated into the parallel-execution mechanism). The canonical only defines the semantics; the how of the mechanism (progress display, concrete resume steps) is delegated to host-specific procedures (Claude Code: \"Observability and interrupt\u002Fresume\" in `SKILL.claude-code.md`):\n\n- A worker may not be able to give streaming intermediate reports while running. The parent visualizes progress, but **finalizes state via the final JSON return value once all workers complete** (the return value is the SSOT for finalization; intermediate display is merely auxiliary)\n- Even if interrupted, drive can resume from where it left off via idempotent resume (detecting completed workers \u002F existing PRs \u002F already-merged PRs). **The how of the resume mechanism is host-dependent** (on Claude Code it's the Workflow's journal resume `resumeFromRunId`; the Agent tool fallback is `gh pr list` polling + manual re-run)\n\n#### Waiting for wave completion\n\n- The wave is complete once all workers have completed\n- Since workers don't self-merge, regardless of `--merge`, wave completion = the point at which every PR in the wave has reached `merge-ready` or better (unmerged). The following wave creates its PRs stacked on the base of the preceding PR's `headRefName`\n- The actual merge is performed centrally by the parent in dependency order in Phase Final-4, after all waves complete\n\n#### Handling failed \u002F merge-ready tasks\n\nSince workers don't merge during the run, from a downstream perspective, an upstream is only ever one of two values: `merge-ready` (success) or `failed`:\n\n| Upstream state | downstream treatment |\n|---|---|\n| merge-ready | proceed (create a stacked PR based on the preceding PR's headRefName) |\n| failed | excluded as `skipped (upstream failed: #N)` |\n\n- Failed targets are recorded\n- Other independent tasks (with no dependency relationship) are not affected\n\n### Phase Final: cross-cutting self-resolution, merge, and aggregate report\n\nPhase Final consists of the following 6 steps, run in order. **The core of the design**: placing cleanup (Final-5) last, and running audit (Final-2) and reconciliation (Final-3) **before the merge**, folds cross-cutting gaps into the originating PR while the worker's working copy still remains. This ensures no follow-up is left behind after a single run.\n\n#### Phase Final-1: parent working-copy consistency check\n\nA fail-safe that verifies workers haven't polluted the parent repository's git state (`HEAD` \u002F `index` \u002F base-branch ref). The specific verification axes and recovery sequence depend on the parallel-execution mechanism, so follow the host-specific procedure (Claude Code: \"Phase Final-1: parent worktree consistency check\" in `SKILL.claude-code.md`).\n\nAt minimum, verify the following invariants regardless of host:\n\n1. The parent's HEAD points to the base branch (usually `main`) and is not detached\n2. The parent's index \u002F working tree is clean\n3. The base-branch ref matches `origin\u002F\u003Cbase-branch>`\n4. There's no discrepancy between the worker return value's `final_head_state` and the actually measured git state\n\nIf any of these don't match, output a warning and host-specific recovery steps at the end of the aggregate report.\n\n#### Phase Final-2: cross-cutting audit (pre-merge, parallel within worker working copies)\n\nSince multiple workers run in parallel, each confined to its own sub-issue scope, **cross-cutting impact spanning scopes can structurally leak through** (an enum\u002Ffield\u002FCLI flag not reflected in help\u002Ferror messages\u002Fsamples, leftover status wording, lockfile drift, etc.). This is detected **before merging** and folded into the originating PR in Phase Final-3 (originating from [Issue #70](https:\u002F\u002Fgithub.com\u002Fozzy-labs\u002Fskills\u002Fissues\u002F70) \u002F [#166](https:\u002F\u002Fgithub.com\u002Fozzy-labs\u002Fskills\u002Fissues\u002F166)).\n\n**Why this can be detected before merge, within the worktree**: the essence of a cross-cutting gap is \"PR-A adds enum X → help\u002Fdocs (an existing file nobody touched) doesn't reflect X.\" This existing file can be grepped in **PR-A's own working copy (which includes X)**, so \"no X = gap\" can be detected there, determinable before merging into main (equivalent to a post-merge grep of main).\n\n**Parallel**: since each PR's inspection is independent, **run it in parallel per PR (by default)**. Each inspection is performed within that worker's working copy (workers aren't cleaned up until Phase Final-5, so they remain).\n\n##### 0. Aggregate reports from workers\n\nAs a starting point for inspection, aggregate the `cross_cutting_gaps` field from every worker's return value. This includes gaps the worker itself noticed but did not fix in its own PR.\n\n##### 1. Sync check for cross-cutting symbols (heuristic)\n\nFor each worker's `pr_number`, fetch the diff with `gh pr diff \u003CN>` (even for stacked PRs, `base...head` = that PR's own diff only, no double-counting), and heuristically extract newly added enum values, field names, and CLI-flag-looking symbols:\n\n```bash\ngh pr diff \u003CN> | grep -E '^\\+' | grep -oE '(case\\s+[\"'\\'']\\w[\\w-]+[\"'\\''])|(--[a-z][a-z0-9-]+)|([\"'\\''][a-z][a-z0-9-]+[\"'\\''])' | sort -u\n```\n\nGrep the extracted symbols across the whole repo within that worker's working copy, and check whether they're reflected in help strings \u002F error messages \u002F samples \u002F docs (false positives are acceptable; the AI judges).\n\n##### 2. Detecting remnants of stale wording\n\nIf a status keyword (`alpha`, `beta`, `Phase \\d+`, `pending`, etc.) has been removed in a PR, grep within the working copy for whether the same string remains as a remnant in other files. Legitimate uses as proper nouns are excluded by the AI's judgment.\n\n##### 3. lockfile drift\n\nDetect, from each PR's diff, cases where a lockfile (`pnpm-lock.yaml` \u002F `package-lock.json` \u002F `uv.lock`, etc.) was changed in the PR but the corresponding manifest (`package.json` \u002F `pyproject.toml`, etc.) was not — or vice versa.\n\n##### 4. docs ⇄ code grep consistency (reduced-scope version)\n\nExtract newly added CLI invocation strings from the diff of docs-related PRs (with a `docs:` title, etc.), and grep within the working copy for whether the corresponding string exists on the code side. No \"execution-based\" verification is performed.\n\n##### Audit output (attribution)\n\nOutput each detected gap **attributed to its originating PR** in the following form. Phase Final-3 uses this `source_pr` to decide where to fold it:\n\n```text\ngap:        \u003Ctarget_file:line — symbol \u002F message>\nsource_pr:  #\u003CN>（symbol を導入した PR）\ncategory:   enum-flag-sync | stale-text | lockfile-drift | docs-code\n```\n\nWorker reports and independently detected ones are deduplicated. The dedup key is based on `file:line`; if the same `file:line` has multiple messages, both are listed (no information is discarded). If there are 0 gaps, Final-3 is skipped.\n\n#### Phase Final-3: reconciliation (folding into the originating PR, parallel per PR)\n\nGroup the gaps detected in Final-2 by `source_pr`, and **fix and push in the originating PR's working copy** (since it's before the merge, this naturally folds into the PR, leaving no follow-up behind).\n\n- **Parallel**: groupBy gaps per PR → **parallel per PR** (no collision, since each uses a separate working copy). **Multiple gaps within the same PR are sequential** (they share the same working copy)\n- **Steps**: edit the target file in the originating PR's working copy → lint (auto-fix) → commit (`fix(sync): ...`) → push\n- **No full review loop is run** (since this is mechanical synchronization). Only a lint pass is confirmed\n\nEdge cases:\n\n| Case | Handling |\n|---|---|\n| The target file is already being edited by a different PR-B, causing a folding conflict | Give up folding into the originating PR and fall back to a **dedicated reconciliation PR** (below) |\n| Multiple PRs introduce the same symbol | Dedicated reconciliation PR |\n| Reconciliation's lint\u002Ffolding fails | **Fail-soft**: leave only that gap as a warning and continue the run (same as for things that can't be mechanically fixed at the design level) |\n| Folding introduces a new cross-cutting issue | audit→reconciliation is **fixed at 1 pass** (not recursive). The remainder is a warning. Guarantees convergence and a cost ceiling |\n| Folding into an upstream stacked PR → downstream base drift | Subsumed into Phase Final-4's dependency-order merge procedure |\n\n**Dedicated reconciliation PR**: a corrective PR created when a single gap can't be folded into one PR (conflict \u002F spanning multiple PRs). Since a GitHub PR's base is singular, \"stacked onto every tip\" isn't possible. So **it merges last, with main as the base, after all content PRs have merged** (built into the tail of Phase Final-4). This PR is also merged within the run, so no follow-up is left behind.\n\nGaps resolved via reconciliation are recorded in the aggregate report as \"resolved within the run (folded)\". Only gaps left over via fail-soft are treated as warnings.\n\n#### Phase Final-4: dependency-order merge (centralized by the parent)\n\nSince workers don't self-merge, the actual merge is centrally managed here by the parent. The merge follows the central policy's `irreversible` gate (see \"Merge and the autonomy policy\"; default `ask`). It runs when `--merge` is specified (`--merge` is an explicit opt-in that overrides the gate to `proceed`; when not specified, it follows the default `ask` and goes through the \"After completion\" confirmation below).\n\nMerge each PR in topological order (upstream → downstream):\n\n1. `POLICY_GUARD_PROCEED=merge gh pr merge \u003C上流> --squash` (**remote-only merge; do not add `--delete-branch`** — at this point the worker's working copy still holds the branch and remains, so deleting the local branch would fail with `fatal: '\u003Cbranch>' is already used by worktree`. Deletion of the remote\u002Flocal branch and the working copy is consolidated into Final-5 cleanup. `POLICY_GUARD_PROCEED=merge` conveys `--merge`'s proceed override to the PreToolUse `policy-hook.mjs`; see \"Merge and the autonomy policy\")\n2. Reassign the downstream PR's base with `gh pr edit \u003C下流> --base main` (switching the base from the upstream head → main) before merging the next one. Since the upstream's squash-merge has already introduced changes into main, if the base reassignment alone causes a phantom conflict, run `git rebase origin\u002Fmain` in the downstream's working copy before continuing (the parent-side ref is left untouched)\n3. **If a dedicated reconciliation PR was created in Phase Final-3, it merges last, with main as the base, after all content PRs have merged** (this PR too is merged within the run, leaving no follow-up)\n4. If auto-merge is disabled on the repository \u002F an immediate merge isn't possible due to branch protection, etc. → leave that PR as `merge-ready` and mark its downstream dependents as `skipped`, with a warning\n5. Confirm each PR's merge completion with `gh pr view --json mergedAt,state` before proceeding to the next (waiting for the squash merge to take effect)\n\nEven if the parent dies partway through, drive can continue the rest via idempotent resume (detecting already-merged PRs).\n\n#### Phase Final-5: cleanup of worker working copies\n\nCleans up the working copies and related local branches for **workers launched in this drive run**. Since this runs after Final-4's merge, successful workers are all already merged and become cleanup targets (working copies that used to be \"left as merge-ready\" are now also cleaned up here, resolving the leftover problem). Orphans outside this run's scope are out of scope (delegated to `\u002Fhealth` area #7. [Issue #71](https:\u002F\u002Fgithub.com\u002Fozzy-labs\u002Fskills\u002Fissues\u002F71)).\n\nCleanup policy by status (common across hosts):\n\n- **`merged`** (merge completed in Final-4): cleanup target\n- **`merge-ready`** (left in place in Final-4 due to auto-merge being unavailable): **do not** clean up (leave it until the user merges manually)\n- **`failed`**: **do not** clean up (leave it so it can be resumed by re-running)\n\nThe specific deletion steps and known pitfalls (loss of cwd, lock release, leftover synthetic branches) depend on the isolation mechanism, so follow the host-specific procedure (Claude Code: \"Phase Final-5: subagent worktree cleanup\" in `SKILL.claude-code.md`). If any working copy other than `merged` remains, or cleanup itself fails, output a list of leftovers and manual cleanup steps as a warning at the end of the aggregate report.\n\n#### Phase Final-6: aggregate report\n\nFormatting the aggregate report is handled by `drive-report.mjs aggregate`. Passing the array of worker return values and the meta collected in Final-1 through Final-5 (`{results, targets_order, original_args, cross_cutting, cleanup, integrity_warnings}`) via stdin or `--input` returns formatted per-status counts, review aggregation, cross-cutting\u002Fcleanup lines, and the output decision for the resume line:\n\n```bash\necho '\u003Caggregate-json>' | node \u003Cこの skill のディレクトリ>\u002Fdrive-report.mjs aggregate\n```\n\nBased on the results of the consistency check, audit, reconciliation, merge, and cleanup, output the aggregate report:\n\n```text\ndrive 完了 (4\u002F5 merged, 1 skipped):\n  #1 feat: ...        | PR #100 | merged\n  #2 fix:  ...        | PR #101 | merged       (Review: C0 W0 I2)\n  #3 feat: ...        | PR #102 | merged\n  #4 chore: ...       | skipped (upstream failed: #5)\n  #5 refactor: ...    | failed (test loop)\n\n集計:\n  merged:           3\n  skipped:          1\n  failed:           1\n  総レビュー反復:    5 回\n  cross-cutting:    2 gaps resolved (folded into PR #100, #102)\n  cleanup:          3\u002F5 removed (2 preserved: 1 failed, 1 skipped)\n\n再開: \u002Fdrive \u003C元の引数>\n```\n\nThe `cross-cutting:` line displays the number of gaps resolved via reconciliation in Phase Final-3 and the PRs they were folded into, in the form `\u003CN> gaps resolved (folded into ...)`. If a dedicated reconciliation PR was created and merged, it also appears as one line in the merged list, and the PR number is included in `folded into`. If there are 0 gaps, it's `cross-cutting: none`. If gaps remain via fail-soft, it's shown as `\u003CN> resolved, \u003CM> unresolved (warning)`, with a warning block listing the unresolved items and a recommendation for manual handling.\n\nThe `再開:` line is **always** output as a single line right after the tally block — `再開: \u002Fdrive \u003C元の引数>` — whenever there's 1 or more `failed` \u002F leftover `merge-ready` \u002F `skipped` (following the \"Argument restoration (resume command)\" convention). Re-running triggers idempotent resume, which detects already-merged PRs \u002F existing PRs, skips completed targets, and continues from the remaining targets. It's not shown when all targets complete as merged.\n\n## Failure semantics\n\n| Situation | Treatment | Impact on downstream |\n|---|---|---|\n| Per-axis exit_criteria still unmet even after the review loop cap | partial success (merge-ready) | none |\n| Auto-merge unavailable in Phase Final-4 (branch protection, etc.) | leave that PR as merge-ready | downstream marked skipped |\n| implement \u002F ship aborted (test failure, etc.) | failed | skipped |\n| Reconciliation folding fails | fail-soft (gap left as a warning) | none (the PR itself is still merge-ready) |\n| Independent task failure | doesn't affect other parallel tasks | - |\n\nFor any failure or leftover, the resume method is the same — just re-run the `再開: \u002Fdrive \u003C元の引数>` at the end of the report (see Phase 5 \u002F Phase Final-6). Idempotent resume detects the existing PR \u002F branch \u002F already-merged PR, skips completed targets, and resumes from where it left off.\n\n## Notes\n\n- Never read or stage `.env` files\n- If the `gh` CLI is unauthenticated, display an error message and abort\n- Merging follows the central autonomy policy's `irreversible` gate (default `ask`; see \"Merge and the autonomy policy\"). It is not performed by default, and runs only when `--merge` is specified (`--merge` is an explicit opt-in that overrides the gate to `proceed`; single mode auto-merges in Phase 4, orchestration has the parent centrally merge in dependency order in Phase Final-4)\n- Orchestration workers don't self-merge (they stop at `merge-ready` and the parent merges in Final-4). This allows cross-cutting concerns to be folded in before the merge\n- Info findings are not fixed, only reported (design-related changes aren't made mechanically)\n- In orchestration mode, workers are always launched in an isolated working copy (the isolation mechanism is host-dependent)\n- Exceeding a concurrency of 8 only warns. Be mindful of GitHub Actions concurrent-run limits \u002F API rate limits \u002F observability \u002F cost\n- If a circular dependency is detected, report the error and abort\n","# drive - Autonomously driving from an Issue to a merge-ready PR\n\nTakes an Issue or an instruction and automatically repeats implement → ship → self-review → fix to produce a merge-ready PR. Supports parallel driving of multiple Issues\u002FPRs, and can optionally complete all the way through to merge.\n\nDeterminism (argument parsing, target expansion, DAG\u002Fwave construction, cycle detection, concurrency\u002Freview-mode resolution, aggregating worker return values, and report formatting) is handled by the two bundled engines ([ADR-0028](https:\u002F\u002Fgithub.com\u002Fozzy-labs\u002Fhandbook\u002Fblob\u002Fmain\u002Fadr\u002F0028-skills-architecture-engine-judgment-policy-catalog.md) R1, following the precedent of `health-check.mjs` \u002F `topics.mjs` \u002F `review.mjs`):\n\n- **`drive-plan.mjs`**: Input (argument string + optional target meta) → wave configuration JSON. Handles target expansion, `->` dependency parsing, DAG construction, topological wave splitting, circular dependency detection, mode branching, and concurrency\u002Freview mode resolution.\n- **`drive-report.mjs`**: Aggregates worker return-value JSON → formats the single-mode Phase 5 completion report \u002F the orchestration Phase Final-6 aggregate report. Handles review aggregation (by_axis \u002F total), cross-cutting gaps display, and the output decision for the `再開: \u002Fdrive \u003C元の引数>` line.\n\nThis SKILL.md is confined to the judgment layer — when to call the engine, the meaning of each Phase, the per-axis exit determination for the review loop, the folding decision for cross-cutting concerns, and where to confirm with a human. This file is the SSOT for the behavioral contract (the semantics of Phase 1-5 \u002F Phase Final-1–6, failure semantics, and the meaning of `--merge` \u002F `--review` \u002F `--concurrency`).\n\n## Input parsing\n\nArgument parsing is handled by `drive-plan.mjs` (in the same directory as this SKILL.md; on Claude Code it's `~\u002F.claude\u002Fskills\u002Fdrive\u002Fdrive-plan.mjs`, and for dogfooding it's `\u003Crepo>\u002F.claude\u002Fskills\u002Fdrive\u002Fdrive-plan.mjs`):\n\n```bash\nnode \u003Cこの skill のディレクトリ>\u002Fdrive-plan.mjs \"\u003C元の引数>\" [--meta-file \u003Cpath>] [--json]\n```\n\nContent resolved by the engine (behavioral contract):\n\n- **Target expansion:** single `#42` \u002F `42`, comma-separated `#1,#2`, range `#3-5` → `#3,#4,#5`, whitespace-separated `#1 #2`, mixed `#1,#3-5`. An argument matching none of these is treated as a text instruction (single target).\n- **Explicit dependency notation `->`:** `#1,#2 -> #3` (#1 and #2 run in parallel → #3 runs after both complete), `#1 -> #2 -> #3` (fully sequential).\n- **DAG construction:** explicit dependencies (highest priority) + PR base↔head matching (stacked) + best-effort detection of \"depends on #X\" in the issue body (when issue\u002FPR meta is passed via `--meta-file`).\n- **Wave splitting \u002F cycle detection:** splits into topological levels. If a circular dependency exists, returns `error` + `cycle` (→ report and abort).\n- **Mode branching:** 1 target with no dependencies → single mode; 2 or more targets, or dependencies present → orchestration mode.\n- **Concurrency \u002F review mode:** default `min(4, task count)`, overridable via `--concurrency` (>8 only warns). Orchestration forces `--review=quick` (`final-deep`\u002F`deep` are downgraded with a warning).\n\nThe `resume_command` in the engine output (`--json`) is already assembled according to the \"Argument restoration (resume command)\" convention.\n\n### Options\n\n- `--merge`: Attempts an automatic merge. The merge follows the central autonomy policy's `irreversible` gate (see \"Merge and the autonomy policy\" below). **The `--merge` flag itself is an explicit opt-in** — it treats the user as having already delegated autonomous merging, overriding the gate to `proceed` (merge without confirmation)\n- `--concurrency N`: Overrides the concurrency level (default `min(4, task count)`, N > 8 only warns)\n- `--review=\u003Cmode>`: review mode (default `quick`). The value is one of the following:\n  - `quick` (default): quick mode for every review pass (up to 3 iterations)\n  - `final-deep`: loops in quick mode up to 2 times, then upgrades only the final pass to deep (quick 2 + deep 1)\n  - `deep`: deep mode for every pass (up to 1 iteration; prevents cost blowup)\n\n  In orchestration mode, `--review=quick` is forced; if `final-deep` \u002F `deep` is specified, a warning is shown and it falls back to `quick`.\n\n- usage-guard: pauses work just before the Claude Code Usage Limit is exceeded, and automatically resumes once the budget recovers. **Enabled by default (opt-out)**. Add `--no-usage-guard` to disable it. Takes effect **only in the Claude Code environment** (same treatment as `review --deep`; it depends on the OAuth usage-rate endpoint + `ScheduleWakeup`, so it's a no-op on other adapters). It's ON by default, but only takes effect on the claude-code adapter — other adapters (codex\u002Fgemini\u002Fcopilot) do nothing, as before. Since the pause\u002Fresume wiring is host-dependent, it is absorbed into \"usage-guard wiring (default ON, disabled via `--no-usage-guard`)\" in `SKILL.claude-code.md`.\n  - `--no-usage-guard`: disables usage-guard and runs a plain drive with no checkpoints inserted at all.\n  - `--usage-guard`: a **deprecated no-op alias** kept for backward compatibility (no longer needs to be explicit since it's now enabled by default). Accepted, but behaves identically to the default ON state.\n  - Pauses occur only at the **entry to a resumable unit** (single mode: before Phase 1 begins \u002F before each review-loop iteration; orchestration: before each wave begins \u002F before worker dispatch). It does not pause mid-implement (before PR creation).\n  - The pause granularity for orchestration is the **wave boundary**. A mid-unit overage in an already-running worker cannot be stopped by this flag; the PreToolUse hook (#123) serves as the ceiling.\n  - On overage, it waits until the budget resets, then re-enters via the continuation command `\u002Fdrive \u003C元の引数>` (continuing via drive's idempotent resume). `--no-usage-guard` is carried over to the continuation command only if the user specified it explicitly (`--usage-guard` is never force-added).\n  - Even in environments where the usage-guard skill \u002F `usage-check.mjs` is not installed, drive is not stopped with an error. If the skill's absence is detected, a one-line warning is shown and it proceeds normally (treated as fail-open).\n\n### Merge and the autonomy policy (irreversible gate)\n\nMerging (single-mode Phase 4 \u002F orchestration Phase Final-4) is an **irreversible, destructive action**. Rather than hardcoding an individual approval gate in prose, it follows the central autonomy policy (the SSOT for the 3 action classes and gate vocabulary, defined by the `policy` skill. [ADR-0028](https:\u002F\u002Fgithub.com\u002Fozzy-labs\u002Fhandbook\u002Fblob\u002Fmain\u002Fadr\u002F0028-skills-architecture-engine-judgment-policy-catalog.md) R3, [#181](https:\u002F\u002Fgithub.com\u002Fozzy-labs\u002Fskills\u002Fissues\u002F181)). Classification and zero-config default:\n\n| Action in this skill | Class | policy reference | zero-config default gate |\n|---|---|---|---|\n| PR merge (`gh pr merge`) | `irreversible` | `--action=merge` | `ask` (explicit approval before merging) |\n\nThe effective gate is looked up via `policy-read.mjs` in the sibling `policy` skill (in Claude Code's user-scope it's `~\u002F.claude\u002Fskills\u002Fpolicy\u002Fpolicy-read.mjs`, for dogfooding it's `\u003Crepo>\u002F.claude\u002Fskills\u002Fpolicy\u002Fpolicy-read.mjs`, and on Codex\u002FGemini it's `.agents\u002Fskills\u002Fpolicy\u002Fpolicy-read.mjs`):\n\n```bash\nnode \u003Cpolicy skill のディレクトリ>\u002Fpolicy-read.mjs --action=merge --repo-root=\"$PWD\"\n# => .resolved.gate（既定 ask）\n```\n\n- **Default is `ask`:** when `--merge` is not specified, the merge follows gate=`ask` and executes only after **confirming with a human** (single mode: Phase 4; orchestration: the \"After completion\" confirmation in Phase Final-4).\n- **`--merge` is an explicit opt-in that overrides to `proceed`:** the moment the user adds `--merge`, it is treated as having delegated autonomous merging, overriding the gate to `proceed` (merge without confirmation + audit trail). This is an extension of the same \"drive has been delegated autonomous execution\" principle as implement's `reversible-local`=`proceed` (plan approval is skipped under drive).\n- **Doesn't break even without a policy present (fail-safe):** `policy-read.mjs` is fail-safe by design — unreadable or invalid values always fall to the stricter side (`ask`). In environments where the `policy` skill isn't installed, the default gate (`irreversible`=`ask`) is applied directly. The explicit opt-in of `--merge` remains effective in this case too.\n- **Architectural enforcement (Claude Code) and how `--merge` gets through:** in environments where the execution-engine-side gate for `gh pr merge` (the PreToolUse `policy-hook.mjs`, wired via `npx @ozzylabs\u002Fskills hooks add policy`) is in place, a merge with gate=`ask` (the default) is denied (exit 2) by the hook. **Since `--merge` is an explicit opt-in that overrides the merge to `proceed` at the prose layer, when actually running `gh pr merge`, export `POLICY_GUARD_PROCEED=merge` before running it** (the hook allows this pre-authorized action without re-gating it; resolves the [#195](https:\u002F\u002Fgithub.com\u002Fozzy-labs\u002Fskills\u002Fissues\u002F195) gap). This ensures that even in environments with the hook wired up, drive's own legitimate merges aren't blocked by the enforcement net. In environments without the hook wired, this is just a harmless env prefix. Likewise, when a human approves the merge during the \"After completion\" confirmation when `--merge` is not specified, that one command is also run with `POLICY_GUARD_PROCEED=merge` prefixed (since the explicit approval via AskUserQuestion satisfies the `ask` gate's requirement).\n\n### Argument restoration (resume command)\n\n**The original argument list is saved** at parse time. The resume line in the failure-time report (single-mode Phase 5 \u002F orchestration Phase Final-6) and usage-guard's continuation command both assemble `\u002Fdrive \u003C元の引数>` from these saved arguments. The restoration convention is identical to usage-guard's continuation-command convention:\n\n- Restates the original arguments as-is. drive's idempotent resume (detecting an existing PR \u002F branch \u002F already-merged PR) resumes from where it left off\n- `--no-usage-guard` is carried over only if the user specified it\n- `--usage-guard` is a deprecated no-op alias, so it is neither saved nor added (nor force-added)\n\n### Mode branching\n\nFollows the `mode` output from `drive-plan.mjs`:\n\n- 1 target with no dependency notation → **single mode**\n- 2 or more targets, or dependency notation present → **orchestration mode**\n\n## Single mode\n\n### Phase 1: implement\n\nRuns the implement skill's workflow. However, the following points differ:\n\n- **Skip plan approval:** since the user has already delegated autonomous execution by running drive, the plan is self-approved and implementation proceeds\n- **Ignore the completion report and next-action confirmation:** transitions between phases are controlled by this skill\n\n**Abort condition:** if behavior verification repeatedly fails → report the error and abort\n\n### Phase 2: ship\n\nRuns the ship skill's workflow (verify → commit → create PR). Ignores the completion report and next-action confirmation.\n\n- Records the PR number (used in Phase 3)\n- **Idempotency:** if an existing PR is detected, it's treated as a resume — instead of creating a new one, it resumes from Phase 3. Criteria:\n  - target is a PR number → adopt that PR\n  - target is an issue number → adopt the latest single result from `gh pr list --search \"in:body #\u003CN>\" --state open`, or the PR matching the current branch name\n\n**Abort condition:** if verify (validation) fails and can't be fixed → report the error and abort\n\n### Phase 3: review loop (determined by per-axis exit criteria)\n\nAggregates the review skill's per-axis `exit_criteria.drive_loop` to determine when to exit. The loop cap switches based on the `--review` mode:\n\n| `--review` | max quick iterations | max deep iterations | notes |\n| --- | --- | --- | --- |\n| `quick` (default) | 3 | 0 | quick for every review pass |\n| `final-deep` | 2 | 1 (final pass only) | loops in quick, then only the final pass is deep |\n| `deep` | 0 | 1 | deep for every pass. Capped at 1 to prevent cost blowup |\n\nSteps for each pass:\n\n1. **Run the review:** review the PR with the review skill and post the result as a PR comment. At this point, embed JSON in the HTML comment `\u003C!-- review-json:v\u003CN> ... -->` at the end of the PR comment ([ADR-0025](https:\u002F\u002Fgithub.com\u002Fozzy-labs\u002Fhandbook\u002Fblob\u002Fmain\u002Fadr\u002F0025-skills-review-multi-perspective.md) Schema v1)\n2. **Determination:**\n   - If the JSON can be parsed → determine whether **all** per-axis `exit_criteria.drive_loop` are satisfied. `exit_criteria` refers to the `exit_criteria.drive_loop` of the corresponding `perspectives\u002F\u003Caxis>.md` (the acceptable critical\u002Fwarning thresholds differ per axis)\n   - If all applicable axes satisfy `exit_criteria` → end the loop (merge-ready)\n   - If even one axis is unmet → proceed to fixing\n   - If JSON parsing fails \u002F `unknown_review_version` → fail-soft, handling only the human-readable portion, determined by whether Critical or Warning counts are 0 (legacy-behavior compatible)\n   - If the loop cap is reached → end the loop (include remaining findings in the report)\n3. **Fix:** fix only the Critical and Warning findings for unmet axes. Info is not fixed (reported only). After fixing, run verify → commit → push, and return to step 1\n\nFor `--review=final-deep`, only the last pass (either right before the quick cap is reached, or the final single iteration) is re-reviewed in deep mode.\n\nIf `unknown_review_version` is detected, the JSON is ignored and the determination uses only the human-readable portion, with the loop continuing as-is (maintaining compatibility after a schema bump).\n\n#### Resume compatibility with existing PR comments\n\n- If a past PR comment doesn't include `\u003C!-- review-json:v\u003CN> -->`, that PR is treated as a **legacy comment**, and a new review pass is run (the old comment isn't deleted)\n- The same applies for `\u003C!-- review-json:v\u003Cunknown> -->` — a new pass is run\n\n### Phase 4: merge (optional)\n\n**When single mode is executed as an orchestration worker, Phase 4 is not run.** The worker stops at `merge-ready` (review passed, not yet merged) and returns `status` capped at `merge-ready`. Merging is centrally managed by the parent in Phase Final-4 (to secure a window for folding in cross-cutting concerns before merge — if a worker were to self-merge, it would already be merged and unfoldable, leaving follow-up behind).\n\nThe merge follows the central policy's `irreversible` gate (see \"Merge and the autonomy policy\"; default `ask`). The following runs only when **single mode is executed directly (not as a worker) and `--merge` is specified** (`--merge` is an explicit opt-in that overrides the gate to `proceed`):\n\n1. **Enable auto-merge:** run `POLICY_GUARD_PROCEED=merge gh pr merge --auto --squash --delete-branch` (`POLICY_GUARD_PROCEED=merge` conveys `--merge`'s proceed override to the PreToolUse `policy-hook.mjs`; see \"Merge and the autonomy policy\")\n2. **Check success\u002Ffailure:**\n   - Success (auto-merge was set, or it was merged immediately) → proceed\n   - Failure (e.g., auto-merge disabled on the repository) → notify the user and prompt for a manual merge (set the state to `merge-ready`)\n3. **Cleanup (if merged immediately):**\n   - Confirm the local branch has been deleted and it's switched to the base branch (e.g., main)\n   - Run `git pull` on the base branch to sync to the latest state\n\n### Phase 5: completion report\n\nFormatting the completion report is handled by `drive-report.mjs single`. Passing the worker\u002Fsingle-mode return-value JSON (`target` \u002F `title` \u002F `branch` \u002F `pr_url` \u002F `status` \u002F `review` \u002F `original_args`) via stdin or `--input` returns the following formatting (including by_axis aggregation and the output decision for the resume line):\n\n```bash\necho '\u003Cresult-json>' | node \u003Cこの skill のディレクトリ>\u002Fdrive-report.mjs single\n```\n\n```text\ndrive 完了:\n  Issue:    #\u003Cnumber> \u003Ctitle>\n  ブランチ: \u003Cbranch-name>\n  PR:       \u003CPR URL>\n  レビュー: N 回実施 (mode: \u003Cquick|final-deep|deep>)\n            総計 Critical: 0, Warning: 0, Info: N\n            by_axis: correctness:C0W0I0 security:C0W0I0 ...\n  状態:     \u003Cmerged | merge-ready | auto-merge enabled | failed>\n  再開:     \u002Fdrive \u003C元の引数>\n```\n\nThe `再開:` line is **always** output when the status is `failed` or `merge-ready` (for discoverability — so it's known that resume works without having to read the SKILL.md). The arguments are restored following the \"Argument restoration (resume command)\" convention, and shown as a single `再開: \u002Fdrive \u003C元の引数>` line. Re-running triggers idempotent resume, which detects the existing PR \u002F branch and resumes from Phase 3. It's not shown when the status completes as `merged` \u002F `auto-merge enabled`. This output decision and argument restoration are implemented by `drive-report.mjs`.\n\n## Orchestration mode\n\n### Phase 0: input expansion and DAG construction\n\nTarget expansion, DAG construction, wave splitting, and cycle detection are handled by `drive-plan.mjs` (the judgment layer only fetches meta from GitHub and calls the engine):\n\n1. For each target, fetch meta from GitHub (used for the DAG's PR-base matching \u002F issue-body detection):\n   - issue: `gh issue view \u003CN> --json number,title,body`\n   - PR: `gh pr view \u003CN> --json number,title,body,baseRefName,headRefName`\n   - If it's ambiguous whether it's an issue or a PR, try both and adopt whichever hits\n   - Assemble the fetched meta into JSON of the form `{\"#N\": {kind,title,body,baseRefName,headRefName}, ...}` and write it to a temp file\n2. Run `drive-plan.mjs \"\u003C元の引数>\" --meta-file \u003Cpath> --json`. Adopt the `waves` \u002F `deps` \u002F `mode` \u002F `concurrency` \u002F `review` \u002F `cycle` returned by the engine:\n   - **DAG:** explicit dependency `->` (highest priority) + PR base↔head matching (stacked) + best-effort detection of \"depends on #X\" \u002F \"blocked by #X\" \u002F \"after #X\" in the issue body (misses fall back to parallel treatment rather than being an error)\n   - **Circular dependency:** if the engine returns `error: \"circular dependency detected\"` + `cycle`, report the error and abort\n3. Present the output of `drive-plan.mjs` (without `--json`) as-is. Formatting is handled by the engine (do not reformat it):\n\n```text\ndrive 開始:\n  Targets:  #1, #2, #3, #4, #5\n  並列度:    4 (既定: min(4, タスク数))\n  --merge:  有効\n  Waves:\n    Wave 1: #1, #2 (並列)\n    Wave 2: #3 (← #1, #2)\n    Wave 3: #4, #5 (並列, ← #3)\n```\n\n### Phase 1..N: wave parallel execution\n\nRuns the waves in order.\n\n#### Concurrency\n\n- Default: `min(4, tasks in wave)`\n- Overridable with `--concurrency N`\n- If N > 8, show a warning and continue (no hard cap)\n\n#### worker dispatch\n\nFor each target, launch a worker (a unit of parallel execution). Launches proceed up to the concurrency level at a time, dispatching the next as slots free up. The worker launch mechanism, and the prohibitions\u002Ftool constraints for protecting the parent repository's git state, **depend on the parallel-execution mechanism**, so follow the host-specific procedure (Claude Code: \"subagent dispatch\" in `SKILL.claude-code.md`).\n\n- **Isolation:** workers must always be launched in an isolated working copy (mandatory — prevents working-directory collisions during parallel execution). A worker stays self-contained within its own working copy and branch, and never writes to the parent's base branch, refs, or working copy\n- **Delegation granularity:** have the worker read this SKILL.md and run the single-mode workflow (Phase 1-3) for target #N. **The worker does not run Phase 4 (merge)** — it stops at `merge-ready`, and merging is centrally managed by the parent in Phase Final-4 (to secure a window for folding in cross-cutting concerns before merge)\n- **Merge prohibition:** the worker never calls `gh pr merge` at all (neither `--auto` nor `--delete-branch`). If it were to self-merge, it would already be merged and the gap couldn't be folded in, leaving follow-up behind. Cleanup of local branches \u002F working copies is also handled in bulk by the parent in Phase Final-5\n- **Minimal cross-scope-impact check:** if a schema enum \u002F field \u002F CLI flag was added within its own issue's scope, grep the whole repo for the corresponding help strings \u002F error messages \u002F samples\u002Fdocs and check whether they're in sync (e.g., `rg -n '\u003Cold-enum-list>' src\u002F docs\u002F`). If not in sync, **include the fix in its own PR if feasible** (as a natural extension of its own scope). If it's a judgment call or clearly beyond its own scope, don't fix it — instead record it in the return value's `cross_cutting_gaps` in the form `\u003Cfile>:\u003Cline> — \u003Csymbol> not synced`, to be aggregated into the parent's Phase Final-2 audit ([Issue #70](https:\u002F\u002Fgithub.com\u002Fozzy-labs\u002Fskills\u002Fissues\u002F70))\n- **Base branch:**\n  - target with no upstream wave dependency → branch from main\n  - target with an upstream wave dependency → branch based on the upstream PR's `headRefName` (stacked PR). Since the worker doesn't self-merge, the upstream remains unmerged during the run. So regardless of `--merge`, **stacked structure is the default** (the parent reassigns the base to main when merging in dependency order in Phase Final-4)\n- **Return value:** each worker returns the following JSON on completion\n\n```json\n{\n  \"target\": \"#\u003CN>\",\n  \"title\": \"\u003Cissue\u002FPR title>\",\n  \"branch\": \"\u003Cbranch-name>\",\n  \"pr_url\": \"\u003CURL>\",\n  \"pr_number\": \u003CN>,\n  \"status\": \"merge-ready\" | \"failed\",\n  \"review\": {\n    \"mode\": \"quick\" | \"final-deep\" | \"deep\",\n    \"axes_applied\": [\"security\", \"...\"],\n    \"by_axis\": {\"security\": {\"critical\": 0, \"warning\": 0, \"info\": 0}, ...},\n    \"total\": {\"critical\": 0, \"warning\": 0, \"info\": 0},\n    \"iterations\": \u003CN>\n  },\n  \"cross_cutting_gaps\": [\n    \"src\u002Fcli\u002Ffoo.ts:213 — help text missing new kind 'html-js'\",\n    \"src\u002Fcli\u002Ffoo.ts:299 — validation error message lists old enum set\"\n  ],\n  \"final_head_state\": {\n    \"symbolic_ref\": \"\u003Cgit symbolic-ref HEAD 出力、例: refs\u002Fheads\u002Ffeat\u002Ffoo>\",\n    \"rev_parse_HEAD\": \"\u003Cgit rev-parse HEAD 出力>\",\n    \"status_short\": \"\u003Cgit status --short 出力、clean なら空文字列>\"\n  },\n  \"error\": \"\u003Cmessage if failed>\"\n}\n```\n\n`status` is capped at `merge-ready` for workers (review passed, unmerged). `merged` is only confirmed by the parent in Phase Final-4 (immediate squash merge), and `auto-merge enabled` only appears in Phase 4 (`--auto`) when single mode is run directly. Neither appears in a worker's return value (the parent accepts them anyway, for backward compatibility).\n\n`cross_cutting_gaps` is an optional field recording items the worker noticed during its \"minimal cross-scope-impact check\" but did not fix in its own PR (an empty array is fine). A return value missing this field is treated as `[]`, not an error, for backward compatibility. The parent aggregates these as a starting point in Phase Final-2's **pre-merge** audit, combining them with its own independently detected gaps, and folds them into the originating PR in Phase Final-3 reconciliation.\n\n`final_head_state` is a field that always reports the git HEAD state of the worker's own working copy at completion. Since discrepancies between self-reported state and actual state have been observed, the actual measured values are submitted in the return value for cross-checking on the parent side in Phase Final-1. If the field is missing, it's treated as `null` for backward compatibility and the cross-check is skipped (see the host-specific procedure for the discrepancy criteria).\n\n#### Observability and interrupt\u002Fresume\n\nThe **execution mechanism** for progress observation and interrupt\u002Fresume **is host-dependent** (since it's integrated into the parallel-execution mechanism). The canonical only defines the semantics; the how of the mechanism (progress display, concrete resume steps) is delegated to host-specific procedures (Claude Code: \"Observability and interrupt\u002Fresume\" in `SKILL.claude-code.md`):\n\n- A worker may not be able to give streaming intermediate reports while running. The parent visualizes progress, but **finalizes state via the final JSON return value once all workers complete** (the return value is the SSOT for finalization; intermediate display is merely auxiliary)\n- Even if interrupted, drive can resume from where it left off via idempotent resume (detecting completed workers \u002F existing PRs \u002F already-merged PRs). **The how of the resume mechanism is host-dependent** (on Claude Code it's the Workflow's journal resume `resumeFromRunId`; the Agent tool fallback is `gh pr list` polling + manual re-run)\n\n#### Waiting for wave completion\n\n- The wave is complete once all workers have completed\n- Since workers don't self-merge, regardless of `--merge`, wave completion = the point at which every PR in the wave has reached `merge-ready` or better (unmerged). The following wave creates its PRs stacked on the base of the preceding PR's `headRefName`\n- The actual merge is performed centrally by the parent in dependency order in Phase Final-4, after all waves complete\n\n#### Handling failed \u002F merge-ready tasks\n\nSince workers don't merge during the run, from a downstream perspective, an upstream is only ever one of two values: `merge-ready` (success) or `failed`:\n\n| Upstream state | downstream treatment |\n|---|---|\n| merge-ready | proceed (create a stacked PR based on the preceding PR's headRefName) |\n| failed | excluded as `skipped (upstream failed: #N)` |\n\n- Failed targets are recorded\n- Other independent tasks (with no dependency relationship) are not affected\n\n### Phase Final: cross-cutting self-resolution, merge, and aggregate report\n\nPhase Final consists of the following 6 steps, run in order. **The core of the design**: placing cleanup (Final-5) last, and running audit (Final-2) and reconciliation (Final-3) **before the merge**, folds cross-cutting gaps into the originating PR while the worker's working copy still remains. This ensures no follow-up is left behind after a single run.\n\n#### Phase Final-1: parent working-copy consistency check\n\nA fail-safe that verifies workers haven't polluted the parent repository's git state (`HEAD` \u002F `index` \u002F base-branch ref). The specific verification axes and recovery sequence depend on the parallel-execution mechanism, so follow the host-specific procedure (Claude Code: \"Phase Final-1: parent worktree consistency check\" in `SKILL.claude-code.md`).\n\nAt minimum, verify the following invariants regardless of host:\n\n1. The parent's HEAD points to the base branch (usually `main`) and is not detached\n2. The parent's index \u002F working tree is clean\n3. The base-branch ref matches `origin\u002F\u003Cbase-branch>`\n4. There's no discrepancy between the worker return value's `final_head_state` and the actually measured git state\n\nIf any of these don't match, output a warning and host-specific recovery steps at the end of the aggregate report.\n\n#### Phase Final-2: cross-cutting audit (pre-merge, parallel within worker working copies)\n\nSince multiple workers run in parallel, each confined to its own sub-issue scope, **cross-cutting impact spanning scopes can structurally leak through** (an enum\u002Ffield\u002FCLI flag not reflected in help\u002Ferror messages\u002Fsamples, leftover status wording, lockfile drift, etc.). This is detected **before merging** and folded into the originating PR in Phase Final-3 (originating from [Issue #70](https:\u002F\u002Fgithub.com\u002Fozzy-labs\u002Fskills\u002Fissues\u002F70) \u002F [#166](https:\u002F\u002Fgithub.com\u002Fozzy-labs\u002Fskills\u002Fissues\u002F166)).\n\n**Why this can be detected before merge, within the worktree**: the essence of a cross-cutting gap is \"PR-A adds enum X → help\u002Fdocs (an existing file nobody touched) doesn't reflect X.\" This existing file can be grepped in **PR-A's own working copy (which includes X)**, so \"no X = gap\" can be detected there, determinable before merging into main (equivalent to a post-merge grep of main).\n\n**Parallel**: since each PR's inspection is independent, **run it in parallel per PR (by default)**. Each inspection is performed within that worker's working copy (workers aren't cleaned up until Phase Final-5, so they remain).\n\n##### 0. Aggregate reports from workers\n\nAs a starting point for inspection, aggregate the `cross_cutting_gaps` field from every worker's return value. This includes gaps the worker itself noticed but did not fix in its own PR.\n\n##### 1. Sync check for cross-cutting symbols (heuristic)\n\nFor each worker's `pr_number`, fetch the diff with `gh pr diff \u003CN>` (even for stacked PRs, `base...head` = that PR's own diff only, no double-counting), and heuristically extract newly added enum values, field names, and CLI-flag-looking symbols:\n\n```bash\ngh pr diff \u003CN> | grep -E '^\\+' | grep -oE '(case\\s+[\"'\\'']\\w[\\w-]+[\"'\\''])|(--[a-z][a-z0-9-]+)|([\"'\\''][a-z][a-z0-9-]+[\"'\\''])' | sort -u\n```\n\nGrep the extracted symbols across the whole repo within that worker's working copy, and check whether they're reflected in help strings \u002F error messages \u002F samples \u002F docs (false positives are acceptable; the AI judges).\n\n##### 2. Detecting remnants of stale wording\n\nIf a status keyword (`alpha`, `beta`, `Phase \\d+`, `pending`, etc.) has been removed in a PR, grep within the working copy for whether the same string remains as a remnant in other files. Legitimate uses as proper nouns are excluded by the AI's judgment.\n\n##### 3. lockfile drift\n\nDetect, from each PR's diff, cases where a lockfile (`pnpm-lock.yaml` \u002F `package-lock.json` \u002F `uv.lock`, etc.) was changed in the PR but the corresponding manifest (`package.json` \u002F `pyproject.toml`, etc.) was not — or vice versa.\n\n##### 4. docs ⇄ code grep consistency (reduced-scope version)\n\nExtract newly added CLI invocation strings from the diff of docs-related PRs (with a `docs:` title, etc.), and grep within the working copy for whether the corresponding string exists on the code side. No \"execution-based\" verification is performed.\n\n##### Audit output (attribution)\n\nOutput each detected gap **attributed to its originating PR** in the following form. Phase Final-3 uses this `source_pr` to decide where to fold it:\n\n```text\ngap:        \u003Ctarget_file:line — symbol \u002F message>\nsource_pr:  #\u003CN>（symbol を導入した PR）\ncategory:   enum-flag-sync | stale-text | lockfile-drift | docs-code\n```\n\nWorker reports and independently detected ones are deduplicated. The dedup key is based on `file:line`; if the same `file:line` has multiple messages, both are listed (no information is discarded). If there are 0 gaps, Final-3 is skipped.\n\n#### Phase Final-3: reconciliation (folding into the originating PR, parallel per PR)\n\nGroup the gaps detected in Final-2 by `source_pr`, and **fix and push in the originating PR's working copy** (since it's before the merge, this naturally folds into the PR, leaving no follow-up behind).\n\n- **Parallel**: groupBy gaps per PR → **parallel per PR** (no collision, since each uses a separate working copy). **Multiple gaps within the same PR are sequential** (they share the same working copy)\n- **Steps**: edit the target file in the originating PR's working copy → lint (auto-fix) → commit (`fix(sync): ...`) → push\n- **No full review loop is run** (since this is mechanical synchronization). Only a lint pass is confirmed\n\nEdge cases:\n\n| Case | Handling |\n|---|---|\n| The target file is already being edited by a different PR-B, causing a folding conflict | Give up folding into the originating PR and fall back to a **dedicated reconciliation PR** (below) |\n| Multiple PRs introduce the same symbol | Dedicated reconciliation PR |\n| Reconciliation's lint\u002Ffolding fails | **Fail-soft**: leave only that gap as a warning and continue the run (same as for things that can't be mechanically fixed at the design level) |\n| Folding introduces a new cross-cutting issue | audit→reconciliation is **fixed at 1 pass** (not recursive). The remainder is a warning. Guarantees convergence and a cost ceiling |\n| Folding into an upstream stacked PR → downstream base drift | Subsumed into Phase Final-4's dependency-order merge procedure |\n\n**Dedicated reconciliation PR**: a corrective PR created when a single gap can't be folded into one PR (conflict \u002F spanning multiple PRs). Since a GitHub PR's base is singular, \"stacked onto every tip\" isn't possible. So **it merges last, with main as the base, after all content PRs have merged** (built into the tail of Phase Final-4). This PR is also merged within the run, so no follow-up is left behind.\n\nGaps resolved via reconciliation are recorded in the aggregate report as \"resolved within the run (folded)\". Only gaps left over via fail-soft are treated as warnings.\n\n#### Phase Final-4: dependency-order merge (centralized by the parent)\n\nSince workers don't self-merge, the actual merge is centrally managed here by the parent. The merge follows the central policy's `irreversible` gate (see \"Merge and the autonomy policy\"; default `ask`). It runs when `--merge` is specified (`--merge` is an explicit opt-in that overrides the gate to `proceed`; when not specified, it follows the default `ask` and goes through the \"After completion\" confirmation below).\n\nMerge each PR in topological order (upstream → downstream):\n\n1. `POLICY_GUARD_PROCEED=merge gh pr merge \u003C上流> --squash` (**remote-only merge; do not add `--delete-branch`** — at this point the worker's working copy still holds the branch and remains, so deleting the local branch would fail with `fatal: '\u003Cbranch>' is already used by worktree`. Deletion of the remote\u002Flocal branch and the working copy is consolidated into Final-5 cleanup. `POLICY_GUARD_PROCEED=merge` conveys `--merge`'s proceed override to the PreToolUse `policy-hook.mjs`; see \"Merge and the autonomy policy\")\n2. Reassign the downstream PR's base with `gh pr edit \u003C下流> --base main` (switching the base from the upstream head → main) before merging the next one. Since the upstream's squash-merge has already introduced changes into main, if the base reassignment alone causes a phantom conflict, run `git rebase origin\u002Fmain` in the downstream's working copy before continuing (the parent-side ref is left untouched)\n3. **If a dedicated reconciliation PR was created in Phase Final-3, it merges last, with main as the base, after all content PRs have merged** (this PR too is merged within the run, leaving no follow-up)\n4. If auto-merge is disabled on the repository \u002F an immediate merge isn't possible due to branch protection, etc. → leave that PR as `merge-ready` and mark its downstream dependents as `skipped`, with a warning\n5. Confirm each PR's merge completion with `gh pr view --json mergedAt,state` before proceeding to the next (waiting for the squash merge to take effect)\n\nEven if the parent dies partway through, drive can continue the rest via idempotent resume (detecting already-merged PRs).\n\n#### Phase Final-5: cleanup of worker working copies\n\nCleans up the working copies and related local branches for **workers launched in this drive run**. Since this runs after Final-4's merge, successful workers are all already merged and become cleanup targets (working copies that used to be \"left as merge-ready\" are now also cleaned up here, resolving the leftover problem). Orphans outside this run's scope are out of scope (delegated to `\u002Fhealth` area #7. [Issue #71](https:\u002F\u002Fgithub.com\u002Fozzy-labs\u002Fskills\u002Fissues\u002F71)).\n\nCleanup policy by status (common across hosts):\n\n- **`merged`** (merge completed in Final-4): cleanup target\n- **`merge-ready`** (left in place in Final-4 due to auto-merge being unavailable): **do not** clean up (leave it until the user merges manually)\n- **`failed`**: **do not** clean up (leave it so it can be resumed by re-running)\n\nThe specific deletion steps and known pitfalls (loss of cwd, lock release, leftover synthetic branches) depend on the isolation mechanism, so follow the host-specific procedure (Claude Code: \"Phase Final-5: subagent worktree cleanup\" in `SKILL.claude-code.md`). If any working copy other than `merged` remains, or cleanup itself fails, output a list of leftovers and manual cleanup steps as a warning at the end of the aggregate report.\n\n#### Phase Final-6: aggregate report\n\nFormatting the aggregate report is handled by `drive-report.mjs aggregate`. Passing the array of worker return values and the meta collected in Final-1 through Final-5 (`{results, targets_order, original_args, cross_cutting, cleanup, integrity_warnings}`) via stdin or `--input` returns formatted per-status counts, review aggregation, cross-cutting\u002Fcleanup lines, and the output decision for the resume line:\n\n```bash\necho '\u003Caggregate-json>' | node \u003Cこの skill のディレクトリ>\u002Fdrive-report.mjs aggregate\n```\n\nBased on the results of the consistency check, audit, reconciliation, merge, and cleanup, output the aggregate report:\n\n```text\ndrive 完了 (4\u002F5 merged, 1 skipped):\n  #1 feat: ...        | PR #100 | merged\n  #2 fix:  ...        | PR #101 | merged       (Review: C0 W0 I2)\n  #3 feat: ...        | PR #102 | merged\n  #4 chore: ...       | skipped (upstream failed: #5)\n  #5 refactor: ...    | failed (test loop)\n\n集計:\n  merged:           3\n  skipped:          1\n  failed:           1\n  総レビュー反復:    5 回\n  cross-cutting:    2 gaps resolved (folded into PR #100, #102)\n  cleanup:          3\u002F5 removed (2 preserved: 1 failed, 1 skipped)\n\n再開: \u002Fdrive \u003C元の引数>\n```\n\nThe `cross-cutting:` line displays the number of gaps resolved via reconciliation in Phase Final-3 and the PRs they were folded into, in the form `\u003CN> gaps resolved (folded into ...)`. If a dedicated reconciliation PR was created and merged, it also appears as one line in the merged list, and the PR number is included in `folded into`. If there are 0 gaps, it's `cross-cutting: none`. If gaps remain via fail-soft, it's shown as `\u003CN> resolved, \u003CM> unresolved (warning)`, with a warning block listing the unresolved items and a recommendation for manual handling.\n\nThe `再開:` line is **always** output as a single line right after the tally block — `再開: \u002Fdrive \u003C元の引数>` — whenever there's 1 or more `failed` \u002F leftover `merge-ready` \u002F `skipped` (following the \"Argument restoration (resume command)\" convention). Re-running triggers idempotent resume, which detects already-merged PRs \u002F existing PRs, skips completed targets, and continues from the remaining targets. It's not shown when all targets complete as merged.\n\n## Failure semantics\n\n| Situation | Treatment | Impact on downstream |\n|---|---|---|\n| Per-axis exit_criteria still unmet even after the review loop cap | partial success (merge-ready) | none |\n| Auto-merge unavailable in Phase Final-4 (branch protection, etc.) | leave that PR as merge-ready | downstream marked skipped |\n| implement \u002F ship aborted (test failure, etc.) | failed | skipped |\n| Reconciliation folding fails | fail-soft (gap left as a warning) | none (the PR itself is still merge-ready) |\n| Independent task failure | doesn't affect other parallel tasks | - |\n\nFor any failure or leftover, the resume method is the same — just re-run the `再開: \u002Fdrive \u003C元の引数>` at the end of the report (see Phase 5 \u002F Phase Final-6). Idempotent resume detects the existing PR \u002F branch \u002F already-merged PR, skips completed targets, and resumes from where it left off.\n\n## Notes\n\n- Never read or stage `.env` files\n- If the `gh` CLI is unauthenticated, display an error message and abort\n- Merging follows the central autonomy policy's `irreversible` gate (default `ask`; see \"Merge and the autonomy policy\"). It is not performed by default, and runs only when `--merge` is specified (`--merge` is an explicit opt-in that overrides the gate to `proceed`; single mode auto-merges in Phase 4, orchestration has the parent centrally merge in dependency order in Phase Final-4)\n- Orchestration workers don't self-merge (they stop at `merge-ready` and the parent merges in Final-4). This allows cross-cutting concerns to be folded in before the merge\n- Info findings are not fixed, only reported (design-related changes aren't made mechanically)\n- In orchestration mode, workers are always launched in an isolated working copy (the isolation mechanism is host-dependent)\n- Exceeding a concurrency of 8 only warns. Be mindful of GitHub Actions concurrent-run limits \u002F API rate limits \u002F observability \u002F cost\n- If a circular dependency is detected, report the error and abort\n",{"name":5,"description":7},"main","db212a47efe751fa1c42bd76e61dbfd8328e5b10",".agents\u002Fskills\u002Fdrive","https:\u002F\u002Fgithub.com\u002Fozzy-labs\u002Fskills","https:\u002F\u002Fgithub.com\u002Fozzy-labs","2026-07-13 06:49:42",{"source":8,"skillName":5,"commands":49,"prompt":59,"zipAvailable":60},[50,53,56],{"tool":51,"command":52},"npx","npx skills add ozzy-labs\u002Fskills --skill drive",{"tool":54,"command":55},"bunx","bunx skills add ozzy-labs\u002Fskills --skill drive",{"tool":57,"command":58},"pnpm","pnpm dlx skills add ozzy-labs\u002Fskills --skill drive","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fozzy-labs\u002Fskills\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fdrive\u002FSKILL.md",true,[62,68,72,78],{"path":63,"resourceType":64,"resourceTypeDesc":65,"sizeBytes":66,"sourceHtmlUrl":67},"drive-plan.mjs","SCRIPT","脚本",19539,"https:\u002F\u002Fgithub.com\u002Fozzy-labs\u002Fskills\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fdrive\u002Fdrive-plan.mjs",{"path":69,"resourceType":64,"resourceTypeDesc":65,"sizeBytes":70,"sourceHtmlUrl":71},"drive-report.mjs",12307,"https:\u002F\u002Fgithub.com\u002Fozzy-labs\u002Fskills\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fdrive\u002Fdrive-report.mjs",{"path":73,"resourceType":74,"resourceTypeDesc":75,"sizeBytes":76,"sourceHtmlUrl":77},"SKILL.claude-code.md","REFERENCE","参考文档",39605,"https:\u002F\u002Fgithub.com\u002Fozzy-labs\u002Fskills\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fdrive\u002FSKILL.claude-code.md",{"path":79,"resourceType":74,"resourceTypeDesc":75,"sizeBytes":80,"sourceHtmlUrl":81},"worktree-safety.claude-code.md",9418,"https:\u002F\u002Fgithub.com\u002Fozzy-labs\u002Fskills\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fdrive\u002Fworktree-safety.claude-code.md",[83,109,135,157,179,200],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":37},"01M71J6R63H4E6ZE6KMDM4CT85","verify","An integrated skill that runs the combined validation of build \u002F typecheck \u002F test \u002F lint in one shot. The `verify.mjs` engine auto-discovers validation commands via a discovery chain (AGENTS.md's 「検証」 section → package.json scripts → justfile\u002FMakefile\u002Flefthook → language heuristics), executes them serially with their source attached, and returns a result summary. If a higher-priority stage produces a hit, only that stage is executed (no crossing stages).","https:\u002F\u002Fgithub.com\u002Fozzy-labs\u002Fskills\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fverify\u002FSKILL.md",[],[85,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108],"combined","heuristics","chain","repo","discovery","section","lefthook","only","auto","package","stage","Bash","one","lint","dry","engine","with","test","typecheck",{"skillNo":110,"name":111,"nameZh":6,"description":112,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":113,"categories":114,"keywords":115,"publishedAt":37},"01M71J6JW7SAY9PDKAWHG3SJCR","usage-guard","Monitors Claude Code's Usage Limit (5-hour = Current \u002F weekly = Weekly), pauses work when it exceeds 95%, and automatically resumes once the reset restores headroom. Bundles an engine form that a caller such as drive Reads at a checkpoint, and a standalone form, `\u002Fusage-guard \"\u003Ccontinuation command>\"`, that guards arbitrary work. Claude-only (depends on the OAuth usage-rate endpoint + ScheduleWakeup).","https:\u002F\u002Fgithub.com\u002Fozzy-labs\u002Fskills\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fusage-guard\u002FSKILL.md",[],[116,117,118,119,120,97,121,122,123,124,125,126,127,128,129,130,131,132,133,134],"usage","usage guard","guard","weekly","standalone","guards","when","code","reset","work","command","at","rate","status","endpoint","as","continuation","form","limit",{"skillNo":136,"name":137,"nameZh":6,"description":138,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":139,"categories":140,"keywords":141,"publishedAt":37},"01M71J6FRG119REA1G0S99Q4GZ","topics","Selects GitHub topic candidates by having the `topics.mjs` engine perform constraint validation, popularity measurement, broad+narrow \u002F singular-plural comparison, and hardcoded ozzy-labs conventions, then applies them via `gh repo edit --add-topic` following the policy's `externally-visible` gate (default batch-confirm). Scope is limited to use within ozzy-labs.","https:\u002F\u002Fgithub.com\u002Fozzy-labs\u002Fskills\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Ftopics\u002FSKILL.md",[],[137,142,143,93,144,145,146,147,148,149,150,101,151,152,153,104,105,154,155,156],"measurement","scope","policy","default","true","gh","plural","use","comparison","apply","candidate","batch","candidates","github","via",{"skillNo":158,"name":159,"nameZh":6,"description":160,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":161,"categories":162,"keywords":163,"publishedAt":37},"01M71J6DC27P4FDSP10SDT2PSN","skill-observability","Defines the skill observability event contract (event.schema.json) and emit substrate (obs-emit.mjs). The SSOT for the measurement layer of the skill improvement loop. Referenced by other skills and hooks.","https:\u002F\u002Fgithub.com\u002Fozzy-labs\u002Fskills\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fskill-observability\u002FSKILL.md",[],[164,165,142,166,167,168,169,170,171,172,173,174,175,176,177,178],"observability","skill observability","improvement","skill improvement","for","event","hooks","contract","schema","loop","false","substrate","json","improvement loop","layer",{"skillNo":180,"name":181,"nameZh":6,"description":182,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":183,"categories":184,"keywords":185,"publishedAt":37},"01M71J6AYECH1J94RAZ49QZ19Y","skill-metrics","Aggregates the local observability event log (~\u002F.agents\u002Fobservability\u002Fevents.jsonl) and presents, read-only, per-skill invocation counts and notable events (fallback \u002F HITL rejection \u002F loop cap reached \u002F abort). Fires on \"show me the skill metrics,\" \"aggregate the observability results,\" \"which skills get used the most?\" Does not send anything.","https:\u002F\u002Fgithub.com\u002Fozzy-labs\u002Fskills\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fskill-metrics\u002FSKILL.md",[],[186,187,164,188,189,190,191,192,169,193,194,195,196,146,97,173,197,101,198,199],"skill metrics","metrics","event log","which","show","get","read-only","iso","aggregates","send","local","show me","log","jsonl",{"skillNo":201,"name":202,"nameZh":6,"description":203,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":204,"categories":205,"keywords":206,"publishedAt":37},"01M71J68TD0QFATGW3BBZVCWA2","ship","Runs verification, commit, and PR creation all at once. An integrated pipeline that runs verify (build + type + test + lint) → commit → PR creation in sequence against the changes.","https:\u002F\u002Fgithub.com\u002Fozzy-labs\u002Fskills\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fship\u002FSKILL.md",[],[202,207,208,107,209,24,85,35,210,211,127,212,213,214,146,27,101,215,103],"type","verification","changes","build","pipeline","read","sequence","grep","commit"]