[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M72TAT086ZA602DS57K7P1K5":3,"skill-same:01M72TAT086ZA602DS57K7P1K5":89},{"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":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":23,"commitSha":24,"skillDirectory":25,"forksCount":26,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":29,"ownerDescription":6,"updatedAt":30,"install":31,"resources":44},"01M72TAT086ZA602DS57K7P1K5","ywc-finish-branch",null,"(ywc) Use when delivering one completed feature branch to the base branch: PR-ready, CI wait, bot review polling, merge, post-merge verification, task bookkeeping, and local branch cleanup. Triggers: \"finish branch\", \"deliver branch\", \"ywc-finish-branch\", \"merge feature branch\", \"branch 마무리\", \"ブランチ完了\", \"deliver task\". Do not use for branch creation, worktree management, draft PR creation alone (use ywc-create-pr), or PR review comment handling (use ywc-handle-pr-reviews).","yongwoon\u002Fywc-agent-toolkit","yongwoon","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F9317029?v=4","01M72SZSF6VKANKG5QTMV4V95S","01M72SZSG8HHC3W2CV5P7EJ5AH",8,"MIT","https:\u002F\u002Fgithub.com\u002Fyongwoon\u002Fywc-agent-toolkit\u002Fblob\u002Fmain\u002Fcodex\u002Fskills\u002Fywc-finish-branch\u002FSKILL.md",[],[],"2026-11-10 22:39:42",false,"---\nname: ywc-finish-branch\ndescription: >-\n  (ywc) Use when delivering one completed feature branch to the base branch:\n  PR-ready, CI wait, bot review polling, merge, post-merge verification, task\n  bookkeeping, and local branch cleanup. Triggers: \"finish branch\", \"deliver\n  branch\", \"ywc-finish-branch\", \"merge feature branch\", \"branch 마무리\",\n  \"ブランチ完了\", \"deliver task\". Do not use for branch creation, worktree\n  management, draft PR creation alone (use ywc-create-pr), or PR review\n  comment handling (use ywc-handle-pr-reviews).\n---\n\n# ywc-finish-branch\n\n**Announce at start:** \"I'm using the ywc-finish-branch skill to deliver this feature branch.\"\n\nEncapsulates the post-implementation delivery flow that `ywc-sequential-executor` and `ywc-parallel-executor` previously inlined separately. One feature branch, one task — given a verified branch with passing local tests, this skill takes it the rest of the way to \"done\": optionally creates the PR, marks it ready, waits for CI, handles automated bot reviews, merges (PR or local), runs the post-merge hard gate, moves the task directory to `completed\u002F`, and deletes the local feature branch. Worktree-specific cleanup is intentionally **not** in scope — that stays with `ywc-parallel-executor` because the lifecycle differs.\n\n## Rationalization Defense\n\nWhen tempted to skip a step, check this table first:\n\n| Excuse | Reality |\n|---|---|\n| \"Step 4 (Merge) succeeded, that means we are done\" | The Definition of Done has 5 conditions. Merge is condition 2 of 5. Mark Task Complete (Step 7) and branch deletion (Step 8) are equally required — skipping them silently breaks dependency resolution for downstream tasks. |\n| \"Post-merge verification is just running `git log` — skip it for speed\" | The hard gate exists because `git merge` can silently no-op (already merged, nothing to do, fast-forward elided) and the caller cannot tell from exit code alone. Always verify. |\n| \"Bot review polling found 0 comments, skip the wait window\" | Polling the full window is the contract. Bots can post asynchronously after CI completes; cutting short the window misses real findings. `poll-pr-reviews.sh --verify` must confirm the completed-poll artifact before merge. |\n| \"Branch was already deleted by `gh pr merge --delete-branch`, skip the local cleanup\" | `--delete-branch` only removes the **remote** branch. The local copy persists and the next task's branch creation will conflict. Always run `git branch -d`. |\n| \"Mode flag conflict was already validated upstream, skip the check here\" | This skill is a callable unit and may be invoked outside the executors. Validate flag conflicts at every entry point, not just the upstream caller. |\n| \"Mark Task Complete is bookkeeping — defer it for after all wave tasks merge\" | `tasks\u002Fcompleted\u002F` is the contract that downstream tasks read for dependency resolution. Move-then-merge ordering is forbidden by the Definition of Done; merge-then-move within the same task cycle is required. |\n| \"If `git merge --no-ff` reports a conflict, abort and try again\" | An aborted merge loses the working state needed to debug the conflict. **Never** auto-abort — surface the conflict to the user so they can inspect it. |\n| \"`build-pr-title.py` exited 1 — I'll use just the slug as the title\" | Exit 1 means `TASK_NUMBER` was not detected. Stop and return `NEEDS_CONTEXT` — do not construct a title without `[TASK_NUMBER]`. A title without the task number cannot be traced back to the task in the audit trail. |\n| \"`ywc-create-pr` generates its own title from `git log`, so `--title` is optional\" | `ywc-create-pr`'s internal title generation does not know the task-number format. It silently produces a title without `[TASK_NUM]`. Always pass `--title` explicitly with `[TASK_NUMBER]` already included. |\n| \"CI failed twice — return BLOCKED and let the user fix it\" | Before returning BLOCKED, categorize the failure type. Lint\u002Fformat failures are auto-fixable without judgment. Type errors and build errors usually have a clear mechanical fix visible in the log. Only return BLOCKED when the root cause requires a design decision or all fix attempts are genuinely exhausted. |\n| \"CI is green, so `gh pr merge` will succeed\" | A PR can be `CONFLICTING` or `BEHIND` against the base even with green CI — a sibling task or another PR merged first. Check `gh pr view --json mergeable,mergeStateStatus` before merging instead of letting `gh pr merge` fail. If the branch is merely behind, merge the base into it (never rebase — it orphans review threads) and re-verify CI; if it is a real textual conflict, surface it and return `BLOCKED`. See `..\u002Freferences\u002Fpr-conflict-resolution.md`. |\n| \"The UL update in Step 1.5 is optional bookkeeping — skip it to save time\" | The glossary is the shared vocabulary LLMs use in every subsequent prompt on this project. A branch that introduces new domain terms without updating the glossary silently pollutes downstream code generation and spec reviews. If `docs\u002Fubiquitous-language.md` does not exist, Step 1.5 skips automatically — there is no overhead in that case. |\n\n**Violating the letter of these rules is violating the spirit.** Delivery is the step where the user trusts the executor most — earning that trust requires honesty about partial completion.\n\n## Arguments\n\n| Parameter | Format | Example | Description |\n|---|---|---|---|\n| `--mode` | `\u003Cmode>` | `--mode local-merge` | One of `normal-pr`, `local-merge`, `draft`, `skip-ci-wait`, `per-task-pr`. See [Modes](#modes). |\n| `--branch` | `feature\u002F\u003Ctask-name>` | `--branch feature\u002Fyk-000001-010-db-create-users` | The feature branch to deliver. Must already exist locally; prefixed, unprefixed, and legacy task names are carried unchanged. |\n| `--base-branch` | `\u003Cbranch-name>` | `--base-branch develop` | Target branch. Default: auto-detect (`develop` > `main` > `master`). |\n| `--task-name` | `\u003Ctask-name>` | `--task-name yk-000001-010-db-create-users` | Task directory name under `\u003Ctasks-dir>\u002F`, used for the Mark Complete commit. All supported ID forms remain valid. |\n| `--tasks-dir` | `\u003Cpath>` | `--tasks-dir tasks\u002F` | Tasks directory root. Default: `tasks\u002F`. |\n| `--pr-lang` | `en` \\| `ja` \\| `ko` \\| `zh` \\| `es` \\| `auto` | `--pr-lang ja` | PR title\u002Fdescription language. If omitted or `auto`, resolve through shared YWC language policy; if no tier resolves a language, ask the user before creating the PR. |\n| `--bot-action` | `sequential` \\| `parallel` | `--bot-action sequential` | Post-bot polling behavior. Default: `sequential` (re-run CI after bot fixes). Use `parallel` when called from a wave loop where CI does not re-gate between bot iterations. |\n| `--defer-push` | flag | | Skip the push of the Mark Complete commit. Used by range-mode callers that batch pushes at the end of the range. |\n| `--keep-branch` | flag | | Skip the local feature branch deletion (`git branch -d`). Used by `ywc-parallel-executor`, where the branch is checked out in a worktree at the time of merge — `git branch -d` would fail until the worktree is removed. Caller takes responsibility for the eventual `git worktree remove` + `git branch -d`. |\n| `--worktree-path` | `\u003Cpath>` | `--worktree-path ..\u002Fworktree-run-001010` | Run merge, verification, and Mark Complete commands against the supplied worktree using `git -C \u003Cpath>` and path-scoped task moves. Used by `ywc-sequential-executor --worktree`. |\n\n**Mode-flag mutual exclusivity**: `--mode` is a single value; conflicts are impossible by construction. The caller is responsible for resolving ambiguity (e.g., the upstream executor's `--draft` and `--local-merge` flags must be collapsed into one `--mode` value before invoking this skill).\n\n## Modes\n\n| Mode | PR? | CI wait? | Merge? | Mark Complete? | Cleanup? | Use case |\n|---|---|---|---|---|---|---|\n| `normal-pr` | yes (delegates to `ywc-create-pr`) | yes | yes (`gh pr merge --delete-branch`) | yes | yes (`git branch -d`) | Default upstream flow |\n| `local-merge` | no | no | yes (`git merge --no-ff` + push) | yes | yes | Personal repos, fast iteration |\n| `draft` | yes | no | no | **no** (task stays open until manually merged) | no | User wants PR for review without auto-merge |\n| `skip-ci-wait` | yes (mark ready) | no | no | **no** | no | User merges manually after offline review |\n| `per-task-pr` | yes | no (caller handles per-wave CI) | no (caller merges locally for wave progression) | no (caller marks complete in wave loop) | no | `ywc-parallel-executor` per-task PR delivery |\n\n`per-task-pr` is the special mode used inside `ywc-parallel-executor`'s wave loop — this skill creates and pushes the PR but stops short of merging or marking complete, because wave-level orchestration handles those steps. For all other modes, this skill executes the full lifecycle.\n\n## Worktree-path Mode\n\nWhen `--worktree-path \u003Cpath>` is supplied, this skill remains a single-branch\ndelivery unit but scopes filesystem and git operations to that worktree:\n\n- Validate the path exists and is a git worktree before changing branches.\n- Use `git -C \u003Cpath>` for branch checks, merge, post-merge verification,\n  marker commits, and branch cleanup.\n- Resolve `\u003Ctasks-dir>` relative to `\u003Cpath>` for Mark Complete so the run-level\n  worktree state and task directories move together.\n- Do not create or remove the worktree here. `ywc-sequential-executor\n  --worktree` owns run-level worktree creation and cleanup through\n  `ywc-worktrees --mode prune --keep-branch`.\n\nExample local-merge command shape:\n\n```bash\ngit -C \u003Cpath> checkout \u003Cbase-branch>\ngit -C \u003Cpath> pull origin \u003Cbase-branch>\ngit -C \u003Cpath> merge --no-ff feature\u002F\u003Ctask-name> -m \"Merge branch 'feature\u002F\u003Ctask-name>'\"\ngit -C \u003Cpath> push origin \u003Cbase-branch>\n```\n\n## Definition of Done\n\nA `--mode normal-pr` or `--mode local-merge` invocation is **done** only when all of the following have happened, in this order:\n\n1. **Verification gate passed** (caller's responsibility — this skill does not re-run tests; the upstream executor must have completed its verification before invoking).\n2. **Merge succeeded**: either the PR was merged via `gh pr merge --delete-branch` (normal-pr) or `git merge --no-ff` succeeded locally and was pushed (local-merge).\n3. **Post-merge verification passed**: `git log -1 --format=\"%s\"` on the base branch begins with `Merge branch 'feature\u002F`.\n4. **Task directory moved**: `git mv \u003Ctasks-dir>\u002F\u003Ctask-name> \u003Ctasks-dir>\u002Fcompleted\u002F\u003Ctask-name>` and the `chore: mark \u003Ctask-name> as completed` commit was created.\n5. **Local feature branch deleted**: `git branch -d feature\u002F\u003Ctask-name>` succeeded (refuses to delete an unmerged branch — that is the safety check).\n\nFor `--mode draft` and `--mode skip-ci-wait`, conditions 2–5 are intentionally not performed; the skill's responsibility ends at PR creation (and ready-marking for `skip-ci-wait`). For `--mode per-task-pr`, only the PR creation portion runs; the caller handles the rest within the wave loop.\n\n## Execution Steps\n\n### Step 1: Validate Inputs\n\n- Confirm `--branch` exists locally (`git branch --list \u003Cbranch>` returns the branch).\n- Confirm `--base-branch` is reachable (`git rev-parse --verify \u003Cbase-branch>` succeeds).\n- Confirm `--task-name` matches an entry under `\u003Ctasks-dir>\u002F` (not under `\u003Ctasks-dir>\u002Fcompleted\u002F`).\n- If `--worktree-path` is supplied, confirm the path exists and use `git -C \u003Cpath>` for all subsequent git commands.\n- For PR-based modes: confirm `gh auth status` succeeds.\n\nIf any check fails, return `NEEDS_CONTEXT` with the specific missing input. Do not proceed with partial information.\n\n### Step 1.5: Ubiquitous Language Update (optional)\n\nCheck whether `docs\u002Fubiquitous-language.md` exists in the project root:\n\n```bash\ntest -f docs\u002Fubiquitous-language.md\n```\n\n- **Exists**: Invoke `ywc-ubiquitous-language --mode update`. This runs before PR creation so that any new domain terms introduced by this branch are captured in the glossary before the PR description is written.\n- **Not exists**: Skip silently — the project has not yet established a ubiquitous language document.\n\n`ywc-create-pr` is called in Step 2 with `--skip-ubiquitous-update` to prevent a second invocation of the same update.\n\n### Step 2: PR Creation (PR-based modes only)\n\nFor `--mode` ∈ {`normal-pr`, `draft`, `skip-ci-wait`, `per-task-pr`}: resolve `--pr-lang` first. Explicit `en|ja|ko|zh|es` wins. Omitted or `auto` language uses [`..\u002Freferences\u002Flanguage-resolution.md`](..\u002Freferences\u002Flanguage-resolution.md); if no policy tier resolves a language, ask the user before creating the PR.\n\nConstruct the PR title per the format below, then invoke `ywc-create-pr` passing:\n- `--title \"\u003Cconstructed-title>\"` — the `[task-number] description` string built from `--task-name` and `--pr-lang`\n- `--lang \u003Cpr-lang>` — so the description is written in the correct language\n- `--base-branch \u003Cbase-branch>` — the resolved target branch\n- `--skip-post-ci-check` — prevents `ywc-create-pr` from running its own post-PR CI + bot check; this skill handles CI verification in Step 4\n- `--skip-ubiquitous-update` — prevents `ywc-create-pr` from running the UL update a second time; Step 1.5 already ran it\n\n`ywc-create-pr` handles security check, CI pre-push validation, push, and PR creation as a draft. Because `--title` is provided explicitly, `ywc-create-pr` will use it verbatim and skip its own title-generation step.\n\n**PR title format**: `[\u003Ctask-number>] \u003Chuman-readable description in --pr-lang>`\n\n`--pr-lang` supports `en`, `ja`, `ko`, `zh`, and `es`. Pass the selected value unchanged to `ywc-create-pr` as `--lang \u003Cpr-lang>`. The PR title\u002Fbody prose follows that language, while branch names, task IDs, file paths, commands, labels, code blocks, and other machine identifiers stay unchanged. If the caller provided an explicit `--title`, `ywc-create-pr` uses it verbatim.\n\nRun the bundled script to extract the task number and English slug without regex parsing:\n\n```bash\nRESOLVER_LAUNCHER=\"$(bash \"${CODEX_HOME:-$HOME\u002F.codex}\u002Fskills\u002Fscripts\u002Fselect-resolver-launcher.sh\" 2>&1)\" || { echo \"BLOCKED: ${RESOLVER_LAUNCHER#BLOCKED: }\" >&2; exit 3; }\nTITLE_SCRIPT=\"$(bash \"$RESOLVER_LAUNCHER\" \"ywc-finish-branch\u002Fscripts\u002Fbuild-pr-title.py\" python)\" || exit $?\npython \"$TITLE_SCRIPT\" \u003Ctask-name>\n# TASK_NUMBER=000001-010\n# SLUG_EN=Db Create Users Table\n```\n\n**If the script exits 1 (`TASK_NUMBER` is empty)**: stop immediately and return `NEEDS_CONTEXT` — report the task name that failed to parse. Do not construct a title with an empty task number.\n\nFor English PRs (`--pr-lang en`), use `--format title` to get the complete title directly:\n\n```bash\nRESOLVER_LAUNCHER=\"$(bash \"${CODEX_HOME:-$HOME\u002F.codex}\u002Fskills\u002Fscripts\u002Fselect-resolver-launcher.sh\" 2>&1)\" || { echo \"BLOCKED: ${RESOLVER_LAUNCHER#BLOCKED: }\" >&2; exit 3; }\nTITLE_SCRIPT=\"$(bash \"$RESOLVER_LAUNCHER\" \"ywc-finish-branch\u002Fscripts\u002Fbuild-pr-title.py\" python)\" || exit $?\npython \"$TITLE_SCRIPT\" \u003Ctask-name> --format title\n# [000001-010] Db Create Users Table\n```\n\nFor other languages (`ja`, `ko`, `zh`, `es`), translate only `SLUG_EN` to `--pr-lang`, then compose: `[\u003CTASK_NUMBER>] \u003Ctranslated-slug>`.\n\nThe script supports initials-prefixed (`yk-000001-010-slug`), current unprefixed (`000001-010-slug`), and legacy (`001010-slug`) task names. Completion moves use the original full task name in every form.\n\n**Before calling `ywc-create-pr`**: verify the constructed title string starts with `[`. If it does not, stop — the `[TASK_NUMBER]` prefix was lost somewhere in the construction. Do not call `ywc-create-pr` without a valid title.\n\nFor `--mode local-merge`: skip this step entirely. Local-merge does not produce a PR.\n\n### Step 3: Mark PR Ready (normal-pr only)\n\nInvoke `gh pr ready \u003Cpr-number>` to convert the draft into an open PR. Skip for `--mode draft`, `--mode skip-ci-wait`, `--mode per-task-pr` (those modes leave the PR as draft or hand control back to the caller).\n\n### Step 4: CI Verification + Bot Review Polling (normal-pr only)\n\n> **Action required**: Read [`..\u002Freferences\u002Fpr-bot-polling.md`](..\u002Freferences\u002Fpr-bot-polling.md) now before proceeding. The 60-second initial wait, the 300-second polling window, the `BOT_COUNT` jq query, and the merge condition are all defined there. Do not implement your own polling logic without reading it first.\n\nRun the CI wait + fix loop and the bot review polling per [..\u002Freferences\u002Fpr-bot-polling.md](..\u002Freferences\u002Fpr-bot-polling.md). The polling reference defines the canonical loop; this skill applies its `--bot-action` parameter to choose the post-bot behavior:\n\nBefore entering Step 4 final or Step 5, run the reference's `poll-pr-reviews.sh --verify \u003Cpr-number>` command. If it fails, return `BLOCKED`; do not treat a timeout, fetch failure, or missing artifact as zero bot comments, and do not call `gh pr merge`.\n\n- `--bot-action sequential`: after `ywc-handle-pr-reviews` runs, re-run the CI verification step before re-polling. Bot fixes may trigger a new CI run that must pass before merging.\n- `--bot-action parallel`: after `ywc-handle-pr-reviews` runs, re-poll without re-gating on CI. The wave loop in `ywc-parallel-executor` handles CI at the wave level.\n\n**CI failure handling (up to 2 fix attempts per failure cycle):**\n\n1. **Identify failing checks:**\n   ```bash\n   gh pr checks \u003Cpr-number>\n   ```\n\n2. **Get failure logs:**\n   ```bash\n   # Get the most recent failed run ID for the feature branch\n   gh run list --branch \u003Cfeature-branch> \\\n     --json databaseId,name,conclusion \\\n     --jq '.[] | select(.conclusion == \"failure\") | .databaseId' | head -1\n   gh run view \u003Crun-id> --log-failed\n   ```\n\n3. **Categorize and fix by failure type:**\n\n   | Failure type | Fix action |\n   |---|---|\n   | Lint \u002F format | Run the project's auto-fix command (`eslint --fix`, `prettier --write`, `ruff --fix`, `biome check --apply`), commit, push |\n   | Type errors | Read compiler output, fix type mismatches in affected files, commit, push |\n   | Test failures | Analyze failing test output, fix the implementation (never disable or weaken tests), commit, push |\n   | Build errors | Read compiler\u002Fbundler output, fix compilation or import errors, commit, push |\n\n4. After each push, re-run the CI wait and bot review polling loop (return to the top of Step 4).\n\n5. If CI still fails after **2 fix attempts**, return `BLOCKED` with: the failing check name(s), a log excerpt (last 30 lines), the PR URL, and the failure category so the user has enough context to resolve it manually.\n\nSkip this step entirely for `--mode local-merge`, `--mode draft`, `--mode skip-ci-wait`, `--mode per-task-pr`.\n\n#### Step 4 final: Merge-Readiness Gate (normal-pr only)\n\nCI green is necessary but not sufficient — the base may have advanced into a conflict while CI ran. Before Step 5's `gh pr merge`, confirm the PR can actually merge:\n\n> **Action required**: Read [`..\u002Freferences\u002Fpr-conflict-resolution.md`](..\u002Freferences\u002Fpr-conflict-resolution.md) — it defines the `mergeable` \u002F `mergeStateStatus` table and the merge-not-rebase update procedure.\n\n```bash\ngh pr view \u003Cpr-number> --json mergeable,mergeStateStatus --jq '{mergeable, mergeStateStatus}'\n```\n\n- `MERGEABLE` \u002F `CLEAN` → proceed to Step 5.\n- `BEHIND` (branch protection requires up-to-date; no textual conflict) → merge the base into the feature branch (never rebase), push, and re-verify CI (counts as one CI cycle). Then re-check the gate.\n- `CONFLICTING` \u002F `DIRTY` that auto-resolves → merge the base into the feature branch (never rebase), push, and re-verify CI (counts as one CI cycle). Then re-check the gate.\n- `CONFLICTING` \u002F `DIRTY` with real textual conflicts → surface the conflicting files + PR URL and return `BLOCKED`. Do not auto-resolve or force-push.\n- `BLOCKED` (a required check or review is missing — not a conflict) → do not run the base-merge procedure; surface the outstanding required check\u002Freview and return `BLOCKED` so the user can resolve the gate.\n- `UNKNOWN` → poll briefly per the reference, then re-read.\n\n### Step 5: Merge\n\nFor `--mode normal-pr`:\n```bash\n# Step 4 must have produced and verified the completed-poll artifact for this PR.\n# Pin to the head Step 4 verified: read headRefOid when its CI gate passed (must match\n# ^[0-9a-f]{40}$, else BLOCKED: head unreadable) and write it here as a literal.\ngh pr merge \u003Cpr-number> --delete-branch --match-head-commit \"\u003CHEAD_SHA>\"\n```\n\nA refused pinned merge means the head moved after CI passed: re-run Step 4 on the new head and pin to it. Never retry the merge unpinned.\n\nFor `--mode local-merge`:\n```bash\n# Caller has already verified its Step 4 (Task Verification); this skill does not re-verify.\ngit checkout \u003Cbase-branch>             # or: git -C \u003Cpath> checkout \u003Cbase-branch>\ngit pull origin \u003Cbase-branch>          # or: git -C \u003Cpath> pull origin \u003Cbase-branch>\ngit merge --no-ff feature\u002F\u003Ctask-name> -m \"Merge branch 'feature\u002F\u003Ctask-name>'\"\ngit push origin \u003Cbase-branch>          # omit when --defer-push is set; use git -C \u003Cpath> in worktree-path mode\ngit branch -d feature\u002F\u003Ctask-name>      # omit when --keep-branch is set; use git -C \u003Cpath> in worktree-path mode\n```\n\nFor all other modes: skip — merge happens later (manual for `draft`, caller for `skip-ci-wait` and `per-task-pr`).\n\n**Why `git merge --no-ff` specifically** (not cherry-pick, not direct commit on main): preserves original commit SHAs, marks the task boundary in `git log --graph`, and lets `git branch -d` act as a built-in safety check that refuses to delete an unmerged branch. Full rationale lives in the upstream executor's `references\u002Fbranch-lifecycle.md`.\n\n**Error handling**: `git merge` conflict → stop and ask the user to resolve manually (do not auto-abort; the user may want to inspect). `gh pr merge` failure due to conflict\u002Fout-of-date → apply the Step 4 final Merge-Readiness Gate (`..\u002Freferences\u002Fpr-conflict-resolution.md`): merge the base into the feature branch and re-verify, or return `BLOCKED` on a real textual conflict. Other `gh pr merge` failures → stop and report. Push rejected (remote moved) → stop; never force-push.\n\n### Step 6: Post-Merge Verification (hard gate)\n\nFor `--mode normal-pr` and `--mode local-merge`:\n```bash\ngit log -1 --format=\"%s\"\n```\nThe output **must** begin with `Merge branch 'feature\u002F`. If not, the merge did not execute correctly — investigate and retry before proceeding to Step 7. Do not write a completion marker for a merge that did not happen; downstream tasks would resolve dependencies against a broken contract.\n\n### Step 7: Mark Task Complete\n\nFor `--mode normal-pr` and `--mode local-merge`:\n\nUse the shared marker script — it handles the `.gitignore` branch, the mandatory marker commit, and the post-move verification in one deterministic step (exits non-zero if anything failed):\n\n```bash\nRESOLVER_LAUNCHER=\"$(bash \"${CODEX_HOME:-$HOME\u002F.codex}\u002Fskills\u002Fscripts\u002Fselect-resolver-launcher.sh\" 2>&1)\" || { echo \"BLOCKED: ${RESOLVER_LAUNCHER#BLOCKED: }\" >&2; exit 3; }\nMARK_SCRIPT=\"$(bash \"$RESOLVER_LAUNCHER\" \"scripts\u002Fmark-complete.sh\" bash)\" || exit $?\nbash \"$MARK_SCRIPT\" \u003Ctasks-dir> \u003Ctask-name> [--push | --defer-push]\n```\n\nIn `--worktree-path` mode, run the marker script from `\u003Cpath>` or pass a\n`\u003Ctasks-dir>` that resolves inside `\u003Cpath>`; the post-move verification must\nprove `\u003Cpath>\u002F\u003Ctasks-dir>\u002Fcompleted\u002F\u003Ctask-name>` exists and\n`\u003Cpath>\u002F\u003Ctasks-dir>\u002F\u003Ctask-name>` is gone.\n\nThe marker script runs `codex\u002Fskills\u002Fywc-task-generator\u002Fscripts\u002Fcompact-dependency-graph.py` between the move and marker commit, using the same resolved `\u003Ctasks-dir>`, and stages the resulting graph when it is tracked. The heading-based compactor retroactively handles existing graphs: completed phases become `## Phase NNNNNN — done` plus a `- Completed: ...` bullet, while fully completed Parallel Execution Notes and Visual Dependency Graph sections are removed. In worktree mode, the script path may come from the main checkout, but `\u003Ctasks-dir>` must resolve inside `\u003Cpath>`.\n\nWhy a script, not inline git: `git mv` cannot stage a path inside a gitignored `\u003Ctasks-dir>` (the move produces no diff), so that case needs a plain `mv` plus an `--allow-empty` marker commit, while a tracked `\u003Ctasks-dir>` uses `git mv`. The script detects which applies. The `chore: mark \u003Ctask-name> as completed` commit is **mandatory in both cases** — it is the `git log` audit boundary that humans, audit tooling, downstream skills, the Completion Report, and resume \u002F replay all rely on to verify task completion at a specific commit. The script then verifies the move (destination exists, source gone, marker commit at HEAD) and exits non-zero if any check fails; **do not declare `DONE` on a non-zero exit** — investigate and retry.\n\n**Push strategy**: pass `--push` to `mark-complete.sh` for `--mode local-merge` and for `--mode normal-pr` when `--defer-push` is **not** set. Otherwise pass `--defer-push` (the script's default) so the caller can batch completion-marker commits and push them once at the end of the range. The caller is responsible for the eventual push when deferral is requested.\n\nFor `--mode draft`, `--mode skip-ci-wait`, `--mode per-task-pr`: skip Step 7 entirely. The task is not yet merged; marking it complete would be incorrect.\n\n### Step 8: Local Branch Cleanup\n\nFor `--mode normal-pr`:\n```bash\ngit checkout \u003Cbase-branch>\ngit pull origin \u003Cbase-branch>\ngit branch -d feature\u002F\u003Ctask-name>      # omit when --keep-branch is set\n```\nThe local branch must be deleted explicitly because `gh pr merge --delete-branch` only removes the remote. Skip the deletion when `--keep-branch` is set — the caller (typically `ywc-parallel-executor`) will release the worktree and delete the branch in its own cleanup step.\n\nFor `--mode local-merge`: already handled inside Step 5's command sequence (which honors `--keep-branch` likewise).\n\nFor all other modes: skip. The branch stays alive for the user or caller to handle.\n\n**Remote deletion guard**: normal delivery removes a remote branch through `gh pr merge --delete-branch`. A separate user-requested remote deletion runs only after every guard below passes, in this order. `$branch` is the caller's branch and `$base` its intended base. These are instruction contracts, not enforced hooks.\n\n1. Validate the branch in-process, without interpolating it into any shell command: it must match `^[A-Za-z0-9._\u002F-]+$` over the whole string, must not start with `-`, and must not contain `..`; only then `git check-ref-format \"refs\u002Fheads\u002F$branch\"` must succeed. Any failure returns `BLOCKED: invalid branch name` and runs no remote command. The branch to delete must also not be `HEAD` (which `check-ref-format` accepts) or equal `$base`; either returns `BLOCKED: refusing to delete \u003Cbranch>` with no remote command. Pass the branch only as a quoted argument, never shell source.\n2. Pin the push target: `url` is `git remote get-url origin` and must not start with `-`. `url` is the git remote URL (HTTPS or SSH, as `git remote get-url` prints it); `gh repo view` accepts both forms. `git remote get-url --push --all origin` must print exactly one line, equal to `url` (a `pushurl` or `pushInsteadOf` would send the delete somewhere these checks never looked); otherwise return `NEEDS_CONTEXT` with zero deletions.\n3. Bind the repository to `origin`: run every `gh` call in this guard as `env -u GH_HOST gh …` with an explicit `--repo`. `env -u GH_HOST gh repo view --json url,isFork,parent,defaultBranchRef -- \"$url\"` (flags before `--`) gives `repo`, the `url` without its `https:\u002F\u002F` prefix (`\u003Chost>\u002F\u003Cowner>\u002F\u003Cname>`). Take `repo` from the `url` field of gh's JSON output (always `https:\u002F\u002F\u003Chost>\u002F\u003Cowner>\u002F\u003Cname>`), never from the git remote string: an SSH remote such as `git@github.com:o\u002Fr.git` has no `https:\u002F\u002F` prefix to strip and would fail the shape check below. When `isFork` is true, `parent` is `\u003Chost>\u002F\u003Cparent.owner.login>\u002F\u003Cparent.name>` and `env -u GH_HOST gh repo view --json isFork -- \"$parent\"` must report `false`; a fork of a fork returns `NEEDS_CONTEXT`. Each value must match `^[A-Za-z0-9.-]+\u002F[A-Za-z0-9._-]+\u002F[A-Za-z0-9._-]+$`, otherwise `NEEDS_CONTEXT`. Every `gh pr list` below runs with `--repo \"$repo\"` and, for a fork, again with `--repo \"$parent\"`; never rely on gh's implicit remote pick.\n4. Read the exact remote tip with `git ls-remote origin \"refs\u002Fheads\u002F$branch\"`. Patterns tail-match, so take `tip` from the one line whose ref field is exactly `refs\u002Fheads\u002F$branch`; it must match `^[0-9a-f]{40}([0-9a-f]{24})?$`. No exact line means the ref is already absent: report it with zero deletions. Then refuse the repository's default branch and any protected branch: `$branch` must differ from `defaultBranchRef.name` of the step 3 JSON, and `env -u GH_HOST gh api --hostname \"\u003Chost>\" \"repos\u002F\u003Cowner>\u002F\u003Cname>\u002Fbranches\u002F$branch\" --jq .protected` (host, owner and name from `repo`) must print exactly `false`; `true` stops with zero deletions and reports `protected branch`. Ambiguous output or a malformed `tip` is `NEEDS_CONTEXT`.\n5. Merged check (unconditional): `env -u GH_HOST gh pr list --repo \"$repo\" --head \"$branch\" --state merged --json number,baseRefName,headRefOid,headRepository,headRepositoryOwner` (plus the `$parent` run for a fork) must return a row whose `baseRefName` is the intended base and `headRefOid` equals the current remote tip. The row's head repository must be `origin`: `headRepositoryOwner.login` and `headRepository.name` must equal the owner and name in `repo`, in the `$parent` run too, since `--head` filters by branch name only and a same-named branch from another fork is not evidence. A different base or tip means zero deletions; a differing tip means commits were pushed after the merge. Never infer a merge from `git branch -r --merged HEAD`, or from `gh pr view \u003Cbranch>` returning only one of several PRs.\n6. Open-PR check, last before the delete to shrink the race window: `env -u GH_HOST gh pr list --repo \"$repo\" --head \"$branch\" --state open --json number` must exit 0, and the parsed array must have exactly 0 entries; for a fork, the `--repo \"$parent\"` run must return an empty array too. Check the array in-process; only a successful, parseable, empty result allows deletion. Any entry is an open PR: stop with zero deletions and report its numbers.\n7. Protect the final delete with a tip-bound lease (`git push --force-with-lease=\"refs\u002Fheads\u002F$branch:$tip\" origin --delete \"refs\u002Fheads\u002F$branch\"`). This lease authorizes deletion of that exact tip only; a push landing after step 4 rejects the delete. A race window remains between step 6 and this push: a PR opened in it is not seen and is auto-closed by the delete; the lease does not cover that. A failed or uncertain result stops subsequent mutation; reconcile the exact remote ref before any retry and rerun every guard. Never turn partial cleanup into `DONE`.\n\nOutcomes: any command exiting non-zero (`gh`, `git ls-remote`, the push) is `BLOCKED`. An undeterminable repository, a value failing its shape check, or ambiguous output (unparseable JSON, a malformed `tip`) is `NEEDS_CONTEXT`. An open PR, no qualifying merged row, or a tip mismatch stops with zero deletions and reports the PR numbers or both SHAs. Compare JSON on the parsed result in-process (or with `jq --arg`); never interpolate `$base` or `$tip` into a `--jq` filter.\n\n**Worktree prune (when caller used a worktree)** — if the caller created a per-task worktree (`ywc-parallel-executor` does this), the post-cleanup prune is delegated to the installed `ywc-worktrees` skill:\n\n```bash\nywc-worktrees --mode prune --task-name \u003Ctask-name>\n```\n\n`ywc-worktrees --mode prune` runs the bundled `cleanup-worktree.sh` against the resolved worktree path — `git worktree remove` + local `git branch -d` + `git worktree prune` + post-removal verification, refusing to operate on dirty worktrees without `--force`. This skill does not inline the prune logic; the worktree priority chain (`.worktrees\u002F` > CLAUDE.md `worktree_root` > `--root` fallback) and the dirty-tree safety check live in one place. Skip this delegation when no worktree was created (the typical `--mode local-merge` \u002F `--mode normal-pr` flow that ran inside the main checkout).\n\n## Output Format\n\n```text\n## Finish Branch Result: \u003Ctask-name>\n\n### Mode\n\u003Cmode>\n\n### Outcome\n- PR: \u003Cpr-url-or-\"none-local-merge\">\n- Merge: \u003Ccommit-sha-or-\"deferred\">\n- Mark Complete commit: \u003Ccommit-sha-or-\"skipped\">\n- Local branch: \u003C\"deleted\"|\"preserved\">\n- Remote branch: \u003C\"deleted\"|\"retained\"|\"already-absent\"|\"uncertain\">\n\n### Verification\n- Post-merge gate: \u003Cpassed|skipped|failed>\n- Post-move gate: \u003Cpassed|skipped|failed>\n\n### Completion Status\n\u003CDONE | DONE_WITH_CONCERNS | BLOCKED | NEEDS_CONTEXT>\n```\n\n**Completion Status rules:**\n\n| Status | When to use |\n|---|---|\n| `DONE` | All applicable steps for the chosen mode succeeded; verification gates passed |\n| `DONE_WITH_CONCERNS` | Delivery succeeded but with caveats (e.g., advisor budget exceeded for the bot-polling loop, or `--defer-push` was set and the caller now owns the push) |\n| `BLOCKED` | Cannot proceed — merge conflict, CI failure unfixable in 2 attempts, push rejected, post-merge verification failed, or a remote deletion guard command failed or the final lease-protected delete failed or had an uncertain result (report `Remote branch: uncertain` — the remote ref may already have changed) |\n| `NEEDS_CONTEXT` | One of `--branch`, `--base-branch`, `--task-name`, `--tasks-dir`, or `--mode` was missing or invalid; no work was performed. A remote deletion guard that finds missing or ambiguous evidence before the delete is attempted also returns this, with `Remote branch: retained` |\n\n## Validation\n\nBefore reporting `DONE`, verify:\n\n- [ ] Input validation passed for branch, base branch, task name, tasks directory, and mode.\n- [ ] PR-based modes created the expected PR and applied the documented CI \u002F bot-review \u002F merge-readiness gates.\n- [ ] `normal-pr` and `local-merge` modes produced a verified merge commit whose subject starts with `Merge branch 'feature\u002F`.\n- [ ] Mark Task Complete moved the task under `\u003Ctasks-dir>\u002Fcompleted\u002F\u003Ctask-name>` or created the required empty marker commit for gitignored task directories.\n- [ ] The latest commit subject is exactly `chore: mark \u003Ctask-name> as completed` after Mark Task Complete.\n- [ ] Local feature branch cleanup ran unless the selected mode or `--keep-branch` explicitly preserves it.\n- [ ] Required pushes completed, or `--defer-push` is reported as a caller-owned concern.\n\n## Banned Output Patterns\n\nThis skill produces operational side effects (commits, pushes, merges), not source code. The \"Banned Output Patterns\" idea applied here means: **never** declare `DONE` while leaving any of the following:\n\n- A merge commit that the post-merge verification step did not confirm\n- A `chore: mark \u003Ctask-name> as completed` commit that has not been verified by the post-move test\n- A local feature branch that should have been deleted (modes `normal-pr` and `local-merge`, when `--keep-branch` is **not** set)\n- An unpushed commit when push was required (modes `local-merge` always; `normal-pr` when `--defer-push` is not set)\n\nEach of these is a hidden defect that breaks the next task's dependency resolution. Surface them honestly via `DONE_WITH_CONCERNS` or `BLOCKED` rather than declaring `DONE`.\n\n## Integration\n\n- **upstream**: `ywc-sequential-executor` (replaces its Steps 5–8), `ywc-parallel-executor` (replaces the merge + mark-complete portion of Step 4e–4f; worktree cleanup at Step 4g stays in parallel).\n- **internal delegation**: `ywc-create-pr` (Step 2), `ywc-handle-pr-reviews` (Step 4 inside the bot polling loop).\n- **shared references**: [..\u002Freferences\u002Fpr-bot-polling.md](..\u002Freferences\u002Fpr-bot-polling.md) (CI + bot polling), [..\u002Freferences\u002Flocal-merge-permissions.md](..\u002Freferences\u002Flocal-merge-permissions.md) (pre-authorized git\u002Fgh patterns the caller must set), [..\u002Freferences\u002Fsubagent-status-actions.md](..\u002Freferences\u002Fsubagent-status-actions.md) (how the caller responds to this skill's status return).\n\n## Notes\n\nThis skill is a single-task delivery unit. It does not iterate over a range, manage a wave, or maintain checkpoint state — those concerns belong to the calling executor. Worktree creation and removal are intentionally out of scope, because the lifecycle differs between sequential (no worktree) and parallel (per-task worktree); placing it here would force one of the two callers to special-case its cleanup.\n","# ywc-finish-branch\n\n**Announce at start:** \"I'm using the ywc-finish-branch skill to deliver this feature branch.\"\n\nEncapsulates the post-implementation delivery flow that `ywc-sequential-executor` and `ywc-parallel-executor` previously inlined separately. One feature branch, one task — given a verified branch with passing local tests, this skill takes it the rest of the way to \"done\": optionally creates the PR, marks it ready, waits for CI, handles automated bot reviews, merges (PR or local), runs the post-merge hard gate, moves the task directory to `completed\u002F`, and deletes the local feature branch. Worktree-specific cleanup is intentionally **not** in scope — that stays with `ywc-parallel-executor` because the lifecycle differs.\n\n## Rationalization Defense\n\nWhen tempted to skip a step, check this table first:\n\n| Excuse | Reality |\n|---|---|\n| \"Step 4 (Merge) succeeded, that means we are done\" | The Definition of Done has 5 conditions. Merge is condition 2 of 5. Mark Task Complete (Step 7) and branch deletion (Step 8) are equally required — skipping them silently breaks dependency resolution for downstream tasks. |\n| \"Post-merge verification is just running `git log` — skip it for speed\" | The hard gate exists because `git merge` can silently no-op (already merged, nothing to do, fast-forward elided) and the caller cannot tell from exit code alone. Always verify. |\n| \"Bot review polling found 0 comments, skip the wait window\" | Polling the full window is the contract. Bots can post asynchronously after CI completes; cutting short the window misses real findings. `poll-pr-reviews.sh --verify` must confirm the completed-poll artifact before merge. |\n| \"Branch was already deleted by `gh pr merge --delete-branch`, skip the local cleanup\" | `--delete-branch` only removes the **remote** branch. The local copy persists and the next task's branch creation will conflict. Always run `git branch -d`. |\n| \"Mode flag conflict was already validated upstream, skip the check here\" | This skill is a callable unit and may be invoked outside the executors. Validate flag conflicts at every entry point, not just the upstream caller. |\n| \"Mark Task Complete is bookkeeping — defer it for after all wave tasks merge\" | `tasks\u002Fcompleted\u002F` is the contract that downstream tasks read for dependency resolution. Move-then-merge ordering is forbidden by the Definition of Done; merge-then-move within the same task cycle is required. |\n| \"If `git merge --no-ff` reports a conflict, abort and try again\" | An aborted merge loses the working state needed to debug the conflict. **Never** auto-abort — surface the conflict to the user so they can inspect it. |\n| \"`build-pr-title.py` exited 1 — I'll use just the slug as the title\" | Exit 1 means `TASK_NUMBER` was not detected. Stop and return `NEEDS_CONTEXT` — do not construct a title without `[TASK_NUMBER]`. A title without the task number cannot be traced back to the task in the audit trail. |\n| \"`ywc-create-pr` generates its own title from `git log`, so `--title` is optional\" | `ywc-create-pr`'s internal title generation does not know the task-number format. It silently produces a title without `[TASK_NUM]`. Always pass `--title` explicitly with `[TASK_NUMBER]` already included. |\n| \"CI failed twice — return BLOCKED and let the user fix it\" | Before returning BLOCKED, categorize the failure type. Lint\u002Fformat failures are auto-fixable without judgment. Type errors and build errors usually have a clear mechanical fix visible in the log. Only return BLOCKED when the root cause requires a design decision or all fix attempts are genuinely exhausted. |\n| \"CI is green, so `gh pr merge` will succeed\" | A PR can be `CONFLICTING` or `BEHIND` against the base even with green CI — a sibling task or another PR merged first. Check `gh pr view --json mergeable,mergeStateStatus` before merging instead of letting `gh pr merge` fail. If the branch is merely behind, merge the base into it (never rebase — it orphans review threads) and re-verify CI; if it is a real textual conflict, surface it and return `BLOCKED`. See `..\u002Freferences\u002Fpr-conflict-resolution.md`. |\n| \"The UL update in Step 1.5 is optional bookkeeping — skip it to save time\" | The glossary is the shared vocabulary LLMs use in every subsequent prompt on this project. A branch that introduces new domain terms without updating the glossary silently pollutes downstream code generation and spec reviews. If `docs\u002Fubiquitous-language.md` does not exist, Step 1.5 skips automatically — there is no overhead in that case. |\n\n**Violating the letter of these rules is violating the spirit.** Delivery is the step where the user trusts the executor most — earning that trust requires honesty about partial completion.\n\n## Arguments\n\n| Parameter | Format | Example | Description |\n|---|---|---|---|\n| `--mode` | `\u003Cmode>` | `--mode local-merge` | One of `normal-pr`, `local-merge`, `draft`, `skip-ci-wait`, `per-task-pr`. See [Modes](#modes). |\n| `--branch` | `feature\u002F\u003Ctask-name>` | `--branch feature\u002Fyk-000001-010-db-create-users` | The feature branch to deliver. Must already exist locally; prefixed, unprefixed, and legacy task names are carried unchanged. |\n| `--base-branch` | `\u003Cbranch-name>` | `--base-branch develop` | Target branch. Default: auto-detect (`develop` > `main` > `master`). |\n| `--task-name` | `\u003Ctask-name>` | `--task-name yk-000001-010-db-create-users` | Task directory name under `\u003Ctasks-dir>\u002F`, used for the Mark Complete commit. All supported ID forms remain valid. |\n| `--tasks-dir` | `\u003Cpath>` | `--tasks-dir tasks\u002F` | Tasks directory root. Default: `tasks\u002F`. |\n| `--pr-lang` | `en` \\| `ja` \\| `ko` \\| `zh` \\| `es` \\| `auto` | `--pr-lang ja` | PR title\u002Fdescription language. If omitted or `auto`, resolve through shared YWC language policy; if no tier resolves a language, ask the user before creating the PR. |\n| `--bot-action` | `sequential` \\| `parallel` | `--bot-action sequential` | Post-bot polling behavior. Default: `sequential` (re-run CI after bot fixes). Use `parallel` when called from a wave loop where CI does not re-gate between bot iterations. |\n| `--defer-push` | flag | | Skip the push of the Mark Complete commit. Used by range-mode callers that batch pushes at the end of the range. |\n| `--keep-branch` | flag | | Skip the local feature branch deletion (`git branch -d`). Used by `ywc-parallel-executor`, where the branch is checked out in a worktree at the time of merge — `git branch -d` would fail until the worktree is removed. Caller takes responsibility for the eventual `git worktree remove` + `git branch -d`. |\n| `--worktree-path` | `\u003Cpath>` | `--worktree-path ..\u002Fworktree-run-001010` | Run merge, verification, and Mark Complete commands against the supplied worktree using `git -C \u003Cpath>` and path-scoped task moves. Used by `ywc-sequential-executor --worktree`. |\n\n**Mode-flag mutual exclusivity**: `--mode` is a single value; conflicts are impossible by construction. The caller is responsible for resolving ambiguity (e.g., the upstream executor's `--draft` and `--local-merge` flags must be collapsed into one `--mode` value before invoking this skill).\n\n## Modes\n\n| Mode | PR? | CI wait? | Merge? | Mark Complete? | Cleanup? | Use case |\n|---|---|---|---|---|---|---|\n| `normal-pr` | yes (delegates to `ywc-create-pr`) | yes | yes (`gh pr merge --delete-branch`) | yes | yes (`git branch -d`) | Default upstream flow |\n| `local-merge` | no | no | yes (`git merge --no-ff` + push) | yes | yes | Personal repos, fast iteration |\n| `draft` | yes | no | no | **no** (task stays open until manually merged) | no | User wants PR for review without auto-merge |\n| `skip-ci-wait` | yes (mark ready) | no | no | **no** | no | User merges manually after offline review |\n| `per-task-pr` | yes | no (caller handles per-wave CI) | no (caller merges locally for wave progression) | no (caller marks complete in wave loop) | no | `ywc-parallel-executor` per-task PR delivery |\n\n`per-task-pr` is the special mode used inside `ywc-parallel-executor`'s wave loop — this skill creates and pushes the PR but stops short of merging or marking complete, because wave-level orchestration handles those steps. For all other modes, this skill executes the full lifecycle.\n\n## Worktree-path Mode\n\nWhen `--worktree-path \u003Cpath>` is supplied, this skill remains a single-branch\ndelivery unit but scopes filesystem and git operations to that worktree:\n\n- Validate the path exists and is a git worktree before changing branches.\n- Use `git -C \u003Cpath>` for branch checks, merge, post-merge verification,\n  marker commits, and branch cleanup.\n- Resolve `\u003Ctasks-dir>` relative to `\u003Cpath>` for Mark Complete so the run-level\n  worktree state and task directories move together.\n- Do not create or remove the worktree here. `ywc-sequential-executor\n  --worktree` owns run-level worktree creation and cleanup through\n  `ywc-worktrees --mode prune --keep-branch`.\n\nExample local-merge command shape:\n\n```bash\ngit -C \u003Cpath> checkout \u003Cbase-branch>\ngit -C \u003Cpath> pull origin \u003Cbase-branch>\ngit -C \u003Cpath> merge --no-ff feature\u002F\u003Ctask-name> -m \"Merge branch 'feature\u002F\u003Ctask-name>'\"\ngit -C \u003Cpath> push origin \u003Cbase-branch>\n```\n\n## Definition of Done\n\nA `--mode normal-pr` or `--mode local-merge` invocation is **done** only when all of the following have happened, in this order:\n\n1. **Verification gate passed** (caller's responsibility — this skill does not re-run tests; the upstream executor must have completed its verification before invoking).\n2. **Merge succeeded**: either the PR was merged via `gh pr merge --delete-branch` (normal-pr) or `git merge --no-ff` succeeded locally and was pushed (local-merge).\n3. **Post-merge verification passed**: `git log -1 --format=\"%s\"` on the base branch begins with `Merge branch 'feature\u002F`.\n4. **Task directory moved**: `git mv \u003Ctasks-dir>\u002F\u003Ctask-name> \u003Ctasks-dir>\u002Fcompleted\u002F\u003Ctask-name>` and the `chore: mark \u003Ctask-name> as completed` commit was created.\n5. **Local feature branch deleted**: `git branch -d feature\u002F\u003Ctask-name>` succeeded (refuses to delete an unmerged branch — that is the safety check).\n\nFor `--mode draft` and `--mode skip-ci-wait`, conditions 2–5 are intentionally not performed; the skill's responsibility ends at PR creation (and ready-marking for `skip-ci-wait`). For `--mode per-task-pr`, only the PR creation portion runs; the caller handles the rest within the wave loop.\n\n## Execution Steps\n\n### Step 1: Validate Inputs\n\n- Confirm `--branch` exists locally (`git branch --list \u003Cbranch>` returns the branch).\n- Confirm `--base-branch` is reachable (`git rev-parse --verify \u003Cbase-branch>` succeeds).\n- Confirm `--task-name` matches an entry under `\u003Ctasks-dir>\u002F` (not under `\u003Ctasks-dir>\u002Fcompleted\u002F`).\n- If `--worktree-path` is supplied, confirm the path exists and use `git -C \u003Cpath>` for all subsequent git commands.\n- For PR-based modes: confirm `gh auth status` succeeds.\n\nIf any check fails, return `NEEDS_CONTEXT` with the specific missing input. Do not proceed with partial information.\n\n### Step 1.5: Ubiquitous Language Update (optional)\n\nCheck whether `docs\u002Fubiquitous-language.md` exists in the project root:\n\n```bash\ntest -f docs\u002Fubiquitous-language.md\n```\n\n- **Exists**: Invoke `ywc-ubiquitous-language --mode update`. This runs before PR creation so that any new domain terms introduced by this branch are captured in the glossary before the PR description is written.\n- **Not exists**: Skip silently — the project has not yet established a ubiquitous language document.\n\n`ywc-create-pr` is called in Step 2 with `--skip-ubiquitous-update` to prevent a second invocation of the same update.\n\n### Step 2: PR Creation (PR-based modes only)\n\nFor `--mode` ∈ {`normal-pr`, `draft`, `skip-ci-wait`, `per-task-pr`}: resolve `--pr-lang` first. Explicit `en|ja|ko|zh|es` wins. Omitted or `auto` language uses [`..\u002Freferences\u002Flanguage-resolution.md`](..\u002Freferences\u002Flanguage-resolution.md); if no policy tier resolves a language, ask the user before creating the PR.\n\nConstruct the PR title per the format below, then invoke `ywc-create-pr` passing:\n- `--title \"\u003Cconstructed-title>\"` — the `[task-number] description` string built from `--task-name` and `--pr-lang`\n- `--lang \u003Cpr-lang>` — so the description is written in the correct language\n- `--base-branch \u003Cbase-branch>` — the resolved target branch\n- `--skip-post-ci-check` — prevents `ywc-create-pr` from running its own post-PR CI + bot check; this skill handles CI verification in Step 4\n- `--skip-ubiquitous-update` — prevents `ywc-create-pr` from running the UL update a second time; Step 1.5 already ran it\n\n`ywc-create-pr` handles security check, CI pre-push validation, push, and PR creation as a draft. Because `--title` is provided explicitly, `ywc-create-pr` will use it verbatim and skip its own title-generation step.\n\n**PR title format**: `[\u003Ctask-number>] \u003Chuman-readable description in --pr-lang>`\n\n`--pr-lang` supports `en`, `ja`, `ko`, `zh`, and `es`. Pass the selected value unchanged to `ywc-create-pr` as `--lang \u003Cpr-lang>`. The PR title\u002Fbody prose follows that language, while branch names, task IDs, file paths, commands, labels, code blocks, and other machine identifiers stay unchanged. If the caller provided an explicit `--title`, `ywc-create-pr` uses it verbatim.\n\nRun the bundled script to extract the task number and English slug without regex parsing:\n\n```bash\nRESOLVER_LAUNCHER=\"$(bash \"${CODEX_HOME:-$HOME\u002F.codex}\u002Fskills\u002Fscripts\u002Fselect-resolver-launcher.sh\" 2>&1)\" || { echo \"BLOCKED: ${RESOLVER_LAUNCHER#BLOCKED: }\" >&2; exit 3; }\nTITLE_SCRIPT=\"$(bash \"$RESOLVER_LAUNCHER\" \"ywc-finish-branch\u002Fscripts\u002Fbuild-pr-title.py\" python)\" || exit $?\npython \"$TITLE_SCRIPT\" \u003Ctask-name>\n# TASK_NUMBER=000001-010\n# SLUG_EN=Db Create Users Table\n```\n\n**If the script exits 1 (`TASK_NUMBER` is empty)**: stop immediately and return `NEEDS_CONTEXT` — report the task name that failed to parse. Do not construct a title with an empty task number.\n\nFor English PRs (`--pr-lang en`), use `--format title` to get the complete title directly:\n\n```bash\nRESOLVER_LAUNCHER=\"$(bash \"${CODEX_HOME:-$HOME\u002F.codex}\u002Fskills\u002Fscripts\u002Fselect-resolver-launcher.sh\" 2>&1)\" || { echo \"BLOCKED: ${RESOLVER_LAUNCHER#BLOCKED: }\" >&2; exit 3; }\nTITLE_SCRIPT=\"$(bash \"$RESOLVER_LAUNCHER\" \"ywc-finish-branch\u002Fscripts\u002Fbuild-pr-title.py\" python)\" || exit $?\npython \"$TITLE_SCRIPT\" \u003Ctask-name> --format title\n# [000001-010] Db Create Users Table\n```\n\nFor other languages (`ja`, `ko`, `zh`, `es`), translate only `SLUG_EN` to `--pr-lang`, then compose: `[\u003CTASK_NUMBER>] \u003Ctranslated-slug>`.\n\nThe script supports initials-prefixed (`yk-000001-010-slug`), current unprefixed (`000001-010-slug`), and legacy (`001010-slug`) task names. Completion moves use the original full task name in every form.\n\n**Before calling `ywc-create-pr`**: verify the constructed title string starts with `[`. If it does not, stop — the `[TASK_NUMBER]` prefix was lost somewhere in the construction. Do not call `ywc-create-pr` without a valid title.\n\nFor `--mode local-merge`: skip this step entirely. Local-merge does not produce a PR.\n\n### Step 3: Mark PR Ready (normal-pr only)\n\nInvoke `gh pr ready \u003Cpr-number>` to convert the draft into an open PR. Skip for `--mode draft`, `--mode skip-ci-wait`, `--mode per-task-pr` (those modes leave the PR as draft or hand control back to the caller).\n\n### Step 4: CI Verification + Bot Review Polling (normal-pr only)\n\n> **Action required**: Read [`..\u002Freferences\u002Fpr-bot-polling.md`](..\u002Freferences\u002Fpr-bot-polling.md) now before proceeding. The 60-second initial wait, the 300-second polling window, the `BOT_COUNT` jq query, and the merge condition are all defined there. Do not implement your own polling logic without reading it first.\n\nRun the CI wait + fix loop and the bot review polling per [..\u002Freferences\u002Fpr-bot-polling.md](..\u002Freferences\u002Fpr-bot-polling.md). The polling reference defines the canonical loop; this skill applies its `--bot-action` parameter to choose the post-bot behavior:\n\nBefore entering Step 4 final or Step 5, run the reference's `poll-pr-reviews.sh --verify \u003Cpr-number>` command. If it fails, return `BLOCKED`; do not treat a timeout, fetch failure, or missing artifact as zero bot comments, and do not call `gh pr merge`.\n\n- `--bot-action sequential`: after `ywc-handle-pr-reviews` runs, re-run the CI verification step before re-polling. Bot fixes may trigger a new CI run that must pass before merging.\n- `--bot-action parallel`: after `ywc-handle-pr-reviews` runs, re-poll without re-gating on CI. The wave loop in `ywc-parallel-executor` handles CI at the wave level.\n\n**CI failure handling (up to 2 fix attempts per failure cycle):**\n\n1. **Identify failing checks:**\n   ```bash\n   gh pr checks \u003Cpr-number>\n   ```\n\n2. **Get failure logs:**\n   ```bash\n   # Get the most recent failed run ID for the feature branch\n   gh run list --branch \u003Cfeature-branch> \\\n     --json databaseId,name,conclusion \\\n     --jq '.[] | select(.conclusion == \"failure\") | .databaseId' | head -1\n   gh run view \u003Crun-id> --log-failed\n   ```\n\n3. **Categorize and fix by failure type:**\n\n   | Failure type | Fix action |\n   |---|---|\n   | Lint \u002F format | Run the project's auto-fix command (`eslint --fix`, `prettier --write`, `ruff --fix`, `biome check --apply`), commit, push |\n   | Type errors | Read compiler output, fix type mismatches in affected files, commit, push |\n   | Test failures | Analyze failing test output, fix the implementation (never disable or weaken tests), commit, push |\n   | Build errors | Read compiler\u002Fbundler output, fix compilation or import errors, commit, push |\n\n4. After each push, re-run the CI wait and bot review polling loop (return to the top of Step 4).\n\n5. If CI still fails after **2 fix attempts**, return `BLOCKED` with: the failing check name(s), a log excerpt (last 30 lines), the PR URL, and the failure category so the user has enough context to resolve it manually.\n\nSkip this step entirely for `--mode local-merge`, `--mode draft`, `--mode skip-ci-wait`, `--mode per-task-pr`.\n\n#### Step 4 final: Merge-Readiness Gate (normal-pr only)\n\nCI green is necessary but not sufficient — the base may have advanced into a conflict while CI ran. Before Step 5's `gh pr merge`, confirm the PR can actually merge:\n\n> **Action required**: Read [`..\u002Freferences\u002Fpr-conflict-resolution.md`](..\u002Freferences\u002Fpr-conflict-resolution.md) — it defines the `mergeable` \u002F `mergeStateStatus` table and the merge-not-rebase update procedure.\n\n```bash\ngh pr view \u003Cpr-number> --json mergeable,mergeStateStatus --jq '{mergeable, mergeStateStatus}'\n```\n\n- `MERGEABLE` \u002F `CLEAN` → proceed to Step 5.\n- `BEHIND` (branch protection requires up-to-date; no textual conflict) → merge the base into the feature branch (never rebase), push, and re-verify CI (counts as one CI cycle). Then re-check the gate.\n- `CONFLICTING` \u002F `DIRTY` that auto-resolves → merge the base into the feature branch (never rebase), push, and re-verify CI (counts as one CI cycle). Then re-check the gate.\n- `CONFLICTING` \u002F `DIRTY` with real textual conflicts → surface the conflicting files + PR URL and return `BLOCKED`. Do not auto-resolve or force-push.\n- `BLOCKED` (a required check or review is missing — not a conflict) → do not run the base-merge procedure; surface the outstanding required check\u002Freview and return `BLOCKED` so the user can resolve the gate.\n- `UNKNOWN` → poll briefly per the reference, then re-read.\n\n### Step 5: Merge\n\nFor `--mode normal-pr`:\n```bash\n# Step 4 must have produced and verified the completed-poll artifact for this PR.\n# Pin to the head Step 4 verified: read headRefOid when its CI gate passed (must match\n# ^[0-9a-f]{40}$, else BLOCKED: head unreadable) and write it here as a literal.\ngh pr merge \u003Cpr-number> --delete-branch --match-head-commit \"\u003CHEAD_SHA>\"\n```\n\nA refused pinned merge means the head moved after CI passed: re-run Step 4 on the new head and pin to it. Never retry the merge unpinned.\n\nFor `--mode local-merge`:\n```bash\n# Caller has already verified its Step 4 (Task Verification); this skill does not re-verify.\ngit checkout \u003Cbase-branch>             # or: git -C \u003Cpath> checkout \u003Cbase-branch>\ngit pull origin \u003Cbase-branch>          # or: git -C \u003Cpath> pull origin \u003Cbase-branch>\ngit merge --no-ff feature\u002F\u003Ctask-name> -m \"Merge branch 'feature\u002F\u003Ctask-name>'\"\ngit push origin \u003Cbase-branch>          # omit when --defer-push is set; use git -C \u003Cpath> in worktree-path mode\ngit branch -d feature\u002F\u003Ctask-name>      # omit when --keep-branch is set; use git -C \u003Cpath> in worktree-path mode\n```\n\nFor all other modes: skip — merge happens later (manual for `draft`, caller for `skip-ci-wait` and `per-task-pr`).\n\n**Why `git merge --no-ff` specifically** (not cherry-pick, not direct commit on main): preserves original commit SHAs, marks the task boundary in `git log --graph`, and lets `git branch -d` act as a built-in safety check that refuses to delete an unmerged branch. Full rationale lives in the upstream executor's `references\u002Fbranch-lifecycle.md`.\n\n**Error handling**: `git merge` conflict → stop and ask the user to resolve manually (do not auto-abort; the user may want to inspect). `gh pr merge` failure due to conflict\u002Fout-of-date → apply the Step 4 final Merge-Readiness Gate (`..\u002Freferences\u002Fpr-conflict-resolution.md`): merge the base into the feature branch and re-verify, or return `BLOCKED` on a real textual conflict. Other `gh pr merge` failures → stop and report. Push rejected (remote moved) → stop; never force-push.\n\n### Step 6: Post-Merge Verification (hard gate)\n\nFor `--mode normal-pr` and `--mode local-merge`:\n```bash\ngit log -1 --format=\"%s\"\n```\nThe output **must** begin with `Merge branch 'feature\u002F`. If not, the merge did not execute correctly — investigate and retry before proceeding to Step 7. Do not write a completion marker for a merge that did not happen; downstream tasks would resolve dependencies against a broken contract.\n\n### Step 7: Mark Task Complete\n\nFor `--mode normal-pr` and `--mode local-merge`:\n\nUse the shared marker script — it handles the `.gitignore` branch, the mandatory marker commit, and the post-move verification in one deterministic step (exits non-zero if anything failed):\n\n```bash\nRESOLVER_LAUNCHER=\"$(bash \"${CODEX_HOME:-$HOME\u002F.codex}\u002Fskills\u002Fscripts\u002Fselect-resolver-launcher.sh\" 2>&1)\" || { echo \"BLOCKED: ${RESOLVER_LAUNCHER#BLOCKED: }\" >&2; exit 3; }\nMARK_SCRIPT=\"$(bash \"$RESOLVER_LAUNCHER\" \"scripts\u002Fmark-complete.sh\" bash)\" || exit $?\nbash \"$MARK_SCRIPT\" \u003Ctasks-dir> \u003Ctask-name> [--push | --defer-push]\n```\n\nIn `--worktree-path` mode, run the marker script from `\u003Cpath>` or pass a\n`\u003Ctasks-dir>` that resolves inside `\u003Cpath>`; the post-move verification must\nprove `\u003Cpath>\u002F\u003Ctasks-dir>\u002Fcompleted\u002F\u003Ctask-name>` exists and\n`\u003Cpath>\u002F\u003Ctasks-dir>\u002F\u003Ctask-name>` is gone.\n\nThe marker script runs `codex\u002Fskills\u002Fywc-task-generator\u002Fscripts\u002Fcompact-dependency-graph.py` between the move and marker commit, using the same resolved `\u003Ctasks-dir>`, and stages the resulting graph when it is tracked. The heading-based compactor retroactively handles existing graphs: completed phases become `## Phase NNNNNN — done` plus a `- Completed: ...` bullet, while fully completed Parallel Execution Notes and Visual Dependency Graph sections are removed. In worktree mode, the script path may come from the main checkout, but `\u003Ctasks-dir>` must resolve inside `\u003Cpath>`.\n\nWhy a script, not inline git: `git mv` cannot stage a path inside a gitignored `\u003Ctasks-dir>` (the move produces no diff), so that case needs a plain `mv` plus an `--allow-empty` marker commit, while a tracked `\u003Ctasks-dir>` uses `git mv`. The script detects which applies. The `chore: mark \u003Ctask-name> as completed` commit is **mandatory in both cases** — it is the `git log` audit boundary that humans, audit tooling, downstream skills, the Completion Report, and resume \u002F replay all rely on to verify task completion at a specific commit. The script then verifies the move (destination exists, source gone, marker commit at HEAD) and exits non-zero if any check fails; **do not declare `DONE` on a non-zero exit** — investigate and retry.\n\n**Push strategy**: pass `--push` to `mark-complete.sh` for `--mode local-merge` and for `--mode normal-pr` when `--defer-push` is **not** set. Otherwise pass `--defer-push` (the script's default) so the caller can batch completion-marker commits and push them once at the end of the range. The caller is responsible for the eventual push when deferral is requested.\n\nFor `--mode draft`, `--mode skip-ci-wait`, `--mode per-task-pr`: skip Step 7 entirely. The task is not yet merged; marking it complete would be incorrect.\n\n### Step 8: Local Branch Cleanup\n\nFor `--mode normal-pr`:\n```bash\ngit checkout \u003Cbase-branch>\ngit pull origin \u003Cbase-branch>\ngit branch -d feature\u002F\u003Ctask-name>      # omit when --keep-branch is set\n```\nThe local branch must be deleted explicitly because `gh pr merge --delete-branch` only removes the remote. Skip the deletion when `--keep-branch` is set — the caller (typically `ywc-parallel-executor`) will release the worktree and delete the branch in its own cleanup step.\n\nFor `--mode local-merge`: already handled inside Step 5's command sequence (which honors `--keep-branch` likewise).\n\nFor all other modes: skip. The branch stays alive for the user or caller to handle.\n\n**Remote deletion guard**: normal delivery removes a remote branch through `gh pr merge --delete-branch`. A separate user-requested remote deletion runs only after every guard below passes, in this order. `$branch` is the caller's branch and `$base` its intended base. These are instruction contracts, not enforced hooks.\n\n1. Validate the branch in-process, without interpolating it into any shell command: it must match `^[A-Za-z0-9._\u002F-]+$` over the whole string, must not start with `-`, and must not contain `..`; only then `git check-ref-format \"refs\u002Fheads\u002F$branch\"` must succeed. Any failure returns `BLOCKED: invalid branch name` and runs no remote command. The branch to delete must also not be `HEAD` (which `check-ref-format` accepts) or equal `$base`; either returns `BLOCKED: refusing to delete \u003Cbranch>` with no remote command. Pass the branch only as a quoted argument, never shell source.\n2. Pin the push target: `url` is `git remote get-url origin` and must not start with `-`. `url` is the git remote URL (HTTPS or SSH, as `git remote get-url` prints it); `gh repo view` accepts both forms. `git remote get-url --push --all origin` must print exactly one line, equal to `url` (a `pushurl` or `pushInsteadOf` would send the delete somewhere these checks never looked); otherwise return `NEEDS_CONTEXT` with zero deletions.\n3. Bind the repository to `origin`: run every `gh` call in this guard as `env -u GH_HOST gh …` with an explicit `--repo`. `env -u GH_HOST gh repo view --json url,isFork,parent,defaultBranchRef -- \"$url\"` (flags before `--`) gives `repo`, the `url` without its `https:\u002F\u002F` prefix (`\u003Chost>\u002F\u003Cowner>\u002F\u003Cname>`). Take `repo` from the `url` field of gh's JSON output (always `https:\u002F\u002F\u003Chost>\u002F\u003Cowner>\u002F\u003Cname>`), never from the git remote string: an SSH remote such as `git@github.com:o\u002Fr.git` has no `https:\u002F\u002F` prefix to strip and would fail the shape check below. When `isFork` is true, `parent` is `\u003Chost>\u002F\u003Cparent.owner.login>\u002F\u003Cparent.name>` and `env -u GH_HOST gh repo view --json isFork -- \"$parent\"` must report `false`; a fork of a fork returns `NEEDS_CONTEXT`. Each value must match `^[A-Za-z0-9.-]+\u002F[A-Za-z0-9._-]+\u002F[A-Za-z0-9._-]+$`, otherwise `NEEDS_CONTEXT`. Every `gh pr list` below runs with `--repo \"$repo\"` and, for a fork, again with `--repo \"$parent\"`; never rely on gh's implicit remote pick.\n4. Read the exact remote tip with `git ls-remote origin \"refs\u002Fheads\u002F$branch\"`. Patterns tail-match, so take `tip` from the one line whose ref field is exactly `refs\u002Fheads\u002F$branch`; it must match `^[0-9a-f]{40}([0-9a-f]{24})?$`. No exact line means the ref is already absent: report it with zero deletions. Then refuse the repository's default branch and any protected branch: `$branch` must differ from `defaultBranchRef.name` of the step 3 JSON, and `env -u GH_HOST gh api --hostname \"\u003Chost>\" \"repos\u002F\u003Cowner>\u002F\u003Cname>\u002Fbranches\u002F$branch\" --jq .protected` (host, owner and name from `repo`) must print exactly `false`; `true` stops with zero deletions and reports `protected branch`. Ambiguous output or a malformed `tip` is `NEEDS_CONTEXT`.\n5. Merged check (unconditional): `env -u GH_HOST gh pr list --repo \"$repo\" --head \"$branch\" --state merged --json number,baseRefName,headRefOid,headRepository,headRepositoryOwner` (plus the `$parent` run for a fork) must return a row whose `baseRefName` is the intended base and `headRefOid` equals the current remote tip. The row's head repository must be `origin`: `headRepositoryOwner.login` and `headRepository.name` must equal the owner and name in `repo`, in the `$parent` run too, since `--head` filters by branch name only and a same-named branch from another fork is not evidence. A different base or tip means zero deletions; a differing tip means commits were pushed after the merge. Never infer a merge from `git branch -r --merged HEAD`, or from `gh pr view \u003Cbranch>` returning only one of several PRs.\n6. Open-PR check, last before the delete to shrink the race window: `env -u GH_HOST gh pr list --repo \"$repo\" --head \"$branch\" --state open --json number` must exit 0, and the parsed array must have exactly 0 entries; for a fork, the `--repo \"$parent\"` run must return an empty array too. Check the array in-process; only a successful, parseable, empty result allows deletion. Any entry is an open PR: stop with zero deletions and report its numbers.\n7. Protect the final delete with a tip-bound lease (`git push --force-with-lease=\"refs\u002Fheads\u002F$branch:$tip\" origin --delete \"refs\u002Fheads\u002F$branch\"`). This lease authorizes deletion of that exact tip only; a push landing after step 4 rejects the delete. A race window remains between step 6 and this push: a PR opened in it is not seen and is auto-closed by the delete; the lease does not cover that. A failed or uncertain result stops subsequent mutation; reconcile the exact remote ref before any retry and rerun every guard. Never turn partial cleanup into `DONE`.\n\nOutcomes: any command exiting non-zero (`gh`, `git ls-remote`, the push) is `BLOCKED`. An undeterminable repository, a value failing its shape check, or ambiguous output (unparseable JSON, a malformed `tip`) is `NEEDS_CONTEXT`. An open PR, no qualifying merged row, or a tip mismatch stops with zero deletions and reports the PR numbers or both SHAs. Compare JSON on the parsed result in-process (or with `jq --arg`); never interpolate `$base` or `$tip` into a `--jq` filter.\n\n**Worktree prune (when caller used a worktree)** — if the caller created a per-task worktree (`ywc-parallel-executor` does this), the post-cleanup prune is delegated to the installed `ywc-worktrees` skill:\n\n```bash\nywc-worktrees --mode prune --task-name \u003Ctask-name>\n```\n\n`ywc-worktrees --mode prune` runs the bundled `cleanup-worktree.sh` against the resolved worktree path — `git worktree remove` + local `git branch -d` + `git worktree prune` + post-removal verification, refusing to operate on dirty worktrees without `--force`. This skill does not inline the prune logic; the worktree priority chain (`.worktrees\u002F` > CLAUDE.md `worktree_root` > `--root` fallback) and the dirty-tree safety check live in one place. Skip this delegation when no worktree was created (the typical `--mode local-merge` \u002F `--mode normal-pr` flow that ran inside the main checkout).\n\n## Output Format\n\n```text\n## Finish Branch Result: \u003Ctask-name>\n\n### Mode\n\u003Cmode>\n\n### Outcome\n- PR: \u003Cpr-url-or-\"none-local-merge\">\n- Merge: \u003Ccommit-sha-or-\"deferred\">\n- Mark Complete commit: \u003Ccommit-sha-or-\"skipped\">\n- Local branch: \u003C\"deleted\"|\"preserved\">\n- Remote branch: \u003C\"deleted\"|\"retained\"|\"already-absent\"|\"uncertain\">\n\n### Verification\n- Post-merge gate: \u003Cpassed|skipped|failed>\n- Post-move gate: \u003Cpassed|skipped|failed>\n\n### Completion Status\n\u003CDONE | DONE_WITH_CONCERNS | BLOCKED | NEEDS_CONTEXT>\n```\n\n**Completion Status rules:**\n\n| Status | When to use |\n|---|---|\n| `DONE` | All applicable steps for the chosen mode succeeded; verification gates passed |\n| `DONE_WITH_CONCERNS` | Delivery succeeded but with caveats (e.g., advisor budget exceeded for the bot-polling loop, or `--defer-push` was set and the caller now owns the push) |\n| `BLOCKED` | Cannot proceed — merge conflict, CI failure unfixable in 2 attempts, push rejected, post-merge verification failed, or a remote deletion guard command failed or the final lease-protected delete failed or had an uncertain result (report `Remote branch: uncertain` — the remote ref may already have changed) |\n| `NEEDS_CONTEXT` | One of `--branch`, `--base-branch`, `--task-name`, `--tasks-dir`, or `--mode` was missing or invalid; no work was performed. A remote deletion guard that finds missing or ambiguous evidence before the delete is attempted also returns this, with `Remote branch: retained` |\n\n## Validation\n\nBefore reporting `DONE`, verify:\n\n- [ ] Input validation passed for branch, base branch, task name, tasks directory, and mode.\n- [ ] PR-based modes created the expected PR and applied the documented CI \u002F bot-review \u002F merge-readiness gates.\n- [ ] `normal-pr` and `local-merge` modes produced a verified merge commit whose subject starts with `Merge branch 'feature\u002F`.\n- [ ] Mark Task Complete moved the task under `\u003Ctasks-dir>\u002Fcompleted\u002F\u003Ctask-name>` or created the required empty marker commit for gitignored task directories.\n- [ ] The latest commit subject is exactly `chore: mark \u003Ctask-name> as completed` after Mark Task Complete.\n- [ ] Local feature branch cleanup ran unless the selected mode or `--keep-branch` explicitly preserves it.\n- [ ] Required pushes completed, or `--defer-push` is reported as a caller-owned concern.\n\n## Banned Output Patterns\n\nThis skill produces operational side effects (commits, pushes, merges), not source code. The \"Banned Output Patterns\" idea applied here means: **never** declare `DONE` while leaving any of the following:\n\n- A merge commit that the post-merge verification step did not confirm\n- A `chore: mark \u003Ctask-name> as completed` commit that has not been verified by the post-move test\n- A local feature branch that should have been deleted (modes `normal-pr` and `local-merge`, when `--keep-branch` is **not** set)\n- An unpushed commit when push was required (modes `local-merge` always; `normal-pr` when `--defer-push` is not set)\n\nEach of these is a hidden defect that breaks the next task's dependency resolution. Surface them honestly via `DONE_WITH_CONCERNS` or `BLOCKED` rather than declaring `DONE`.\n\n## Integration\n\n- **upstream**: `ywc-sequential-executor` (replaces its Steps 5–8), `ywc-parallel-executor` (replaces the merge + mark-complete portion of Step 4e–4f; worktree cleanup at Step 4g stays in parallel).\n- **internal delegation**: `ywc-create-pr` (Step 2), `ywc-handle-pr-reviews` (Step 4 inside the bot polling loop).\n- **shared references**: [..\u002Freferences\u002Fpr-bot-polling.md](..\u002Freferences\u002Fpr-bot-polling.md) (CI + bot polling), [..\u002Freferences\u002Flocal-merge-permissions.md](..\u002Freferences\u002Flocal-merge-permissions.md) (pre-authorized git\u002Fgh patterns the caller must set), [..\u002Freferences\u002Fsubagent-status-actions.md](..\u002Freferences\u002Fsubagent-status-actions.md) (how the caller responds to this skill's status return).\n\n## Notes\n\nThis skill is a single-task delivery unit. It does not iterate over a range, manage a wave, or maintain checkpoint state — those concerns belong to the calling executor. Worktree creation and removal are intentionally out of scope, because the lifecycle differs between sequential (no worktree) and parallel (per-task worktree); placing it here would force one of the two callers to special-case its cleanup.\n",{"name":5,"description":7},"main","7e8ac872e53df8c89d75663e031626281a2a2f5c","codex\u002Fskills\u002Fywc-finish-branch",1,"https:\u002F\u002Fgithub.com\u002Fyongwoon\u002Fywc-agent-toolkit","https:\u002F\u002Fgithub.com\u002Fyongwoon","https:\u002F\u002Fwww.webhani.com","2026-11-08 17:14:59",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add yongwoon\u002Fywc-agent-toolkit --skill ywc-finish-branch",{"tool":37,"command":38},"bunx","bunx skills add yongwoon\u002Fywc-agent-toolkit --skill ywc-finish-branch",{"tool":40,"command":41},"pnpm","pnpm dlx skills add yongwoon\u002Fywc-agent-toolkit --skill ywc-finish-branch","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fyongwoon\u002Fywc-agent-toolkit\u002Fblob\u002Fmain\u002Fcodex\u002Fskills\u002Fywc-finish-branch\u002FSKILL.md",true,[45,51,55,59,63,67,71,75,79,85],{"path":46,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":49,"sourceHtmlUrl":50},"agents\u002Fopenai.yaml","REFERENCE","参考文档",356,"https:\u002F\u002Fgithub.com\u002Fyongwoon\u002Fywc-agent-toolkit\u002Fblob\u002Fmain\u002Fcodex\u002Fskills\u002Fywc-finish-branch\u002Fagents\u002Fopenai.yaml",{"path":52,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":53,"sourceHtmlUrl":54},"evals\u002Fevals.json",5347,"https:\u002F\u002Fgithub.com\u002Fyongwoon\u002Fywc-agent-toolkit\u002Fblob\u002Fmain\u002Fcodex\u002Fskills\u002Fywc-finish-branch\u002Fevals\u002Fevals.json",{"path":56,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":57,"sourceHtmlUrl":58},"README.en.md",4208,"https:\u002F\u002Fgithub.com\u002Fyongwoon\u002Fywc-agent-toolkit\u002Fblob\u002Fmain\u002Fcodex\u002Fskills\u002Fywc-finish-branch\u002FREADME.en.md",{"path":60,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":61,"sourceHtmlUrl":62},"README.es.md",4906,"https:\u002F\u002Fgithub.com\u002Fyongwoon\u002Fywc-agent-toolkit\u002Fblob\u002Fmain\u002Fcodex\u002Fskills\u002Fywc-finish-branch\u002FREADME.es.md",{"path":64,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":65,"sourceHtmlUrl":66},"README.ja.md",4239,"https:\u002F\u002Fgithub.com\u002Fyongwoon\u002Fywc-agent-toolkit\u002Fblob\u002Fmain\u002Fcodex\u002Fskills\u002Fywc-finish-branch\u002FREADME.ja.md",{"path":68,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":69,"sourceHtmlUrl":70},"README.ko.md",4157,"https:\u002F\u002Fgithub.com\u002Fyongwoon\u002Fywc-agent-toolkit\u002Fblob\u002Fmain\u002Fcodex\u002Fskills\u002Fywc-finish-branch\u002FREADME.ko.md",{"path":72,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":73,"sourceHtmlUrl":74},"README.md",4318,"https:\u002F\u002Fgithub.com\u002Fyongwoon\u002Fywc-agent-toolkit\u002Fblob\u002Fmain\u002Fcodex\u002Fskills\u002Fywc-finish-branch\u002FREADME.md",{"path":76,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":77,"sourceHtmlUrl":78},"README.zh.md",4236,"https:\u002F\u002Fgithub.com\u002Fyongwoon\u002Fywc-agent-toolkit\u002Fblob\u002Fmain\u002Fcodex\u002Fskills\u002Fywc-finish-branch\u002FREADME.zh.md",{"path":80,"resourceType":81,"resourceTypeDesc":82,"sizeBytes":83,"sourceHtmlUrl":84},"scripts\u002Fbuild-pr-title.py","SCRIPT","脚本",3997,"https:\u002F\u002Fgithub.com\u002Fyongwoon\u002Fywc-agent-toolkit\u002Fblob\u002Fmain\u002Fcodex\u002Fskills\u002Fywc-finish-branch\u002Fscripts\u002Fbuild-pr-title.py",{"path":86,"resourceType":81,"resourceTypeDesc":82,"sizeBytes":87,"sourceHtmlUrl":88},"tests\u002Fbuild-pr-title-test.sh",1544,"https:\u002F\u002Fgithub.com\u002Fyongwoon\u002Fywc-agent-toolkit\u002Fblob\u002Fmain\u002Fcodex\u002Fskills\u002Fywc-finish-branch\u002Ftests\u002Fbuild-pr-title-test.sh",[90,96,102,109,116,123],{"skillNo":91,"name":92,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":18},"01M72TQ84GTCPCV2VJ778V17TW","missing-frontmatter","https:\u002F\u002Fgithub.com\u002Fyongwoon\u002Fywc-agent-toolkit\u002Fblob\u002Fmain\u002Fscripts\u002Ffixtures\u002Fcodex-description-limit\u002Fmissing-frontmatter\u002FSKILL.md",[],[],{"skillNo":97,"name":98,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":99,"categories":100,"keywords":101,"publishedAt":18},"01M72TQ6M4BFWE7P9EPW0GZDCM","malformed-frontmatter","https:\u002F\u002Fgithub.com\u002Fyongwoon\u002Fywc-agent-toolkit\u002Fblob\u002Fmain\u002Fscripts\u002Ffixtures\u002Fcodex-description-limit\u002Fmalformed-frontmatter\u002FSKILL.md",[],[],{"skillNo":103,"name":104,"nameZh":6,"description":105,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":106,"categories":107,"keywords":108,"publishedAt":18},"01M72TQ3ESGKXZ4QRWGTX92BKJ","fixture-501-fail","(ywc) Use when aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Do not use for x.","https:\u002F\u002Fgithub.com\u002Fyongwoon\u002Fywc-agent-toolkit\u002Fblob\u002Fmain\u002Fscripts\u002Ffixtures\u002Fcodex-description-limit\u002F501-fail\u002FSKILL.md",[],[],{"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":18},"01M72TQ0HJ8H3R37J9WPWGKJZR","fixture-500-pass","(ywc) Use when aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Do not use for x.","https:\u002F\u002Fgithub.com\u002Fyongwoon\u002Fywc-agent-toolkit\u002Fblob\u002Fmain\u002Fscripts\u002Ffixtures\u002Fcodex-description-limit\u002F500-pass\u002FSKILL.md",[],[],{"skillNo":117,"name":118,"nameZh":6,"description":119,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":120,"categories":121,"keywords":122,"publishedAt":18},"01M72TPWNCC7NEYD0D9N12KSQS","ywc-worktrees","(ywc) Use when creating, auditing, pruning, or resolving git worktrees for isolated task workspaces, whether delegated from an executor or used standalone. Triggers: \"worktree 생성\", \"worktree audit\", \"worktree 정리\", \"worktree prune\", \"ywc-worktrees\", \"create worktree\". Do not use for branch creation\u002Fdeletion alone, PR creation (use ywc-create-pr), CI or merge delivery (use ywc-finish-branch), task orchestration (use ywc-sequential-executor or ywc-parallel-executor), or non-git isolation.","https:\u002F\u002Fgithub.com\u002Fyongwoon\u002Fywc-agent-toolkit\u002Fblob\u002Fmain\u002Fplugins\u002Fywc-agent-toolkit\u002Fskills\u002Fywc-worktrees\u002FSKILL.md",[],[],{"skillNo":124,"name":125,"nameZh":6,"description":126,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":127,"categories":128,"keywords":129,"publishedAt":18},"01M72TPRNR3E6QWB91GM98ABBV","ywc-wayfinder","(ywc) Use when a large or uncertain change needs multi-session discovery with a deterministic local map and exactly one active ticket before planning or implementation. Triggers: \"wayfinder\", \"길찾기\", \"discovery map\", \"multi-session discovery\", \"탐색 ticket\", \"経路整理\", \"探索マップ\", \"ywc-wayfinder\". Do not use for ordinary planning (use ywc-plan), idea clarification (use ywc-brainstorm), direct implementation, or tracker\u002Fdatabase writes outside the local Markdown map.","https:\u002F\u002Fgithub.com\u002Fyongwoon\u002Fywc-agent-toolkit\u002Fblob\u002Fmain\u002Fplugins\u002Fywc-agent-toolkit\u002Fskills\u002Fywc-wayfinder\u002FSKILL.md",[],[]]