Execute when the PR review has converged and authorization to merge, wrap up, or deliver to the main branch already exists; authorization may come from an earlier instruction in this task, with no need to confirm again. Integration with the target branch is completed here in one pass: integrate with the latest target branch, verify, and merge.
For anything repository-specific, always read the repository's own documentation (AGENTS.md, contribution guide, quality gate documentation): check entry point, merge entry point, merge method, and handoff conventions. When the repository does not specify, use the defaults described below.
Steps
- Verify the starting point: the PR is OPEN, local HEAD equals the remote PR head, and the working tree is clean. If there are uncommitted changes (including fixes already verified but not pushed in a previous round), first handle them per
$git-prefs"Commit" and push — like the commits in the next two steps, they are reviewed commits to be delivered in this wrap-up. - Integrate the target branch: after fetching, merge the latest
origin/<base>into the current branch (git merge origin/<base>). If the repository documentation specifies an integration method, follow it. By default use merge: the branch is already pushed and reviewed, and merge only requires resolving each conflict once, preserving the pushed history and the anchors of review comments. - Clean up the baseline: fix compilation, lint, and test problems introduced by the target branch that block this merge or constitute a major risk, and commit them separately from this PR's changes; triage and handle test failures first per
$pr-review-loop"Test failure handling", and record the rest per that skill's "Grading". After committing and pushing, run the pre-merge checks declared by the repository. Completion criteria: the required checks on the remote PR head actually pass, and isolated items are listed separately per that handling rule. - Wrap-up re-review: reviews triggered by the pushes in steps 1 to 3 follow the ledger and budget of
$pr-review-loop, and the round count is not reset. Only verify the changes brought by this integration and baseline fixes: fix blockers among them before pushing again; reply to the rest per that skill's "Grading", without starting a new fix round for them. For a conflict-free integration that changes no code, just wait for checks to pass. Reviewer timeouts are recorded and skipped per "the wait limit is spent only once". Completion criteria: checks pass on the HEAD to be merged, there are no unclosed blockers, and all new comments have been replied to. - Merge: merge using the merge entry point declared by the repository; when none is declared, use
gh pr merge <号> --match-head-commit <HEAD>, with the merge method defaulting to the repository default. What is merged is exactly the commit re-reviewed in step 4. If the target branch has advanced in the meantime: if the merge entry point allows it (no conflicts, branch up-to-date not required), merge directly; if it requires up-to-date, return to step 2, and for a conflict-free integration just wait for checks. Completion criteria: the PR status is MERGED. - Hand off follow-up work: look for handoff conventions in the repository's
AGENTS.mdand.agents/skills/(e.g., build-issue-type skills). If the PR report has leftover items, or the requirement has other ends/stages not yet done, output a handoff prompt per the convention and state which device it is handed to. For test leftovers, follow the records and follow-up arrangements of$pr-review-loop"Test failure handling"; register other confirmed non-blocking baseline issues per repository convention, and create one entry each in the repository's issue tracker for independent issues; only write a handoff prompt for items belonging to subsequent stages of this requirement. Completion criteria: every leftover item has a destination (registration, entry link, or handoff prompt), and when there are no subsequent stages, explicitly write "no subsequent stages". - Close linked issues: The PR is linked to an issue tracker entry, and the entire requirement has been fully implemented; mark it as complete according to the corresponding skill; if the requirement has follow-up PRs, keep it in progress.
- Reclaim branches and worktrees: Invoking this skill is considered the user explicitly requesting deletion of the current worktree.
- Delete the remote branch (skip if it was already automatically deleted on merge);
- Note the main repository's git directory (
git rev-parse --path-format=absolute --git-common-dir) and the current branch name; - When currently in a linked worktree: first switch cwd to the worktree root, run
node <git-prefs 技能目录>/scripts/empty-worktree.mjs(clear the contents, keep the directory shell, so the shell bound to this directory remains usable), thengit --git-dir <主仓库 git 目录> branch -D <分支>. Use only this script to delete the worktree: once the directory disappears, this thread's shell becomes permanently unusable. On the main checkout, switch back to the target branch, pull, then delete the local branch. - When T3 Code is installed on this machine (with
~/.t3/worktrees), also run$t3-code'st3-worktree-gc.mjs --purge-builddry run to reclaim worktrees and build artifacts left by other terminated threads; after confirming the results are correct, add--apply。
- Report: merge commits, conflicts resolved and baseline fixes during integration, final review results (which reviewer, how many rounds, whether there were blockers), handoff prompt, linked issue status, reclamation results.