[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7356MZ7Q5W5KNZ6SSH9CXK2":3,"skill-same:01M7356MZ7Q5W5KNZ6SSH9CXK2":51},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":30,"commitSha":31,"skillDirectory":32,"forksCount":33,"repositoryHtmlUrl":34,"repositoryHomepageUrl":35,"ownerHtmlUrl":36,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":37,"install":38,"resources":50},"01M7356MZ7Q5W5KNZ6SSH9CXK2","post-merge",null,"Wrap up merged PR and run UMS.","Morrison-Lab\u002Fai-config","Morrison-Lab","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F104235520?v=4","01M734G0451S2G35MN4HFQK7XP","Morrison Lab","01M734G059BYFDFQA8YTPDGPMH",4,"MIT","https:\u002F\u002Fgithub.com\u002FMorrison-Lab\u002Fai-config\u002Fblob\u002Fmain\u002Fskills\u002Fpost-merge\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: post-merge\ndescription: \"Wrap up merged PR and run UMS.\"\nuser-invocable: true\nallowed-tools:\n  - Bash\n  - Read\n  - Edit\n  - Write\n---\n\n# post-merge — wrap up a merged PR (verify, tidy, then UMS)\n\nThe per-PR bookend to a piece of work. Once a PR\u002FMR merges: confirm it landed,\nclean up the local branch, make sure nothing was left dangling, and — the\npoint of the skill — **run UMS to learn from how the PR went** while the\nreview lifecycle is still fresh in context.\n\n## When this fires\n\n- A PR\u002FMR you were working on just merged.\n- \"post-merge\", \"wrap up the merged PR\", \"clean up after the merge\", \"the PR\n  merged — now what?\"\n- **\"merge it\" \u002F \"merge this\" route to `merge-it`, not here** — that skill\n  performs the merge first, then chains into this one. Only handle those phrases\n  here when the PR is already merged (no merge left to do).\n- Distinct from **`wrap-up`** (session-level, may span several PRs\u002Fissues) —\n  `post-merge` is the single-PR version, run each time a PR lands.\n\n## Procedure\n\n### 1. Verify the merge — never assume\n\n```bash\ngh pr view \u003CN> --json number,title,state,mergedAt,mergeCommit,headRefName   # VIEW_PR\n# GitLab\nglab mr view \u003CN>\n```\n\nConfirm `state == MERGED` and `mergedAt` is set. If it isn't actually merged,\n**stop and report** — don't tidy a branch whose work hasn't landed. (The\nstanding **never assume; always verify** rule applied to closing out a PR.)\n\n### 1.1. Verify CI passed on the merge commit itself, not only on the PR\n\n[`verify-merge-commit-ci`](..\u002F..\u002Fshared\u002Fworkflow\u002Fverify-merge-commit-ci.md)\n\nThe PR's own CI being green proves nothing about a workflow that only runs\non `push` to the base branch --- a full or PDF render, a deploy, a publish\nstep.\nTake `\u003Cmerge-sha>` from the PR's own `mergeCommit.oid`, not from\n`headRefOid` --- the head is the PR branch's last commit, and a squash or\nmerge commit gets its own, different SHA on the base branch:\n\n```bash\nmerge_sha=$(gh pr view \u003CN> --json mergeCommit -q .mergeCommit.oid)\npython3 scripts\u002Fcheck-merge-commit-ci.py -R \u003Cowner>\u002F\u003Crepo> --sha \"$merge_sha\"\n```\n\nExit 0 is clean.\nExit 1 means a run failed or is still in progress, and the two are handled differently.\nA **failed** run comes before everything else ---\nfix it first,\nper [`fixing-mistakes-is-top-priority`](..\u002F..\u002Fshared\u002Fworkflow\u002Ffixing-mistakes-is-top-priority.md).\nExit 3 means no workflow runs are attached to that SHA yet, which is not a clean verdict.\nThis step applies whether the merge happened under an explicit instruction or under an `mwc` grant ---\nthe grant covers the merge decision, not what happens on `main` afterward.\n\nA run still **in progress**, or exit 3, is a wait rather than a failure.\nArm a check-in that re-runs this step\n(for exit 3, with the bound\n[`verify-merge-commit-ci`](..\u002F..\u002Fshared\u002Fworkflow\u002Fverify-merge-commit-ci.md) sets),\nthen carry on with the rest of the procedure through step 4 now.\nThe PR's learnings are already known,\nand a UMS pass deferred behind a CI wait is the pause\n[`run-ums-proactively`](..\u002F..\u002Fshared\u002Fworkflow\u002Frun-ums-proactively.md) forbids.\nStep 5's report still waits for this step to come back clean at the check-in.\n(Measured 2026-10-08 on\n[Morrison-Lab\u002Flds#460](https:\u002F\u002Fgithub.com\u002FMorrison-Lab\u002Flds\u002Fpull\u002F460) and\n[Morrison-Lab\u002Fmlg#69](https:\u002F\u002Fgithub.com\u002FMorrison-Lab\u002Fmlg\u002Fpull\u002F69):\na session reported both merges,\nsaid the UMS pass would follow the merge-commit check,\nand ended the turn waiting on a pending publish job until the user asked why.)\n\n- **Do:** run this check against the merge commit before step 5's report,\n  every time, not only when a push-triggered workflow is already suspected.\n- **Do:** run step 4's UMS pass while a merge-commit run is still pending,\n  and finish step 1.1 at the check-in.\n- **Don't:** end a turn to wait on a pending merge-commit run\n  with step 4's UMS pass not yet run.\n- **Don't:** read the PR's own green CI as covering a workflow that only\n  triggers on `push`.\n\n### 1.25. Check for reviews that landed just before the merge\n\nA review can post after your last processed round and before the human merges.\nThose findings are real even though they are absent from the merge commit.\nAfter confirming `mergedAt`,\nidentify the last review this session explicitly dispositioned,\nthen read every formal review and PR comment after that timestamp\nand before `mergedAt`.\nDo not use an imprecise \"near the merge time\" window.\nThe lower bound is the last dispositioned review,\nand `mergedAt` is only the upper bound.\n\n**When this session never dispositioned a review on this PR** --- entering\nthrough the \"the PR merged -- now what?\" route, or picking up a PR another\nsession drove --- there is no last-dispositioned-review timestamp to anchor\non.\nDon't skip the scan for lack of a lower bound.\nScan the complete review and comment history through `mergedAt` instead,\nwith no lower bound at all,\nsince anything on the PR is late from this session's point of view.\n\n```bash\ngh api repos\u002F\u003Cowner>\u002F\u003Crepo>\u002Fpulls\u002F\u003CN>\u002Freviews --paginate    # formal review bodies\ngh api repos\u002F\u003Cowner>\u002F\u003Crepo>\u002Fpulls\u002F\u003CN>\u002Fcomments --paginate   # inline review comments\ngh api repos\u002F\u003Cowner>\u002F\u003Crepo>\u002Fissues\u002F\u003CN>\u002Fcomments --paginate  # top-level PR comments\n```\n\nA formal review's top-level body is not enough.\nFor each late review,\nread the inline comments too,\nbecause an empty-body review can carry every finding inline.\nThis is the same two-surface shape `ardi` already requires when reading\nformal reviews;\ndo not reimplement it as a body-only scan here.\n\n**Read the inline comments unfiltered, though --- do not narrow them to one\n`pull_request_review_id`.**\nThat filter is the natural way to pair each late review with its own findings,\nand it is the correct way to drill into a review a human pointed at.\nIt is unsound as a completeness check, because the round and the review object\nare not the same unit: a reviewer can emit two review objects seconds apart\ncarrying one finding each, so filtering by either id returns a strict subset\nthat reads exactly like a complete answer.\n\nTake the timestamp window from the enumeration above, and take *outstanding*\nfrom the **thread list**, which is per-thread rather than per-review and so\ncannot be split across review objects:\n\n```bash\ngh api graphql -f query='{ repository(owner:\"\u003Cowner>\", name:\"\u003Crepo>\") {\n  pullRequest(number:\u003CN>) { reviewThreads(first:100) {\n    totalCount\n    nodes { id isResolved path line comments(first:1){nodes{databaseId}} } } } } }'\n```\n\nPage at `first:100` and select `totalCount`: a `totalCount` above the node\ncount means the cap was hit, so the thread list is itself truncated --- treat\nthat as not-yet-clean, the guard `skills\u002Fpr-status\u002FSKILL.md` and\n`skills\u002Fpr-status-all\u002FSKILL.md` already use.\n`memories\u002Fgh-cli.md` carries the full statement and the case record.\n\n**A finding can also arrive as a plain top-level PR comment rather than a\nformal review** --- a bot posting a summary via `gh pr comment` (or the\nequivalent API call) rather than through the reviews endpoint, or a human\ncommenting directly on the PR conversation.\n`pulls\u002F\u003CN>\u002Freviews` and `pulls\u002F\u003CN>\u002Fcomments` are both scoped to formal\nreviews and their inline threads; neither surface returns a plain PR\nconversation comment.\nThose live on the **issue comments** endpoint --- a pull request is also an\nissue in GitHub's data model --- so the scan needs all three surfaces, not\ntwo, to cover every place a late finding can land.\n\nIf a late review contains findings:\n\n1. Confirm the merge commit does not contain the fix.\n2. File or use a follow-up issue or PR, and carry the findings there with a link back to the merged PR.\n3. Do not count the merged PR's review loop as clean for those findings; the new PR owns them.\n\n- **Do:** check every review and PR comment posted after the last dispositioned review and before `mergedAt`.\n- **Do:** fetch late formal reviews' inline comments, not only their top-level bodies.\n- **Do:** fetch the issue-comments endpoint too, not just the two review surfaces --- a late finding can arrive as a plain top-level PR comment.\n- **Do:** carry late findings forward to a new tracked fix when the merge beat the ARD round.\n- **Don't:** use a vague \"near merge time\" window that can skip a late finding posted well before a delayed merge.\n- **Don't:** treat the merge as proof the final review round was clean.\n- **Don't:** drop a finding because it arrived too late for the merged branch.\n- **Don't:** skip this scan because no last-dispositioned-review timestamp exists --- scan the whole history through `mergedAt` instead.\n- **Don't:** stop at the two formal-review surfaces --- a bot or human can post a late finding as a plain issue comment that neither one returns.\n\n(Morrison-Lab\u002Fai-config#1029:\nCopilot round 7 posted at 2026-08-02T06:29:10Z,\nand the PR merged at 06:30:55Z as `1e0b5fdf`.\nThe suppressed findings were real,\nabsent from the merged code,\nand had to be carried forward to #1034.)\n\n**A review can also arrive *after* `mergedAt`, which the bound above excludes\nby construction.**\nEverything above treats the merge as the scan's upper bound, and for a review\nalready sitting on the PR that is right.\nIt also encodes an assumption that nothing further can land, and a reviewer\ndispatched before the merge does not stop working when the merge happens.\n`post-merge` runs promptly after the merge, which is what makes this a gap\nrather than a curiosity: the scan fires while a late review has not posted\nyet, so a single run returns a clean result that expires.\n\nSo re-read the three surfaces once more before closing the PR out, with no\nupper bound at all, and treat a `submitted_at` later than `mergedAt` as an\nordinary finding rather than as an anomaly.\n\nThat re-read catches a review already sitting on the PR; it cannot catch one\nstill in flight.\nA single synchronous read narrows the window but does not close it --- the\nreview that posted ten minutes after the merge in the case below would still\nbe unposted at the moment `post-merge` runs.\nThe durable catch is staying subscribed to the merged PR's review activity, so\nthe review notification wakes the session when the late verdict actually posts,\nor re-arming a delayed check with a defined completion condition.\n\nTwo things change when the review lands after the merge rather than before it.\n\nThe merged PR is **no longer a place to land code fixes**.\nThat is a third reason for moving work elsewhere, distinct from the two the\ncorpus already carries: ARD's Defer moves a finding because fixing it would\nwiden the PR's scope, and\n[`address-every-comment`](..\u002F..\u002Fshared\u002Fworkflow\u002Faddress-every-comment.md)'s\n`main`-sync case moves one because the line is not yours.\nHere the finding is in scope and is yours, and only the branch it belonged to\nis gone.\n\nAnd the vehicle is a **follow-up PR against `main`**, narrower than the\n\"issue or PR\" item 2 above leaves open.\nThe findings usually still apply to `main`, since `main` now holds the merged\ncode they were written about --- but confirm that against current `main` first,\nsince an overlapping merge can have changed or removed that code before the\nfollow-up runs.\nWhere they do still apply, the fixes are already known, so an issue would\nrecord work that could simply be done.\n\n**Post the back-pointer on the merged PR, not only the forward link.**\nItem 2 asks the follow-up to link back to the merged PR, which serves a reader\nwho already knows the follow-up exists.\nThat is the reader who needs it least.\nThe follow-up is reachable only by someone who has already found it, whereas\nthe merged PR is what a changelog entry, a `git blame`, or the review\nnotification itself points at.\nThat reader finds a review with unaddressed findings sitting under a merged\nbanner, and has no way to tell whether anyone handled them.\nComment on the merged PR naming the follow-up and each finding's disposition,\nso the record reads correctly from whichever end it is entered.\n\n`CLAUDE.md`'s push-races-the-merge case already asks for a comment of this\nshape, saying which of a merged PR's findings did not ship in it.\nIts trigger is a `* [new branch]` push tell rather than a review posting, so\nneither case fires on the other.\n\n- **Do:** re-read the three surfaces with no upper bound before closing out,\n  and treat a review submitted after `mergedAt` as ordinary.\n- **Do:** stay subscribed to the merged PR, or re-arm a delayed check with a\n  completion condition, to catch a review that posts after `post-merge` runs\n  --- a single synchronous re-read cannot close that window.\n- **Do:** open a follow-up PR against `main` when the findings are in scope\n  and the fixes are known, rather than filing an issue.\n- **Do:** comment on the merged PR naming the follow-up and each finding's\n  disposition.\n- **Don't:** read the scan's clean result as durable when it ran promptly\n  after the merge, before a late review could post.\n- **Don't:** treat a post-merge finding as a Defer, since nothing about its\n  scope changed, only the branch's availability.\n- **Don't:** rely on the follow-up's link back as the whole record, since a\n  reader who lands on the merged PR never sees it.\n\n(Morrison-Lab\u002Fai-config#1079 merged at 2026-08-03T03:36:11Z, and Copilot's\nreview posted at 03:46:25Z, ten minutes after the merge rather than two\nminutes before it as in #1029 above.\nIt carried three inline findings plus two more inside a\n`Suppressed comments (2)` block, and all five were correct.\nThey were addressed against `main` in #1082, opened for that purpose and\nmerged at 04:15:05Z, and a comment on #1079 at 03:52:47Z names #1082 and each\nfinding's disposition.)\n\n### 1.5. Cascade conflict scan\n\n**In an ultracode\u002Fcoordinator session, delegate this whole step to a\nsubagent** rather than running the scan-and-resolve loop in the main thread\n--- it's exactly the kind of investigation-plus-fix work the coordinator\nshould hand off (see `memories\u002Fpreferences.md`'s coordinator-mode bullet).\nBrief the subagent with the merged PR's number\u002Fbranch, the resolved invoking\nuser and their aliases, the exact list of PR numbers the request explicitly\nauthorized (possibly empty), the exact list it explicitly excluded (possibly\nempty; a veto over every positive arm, the user's own PRs included), and the\nsteps below;\nhave it report back which PRs it found conflicting, what it did about each,\nand any it skipped (already claimed, conflict it couldn't understand). Do the\nscan inline only for a solo (non-orchestrated) session.\n\n**If any OTHER agents of this session already own a claimed branch (an active,\nresumable `Agent`-tool session, not a one-shot `Workflow`-internal `agent()`\ncall), message each one directly right after the merge, instead of relying solely on\na separate scan to find and fix their conflict after the fact:** \"main just\nadvanced (PR #N merged) --- fetch and merge origin\u002Fmain into your branch now,\nresolve any conflict yourself (you have the context on your own change), then\ncontinue.\" This is faster and higher-context than a scanning subagent\nguessing at the resolution from outside: the branch's own owning agent\nalready knows why its code looks the way it does.\nThose branches are usually this session's own work, but re-check each one\nagainst `memories\u002Freviewing-prs.md`'s scope test before sending the\ninstruction: an assignment can change, and a delegated agent may be driving\nan assigned or requested PR that another author opened.\nA branch that fails the test, or that is claimed by an agent that is not\nyours, is handled like any other open PR: the scope filter decides, and an\nout-of-scope one is reported to the user and left untouched.\nWhen the re-check finds one of this session's own agents on a branch that\nnow fails the test, tell that agent to stop before reporting the PR;\nwithholding the merge-main message alone leaves it free to keep polling and\npushing.\n\n**This depends on the coordinator finding out about a merge in the first\nplace --- so brief every delegated agent, up front, to report back the\ninstant its OWN tracked PR merges, not just when its ARDI work is done.**\nA PR sitting \"ready for merge\" isn't the end of that agent's watch: keep\npolling until the merge actually happens --- by a human, since the agent\nitself must not self-merge --- then notify the coordinator immediately. This\nis what lets the coordinator fan out the \"merge main now\" nudge above to\nevery OTHER live agent right when it matters, instead of the coordinator\nhaving to separately poll every open PR's merge state itself to notice. Fold\nthis into the standard delegation brief (see `gia`\u002F`gii`'s per-issue agent\nprompts) alongside the no-self-merge instruction, rather than treating it as\na one-off ask.\n\nReserve the scan-and-fix\nsubagent above for branches with NO active owning agent (e.g. a completed\n`Workflow` run's one-shot agent that already returned).\n\nA squash-merge on `main` can knock previously-mergeable open PRs into conflict.\nScan right after the merge is confirmed:\n\n```bash\ngh pr list --state open \\\n  --json number,title,headRefName,author,assignees,mergeable,mergeStateStatus,comments   # LIST_PRS\n```\n\nFilter that list by `memories\u002Freviewing-prs.md`'s scope test first, as\n`ardia` step 1 does (opened by or assigned to the invoking user, on the\nexplicitly authorized list from the brief, or authored by the GitHub Actions\napp (`github-actions`)), and report the PRs dropped.\nA conflict on an out-of-scope PR is reported to the user and the PR left\nuntouched (no comment, no push); a claim comment does not bring it into scope.\n\nFor each in-scope PR where `mergeable == \"CONFLICTING\"` **or `\"UNKNOWN\"`** (GitHub can\ntake minutes to finish computing mergeability after a push — a genuinely\nconflicting PR can sit in `UNKNOWN` and get missed if you filter for\n`CONFLICTING` alone):\n\n1. **Verify before claiming — don't trust the flag alone.** See\n   `resolve-conflicts`, \"Verify before you act\": `git merge-tree --write-tree\n   origin\u002Fmain origin\u002F\u003Cbranch>` gives ground truth without a worktree\n   (git ≥ 2.38). Skip if it comes back clean.\n2. **Attribute before claiming --- a conflict this sweep found is not\n   necessarily one your merge caused.**\n   On a repo with an old PR backlog most surviving conflicts are ordinary drift\n   (`DESCRIPTION`, a word list, a directory deleted months ago)\n   and were conflicting before you arrived.\n   Claiming them means resolving other people's branches for no reason.\n   Derive the merge's own deleted and renamed paths\n   and intersect them with each conflict's paths:\n   ```bash\n   merge=$(git rev-parse HEAD)   # the merge commit you just confirmed\n   git diff --name-status -M \"$merge^1\" \"$merge\" | grep -E '^(D|R)'\n   ```\n   A conflicting path in neither set is drift --- skip it.\n   **One exception, and it is the conflict this merge most certainly caused:**\n   a PR **stacked** on the branch you just merged conflicts on the paths that\n   merge modified and added, never on the ones it deleted or renamed, so the\n   intersection is empty and this step would skip it.\n   Check `gh pr list --base \u003Cmerged-branch>` before merging, treat any PR it\n   returns as caused by you whatever the intersection says, and reach for\n   [`cascade`](..\u002Fcascade\u002FSKILL.md) rather than resolving the conflicts\n   line by line.\n   The `git diff` form is used because it is correct for **both** merge\n   styles, which `git show` is not.\n   A squash merge is an ordinary single-parent commit, so\n   `git show --name-status \"$merge\"` diffs it normally and would do.\n   A **true** merge commit has two parents, and `git show` defaults to a\n   combined diff that omits every path changed in only one parent ---\n   on a clean merge that is all of them, so it prints no file list at all\n   and silently yields an empty attribution set.\n   Reaching for `git show` therefore works or fails depending on how the\n   repo merges, which is not a property of the commit in front of you;\n   naming `^1` explicitly removes the question.\n   See [`batch-merge-and-resolve`](..\u002F..\u002Fshared\u002Fworkflow\u002Fbatch-merge-and-resolve.md),\n   \"A conflict your sweep found is not a conflict your merge caused\"\n   and \"A stacked PR is the one conflict that intersection cannot attribute\".\n3. **Check claim status.**\n   Read the most recent comment **of the claim\u002Frelease exchange**, not the most recent comment overall:\n\n   ```bash\n   gh pr view \u003CN> --json comments \\\n     --jq '[.comments[] | select(.body | test(\"hold off|paws off|back off|unclaim|released|PR is free|now mergeable\"; \"i\"))] | last | .body'   # READ_PR_COMMENTS\n   ```\n\n   Any unrelated comment posted after a claim --- a status note, a bot result --- becomes the newest comment while the claim is still live, since a claim expires on activity rather than on age.\n   Reading the newest comment alone therefore reports a claimed PR as free.\n   Match the two-word invariant, `hold off` or either retired wording `paws off` \u002F `back off`, case-insensitively --- never a whole sentence.\n   The PR and issue claims differ after those two words, and the dash between them is an em-dash in this file's own claim emitter (step 4), so a quoted prefix misses claims this very skill posts.\n   See [`claim-pr`](..\u002F..\u002Fshared\u002Fworkflow\u002Fclaim-pr.md)'s \"Match the two-word invariant\".\n\n   **Then check the same comment for a release term, because one release marker contains a claim invariant.**\n   The retired release wording is `... done --- paws off released.`, which matches `paws off` --- so the invariant that fixes one bug introduces another, and this one fails the safe way round: a released PR reads as claimed, the sweep skips it, and the conflict is never resolved with nothing reporting why.\n   The sentence matcher this replaced did not collide, so the collision arrived with the fix.\n   Treat the comment as a release, not a claim, if it also matches `unclaim|released|PR is free|now mergeable`.\n   If a live claim stands --- a push or comment within the last 2 hours --- skip the PR.\n   Another session owns it.\n   An expired claim (over 2 idle hours) no longer blocks.\n   Take over with a fresh claim comment of your own, per [`claim-pr`](..\u002F..\u002Fshared\u002Fworkflow\u002Fclaim-pr.md)'s expiration rule;\n   that claim guards against session collisions on a PR already in scope, and never reads an out-of-scope PR into scope.\n4. **Claim it.**\n   ```bash\n   gh pr comment \u003CN> --body \"Working on this — please hold off on pushing to this branch until I'm done.\n\n   Session worktree: \u003Coutput of git rev-parse --show-toplevel>\n\n   _Posted by Claude Code (AI agent) --- not written by a human._\"   # COMMENT_PR\n   ```\n5. **Create an isolated worktree**, fetch the latest `main` (the squash-merge commit that caused the conflict), and merge:\n   ```bash\n   git fetch origin main \u003Cbranch>   # FETCH — fetch both: we need the new main tip\n   git worktree add .claude\u002Fworktrees\u002Fpr-\u003CN> origin\u002F\u003Cbranch>\n   cd .claude\u002Fworktrees\u002Fpr-\u003CN>\n   git checkout -b \u003Cbranch>         # or --track origin\u002F\u003Cbranch> if the name is free\n   git merge origin\u002Fmain            # MERGE_BRANCH — picks up the new squash-merge commit\n   ```\n6. **Resolve conflicts** using the `resolve-conflicts` skill (consolidate both\n   sides' intent; do not blindly pick one side wholesale).\n7. **Run the repo's pre-commit checks, `git fetch` the branch again, then push.**\n   The claim comment isn't an atomic lock — a repo's own automated bot (e.g. an\n   `@claude` CI agent triggered independently by the same merge event) can pick up\n   and resolve the identical cascade conflict in parallel even when no claim\n   comment was posted. If the fetch shows the remote has moved with an\n   **equivalent** fix already pushed, adopt it (verify with `git merge-tree\n   --write-tree origin\u002Fmain origin\u002F\u003Cbranch>` [git ≥ 2.38] — no remaining conflict — plus a\n   content diff against what you were about to push) instead of force-pushing\n   a duplicate merge commit. Only push your own resolution if the remote is\n   still where you left it.\n   ```bash\n   git fetch origin \u003Cbranch>   # FETCH\n   # If origin\u002F\u003Cbranch> already carries an equivalent fix, stop here — don't push.\n   git diff HEAD origin\u002F\u003Cbranch>   # empty\u002Fequivalent means the bot beat you to it\n   git push origin \u003Cbranch>   # PUSH — only if the remote hasn't moved\n   cd -\n   git worktree remove .claude\u002Fworktrees\u002Fpr-\u003CN>\n   ```\n8. **Unclaim** with a brief resolution summary:\n   ```bash\n   gh pr comment \u003CN> --body \"Conflict resolved — branch is now mergeable. \u003Cone-line summary of what conflicted and how it was resolved>\n\n   _Posted by Claude Code (AI agent) --- not written by a human._\"   # COMMENT_PR\n   ```\n\nResolve PRs one at a time — not because worktrees race each other (each worktree is an independent checkout), but because the same human or bot may be actively working a PR between your claim and your push.\nOne-at-a-time keeps the blast radius small.\nSkip any PR whose conflict is in a file you can't understand without more context — comment asking for clarification instead.\n\n**Match the response to scope, not only to cause.**\nStep 2 says whether a conflict is yours; the scope filter in the paragraph\nabove step 1 says whether the PR is.\nA conflict you genuinely caused on a PR that fails that test is a report to\nthe user naming the deletion or rename and where the content went; the PR\ngets no comment and no push.\nOn an in-scope PR, `sync-with-main` does prescribe re-applying the change on\nthe sibling branch and pushing it, and that fits a workflow or CI file in a\nrepo you drive.\nA release branch carrying an out-of-band process gets the report instead,\nwhatever the test says.\n\n### 2. Tidy the local branch\n\n```bash\nif [ \"$(git branch --show-current)\" != \"main\" ]; then\n  git checkout main\nfi\ngit fetch origin main\nif [ \"$(git rev-parse HEAD)\" != \"$(git rev-parse origin\u002Fmain)\" ]; then\n  git pull --ff-only origin main\nfi\nif git show-ref --verify --quiet \"refs\u002Fheads\u002F\u003Cmerged-branch>\"; then\n  git branch -d \u003Cmerged-branch>     # -d, NOT -D\nfi\n```\n\nUse `git branch -d` (not `-D`): `-d` refuses to delete a branch with commits\nthat aren't merged. If it refuses, the branch has unmerged work — investigate\nbefore forcing anything.\n\n**Both outcomes are normal after a squash merge --- a `-d` that succeeds is not\nevidence the commits reached `main`.**\nThe natural reading of the paragraph above is that `-d` succeeding means `main`\ncontains the work, so a squash-merged branch must always need `-D`.\nIt does not.\n`git-branch(1)` defines the check against the **upstream**, not `main`:\nthe branch must be \"fully merged in its upstream branch, or in HEAD if no\nupstream was set with `--track` or `--set-upstream-to`.\"\nA branch still tracking a live `origin\u002F\u003Cname>` is trivially fully merged into\nits own upstream, so `-d` succeeds and says so:\n\n```\nwarning: deleting branch 'fix\u002Fthing' that has been merged to\n         'refs\u002Fremotes\u002Forigin\u002Ffix\u002Fthing', but not yet merged to HEAD.\n```\n\nWhich branch of that behavior you land on depends on whether the remote ref\nstill exists, and that varies by repo setting and merge flag.\nA repo that auto-deletes head branches on merge (or `gh pr merge\n--delete-branch`) leaves `[gone]` upstreams that fall back to the HEAD check\nand refuse.\nIn one sweep of 29 branches, 18 deleted with `-d` and 11 needed `-D`;\nneither count meant anything about whether the work had landed.\n\nTwo consequences.\nDon't treat a refusal as a surprise worth debugging --- read step 1's merge\nconfirmation and the `-D` guidance below instead.\nAnd don't treat a **success** as confirmation, either:\nwhen it prints that warning, `-d` checked the remote ref, not `main`.\n\nThese guards avoid a common no-op\u002Ferror sequence after\n`gh pr merge --delete-branch`: that command may already switch this checkout\nto `main`, fast-forward it, and delete the local merged branch.\n\nIf the PR was built in a **git worktree** (agent isolation or `session-lock`),\nremove the worktree as part of the tidy — a worktree pins its branch, so\n`git branch -d` *refuses* while the worktree still holds it (\"branch is checked\nout at \u003Cpath>\"). Remove it first, then delete the branch:\n\n```bash\ngit worktree list                 # find the merged branch's worktree path\ngit worktree remove \u003Cpath>        # refuses on a dirty tree — don't blindly --force\ngit branch -d \u003Cmerged-branch>     # now succeeds\n```\n\n**Worktree containing a submodule:** `git worktree remove \u003Cpath>` refuses with\n`fatal: working trees containing submodules cannot be moved or removed` even\nwhen the tree is perfectly clean (`git status --short` empty) — this is a\ndifferent refusal than the dirty-tree one above, triggered by the mere\npresence of a submodule, not by uncommitted state. Confirm clean with\n`git status --short` first (as always), then `git worktree remove --force\n\u003Cpath>` is the correct move here, not a sign of misclassification.\n\n**Running from within the worktree:** if post-merge fires while the shell is\ninside the worktree being tidied, `git worktree remove \u003Cpath>` fails (\"cannot\nremove the currently checked out worktree\") and `git checkout main` is blocked\n(worktrees are locked to their branch). Use the repo root instead:\n\n```bash\nREPO=\"$(git rev-parse --git-common-dir)\u002F..\"             # main checkout root\ngit -C \"$REPO\" worktree remove \"$(git rev-parse --show-toplevel)\"   # worktree root\ngit -C \"$REPO\" branch -d \u003Cmerged-branch>\n```\n\n**Stale is not diverged, and the two need opposite responses --- check which\none you have before applying the bullet below.**\nA blocked `git checkout main` reads as the diverged case, since the symptom is\nthe same and diverged is the case this skill warns about.\nStale is far commoner: local `main` is merely behind `origin\u002Fmain` and **0\nahead**, carrying nobody's work.\nTwo counts separate the cases exactly, and the rule is three-way rather than\ntwo:\n\n```bash\ngit fetch origin main\necho \"behind: $(git rev-list --count main..origin\u002Fmain)  ahead: $(git rev-list --count origin\u002Fmain..main)\"\n```\n\n| `ahead` | `behind` | what it is | what to do |\n|---|---|---|---|\n| any | 0 | nothing to pull | leave `main` alone; just delete the branch |\n| 0 | > 0 | **stale** | fast-forward by refspec, below |\n| > 0 | > 0 | **diverged** | the bullet below |\n\nBoth counts matter, so do not key the decision on `ahead` alone.\n`git pull --ff-only` fails only in the last row: with `behind: 0` it reports\n`Already up to date.` and exits 0 even when `ahead` is non-zero, so routing\nthat row to the diverged bullet mislabels it (harmlessly --- there is nothing\nto pull either way).\nThe row that actually misleads is the middle one, where treating stale as\ndiverged leaves `main` behind for no reason.\n\nWhat blocks the switch in that case is usually an **unrelated dirty file**\n(a `renv.lock` an `renv::snapshot()` rewrote, a lockfile, a local config)\nwhose content differs between the *stale* `main` and your branch's HEAD, so\ngit refuses to carry the local edit across.\nThat file is frequently identical between HEAD and `origin\u002Fmain`, so\nfast-forwarding first dissolves the conflict --- and a branch that is not\nchecked out can be fast-forwarded by refspec, touching no working tree:\n\n```bash\ngit fetch origin main:main    # fast-forwards the ref; refuses if not a fast-forward\ngit checkout main             # now carries the dirty file across untouched\n```\n\nThe refspec form is safe by construction, refusing a non-fast-forward rather\nthan clobbering, so it cannot destroy a genuinely diverged local `main`.\nPreserve the dirty file rather than stashing or discarding it --- it is\nunrelated to this PR, and may be another session's or the user's.\n\n- **Do:** read both counts before deciding, and fast-forward by refspec when\n  `ahead` is 0 and `behind` is not.\n- **Don't:** treat a blocked checkout as evidence of divergence, or leave\n  `main` stale because the bullet below said to skip the pull.\n- **Don't:** key the decision on `ahead` alone --- `behind: 0` is not\n  divergence, whatever `ahead` reads.\n\n(`ucdavis\u002Fbcs#536`, 2026-08-02: `git checkout main` aborted on a modified\n`renv.lock`, which looked like the diverged case.\nLocal `main` was 54 behind and 0 ahead, and the file was byte-identical\nbetween HEAD and `origin\u002Fmain` --- it differed only from the 54-commit-stale\n`main`.\n`git fetch origin main:main` fast-forwarded the ref and the switch then\nsucceeded with the local edit intact; skipping the pull as the bullet below\nprescribes would have left `main` 54 commits behind.)\n\n**Before `-D`, compare the LOCAL branch against the MERGED head --- step 1\nconfirmed the PR merged, which is not the same claim.**\nThe `-D` guidance below rests on step 1: the PR is merged, so forcing is safe.\nThat reasoning covers the commit the PR *merged*, and `-D` deletes whatever the\n**local ref** points at, which can be a different commit.\n\nThe gap opens without anyone doing anything unusual.\nA `main`-merge pushed to the branch after the PR merged, a bot commit, or your\nown unpushed work all leave the local ref ahead of the merged head, and the\n`-d` refusal a squash repo produces is identical either way --- so the refusal\ncarries no information about which case you are in, and the natural next step\nis the `-D` the text below authorizes.\n\nOne comparison settles it, and it costs nothing:\n\n```bash\nmerged=$(gh pr view \u003CN> --json headRefOid --jq .headRefOid)   # VIEW_PR\ngit fetch origin \"refs\u002Fpull\u002F\u003CN>\u002Fhead\" -q                      # FETCH\ngit log --oneline \"$merged\"..\"\u003Cbranch>\"    # empty => the ref is the merged head\n```\n\n**That fetch is load-bearing, not tidiness, because the merged head is\nroutinely absent from the local object store at exactly this moment, and\ncomparing against `origin\u002Fmain` succeeds and lies.**\nTwo distinct failure modes occur when skipping this fetch:\n\n1. **The error direction (behind merged head):**\n   `gh pr merge --delete-branch` removes the remote branch, and the merge commit\n   on `main` is a *squash* in this repo, so neither `origin\u002Fmain` nor any\n   remaining ref reaches the PR's own head.\n   `git log` then answers with\n\n   ```\n   fatal: Invalid revision range \u003Csha>..\u003Cbranch>\n   ```\n\n   which is the shape [`fail-fast`](..\u002F..\u002Fshared\u002Fprinciples\u002Ffail-fast.md) warns\n   about: the check did not run, and it says so on stderr while printing no\n   commits --- so a caller reading only stdout sees the same empty output a clean\n   comparison produces.\n   `refs\u002Fpull\u002F\u003CN>\u002Fhead` survives the branch deletion and is what makes the SHA\n   resolvable again.\n\n2. **The succeed-and-lie direction (`origin\u002Fmain..\u003Cbranch>` comparison):**\n   Comparing against `origin\u002Fmain..\u003Cbranch>` instead of `refs\u002Fpull\u002F\u003CN>\u002Fhead`\n   exits **0** and prints plausible commit output.\n   Because a squash-merge creates a new commit on `main` with a different SHA\n   and parentage, the branch's original commits are not ancestors of `main` even\n   though their diff is fully merged.\n   `git log --oneline origin\u002Fmain..\u003Cbranch>` lists every commit from the merged PR,\n   falsely suggesting unmerged work remains on the branch.\n   Comparing against `refs\u002Fpull\u002F\u003CN>\u002Fhead` (via `git log \"$merged\"..\"\u003Cbranch>\"`)\n   settles it cleanly:\n\n   ```bash\n   git fetch origin \"refs\u002Fpull\u002F\u003CN>\u002Fhead\" -q &&\n   git log --oneline \"$merged\"..\"\u003Cbranch>\"   # empty => all local work reached the PR\n   ```\n\nSo read the exit status rather than the output, and always anchor the comparison\nto the PR's fetched head ref rather than `origin\u002Fmain`.\nA non-zero exit means the comparison failed to happen, which is not evidence\nthe branch is safe to delete; re-fetch and re-run before touching `-D`.\n\nA non-empty list is not automatically a problem --- a merge commit whose every\ninput is already on `main` is safe to discard --- but it is a question, and it\nhas to be answered before the delete rather than after.\nRead the subjects: anything authored, rather than a merge or a revert of\nalready-landed work, means the branch carries something the PR did not.\n\n- **Do:** compare the local ref against the PR's fetched head (`refs\u002Fpull\u002F\u003CN>\u002Fhead`)\n  before `-D`, and read the extra commits' subjects when they differ.\n- **Do:** name the branch's SHA in the report when it differed from the merged\n  head, so the discrepancy is visible rather than absorbed.\n- **Don't:** read step 1's merge confirmation as covering the local ref --- it\n  is a claim about the PR's head, and `-D` acts on yours.\n- **Don't:** use `origin\u002Fmain..\u003Cbranch>` as a liveness test in a squash-merging\n  repo --- it exits 0 and falsely reports merged commits as unmerged work.\n- **Don't:** infer from a `-d` refusal which case you are in; a squash repo\n  refuses for every branch regardless.\n- **Don't:** read an `Invalid revision range` error as an empty answer --- it\n  prints no commits, exactly as a clean comparison does, and means the merged\n  head is simply not in the local object store.\n\n(`Morrison-Lab\u002Fai-config#1595`, 2026-08-17: running `git log --oneline origin\u002Fmain..\u003Cbranch>`\nimmediately after squash-merging printed two commits that had already merged under squash\ncommit `86cc8233`. Fetching `refs\u002Fpull\u002F1595\u002Fhead` confirmed `FETCH_HEAD..\u003Cbranch>` was empty.)\n\n(`Morrison-Lab\u002Fai-config#1566`, 2026-08-17: the PR merged at head `0a297637`,\nand the local branch stood at `ad3b7640`, which `git branch -D` duly printed\nwhile deleting it.\n`git log 0a297637..ad3b7640` lists nine commits --- a `main` merge plus eight\ncommits from `main`, including the four merge commits for this session's own\nPRs.\nNothing authored, so nothing was lost; the point is that the check ran\nafterwards, prompted by reading the delete output, rather than before.)\n\n(The fetch requirement was measured on the very next merge, `#1586`, which\nshipped the block above.\nRunning it as written, immediately after `gh pr merge --squash\n--delete-branch`, produced\n`fatal: Invalid revision range d8e17de2...ums\u002Fverify-local-branch-before-force-delete`\nand exit 128 --- the merged head was unreachable because the remote branch was\ngone and `main` carried only the squash.\n`git fetch origin refs\u002Fpull\u002F1586\u002Fhead` resolved it, and the re-run printed\nnothing, which is what actually licensed the `-D`.\nThe local ref was *behind* the merged head rather than ahead, so the original\nblock's failure mode was not in play; the recipe still could not answer.)\n\n**Diverged main checkout (`ahead` and `behind` both non-zero):**\n`git pull --ff-only` fails when the main checkout\nhas local commits from a concurrent session that hasn't been pushed. Don't\nforce-merge or reset their work — skip the pull and delete the branch only.\nThe branch deletion is what matters; another session will pull main when it's\nready. If `git branch -d` refuses because local `main` doesn't yet include\nthe merge (diverged HEAD, remote branch already deleted), use `git branch -D` —\nstep 1 already confirmed the PR is merged, so the force-delete is safe here.\n\nFor a repo-wide sweep of *all* dead worktrees (not just this PR's), run\n`clean-worktrees` (`cw`).\n\nIf other local branches were **stacked** on this one, offer to rebase them onto\nthe new `main` rather than deleting silently (see `cb` \u002F `clean-branches`).\n\n### 3. Confirm deferred items are tracked\n\nIf the PR's review loop deferred or acknowledged anything, make sure each has a\nfollow-up issue (preferences: *never leave deferred items untracked*). List\nthem, linked. File any that slipped through.\n\n### 3.5. Check whether delivery is gated on a further human action\n\nIn most repos the merge *is* the delivery, and this step is a no-op.\nIn a repo whose artifact reaches consumers only through a separate,\nhuman-gated release step, the merge is the midpoint, and the gap between the\ntwo is a window in which the repo's own documentation is wrong.\n\n`Morrison-Lab\u002Fgha` is the case to recognize.\nA capability ships with `examples\u002F\u003Cname>.yml` and\n`website\u002Freference\u002F\u003Cname>.qmd` stubs pinning `@v2`, but `@v2` moves only when\nsomeone dispatches `slide-major-tag.yml` --- so a consumer who copies a stub\nliterally between merge and slide gets `workflow-not-found`, per that repo's\nown README.\nThe same holds for any tag-, registry-, or release-gated artifact: a version\nbump merged but unpublished, a submodule pin not yet bumped in its consumer.\n\nTwo things make this the step that gets skipped rather than deferred.\nNothing turns red --- CI passed, the PR is green and merged, and the failure\nlands on a consumer who is not in the room.\nAnd the slide is destructive (it force-moves a tag), so it needs explicit\nhuman authorization and cannot simply be folded into the tidy, which is\nexactly why it evaporates instead: a step you are not allowed to perform is\neasy to stop tracking.\n\nDecide it mechanically rather than from memory of what the PR touched --- two\nlookups settle it, so this is an\n[`algorithmatize-checks`](..\u002F..\u002Fshared\u002Fworkflow\u002Falgorithmatize-checks.md)\ncase:\n\n```bash\ngit fetch origin --tags\ngit rev-parse 'v2^{}' origin\u002Fmain   # equal means current; different means a slide is owed\n```\n\nKeep the `^{}`.\nIt peels a tag to the commit it names, and without it an **annotated** tag\nresolves to its own tag-object SHA instead --- which never equals a commit\nSHA, so the check would report a slide owed on every run and become noise\nrather than an instrument.\nA lightweight tag resolves the same either way, so the peeled form is correct\nfor both and there is no case where dropping it helps.\n(`slide-tag` reads a tag with `git log --oneline -1 \u003Ctag>`, which peels for\nthe same reason.)\n\nThen raise it as a `⚠️ **FLAG** ---` in step 5's report,\nnaming the tag and what is unreachable until it moves.\nAn offer is not a flag: say plainly that the slide is owed and that it needs\nthe human, the same way\n[`report-mistakes-proactively`](..\u002F..\u002Fshared\u002Fworkflow\u002Freport-mistakes-proactively.md)\nrules out offering to file an issue instead of filing it.\n\n- **Do:** compare the release ref against `main` after the merge, and flag the\n  gap with the specific tag and the affected consumer-facing paths.\n- **Do:** run the comparison on every merge rather than first judging whether\n  the repo looks release-gated --- it costs two commands and prints nothing to\n  act on when the SHAs match, so the comparison *is* the classifier.\n- **Don't:** run the release step yourself when it force-moves a ref or\n  publishes --- that is the human-gated action `ardi` reserves for explicit\n  authorization.\n- **Don't:** report a merged PR wrapped up while the artifact it documents is\n  still unreachable at the version its own docs name.\n\n(gha#357, 2026-07-30: three new reusable workflows merged as `159dbf4` while\n`v2` still pointed at `c50e847`, so every `@v2` line in the new capabilities'\nown stubs named a workflow that did not exist yet.\nFound only by an ad-hoc `rev-parse` at the end of the tidy, after steps 1\nthrough 3 had already reported clean.)\n\n### 3.75. Register a merged hook, since the gate that forbade it earlier names no later moment\n\nIf the merged PR touched `hooks\u002F`, the merge did not arm anything.\nIt placed a file and merged a manifest entry.\nOn the non-plugin install path a hook fires only once\n`~\u002F.claude\u002Fsettings.json` binds it, and that binding is per-machine local\nstate no merge can write.\n\nThis step exists because README's activation gate creates a **deferred step\nwith no owner**.\n\"Never activate a new hook before its PR merges\" is read by the author,\nbefore the PR is opened, and its matching action has to happen after the\nmerge, on every consumer machine.\nMerging happens on GitHub, where nothing local prompts anything, so the owed\nregistration is never refused and never scheduled --- it simply never\nhappens.\n\nIt shares its shape with step 3.5 above and differs in the half that decides\nwhat to do.\nBoth are owed after a merge, and neither turns anything red.\nBut 3.5's action force-moves a shared ref, so it is reserved for the human,\nwhereas this one writes one machine's own settings file and is yours to\nperform now.\nDo not carry 3.5's \"don't run it yourself\" bullet over to this step; here\nthat would leave the guard inert, which is the failure rather than the\ncaution.\n\nOne lookup and three calls settle it, run in the ai-config checkout after step 2\nhas already put it on `main` and pulled:\n\n```bash\ngit show --name-only --format= HEAD -- hooks\u002F   # did this merge bring in a hook?\npython3 scripts\u002Finstall-hooks.py                # report: registered \u002F missing \u002F stale\npython3 scripts\u002Finstall-hooks.py --fix          # the call that actually registers\npython3 scripts\u002Fcheck-hook-catalog.py           # print NOTE for allowlisted hooks; exits 0 unless it FAILs\n```\n\n**`--fix` is the load-bearing flag.**\nA bare `install-hooks.py` only reports, and says so itself\n(`Re-run with --fix to register the missing hooks.`), so a step that stops\nthere leaves the guard exactly as inert as before --- which is this step's own\nfailure mode, performed while looking like compliance.\n\nThe instrument is worth running on **any** ai-config merge rather than only one\nthat touched `hooks\u002F` --- it costs one command, prints `All hooks registered.`\nwhen there is nothing to do, and catches every hook that merged while someone\nelse was driving.\nThe first lookup is informational and reads `HEAD` because a squash merge puts\nthe merged content in one commit; it decides nothing, so do not skip the\ninstrument when it comes back empty.\n\nThen follow [`keep-checkouts-fresh`](..\u002F..\u002Fshared\u002Fworkflow\u002Fkeep-checkouts-fresh.md)\npoint 2, the `~\u002F.claude` consumer copies, which already owns the mechanics: if\nthe Claude Code plugin is enabled, its loader serves hooks straight from the\nplugin root, so there is nothing to run --- the merged hook goes live at the\nnext session start (or `\u002Freload-plugins`), since plugin hooks connect at\nsession start rather than the moment `main` moves.\nOtherwise (`install-hooks.py --fix`'s non-plugin path), check `enabledPlugins`\nfirst since the plugin path already loads every hook and a second\nregistration makes each one fire twice, confirm `~\u002F.claude\u002Fhooks` actually\nholds the merged script first --- `bootstrap.sh` no longer places it there\n(see its header comment; tracked as\n[#2352](https:\u002F\u002Fgithub.com\u002FMorrison-Lab\u002Fai-config\u002Fissues\u002F2352)) --- compare\nthe printed `examined N` against the current `hooks\u002Fhooks.json` before\nbelieving a clean report, and say that hooks connect at session start so a\nmid-session `--fix` arms nothing until a restart.\n\n**`--fix` binds the manifest, not every hook file on disk.**\nA hook whose authoring PR left it in the catalog allowlist of\ndocumented-but-inert hooks is absent from `hooks\u002Fhooks.json`, so this\nstep cannot arm it.\n`--fix` then prints `All hooks registered.` over that gap, because\nit iterates only the manifest.\n`check-hook-catalog.py` is the detector: it prints\n`NOTE: \u003Cscript> is documented but not registered (known, ai-config#N)`\nand exits 0 on that path, so read the NOTE, not the exit status.\nSearch for an existing activation issue before filing a follow-up\n(the allowlist maps each entry to that tracker).\nIf the listed tracker has closed and the hook is still inert, repoint\nthe allowlist (and the README **not registered** marker) at a live issue.\nIf none is open, file one covering the manifest entry, dropping\nthe allowlist row, and dropping **not registered** from the README row.\nThe PR that resolves that issue is when this step can bind the hook.\n\n- **Do:** treat a documented-but-inert catalog row as a deferred\n  registration, not as a `--fix` miss on this merge.\n- **Don't:** report the merged hook as live after this step when it is still\n  allowlisted.\n\n**A hook cannot be the instrument that BOOTSTRAPS this**, which is worth\nstating so nobody reaches for one first.\nA guard that detects unregistered hooks is itself a hook, so on a machine where\nnothing is bound it is silent exactly when the condition holds, which is\n[`fail-fast`](..\u002F..\u002Fshared\u002Fprinciples\u002Ffail-fast.md)'s pass-path-equals-failure-path\nshape.\nThe limit stops there, and the measured incident is what shows where: at\n`registered=15 missing=16` a detector among the fifteen would have caught the\nsixteen.\nSo a hook can catch later drift and cannot catch its own first registration ---\nand on the plugin path, where it always runs, none is owed anyway.\nThat is why the owner is a step in a skill, with a hook available at most as a\nsecondary check on top of it.\n\n- **Do:** run `install-hooks.py` as part of every ai-config post-merge sweep,\n  and report the `registered`\u002F`missing`\u002F`stale` counts rather than a verdict.\n- **Do:** register a hook whose PR just merged, since the gate's prohibition\n  expired at the merge and nothing else will do it.\n- **Don't:** read a merged hook as an active one --- merging places a file,\n  and only a binding makes it fire.\n- **Don't:** build a hook to detect this; it is unregistered exactly when the\n  condition is true.\n\n(Morrison-Lab\u002Fai-config#1786, 2026-08-20: one machine reported\n`registered=15 missing=16 stale=0` against a 31-hook manifest.\nAmong the sixteen inert guards was `flag-add-a-outside-pathspec.py`, and in\nthe same session `git add -A ':!inst\u002Fextdata'` swept `SAS\u002Fprogram\u002F` into a\npushed `ucdavis\u002Fbcs` commit carrying a cleartext SAS credential and real\n`StudyID_c` values --- the verbatim mistake that hook was written to prevent,\nand whose docstring describes that exact command.\n`--fix` registered the missing sixteen, and a fed-payload test then confirmed\nthe guard fires on the command and names `SAS\u002F` in its output.\nEvery rule needed to prevent this was already written and had been for weeks;\nwhat was missing was a moment at which anyone would run the command.)\n\n### 4. Run UMS — learn from the PR's lifecycle\n\nRun the full `ums` procedure (invoke the `ums` skill by name), focused on what\n**this PR** taught:\n\n- **Recurring review findings** — anything the reviewer flagged across rounds\n  → encode the fix so the next PR avoids it from the start.\n- **Corrections \u002F guidance the user gave mid-PR** → preference + skill update\n  (per \"update BOTH skills AND preferences\").\n- **Tool \u002F CI quirks** hit during the loop → the matching topical memory file\n  under `memories\u002F`, or `debugging.md`; see `memories\u002FMEMORY.md` for the\n  current set.\n- **A multi-step pattern that emerged** → run `spot-skill-opportunities` to\n  judge whether it's genuinely recurring, then hand off to `skill-builder`.\n\nThis is the \"learn from mistakes and guidance along the way\" step — a merge is\nthe natural checkpoint to bank those lessons before the context is gone. If\nnothing durable emerged, say so explicitly rather than manufacturing edits.\n(UMS commits its own changes via a branch + PR.)\n\n**Guard against recursion: skip this step when the merged PR was itself a\nUMS\u002Flearnings PR — one whose diff is entirely memory\u002Fskill edits capturing a\nprevious PR's lessons — and no new lessons emerged from its own review loop.**\nRe-running UMS there is redundant — the lessons are already encoded in the PR\nthat just merged — and spawns an endless UMS-on-UMS chain (each UMS PR merges →\ntriggers post-merge → triggers another UMS PR). Still do steps 1–3 and 5; just don't\nmanufacture a fresh UMS PR. (If the UMS PR's *own* review surfaced a genuinely\nnew, separate lesson, capture that — but not a restatement of what the PR\nalready banked. Concretely: a reviewer approving with no comments means nothing\nnew, so skip; a reviewer flagging a missing anti-pattern that isn't already in\nthe UMS diff is a new lesson worth a follow-up.)\n\n**The second clause is the operative one, and it is the one that goes\nunevaluated.**\nThe first clause holds for every learnings PR, which is the only kind of PR\nthis guard ever fires on, so it is satisfied before you have read the rest of\nthe sentence.\nEvaluate the second clause explicitly, by an actual pass over the merged PR's\nown review rounds, and emit the guard's outcome as a sentence either way.\n\"Skipped under the recursion guard; the review loop raised nothing that is not\nalready in the diff\" is a report.\nSilence is the failure, because it is indistinguishable from step 4 never\nhaving been reached.\nSee [`skill-checklists`](..\u002F..\u002Fshared\u002Fworkflow\u002Fskill-checklists.md)'s \"An item\na guard exempts is neither run nor skipped\".\n\n### 5. Report\n\n**Pause point: before reporting the merge wrapped up.**\nDo-Confirm; per\n[`shared\u002Fworkflow\u002Fskill-checklists.md`](..\u002F..\u002Fshared\u002Fworkflow\u002Fskill-checklists.md).\n\n- [ ] The merge actually landed (step 1's verification, not the notification).\n- [ ] Step 1.1's instrument ran against the merge commit and reported clean\n      (exit 0) --- not merely that the PR's own CI was green.\n      When it was pending, that clean reading came from the check-in,\n      and step 4 did not wait for it.\n- [ ] The local branch is tidied and `main` is fast-forwarded.\n- [ ] Every deferred item has a filed follow-up issue.\n- [ ] Step 3.75 ran `install-hooks.py --fix` on this ai-config merge, and the\n      counts are reported.\n      Not conditional on the merge having touched `hooks\u002F`: that lookup is\n      informational, and the drift it catches is usually owed by someone\n      else's merge rather than by this one.\n      The bare invocation only reports, so \"I ran install-hooks\" is not\n      evidence that anything was registered.\n- [ ] **Killer item: step 4's UMS pass actually executed**, or was\n      deliberately skipped under the recursion guard and that is stated.\n      Marked because reporting this skill complete asserts that its final step\n      ran, and the recorded failure is a `post-merge` run reported done whose\n      UMS step never happened --- which discards the learnings rather than\n      delaying them.\n      Naming what UMS changed (or that nothing durable emerged) is the\n      evidence; \"ran UMS\" on its own is not.\n\nThen a linked summary: the merged PR, the auto-closed issue, any deferred\nfollow-up issues, what UMS updated, and a Pacific-time timestamp\n(`TZ=America\u002FLos_Angeles date \"+%Y-%m-%d %H:%M %Z\"`; the explicit `TZ` enforces\nPT on a machine set to any other zone).\n\n**Session stopping point signal:**\nWhen this post-merge wrap-up completes the session's work **and no PR this session opened or pushed to remains unmerged** (typically after the UMS follow-up PR itself merges --- note step 4 normally opens one), finish the report with an explicit stopping-point statement (e.g. *\"This session is at a good stopping point.\"*) per `wrap-up`'s closing checklist. If a UMS follow-up PR or another task remains open, state explicitly that the session is not at a clean stopping point and name what is open.\n\n## Relationship to other skills\n\n- **`wrap-up`** — session-level bookend; also embeds UMS. `post-merge` is the\n  per-PR version: run it each time a PR lands; run `wrap-up` once at session\n  end. They share the verify-then-UMS shape.\n- **`ums`** — step 4 invokes it.\n- **`spot-skill-opportunities`** — step 4's \"multi-step pattern that emerged\"\n  bullet routes here to judge recurrence before handing off to `skill-builder`.\n- **`slide-tag`** -- what step 3.5's flag asks the human to authorize; it does\n  the force-move, this skill only detects that one is owed.\n- **`cb` \u002F `clean-branches`** — for stacked or stale sibling branches.\n- **`clean-worktrees` \u002F `cw`** — if the PR was built in a git worktree, remove\n  it during the tidy (step 2); a leftover worktree pins its branch and blocks\n  `git branch -d`.\n- **`st` \u002F `gi`** — the front of the lifecycle that `post-merge` closes.\n\n## Anti-patterns\n\n- ❌ Deleting the branch before confirming the merge actually landed.\n- ❌ Reporting a merge done from the PR's own green CI without running step\n  1.1's instrument against the merge commit --- a push-only workflow (a full\n  or PDF render, a deploy) never ran on the PR at all\n  ([Morrison-Lab\u002Fmds#19](https:\u002F\u002Fgithub.com\u002FMorrison-Lab\u002Fmds\u002Fpull\u002F19)).\n- ❌ Reaching for `git branch -D` (force) without checking why `-d` refused.\n- ❌ Running `-D` without comparing the local ref against the PR's merged\n  head --- step 1 confirms the PR merged, and `-D` deletes whatever your\n  local branch points at, which can be a different commit.\n- ❌ Force-pulling or resetting a diverged main checkout — the divergence may be another session's in-progress work. Skip the pull; don't clobber it.\n- ❌ Skipping UMS on a normal PR — the just-merged PR is exactly when the\n  lessons are freshest.\n- ❌ Recursing UMS on a UMS PR — running UMS again when the just-merged PR was\n  itself the learnings PR, restating lessons it already banked (see step 4's\n  guard). The chain has to terminate somewhere.\n- ❌ Leaving deferred\u002Facknowledged items without follow-up issues.\n- ❌ Reporting an ai-config merge wrapped up without step 3.75's `--fix` run\n  -- whatever hooks are owed stay merged, documented, and inert, which is the\n  deferred-step-with-no-owner shape this skill's own step 3.75 exists to close,\n  arriving one level up in the checklist meant to catch it.\n- ❌ Calling a merge wrapped up in a release-gated repo without comparing the\n  release ref against `main` (step 3.5) -- the merged docs pin a version\n  consumers cannot resolve until a human slides the tag.\n- ❌ Reporting \"all cleaned up\" while a stacked sibling branch dangles unmentioned.\n- ❌ Treating the whole cascade-scan hit list as work caused by this merge, without\n  intersecting it against the merge's own deleted and renamed paths (step 1.5's own step 2) --- on\n  an old backlog that claims other people's stale PRs for no reason.\n- ❌ Pushing to, or commenting on, a PR that fails the scope test --- it gets a\n  report to the user --- or pushing to a release branch carrying an out-of-band\n  process even when it passes, where a report is the safe form.\n","# post-merge — wrap up a merged PR (verify, tidy, then UMS)\n\nThe per-PR bookend to a piece of work. Once a PR\u002FMR merges: confirm it landed,\nclean up the local branch, make sure nothing was left dangling, and — the\npoint of the skill — **run UMS to learn from how the PR went** while the\nreview lifecycle is still fresh in context.\n\n## When this fires\n\n- A PR\u002FMR you were working on just merged.\n- \"post-merge\", \"wrap up the merged PR\", \"clean up after the merge\", \"the PR\n  merged — now what?\"\n- **\"merge it\" \u002F \"merge this\" route to `merge-it`, not here** — that skill\n  performs the merge first, then chains into this one. Only handle those phrases\n  here when the PR is already merged (no merge left to do).\n- Distinct from **`wrap-up`** (session-level, may span several PRs\u002Fissues) —\n  `post-merge` is the single-PR version, run each time a PR lands.\n\n## Procedure\n\n### 1. Verify the merge — never assume\n\n```bash\ngh pr view \u003CN> --json number,title,state,mergedAt,mergeCommit,headRefName   # VIEW_PR\n# GitLab\nglab mr view \u003CN>\n```\n\nConfirm `state == MERGED` and `mergedAt` is set. If it isn't actually merged,\n**stop and report** — don't tidy a branch whose work hasn't landed. (The\nstanding **never assume; always verify** rule applied to closing out a PR.)\n\n### 1.1. Verify CI passed on the merge commit itself, not only on the PR\n\n[`verify-merge-commit-ci`](..\u002F..\u002Fshared\u002Fworkflow\u002Fverify-merge-commit-ci.md)\n\nThe PR's own CI being green proves nothing about a workflow that only runs\non `push` to the base branch --- a full or PDF render, a deploy, a publish\nstep.\nTake `\u003Cmerge-sha>` from the PR's own `mergeCommit.oid`, not from\n`headRefOid` --- the head is the PR branch's last commit, and a squash or\nmerge commit gets its own, different SHA on the base branch:\n\n```bash\nmerge_sha=$(gh pr view \u003CN> --json mergeCommit -q .mergeCommit.oid)\npython3 scripts\u002Fcheck-merge-commit-ci.py -R \u003Cowner>\u002F\u003Crepo> --sha \"$merge_sha\"\n```\n\nExit 0 is clean.\nExit 1 means a run failed or is still in progress, and the two are handled differently.\nA **failed** run comes before everything else ---\nfix it first,\nper [`fixing-mistakes-is-top-priority`](..\u002F..\u002Fshared\u002Fworkflow\u002Ffixing-mistakes-is-top-priority.md).\nExit 3 means no workflow runs are attached to that SHA yet, which is not a clean verdict.\nThis step applies whether the merge happened under an explicit instruction or under an `mwc` grant ---\nthe grant covers the merge decision, not what happens on `main` afterward.\n\nA run still **in progress**, or exit 3, is a wait rather than a failure.\nArm a check-in that re-runs this step\n(for exit 3, with the bound\n[`verify-merge-commit-ci`](..\u002F..\u002Fshared\u002Fworkflow\u002Fverify-merge-commit-ci.md) sets),\nthen carry on with the rest of the procedure through step 4 now.\nThe PR's learnings are already known,\nand a UMS pass deferred behind a CI wait is the pause\n[`run-ums-proactively`](..\u002F..\u002Fshared\u002Fworkflow\u002Frun-ums-proactively.md) forbids.\nStep 5's report still waits for this step to come back clean at the check-in.\n(Measured 2026-10-08 on\n[Morrison-Lab\u002Flds#460](https:\u002F\u002Fgithub.com\u002FMorrison-Lab\u002Flds\u002Fpull\u002F460) and\n[Morrison-Lab\u002Fmlg#69](https:\u002F\u002Fgithub.com\u002FMorrison-Lab\u002Fmlg\u002Fpull\u002F69):\na session reported both merges,\nsaid the UMS pass would follow the merge-commit check,\nand ended the turn waiting on a pending publish job until the user asked why.)\n\n- **Do:** run this check against the merge commit before step 5's report,\n  every time, not only when a push-triggered workflow is already suspected.\n- **Do:** run step 4's UMS pass while a merge-commit run is still pending,\n  and finish step 1.1 at the check-in.\n- **Don't:** end a turn to wait on a pending merge-commit run\n  with step 4's UMS pass not yet run.\n- **Don't:** read the PR's own green CI as covering a workflow that only\n  triggers on `push`.\n\n### 1.25. Check for reviews that landed just before the merge\n\nA review can post after your last processed round and before the human merges.\nThose findings are real even though they are absent from the merge commit.\nAfter confirming `mergedAt`,\nidentify the last review this session explicitly dispositioned,\nthen read every formal review and PR comment after that timestamp\nand before `mergedAt`.\nDo not use an imprecise \"near the merge time\" window.\nThe lower bound is the last dispositioned review,\nand `mergedAt` is only the upper bound.\n\n**When this session never dispositioned a review on this PR** --- entering\nthrough the \"the PR merged -- now what?\" route, or picking up a PR another\nsession drove --- there is no last-dispositioned-review timestamp to anchor\non.\nDon't skip the scan for lack of a lower bound.\nScan the complete review and comment history through `mergedAt` instead,\nwith no lower bound at all,\nsince anything on the PR is late from this session's point of view.\n\n```bash\ngh api repos\u002F\u003Cowner>\u002F\u003Crepo>\u002Fpulls\u002F\u003CN>\u002Freviews --paginate    # formal review bodies\ngh api repos\u002F\u003Cowner>\u002F\u003Crepo>\u002Fpulls\u002F\u003CN>\u002Fcomments --paginate   # inline review comments\ngh api repos\u002F\u003Cowner>\u002F\u003Crepo>\u002Fissues\u002F\u003CN>\u002Fcomments --paginate  # top-level PR comments\n```\n\nA formal review's top-level body is not enough.\nFor each late review,\nread the inline comments too,\nbecause an empty-body review can carry every finding inline.\nThis is the same two-surface shape `ardi` already requires when reading\nformal reviews;\ndo not reimplement it as a body-only scan here.\n\n**Read the inline comments unfiltered, though --- do not narrow them to one\n`pull_request_review_id`.**\nThat filter is the natural way to pair each late review with its own findings,\nand it is the correct way to drill into a review a human pointed at.\nIt is unsound as a completeness check, because the round and the review object\nare not the same unit: a reviewer can emit two review objects seconds apart\ncarrying one finding each, so filtering by either id returns a strict subset\nthat reads exactly like a complete answer.\n\nTake the timestamp window from the enumeration above, and take *outstanding*\nfrom the **thread list**, which is per-thread rather than per-review and so\ncannot be split across review objects:\n\n```bash\ngh api graphql -f query='{ repository(owner:\"\u003Cowner>\", name:\"\u003Crepo>\") {\n  pullRequest(number:\u003CN>) { reviewThreads(first:100) {\n    totalCount\n    nodes { id isResolved path line comments(first:1){nodes{databaseId}} } } } } }'\n```\n\nPage at `first:100` and select `totalCount`: a `totalCount` above the node\ncount means the cap was hit, so the thread list is itself truncated --- treat\nthat as not-yet-clean, the guard `skills\u002Fpr-status\u002FSKILL.md` and\n`skills\u002Fpr-status-all\u002FSKILL.md` already use.\n`memories\u002Fgh-cli.md` carries the full statement and the case record.\n\n**A finding can also arrive as a plain top-level PR comment rather than a\nformal review** --- a bot posting a summary via `gh pr comment` (or the\nequivalent API call) rather than through the reviews endpoint, or a human\ncommenting directly on the PR conversation.\n`pulls\u002F\u003CN>\u002Freviews` and `pulls\u002F\u003CN>\u002Fcomments` are both scoped to formal\nreviews and their inline threads; neither surface returns a plain PR\nconversation comment.\nThose live on the **issue comments** endpoint --- a pull request is also an\nissue in GitHub's data model --- so the scan needs all three surfaces, not\ntwo, to cover every place a late finding can land.\n\nIf a late review contains findings:\n\n1. Confirm the merge commit does not contain the fix.\n2. File or use a follow-up issue or PR, and carry the findings there with a link back to the merged PR.\n3. Do not count the merged PR's review loop as clean for those findings; the new PR owns them.\n\n- **Do:** check every review and PR comment posted after the last dispositioned review and before `mergedAt`.\n- **Do:** fetch late formal reviews' inline comments, not only their top-level bodies.\n- **Do:** fetch the issue-comments endpoint too, not just the two review surfaces --- a late finding can arrive as a plain top-level PR comment.\n- **Do:** carry late findings forward to a new tracked fix when the merge beat the ARD round.\n- **Don't:** use a vague \"near merge time\" window that can skip a late finding posted well before a delayed merge.\n- **Don't:** treat the merge as proof the final review round was clean.\n- **Don't:** drop a finding because it arrived too late for the merged branch.\n- **Don't:** skip this scan because no last-dispositioned-review timestamp exists --- scan the whole history through `mergedAt` instead.\n- **Don't:** stop at the two formal-review surfaces --- a bot or human can post a late finding as a plain issue comment that neither one returns.\n\n(Morrison-Lab\u002Fai-config#1029:\nCopilot round 7 posted at 2026-08-02T06:29:10Z,\nand the PR merged at 06:30:55Z as `1e0b5fdf`.\nThe suppressed findings were real,\nabsent from the merged code,\nand had to be carried forward to #1034.)\n\n**A review can also arrive *after* `mergedAt`, which the bound above excludes\nby construction.**\nEverything above treats the merge as the scan's upper bound, and for a review\nalready sitting on the PR that is right.\nIt also encodes an assumption that nothing further can land, and a reviewer\ndispatched before the merge does not stop working when the merge happens.\n`post-merge` runs promptly after the merge, which is what makes this a gap\nrather than a curiosity: the scan fires while a late review has not posted\nyet, so a single run returns a clean result that expires.\n\nSo re-read the three surfaces once more before closing the PR out, with no\nupper bound at all, and treat a `submitted_at` later than `mergedAt` as an\nordinary finding rather than as an anomaly.\n\nThat re-read catches a review already sitting on the PR; it cannot catch one\nstill in flight.\nA single synchronous read narrows the window but does not close it --- the\nreview that posted ten minutes after the merge in the case below would still\nbe unposted at the moment `post-merge` runs.\nThe durable catch is staying subscribed to the merged PR's review activity, so\nthe review notification wakes the session when the late verdict actually posts,\nor re-arming a delayed check with a defined completion condition.\n\nTwo things change when the review lands after the merge rather than before it.\n\nThe merged PR is **no longer a place to land code fixes**.\nThat is a third reason for moving work elsewhere, distinct from the two the\ncorpus already carries: ARD's Defer moves a finding because fixing it would\nwiden the PR's scope, and\n[`address-every-comment`](..\u002F..\u002Fshared\u002Fworkflow\u002Faddress-every-comment.md)'s\n`main`-sync case moves one because the line is not yours.\nHere the finding is in scope and is yours, and only the branch it belonged to\nis gone.\n\nAnd the vehicle is a **follow-up PR against `main`**, narrower than the\n\"issue or PR\" item 2 above leaves open.\nThe findings usually still apply to `main`, since `main` now holds the merged\ncode they were written about --- but confirm that against current `main` first,\nsince an overlapping merge can have changed or removed that code before the\nfollow-up runs.\nWhere they do still apply, the fixes are already known, so an issue would\nrecord work that could simply be done.\n\n**Post the back-pointer on the merged PR, not only the forward link.**\nItem 2 asks the follow-up to link back to the merged PR, which serves a reader\nwho already knows the follow-up exists.\nThat is the reader who needs it least.\nThe follow-up is reachable only by someone who has already found it, whereas\nthe merged PR is what a changelog entry, a `git blame`, or the review\nnotification itself points at.\nThat reader finds a review with unaddressed findings sitting under a merged\nbanner, and has no way to tell whether anyone handled them.\nComment on the merged PR naming the follow-up and each finding's disposition,\nso the record reads correctly from whichever end it is entered.\n\n`CLAUDE.md`'s push-races-the-merge case already asks for a comment of this\nshape, saying which of a merged PR's findings did not ship in it.\nIts trigger is a `* [new branch]` push tell rather than a review posting, so\nneither case fires on the other.\n\n- **Do:** re-read the three surfaces with no upper bound before closing out,\n  and treat a review submitted after `mergedAt` as ordinary.\n- **Do:** stay subscribed to the merged PR, or re-arm a delayed check with a\n  completion condition, to catch a review that posts after `post-merge` runs\n  --- a single synchronous re-read cannot close that window.\n- **Do:** open a follow-up PR against `main` when the findings are in scope\n  and the fixes are known, rather than filing an issue.\n- **Do:** comment on the merged PR naming the follow-up and each finding's\n  disposition.\n- **Don't:** read the scan's clean result as durable when it ran promptly\n  after the merge, before a late review could post.\n- **Don't:** treat a post-merge finding as a Defer, since nothing about its\n  scope changed, only the branch's availability.\n- **Don't:** rely on the follow-up's link back as the whole record, since a\n  reader who lands on the merged PR never sees it.\n\n(Morrison-Lab\u002Fai-config#1079 merged at 2026-08-03T03:36:11Z, and Copilot's\nreview posted at 03:46:25Z, ten minutes after the merge rather than two\nminutes before it as in #1029 above.\nIt carried three inline findings plus two more inside a\n`Suppressed comments (2)` block, and all five were correct.\nThey were addressed against `main` in #1082, opened for that purpose and\nmerged at 04:15:05Z, and a comment on #1079 at 03:52:47Z names #1082 and each\nfinding's disposition.)\n\n### 1.5. Cascade conflict scan\n\n**In an ultracode\u002Fcoordinator session, delegate this whole step to a\nsubagent** rather than running the scan-and-resolve loop in the main thread\n--- it's exactly the kind of investigation-plus-fix work the coordinator\nshould hand off (see `memories\u002Fpreferences.md`'s coordinator-mode bullet).\nBrief the subagent with the merged PR's number\u002Fbranch, the resolved invoking\nuser and their aliases, the exact list of PR numbers the request explicitly\nauthorized (possibly empty), the exact list it explicitly excluded (possibly\nempty; a veto over every positive arm, the user's own PRs included), and the\nsteps below;\nhave it report back which PRs it found conflicting, what it did about each,\nand any it skipped (already claimed, conflict it couldn't understand). Do the\nscan inline only for a solo (non-orchestrated) session.\n\n**If any OTHER agents of this session already own a claimed branch (an active,\nresumable `Agent`-tool session, not a one-shot `Workflow`-internal `agent()`\ncall), message each one directly right after the merge, instead of relying solely on\na separate scan to find and fix their conflict after the fact:** \"main just\nadvanced (PR #N merged) --- fetch and merge origin\u002Fmain into your branch now,\nresolve any conflict yourself (you have the context on your own change), then\ncontinue.\" This is faster and higher-context than a scanning subagent\nguessing at the resolution from outside: the branch's own owning agent\nalready knows why its code looks the way it does.\nThose branches are usually this session's own work, but re-check each one\nagainst `memories\u002Freviewing-prs.md`'s scope test before sending the\ninstruction: an assignment can change, and a delegated agent may be driving\nan assigned or requested PR that another author opened.\nA branch that fails the test, or that is claimed by an agent that is not\nyours, is handled like any other open PR: the scope filter decides, and an\nout-of-scope one is reported to the user and left untouched.\nWhen the re-check finds one of this session's own agents on a branch that\nnow fails the test, tell that agent to stop before reporting the PR;\nwithholding the merge-main message alone leaves it free to keep polling and\npushing.\n\n**This depends on the coordinator finding out about a merge in the first\nplace --- so brief every delegated agent, up front, to report back the\ninstant its OWN tracked PR merges, not just when its ARDI work is done.**\nA PR sitting \"ready for merge\" isn't the end of that agent's watch: keep\npolling until the merge actually happens --- by a human, since the agent\nitself must not self-merge --- then notify the coordinator immediately. This\nis what lets the coordinator fan out the \"merge main now\" nudge above to\nevery OTHER live agent right when it matters, instead of the coordinator\nhaving to separately poll every open PR's merge state itself to notice. Fold\nthis into the standard delegation brief (see `gia`\u002F`gii`'s per-issue agent\nprompts) alongside the no-self-merge instruction, rather than treating it as\na one-off ask.\n\nReserve the scan-and-fix\nsubagent above for branches with NO active owning agent (e.g. a completed\n`Workflow` run's one-shot agent that already returned).\n\nA squash-merge on `main` can knock previously-mergeable open PRs into conflict.\nScan right after the merge is confirmed:\n\n```bash\ngh pr list --state open \\\n  --json number,title,headRefName,author,assignees,mergeable,mergeStateStatus,comments   # LIST_PRS\n```\n\nFilter that list by `memories\u002Freviewing-prs.md`'s scope test first, as\n`ardia` step 1 does (opened by or assigned to the invoking user, on the\nexplicitly authorized list from the brief, or authored by the GitHub Actions\napp (`github-actions`)), and report the PRs dropped.\nA conflict on an out-of-scope PR is reported to the user and the PR left\nuntouched (no comment, no push); a claim comment does not bring it into scope.\n\nFor each in-scope PR where `mergeable == \"CONFLICTING\"` **or `\"UNKNOWN\"`** (GitHub can\ntake minutes to finish computing mergeability after a push — a genuinely\nconflicting PR can sit in `UNKNOWN` and get missed if you filter for\n`CONFLICTING` alone):\n\n1. **Verify before claiming — don't trust the flag alone.** See\n   `resolve-conflicts`, \"Verify before you act\": `git merge-tree --write-tree\n   origin\u002Fmain origin\u002F\u003Cbranch>` gives ground truth without a worktree\n   (git ≥ 2.38). Skip if it comes back clean.\n2. **Attribute before claiming --- a conflict this sweep found is not\n   necessarily one your merge caused.**\n   On a repo with an old PR backlog most surviving conflicts are ordinary drift\n   (`DESCRIPTION`, a word list, a directory deleted months ago)\n   and were conflicting before you arrived.\n   Claiming them means resolving other people's branches for no reason.\n   Derive the merge's own deleted and renamed paths\n   and intersect them with each conflict's paths:\n   ```bash\n   merge=$(git rev-parse HEAD)   # the merge commit you just confirmed\n   git diff --name-status -M \"$merge^1\" \"$merge\" | grep -E '^(D|R)'\n   ```\n   A conflicting path in neither set is drift --- skip it.\n   **One exception, and it is the conflict this merge most certainly caused:**\n   a PR **stacked** on the branch you just merged conflicts on the paths that\n   merge modified and added, never on the ones it deleted or renamed, so the\n   intersection is empty and this step would skip it.\n   Check `gh pr list --base \u003Cmerged-branch>` before merging, treat any PR it\n   returns as caused by you whatever the intersection says, and reach for\n   [`cascade`](..\u002Fcascade\u002FSKILL.md) rather than resolving the conflicts\n   line by line.\n   The `git diff` form is used because it is correct for **both** merge\n   styles, which `git show` is not.\n   A squash merge is an ordinary single-parent commit, so\n   `git show --name-status \"$merge\"` diffs it normally and would do.\n   A **true** merge commit has two parents, and `git show` defaults to a\n   combined diff that omits every path changed in only one parent ---\n   on a clean merge that is all of them, so it prints no file list at all\n   and silently yields an empty attribution set.\n   Reaching for `git show` therefore works or fails depending on how the\n   repo merges, which is not a property of the commit in front of you;\n   naming `^1` explicitly removes the question.\n   See [`batch-merge-and-resolve`](..\u002F..\u002Fshared\u002Fworkflow\u002Fbatch-merge-and-resolve.md),\n   \"A conflict your sweep found is not a conflict your merge caused\"\n   and \"A stacked PR is the one conflict that intersection cannot attribute\".\n3. **Check claim status.**\n   Read the most recent comment **of the claim\u002Frelease exchange**, not the most recent comment overall:\n\n   ```bash\n   gh pr view \u003CN> --json comments \\\n     --jq '[.comments[] | select(.body | test(\"hold off|paws off|back off|unclaim|released|PR is free|now mergeable\"; \"i\"))] | last | .body'   # READ_PR_COMMENTS\n   ```\n\n   Any unrelated comment posted after a claim --- a status note, a bot result --- becomes the newest comment while the claim is still live, since a claim expires on activity rather than on age.\n   Reading the newest comment alone therefore reports a claimed PR as free.\n   Match the two-word invariant, `hold off` or either retired wording `paws off` \u002F `back off`, case-insensitively --- never a whole sentence.\n   The PR and issue claims differ after those two words, and the dash between them is an em-dash in this file's own claim emitter (step 4), so a quoted prefix misses claims this very skill posts.\n   See [`claim-pr`](..\u002F..\u002Fshared\u002Fworkflow\u002Fclaim-pr.md)'s \"Match the two-word invariant\".\n\n   **Then check the same comment for a release term, because one release marker contains a claim invariant.**\n   The retired release wording is `... done --- paws off released.`, which matches `paws off` --- so the invariant that fixes one bug introduces another, and this one fails the safe way round: a released PR reads as claimed, the sweep skips it, and the conflict is never resolved with nothing reporting why.\n   The sentence matcher this replaced did not collide, so the collision arrived with the fix.\n   Treat the comment as a release, not a claim, if it also matches `unclaim|released|PR is free|now mergeable`.\n   If a live claim stands --- a push or comment within the last 2 hours --- skip the PR.\n   Another session owns it.\n   An expired claim (over 2 idle hours) no longer blocks.\n   Take over with a fresh claim comment of your own, per [`claim-pr`](..\u002F..\u002Fshared\u002Fworkflow\u002Fclaim-pr.md)'s expiration rule;\n   that claim guards against session collisions on a PR already in scope, and never reads an out-of-scope PR into scope.\n4. **Claim it.**\n   ```bash\n   gh pr comment \u003CN> --body \"Working on this — please hold off on pushing to this branch until I'm done.\n\n   Session worktree: \u003Coutput of git rev-parse --show-toplevel>\n\n   _Posted by Claude Code (AI agent) --- not written by a human._\"   # COMMENT_PR\n   ```\n5. **Create an isolated worktree**, fetch the latest `main` (the squash-merge commit that caused the conflict), and merge:\n   ```bash\n   git fetch origin main \u003Cbranch>   # FETCH — fetch both: we need the new main tip\n   git worktree add .claude\u002Fworktrees\u002Fpr-\u003CN> origin\u002F\u003Cbranch>\n   cd .claude\u002Fworktrees\u002Fpr-\u003CN>\n   git checkout -b \u003Cbranch>         # or --track origin\u002F\u003Cbranch> if the name is free\n   git merge origin\u002Fmain            # MERGE_BRANCH — picks up the new squash-merge commit\n   ```\n6. **Resolve conflicts** using the `resolve-conflicts` skill (consolidate both\n   sides' intent; do not blindly pick one side wholesale).\n7. **Run the repo's pre-commit checks, `git fetch` the branch again, then push.**\n   The claim comment isn't an atomic lock — a repo's own automated bot (e.g. an\n   `@claude` CI agent triggered independently by the same merge event) can pick up\n   and resolve the identical cascade conflict in parallel even when no claim\n   comment was posted. If the fetch shows the remote has moved with an\n   **equivalent** fix already pushed, adopt it (verify with `git merge-tree\n   --write-tree origin\u002Fmain origin\u002F\u003Cbranch>` [git ≥ 2.38] — no remaining conflict — plus a\n   content diff against what you were about to push) instead of force-pushing\n   a duplicate merge commit. Only push your own resolution if the remote is\n   still where you left it.\n   ```bash\n   git fetch origin \u003Cbranch>   # FETCH\n   # If origin\u002F\u003Cbranch> already carries an equivalent fix, stop here — don't push.\n   git diff HEAD origin\u002F\u003Cbranch>   # empty\u002Fequivalent means the bot beat you to it\n   git push origin \u003Cbranch>   # PUSH — only if the remote hasn't moved\n   cd -\n   git worktree remove .claude\u002Fworktrees\u002Fpr-\u003CN>\n   ```\n8. **Unclaim** with a brief resolution summary:\n   ```bash\n   gh pr comment \u003CN> --body \"Conflict resolved — branch is now mergeable. \u003Cone-line summary of what conflicted and how it was resolved>\n\n   _Posted by Claude Code (AI agent) --- not written by a human._\"   # COMMENT_PR\n   ```\n\nResolve PRs one at a time — not because worktrees race each other (each worktree is an independent checkout), but because the same human or bot may be actively working a PR between your claim and your push.\nOne-at-a-time keeps the blast radius small.\nSkip any PR whose conflict is in a file you can't understand without more context — comment asking for clarification instead.\n\n**Match the response to scope, not only to cause.**\nStep 2 says whether a conflict is yours; the scope filter in the paragraph\nabove step 1 says whether the PR is.\nA conflict you genuinely caused on a PR that fails that test is a report to\nthe user naming the deletion or rename and where the content went; the PR\ngets no comment and no push.\nOn an in-scope PR, `sync-with-main` does prescribe re-applying the change on\nthe sibling branch and pushing it, and that fits a workflow or CI file in a\nrepo you drive.\nA release branch carrying an out-of-band process gets the report instead,\nwhatever the test says.\n\n### 2. Tidy the local branch\n\n```bash\nif [ \"$(git branch --show-current)\" != \"main\" ]; then\n  git checkout main\nfi\ngit fetch origin main\nif [ \"$(git rev-parse HEAD)\" != \"$(git rev-parse origin\u002Fmain)\" ]; then\n  git pull --ff-only origin main\nfi\nif git show-ref --verify --quiet \"refs\u002Fheads\u002F\u003Cmerged-branch>\"; then\n  git branch -d \u003Cmerged-branch>     # -d, NOT -D\nfi\n```\n\nUse `git branch -d` (not `-D`): `-d` refuses to delete a branch with commits\nthat aren't merged. If it refuses, the branch has unmerged work — investigate\nbefore forcing anything.\n\n**Both outcomes are normal after a squash merge --- a `-d` that succeeds is not\nevidence the commits reached `main`.**\nThe natural reading of the paragraph above is that `-d` succeeding means `main`\ncontains the work, so a squash-merged branch must always need `-D`.\nIt does not.\n`git-branch(1)` defines the check against the **upstream**, not `main`:\nthe branch must be \"fully merged in its upstream branch, or in HEAD if no\nupstream was set with `--track` or `--set-upstream-to`.\"\nA branch still tracking a live `origin\u002F\u003Cname>` is trivially fully merged into\nits own upstream, so `-d` succeeds and says so:\n\n```\nwarning: deleting branch 'fix\u002Fthing' that has been merged to\n         'refs\u002Fremotes\u002Forigin\u002Ffix\u002Fthing', but not yet merged to HEAD.\n```\n\nWhich branch of that behavior you land on depends on whether the remote ref\nstill exists, and that varies by repo setting and merge flag.\nA repo that auto-deletes head branches on merge (or `gh pr merge\n--delete-branch`) leaves `[gone]` upstreams that fall back to the HEAD check\nand refuse.\nIn one sweep of 29 branches, 18 deleted with `-d` and 11 needed `-D`;\nneither count meant anything about whether the work had landed.\n\nTwo consequences.\nDon't treat a refusal as a surprise worth debugging --- read step 1's merge\nconfirmation and the `-D` guidance below instead.\nAnd don't treat a **success** as confirmation, either:\nwhen it prints that warning, `-d` checked the remote ref, not `main`.\n\nThese guards avoid a common no-op\u002Ferror sequence after\n`gh pr merge --delete-branch`: that command may already switch this checkout\nto `main`, fast-forward it, and delete the local merged branch.\n\nIf the PR was built in a **git worktree** (agent isolation or `session-lock`),\nremove the worktree as part of the tidy — a worktree pins its branch, so\n`git branch -d` *refuses* while the worktree still holds it (\"branch is checked\nout at \u003Cpath>\"). Remove it first, then delete the branch:\n\n```bash\ngit worktree list                 # find the merged branch's worktree path\ngit worktree remove \u003Cpath>        # refuses on a dirty tree — don't blindly --force\ngit branch -d \u003Cmerged-branch>     # now succeeds\n```\n\n**Worktree containing a submodule:** `git worktree remove \u003Cpath>` refuses with\n`fatal: working trees containing submodules cannot be moved or removed` even\nwhen the tree is perfectly clean (`git status --short` empty) — this is a\ndifferent refusal than the dirty-tree one above, triggered by the mere\npresence of a submodule, not by uncommitted state. Confirm clean with\n`git status --short` first (as always), then `git worktree remove --force\n\u003Cpath>` is the correct move here, not a sign of misclassification.\n\n**Running from within the worktree:** if post-merge fires while the shell is\ninside the worktree being tidied, `git worktree remove \u003Cpath>` fails (\"cannot\nremove the currently checked out worktree\") and `git checkout main` is blocked\n(worktrees are locked to their branch). Use the repo root instead:\n\n```bash\nREPO=\"$(git rev-parse --git-common-dir)\u002F..\"             # main checkout root\ngit -C \"$REPO\" worktree remove \"$(git rev-parse --show-toplevel)\"   # worktree root\ngit -C \"$REPO\" branch -d \u003Cmerged-branch>\n```\n\n**Stale is not diverged, and the two need opposite responses --- check which\none you have before applying the bullet below.**\nA blocked `git checkout main` reads as the diverged case, since the symptom is\nthe same and diverged is the case this skill warns about.\nStale is far commoner: local `main` is merely behind `origin\u002Fmain` and **0\nahead**, carrying nobody's work.\nTwo counts separate the cases exactly, and the rule is three-way rather than\ntwo:\n\n```bash\ngit fetch origin main\necho \"behind: $(git rev-list --count main..origin\u002Fmain)  ahead: $(git rev-list --count origin\u002Fmain..main)\"\n```\n\n| `ahead` | `behind` | what it is | what to do |\n|---|---|---|---|\n| any | 0 | nothing to pull | leave `main` alone; just delete the branch |\n| 0 | > 0 | **stale** | fast-forward by refspec, below |\n| > 0 | > 0 | **diverged** | the bullet below |\n\nBoth counts matter, so do not key the decision on `ahead` alone.\n`git pull --ff-only` fails only in the last row: with `behind: 0` it reports\n`Already up to date.` and exits 0 even when `ahead` is non-zero, so routing\nthat row to the diverged bullet mislabels it (harmlessly --- there is nothing\nto pull either way).\nThe row that actually misleads is the middle one, where treating stale as\ndiverged leaves `main` behind for no reason.\n\nWhat blocks the switch in that case is usually an **unrelated dirty file**\n(a `renv.lock` an `renv::snapshot()` rewrote, a lockfile, a local config)\nwhose content differs between the *stale* `main` and your branch's HEAD, so\ngit refuses to carry the local edit across.\nThat file is frequently identical between HEAD and `origin\u002Fmain`, so\nfast-forwarding first dissolves the conflict --- and a branch that is not\nchecked out can be fast-forwarded by refspec, touching no working tree:\n\n```bash\ngit fetch origin main:main    # fast-forwards the ref; refuses if not a fast-forward\ngit checkout main             # now carries the dirty file across untouched\n```\n\nThe refspec form is safe by construction, refusing a non-fast-forward rather\nthan clobbering, so it cannot destroy a genuinely diverged local `main`.\nPreserve the dirty file rather than stashing or discarding it --- it is\nunrelated to this PR, and may be another session's or the user's.\n\n- **Do:** read both counts before deciding, and fast-forward by refspec when\n  `ahead` is 0 and `behind` is not.\n- **Don't:** treat a blocked checkout as evidence of divergence, or leave\n  `main` stale because the bullet below said to skip the pull.\n- **Don't:** key the decision on `ahead` alone --- `behind: 0` is not\n  divergence, whatever `ahead` reads.\n\n(`ucdavis\u002Fbcs#536`, 2026-08-02: `git checkout main` aborted on a modified\n`renv.lock`, which looked like the diverged case.\nLocal `main` was 54 behind and 0 ahead, and the file was byte-identical\nbetween HEAD and `origin\u002Fmain` --- it differed only from the 54-commit-stale\n`main`.\n`git fetch origin main:main` fast-forwarded the ref and the switch then\nsucceeded with the local edit intact; skipping the pull as the bullet below\nprescribes would have left `main` 54 commits behind.)\n\n**Before `-D`, compare the LOCAL branch against the MERGED head --- step 1\nconfirmed the PR merged, which is not the same claim.**\nThe `-D` guidance below rests on step 1: the PR is merged, so forcing is safe.\nThat reasoning covers the commit the PR *merged*, and `-D` deletes whatever the\n**local ref** points at, which can be a different commit.\n\nThe gap opens without anyone doing anything unusual.\nA `main`-merge pushed to the branch after the PR merged, a bot commit, or your\nown unpushed work all leave the local ref ahead of the merged head, and the\n`-d` refusal a squash repo produces is identical either way --- so the refusal\ncarries no information about which case you are in, and the natural next step\nis the `-D` the text below authorizes.\n\nOne comparison settles it, and it costs nothing:\n\n```bash\nmerged=$(gh pr view \u003CN> --json headRefOid --jq .headRefOid)   # VIEW_PR\ngit fetch origin \"refs\u002Fpull\u002F\u003CN>\u002Fhead\" -q                      # FETCH\ngit log --oneline \"$merged\"..\"\u003Cbranch>\"    # empty => the ref is the merged head\n```\n\n**That fetch is load-bearing, not tidiness, because the merged head is\nroutinely absent from the local object store at exactly this moment, and\ncomparing against `origin\u002Fmain` succeeds and lies.**\nTwo distinct failure modes occur when skipping this fetch:\n\n1. **The error direction (behind merged head):**\n   `gh pr merge --delete-branch` removes the remote branch, and the merge commit\n   on `main` is a *squash* in this repo, so neither `origin\u002Fmain` nor any\n   remaining ref reaches the PR's own head.\n   `git log` then answers with\n\n   ```\n   fatal: Invalid revision range \u003Csha>..\u003Cbranch>\n   ```\n\n   which is the shape [`fail-fast`](..\u002F..\u002Fshared\u002Fprinciples\u002Ffail-fast.md) warns\n   about: the check did not run, and it says so on stderr while printing no\n   commits --- so a caller reading only stdout sees the same empty output a clean\n   comparison produces.\n   `refs\u002Fpull\u002F\u003CN>\u002Fhead` survives the branch deletion and is what makes the SHA\n   resolvable again.\n\n2. **The succeed-and-lie direction (`origin\u002Fmain..\u003Cbranch>` comparison):**\n   Comparing against `origin\u002Fmain..\u003Cbranch>` instead of `refs\u002Fpull\u002F\u003CN>\u002Fhead`\n   exits **0** and prints plausible commit output.\n   Because a squash-merge creates a new commit on `main` with a different SHA\n   and parentage, the branch's original commits are not ancestors of `main` even\n   though their diff is fully merged.\n   `git log --oneline origin\u002Fmain..\u003Cbranch>` lists every commit from the merged PR,\n   falsely suggesting unmerged work remains on the branch.\n   Comparing against `refs\u002Fpull\u002F\u003CN>\u002Fhead` (via `git log \"$merged\"..\"\u003Cbranch>\"`)\n   settles it cleanly:\n\n   ```bash\n   git fetch origin \"refs\u002Fpull\u002F\u003CN>\u002Fhead\" -q &&\n   git log --oneline \"$merged\"..\"\u003Cbranch>\"   # empty => all local work reached the PR\n   ```\n\nSo read the exit status rather than the output, and always anchor the comparison\nto the PR's fetched head ref rather than `origin\u002Fmain`.\nA non-zero exit means the comparison failed to happen, which is not evidence\nthe branch is safe to delete; re-fetch and re-run before touching `-D`.\n\nA non-empty list is not automatically a problem --- a merge commit whose every\ninput is already on `main` is safe to discard --- but it is a question, and it\nhas to be answered before the delete rather than after.\nRead the subjects: anything authored, rather than a merge or a revert of\nalready-landed work, means the branch carries something the PR did not.\n\n- **Do:** compare the local ref against the PR's fetched head (`refs\u002Fpull\u002F\u003CN>\u002Fhead`)\n  before `-D`, and read the extra commits' subjects when they differ.\n- **Do:** name the branch's SHA in the report when it differed from the merged\n  head, so the discrepancy is visible rather than absorbed.\n- **Don't:** read step 1's merge confirmation as covering the local ref --- it\n  is a claim about the PR's head, and `-D` acts on yours.\n- **Don't:** use `origin\u002Fmain..\u003Cbranch>` as a liveness test in a squash-merging\n  repo --- it exits 0 and falsely reports merged commits as unmerged work.\n- **Don't:** infer from a `-d` refusal which case you are in; a squash repo\n  refuses for every branch regardless.\n- **Don't:** read an `Invalid revision range` error as an empty answer --- it\n  prints no commits, exactly as a clean comparison does, and means the merged\n  head is simply not in the local object store.\n\n(`Morrison-Lab\u002Fai-config#1595`, 2026-08-17: running `git log --oneline origin\u002Fmain..\u003Cbranch>`\nimmediately after squash-merging printed two commits that had already merged under squash\ncommit `86cc8233`. Fetching `refs\u002Fpull\u002F1595\u002Fhead` confirmed `FETCH_HEAD..\u003Cbranch>` was empty.)\n\n(`Morrison-Lab\u002Fai-config#1566`, 2026-08-17: the PR merged at head `0a297637`,\nand the local branch stood at `ad3b7640`, which `git branch -D` duly printed\nwhile deleting it.\n`git log 0a297637..ad3b7640` lists nine commits --- a `main` merge plus eight\ncommits from `main`, including the four merge commits for this session's own\nPRs.\nNothing authored, so nothing was lost; the point is that the check ran\nafterwards, prompted by reading the delete output, rather than before.)\n\n(The fetch requirement was measured on the very next merge, `#1586`, which\nshipped the block above.\nRunning it as written, immediately after `gh pr merge --squash\n--delete-branch`, produced\n`fatal: Invalid revision range d8e17de2...ums\u002Fverify-local-branch-before-force-delete`\nand exit 128 --- the merged head was unreachable because the remote branch was\ngone and `main` carried only the squash.\n`git fetch origin refs\u002Fpull\u002F1586\u002Fhead` resolved it, and the re-run printed\nnothing, which is what actually licensed the `-D`.\nThe local ref was *behind* the merged head rather than ahead, so the original\nblock's failure mode was not in play; the recipe still could not answer.)\n\n**Diverged main checkout (`ahead` and `behind` both non-zero):**\n`git pull --ff-only` fails when the main checkout\nhas local commits from a concurrent session that hasn't been pushed. Don't\nforce-merge or reset their work — skip the pull and delete the branch only.\nThe branch deletion is what matters; another session will pull main when it's\nready. If `git branch -d` refuses because local `main` doesn't yet include\nthe merge (diverged HEAD, remote branch already deleted), use `git branch -D` —\nstep 1 already confirmed the PR is merged, so the force-delete is safe here.\n\nFor a repo-wide sweep of *all* dead worktrees (not just this PR's), run\n`clean-worktrees` (`cw`).\n\nIf other local branches were **stacked** on this one, offer to rebase them onto\nthe new `main` rather than deleting silently (see `cb` \u002F `clean-branches`).\n\n### 3. Confirm deferred items are tracked\n\nIf the PR's review loop deferred or acknowledged anything, make sure each has a\nfollow-up issue (preferences: *never leave deferred items untracked*). List\nthem, linked. File any that slipped through.\n\n### 3.5. Check whether delivery is gated on a further human action\n\nIn most repos the merge *is* the delivery, and this step is a no-op.\nIn a repo whose artifact reaches consumers only through a separate,\nhuman-gated release step, the merge is the midpoint, and the gap between the\ntwo is a window in which the repo's own documentation is wrong.\n\n`Morrison-Lab\u002Fgha` is the case to recognize.\nA capability ships with `examples\u002F\u003Cname>.yml` and\n`website\u002Freference\u002F\u003Cname>.qmd` stubs pinning `@v2`, but `@v2` moves only when\nsomeone dispatches `slide-major-tag.yml` --- so a consumer who copies a stub\nliterally between merge and slide gets `workflow-not-found`, per that repo's\nown README.\nThe same holds for any tag-, registry-, or release-gated artifact: a version\nbump merged but unpublished, a submodule pin not yet bumped in its consumer.\n\nTwo things make this the step that gets skipped rather than deferred.\nNothing turns red --- CI passed, the PR is green and merged, and the failure\nlands on a consumer who is not in the room.\nAnd the slide is destructive (it force-moves a tag), so it needs explicit\nhuman authorization and cannot simply be folded into the tidy, which is\nexactly why it evaporates instead: a step you are not allowed to perform is\neasy to stop tracking.\n\nDecide it mechanically rather than from memory of what the PR touched --- two\nlookups settle it, so this is an\n[`algorithmatize-checks`](..\u002F..\u002Fshared\u002Fworkflow\u002Falgorithmatize-checks.md)\ncase:\n\n```bash\ngit fetch origin --tags\ngit rev-parse 'v2^{}' origin\u002Fmain   # equal means current; different means a slide is owed\n```\n\nKeep the `^{}`.\nIt peels a tag to the commit it names, and without it an **annotated** tag\nresolves to its own tag-object SHA instead --- which never equals a commit\nSHA, so the check would report a slide owed on every run and become noise\nrather than an instrument.\nA lightweight tag resolves the same either way, so the peeled form is correct\nfor both and there is no case where dropping it helps.\n(`slide-tag` reads a tag with `git log --oneline -1 \u003Ctag>`, which peels for\nthe same reason.)\n\nThen raise it as a `⚠️ **FLAG** ---` in step 5's report,\nnaming the tag and what is unreachable until it moves.\nAn offer is not a flag: say plainly that the slide is owed and that it needs\nthe human, the same way\n[`report-mistakes-proactively`](..\u002F..\u002Fshared\u002Fworkflow\u002Freport-mistakes-proactively.md)\nrules out offering to file an issue instead of filing it.\n\n- **Do:** compare the release ref against `main` after the merge, and flag the\n  gap with the specific tag and the affected consumer-facing paths.\n- **Do:** run the comparison on every merge rather than first judging whether\n  the repo looks release-gated --- it costs two commands and prints nothing to\n  act on when the SHAs match, so the comparison *is* the classifier.\n- **Don't:** run the release step yourself when it force-moves a ref or\n  publishes --- that is the human-gated action `ardi` reserves for explicit\n  authorization.\n- **Don't:** report a merged PR wrapped up while the artifact it documents is\n  still unreachable at the version its own docs name.\n\n(gha#357, 2026-07-30: three new reusable workflows merged as `159dbf4` while\n`v2` still pointed at `c50e847`, so every `@v2` line in the new capabilities'\nown stubs named a workflow that did not exist yet.\nFound only by an ad-hoc `rev-parse` at the end of the tidy, after steps 1\nthrough 3 had already reported clean.)\n\n### 3.75. Register a merged hook, since the gate that forbade it earlier names no later moment\n\nIf the merged PR touched `hooks\u002F`, the merge did not arm anything.\nIt placed a file and merged a manifest entry.\nOn the non-plugin install path a hook fires only once\n`~\u002F.claude\u002Fsettings.json` binds it, and that binding is per-machine local\nstate no merge can write.\n\nThis step exists because README's activation gate creates a **deferred step\nwith no owner**.\n\"Never activate a new hook before its PR merges\" is read by the author,\nbefore the PR is opened, and its matching action has to happen after the\nmerge, on every consumer machine.\nMerging happens on GitHub, where nothing local prompts anything, so the owed\nregistration is never refused and never scheduled --- it simply never\nhappens.\n\nIt shares its shape with step 3.5 above and differs in the half that decides\nwhat to do.\nBoth are owed after a merge, and neither turns anything red.\nBut 3.5's action force-moves a shared ref, so it is reserved for the human,\nwhereas this one writes one machine's own settings file and is yours to\nperform now.\nDo not carry 3.5's \"don't run it yourself\" bullet over to this step; here\nthat would leave the guard inert, which is the failure rather than the\ncaution.\n\nOne lookup and three calls settle it, run in the ai-config checkout after step 2\nhas already put it on `main` and pulled:\n\n```bash\ngit show --name-only --format= HEAD -- hooks\u002F   # did this merge bring in a hook?\npython3 scripts\u002Finstall-hooks.py                # report: registered \u002F missing \u002F stale\npython3 scripts\u002Finstall-hooks.py --fix          # the call that actually registers\npython3 scripts\u002Fcheck-hook-catalog.py           # print NOTE for allowlisted hooks; exits 0 unless it FAILs\n```\n\n**`--fix` is the load-bearing flag.**\nA bare `install-hooks.py` only reports, and says so itself\n(`Re-run with --fix to register the missing hooks.`), so a step that stops\nthere leaves the guard exactly as inert as before --- which is this step's own\nfailure mode, performed while looking like compliance.\n\nThe instrument is worth running on **any** ai-config merge rather than only one\nthat touched `hooks\u002F` --- it costs one command, prints `All hooks registered.`\nwhen there is nothing to do, and catches every hook that merged while someone\nelse was driving.\nThe first lookup is informational and reads `HEAD` because a squash merge puts\nthe merged content in one commit; it decides nothing, so do not skip the\ninstrument when it comes back empty.\n\nThen follow [`keep-checkouts-fresh`](..\u002F..\u002Fshared\u002Fworkflow\u002Fkeep-checkouts-fresh.md)\npoint 2, the `~\u002F.claude` consumer copies, which already owns the mechanics: if\nthe Claude Code plugin is enabled, its loader serves hooks straight from the\nplugin root, so there is nothing to run --- the merged hook goes live at the\nnext session start (or `\u002Freload-plugins`), since plugin hooks connect at\nsession start rather than the moment `main` moves.\nOtherwise (`install-hooks.py --fix`'s non-plugin path), check `enabledPlugins`\nfirst since the plugin path already loads every hook and a second\nregistration makes each one fire twice, confirm `~\u002F.claude\u002Fhooks` actually\nholds the merged script first --- `bootstrap.sh` no longer places it there\n(see its header comment; tracked as\n[#2352](https:\u002F\u002Fgithub.com\u002FMorrison-Lab\u002Fai-config\u002Fissues\u002F2352)) --- compare\nthe printed `examined N` against the current `hooks\u002Fhooks.json` before\nbelieving a clean report, and say that hooks connect at session start so a\nmid-session `--fix` arms nothing until a restart.\n\n**`--fix` binds the manifest, not every hook file on disk.**\nA hook whose authoring PR left it in the catalog allowlist of\ndocumented-but-inert hooks is absent from `hooks\u002Fhooks.json`, so this\nstep cannot arm it.\n`--fix` then prints `All hooks registered.` over that gap, because\nit iterates only the manifest.\n`check-hook-catalog.py` is the detector: it prints\n`NOTE: \u003Cscript> is documented but not registered (known, ai-config#N)`\nand exits 0 on that path, so read the NOTE, not the exit status.\nSearch for an existing activation issue before filing a follow-up\n(the allowlist maps each entry to that tracker).\nIf the listed tracker has closed and the hook is still inert, repoint\nthe allowlist (and the README **not registered** marker) at a live issue.\nIf none is open, file one covering the manifest entry, dropping\nthe allowlist row, and dropping **not registered** from the README row.\nThe PR that resolves that issue is when this step can bind the hook.\n\n- **Do:** treat a documented-but-inert catalog row as a deferred\n  registration, not as a `--fix` miss on this merge.\n- **Don't:** report the merged hook as live after this step when it is still\n  allowlisted.\n\n**A hook cannot be the instrument that BOOTSTRAPS this**, which is worth\nstating so nobody reaches for one first.\nA guard that detects unregistered hooks is itself a hook, so on a machine where\nnothing is bound it is silent exactly when the condition holds, which is\n[`fail-fast`](..\u002F..\u002Fshared\u002Fprinciples\u002Ffail-fast.md)'s pass-path-equals-failure-path\nshape.\nThe limit stops there, and the measured incident is what shows where: at\n`registered=15 missing=16` a detector among the fifteen would have caught the\nsixteen.\nSo a hook can catch later drift and cannot catch its own first registration ---\nand on the plugin path, where it always runs, none is owed anyway.\nThat is why the owner is a step in a skill, with a hook available at most as a\nsecondary check on top of it.\n\n- **Do:** run `install-hooks.py` as part of every ai-config post-merge sweep,\n  and report the `registered`\u002F`missing`\u002F`stale` counts rather than a verdict.\n- **Do:** register a hook whose PR just merged, since the gate's prohibition\n  expired at the merge and nothing else will do it.\n- **Don't:** read a merged hook as an active one --- merging places a file,\n  and only a binding makes it fire.\n- **Don't:** build a hook to detect this; it is unregistered exactly when the\n  condition is true.\n\n(Morrison-Lab\u002Fai-config#1786, 2026-08-20: one machine reported\n`registered=15 missing=16 stale=0` against a 31-hook manifest.\nAmong the sixteen inert guards was `flag-add-a-outside-pathspec.py`, and in\nthe same session `git add -A ':!inst\u002Fextdata'` swept `SAS\u002Fprogram\u002F` into a\npushed `ucdavis\u002Fbcs` commit carrying a cleartext SAS credential and real\n`StudyID_c` values --- the verbatim mistake that hook was written to prevent,\nand whose docstring describes that exact command.\n`--fix` registered the missing sixteen, and a fed-payload test then confirmed\nthe guard fires on the command and names `SAS\u002F` in its output.\nEvery rule needed to prevent this was already written and had been for weeks;\nwhat was missing was a moment at which anyone would run the command.)\n\n### 4. Run UMS — learn from the PR's lifecycle\n\nRun the full `ums` procedure (invoke the `ums` skill by name), focused on what\n**this PR** taught:\n\n- **Recurring review findings** — anything the reviewer flagged across rounds\n  → encode the fix so the next PR avoids it from the start.\n- **Corrections \u002F guidance the user gave mid-PR** → preference + skill update\n  (per \"update BOTH skills AND preferences\").\n- **Tool \u002F CI quirks** hit during the loop → the matching topical memory file\n  under `memories\u002F`, or `debugging.md`; see `memories\u002FMEMORY.md` for the\n  current set.\n- **A multi-step pattern that emerged** → run `spot-skill-opportunities` to\n  judge whether it's genuinely recurring, then hand off to `skill-builder`.\n\nThis is the \"learn from mistakes and guidance along the way\" step — a merge is\nthe natural checkpoint to bank those lessons before the context is gone. If\nnothing durable emerged, say so explicitly rather than manufacturing edits.\n(UMS commits its own changes via a branch + PR.)\n\n**Guard against recursion: skip this step when the merged PR was itself a\nUMS\u002Flearnings PR — one whose diff is entirely memory\u002Fskill edits capturing a\nprevious PR's lessons — and no new lessons emerged from its own review loop.**\nRe-running UMS there is redundant — the lessons are already encoded in the PR\nthat just merged — and spawns an endless UMS-on-UMS chain (each UMS PR merges →\ntriggers post-merge → triggers another UMS PR). Still do steps 1–3 and 5; just don't\nmanufacture a fresh UMS PR. (If the UMS PR's *own* review surfaced a genuinely\nnew, separate lesson, capture that — but not a restatement of what the PR\nalready banked. Concretely: a reviewer approving with no comments means nothing\nnew, so skip; a reviewer flagging a missing anti-pattern that isn't already in\nthe UMS diff is a new lesson worth a follow-up.)\n\n**The second clause is the operative one, and it is the one that goes\nunevaluated.**\nThe first clause holds for every learnings PR, which is the only kind of PR\nthis guard ever fires on, so it is satisfied before you have read the rest of\nthe sentence.\nEvaluate the second clause explicitly, by an actual pass over the merged PR's\nown review rounds, and emit the guard's outcome as a sentence either way.\n\"Skipped under the recursion guard; the review loop raised nothing that is not\nalready in the diff\" is a report.\nSilence is the failure, because it is indistinguishable from step 4 never\nhaving been reached.\nSee [`skill-checklists`](..\u002F..\u002Fshared\u002Fworkflow\u002Fskill-checklists.md)'s \"An item\na guard exempts is neither run nor skipped\".\n\n### 5. Report\n\n**Pause point: before reporting the merge wrapped up.**\nDo-Confirm; per\n[`shared\u002Fworkflow\u002Fskill-checklists.md`](..\u002F..\u002Fshared\u002Fworkflow\u002Fskill-checklists.md).\n\n- [ ] The merge actually landed (step 1's verification, not the notification).\n- [ ] Step 1.1's instrument ran against the merge commit and reported clean\n      (exit 0) --- not merely that the PR's own CI was green.\n      When it was pending, that clean reading came from the check-in,\n      and step 4 did not wait for it.\n- [ ] The local branch is tidied and `main` is fast-forwarded.\n- [ ] Every deferred item has a filed follow-up issue.\n- [ ] Step 3.75 ran `install-hooks.py --fix` on this ai-config merge, and the\n      counts are reported.\n      Not conditional on the merge having touched `hooks\u002F`: that lookup is\n      informational, and the drift it catches is usually owed by someone\n      else's merge rather than by this one.\n      The bare invocation only reports, so \"I ran install-hooks\" is not\n      evidence that anything was registered.\n- [ ] **Killer item: step 4's UMS pass actually executed**, or was\n      deliberately skipped under the recursion guard and that is stated.\n      Marked because reporting this skill complete asserts that its final step\n      ran, and the recorded failure is a `post-merge` run reported done whose\n      UMS step never happened --- which discards the learnings rather than\n      delaying them.\n      Naming what UMS changed (or that nothing durable emerged) is the\n      evidence; \"ran UMS\" on its own is not.\n\nThen a linked summary: the merged PR, the auto-closed issue, any deferred\nfollow-up issues, what UMS updated, and a Pacific-time timestamp\n(`TZ=America\u002FLos_Angeles date \"+%Y-%m-%d %H:%M %Z\"`; the explicit `TZ` enforces\nPT on a machine set to any other zone).\n\n**Session stopping point signal:**\nWhen this post-merge wrap-up completes the session's work **and no PR this session opened or pushed to remains unmerged** (typically after the UMS follow-up PR itself merges --- note step 4 normally opens one), finish the report with an explicit stopping-point statement (e.g. *\"This session is at a good stopping point.\"*) per `wrap-up`'s closing checklist. If a UMS follow-up PR or another task remains open, state explicitly that the session is not at a clean stopping point and name what is open.\n\n## Relationship to other skills\n\n- **`wrap-up`** — session-level bookend; also embeds UMS. `post-merge` is the\n  per-PR version: run it each time a PR lands; run `wrap-up` once at session\n  end. They share the verify-then-UMS shape.\n- **`ums`** — step 4 invokes it.\n- **`spot-skill-opportunities`** — step 4's \"multi-step pattern that emerged\"\n  bullet routes here to judge recurrence before handing off to `skill-builder`.\n- **`slide-tag`** -- what step 3.5's flag asks the human to authorize; it does\n  the force-move, this skill only detects that one is owed.\n- **`cb` \u002F `clean-branches`** — for stacked or stale sibling branches.\n- **`clean-worktrees` \u002F `cw`** — if the PR was built in a git worktree, remove\n  it during the tidy (step 2); a leftover worktree pins its branch and blocks\n  `git branch -d`.\n- **`st` \u002F `gi`** — the front of the lifecycle that `post-merge` closes.\n\n## Anti-patterns\n\n- ❌ Deleting the branch before confirming the merge actually landed.\n- ❌ Reporting a merge done from the PR's own green CI without running step\n  1.1's instrument against the merge commit --- a push-only workflow (a full\n  or PDF render, a deploy) never ran on the PR at all\n  ([Morrison-Lab\u002Fmds#19](https:\u002F\u002Fgithub.com\u002FMorrison-Lab\u002Fmds\u002Fpull\u002F19)).\n- ❌ Reaching for `git branch -D` (force) without checking why `-d` refused.\n- ❌ Running `-D` without comparing the local ref against the PR's merged\n  head --- step 1 confirms the PR merged, and `-D` deletes whatever your\n  local branch points at, which can be a different commit.\n- ❌ Force-pulling or resetting a diverged main checkout — the divergence may be another session's in-progress work. Skip the pull; don't clobber it.\n- ❌ Skipping UMS on a normal PR — the just-merged PR is exactly when the\n  lessons are freshest.\n- ❌ Recursing UMS on a UMS PR — running UMS again when the just-merged PR was\n  itself the learnings PR, restating lessons it already banked (see step 4's\n  guard). The chain has to terminate somewhere.\n- ❌ Leaving deferred\u002Facknowledged items without follow-up issues.\n- ❌ Reporting an ai-config merge wrapped up without step 3.75's `--fix` run\n  -- whatever hooks are owed stay merged, documented, and inert, which is the\n  deferred-step-with-no-owner shape this skill's own step 3.75 exists to close,\n  arriving one level up in the checklist meant to catch it.\n- ❌ Calling a merge wrapped up in a release-gated repo without comparing the\n  release ref against `main` (step 3.5) -- the merged docs pin a version\n  consumers cannot resolve until a human slides the tag.\n- ❌ Reporting \"all cleaned up\" while a stacked sibling branch dangles unmentioned.\n- ❌ Treating the whole cascade-scan hit list as work caused by this merge, without\n  intersecting it against the merge's own deleted and renamed paths (step 1.5's own step 2) --- on\n  an old backlog that claims other people's stale PRs for no reason.\n- ❌ Pushing to, or commenting on, a PR that fails the scope test --- it gets a\n  report to the user --- or pushing to a release branch carrying an out-of-band\n  process even when it passes, where a report is the safe form.\n",{"name":5,"description":7,"allowed-tools":24,"user-invocable":29},[25,26,27,28],"Bash","Read","Edit","Write",true,"main","0f720481f8ce3b3d9fef485f6e230d8b3035748e","skills\u002Fpost-merge",1,"https:\u002F\u002Fgithub.com\u002FMorrison-Lab\u002Fai-config","https:\u002F\u002Fmorrison-lab.github.io\u002Fai-config\u002F","https:\u002F\u002Fgithub.com\u002FMorrison-Lab","2026-11-15 04:39:15",{"source":8,"skillName":5,"commands":39,"prompt":49,"zipAvailable":29},[40,43,46],{"tool":41,"command":42},"npx","npx skills add Morrison-Lab\u002Fai-config --skill post-merge",{"tool":44,"command":45},"bunx","bunx skills add Morrison-Lab\u002Fai-config --skill post-merge",{"tool":47,"command":48},"pnpm","pnpm dlx skills add Morrison-Lab\u002Fai-config --skill post-merge","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FMorrison-Lab\u002Fai-config\u002Fblob\u002Fmain\u002Fskills\u002Fpost-merge\u002FSKILL.md",[],[52,59,66,73,80,87],{"skillNo":53,"name":54,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":56,"categories":57,"keywords":58,"publishedAt":19},"01M735BVYCGR5VEC65AFDVSNKW","wrap-up","End-of-session verification and UMS.","https:\u002F\u002Fgithub.com\u002FMorrison-Lab\u002Fai-config\u002Fblob\u002Fmain\u002Fskills\u002Fwrap-up\u002FSKILL.md",[],[],{"skillNo":60,"name":61,"nameZh":6,"description":62,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":19},"01M735BTH469T1CQ8G2Q9GENCR","workaround-watcher","Watch upstream issue for fix.","https:\u002F\u002Fgithub.com\u002FMorrison-Lab\u002Fai-config\u002Fblob\u002Fmain\u002Fskills\u002Fworkaround-watcher\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M735BRKZWFANSQ0GM380B4TD","wn","→ whats-next.","https:\u002F\u002Fgithub.com\u002FMorrison-Lab\u002Fai-config\u002Fblob\u002Fmain\u002Fskills\u002Fwn\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":19},"01M735BPE9V830B3B6NGXQ56J6","whats-next","Recommend concrete next step or action.","https:\u002F\u002Fgithub.com\u002FMorrison-Lab\u002Fai-config\u002Fblob\u002Fmain\u002Fskills\u002Fwhats-next\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":19},"01M735BMHQ60EAD5B7QAWXC5A0","wait-for-results","Wait for pipeline\u002FCI results.","https:\u002F\u002Fgithub.com\u002FMorrison-Lab\u002Fai-config\u002Fblob\u002Fmain\u002Fskills\u002Fwait-for-results\u002FSKILL.md",[],[],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":19},"01M735BKGZHPN1PEMJ7YBD5VJ8","wai","→ send-notes.","https:\u002F\u002Fgithub.com\u002FMorrison-Lab\u002Fai-config\u002Fblob\u002Fmain\u002Fskills\u002Fwai\u002FSKILL.md",[],[]]