| name | finish-pr-cycle |
| description | Finish a completed development branch by verifying tests, pushing the branch, creating a GitHub PR, merging it, deleting the remote branch, removing the git worktree, and deleting the local branch. Use when the user asks to finish the cycle, ship via PR, merge and clean up, or says this is the end of a worktree/PR cycle. |
Finish PR Cycle
Workflow
Use this after implementation is complete and tests have already passed, or when the user explicitly asks to finish a branch through PR and cleanup.
- Verify the worktree is clean:
git status --short
git branch --show-current
If dirty, stop and report the changed files. Do not stash or discard.
- Update the branch from the PR base before verification. The PR base for this project is
develop, so pull in the latest merged work before running tests or creating the PR:
git fetch origin develop
git merge --no-edit origin/develop
If the merge conflicts, stop and report the conflicted files. Do not resolve conflicts silently. This is required because stale feature branches can rediscover round-trip diffs that were already fixed and merged in another branch.
- Verify tests if they were not just run in this session. Prefer the project's normal focused or full test command. In
nkdk-core, use:
pnpm --filter '@nkdk/core' test
- Push the current branch:
git push -u origin <branch>
- Create a PR into
develop. The PR base branch must be exactly develop; do not target main, master, or any other branch unless the user explicitly overrides this in the current request:
gh pr create --base develop --head <branch> --title "<title>" --body "<summary and test plan>"
- Merge the PR with a regular merge commit unless the user requested another merge method:
gh pr merge <number> --merge --delete-branch
If gh pr merge reports a local git/worktree error, check the PR state before retrying:
gh pr view <number> --json state,mergedAt,mergeCommit,url,headRefName,baseRefName
If the PR is already MERGED, continue cleanup.
- Confirm the remote branch is gone. If it remains, delete it:
git ls-remote --heads origin <branch>
git push origin --delete <branch>
- Remove the feature worktree:
git worktree remove <absolute-worktree-path>
- Delete the local branch:
git branch -D <branch>
Use -D only after confirming the PR is merged.
- Verify cleanup:
git worktree list
git branch --list <branch>
git ls-remote --heads origin <branch>
Report the PR URL, merge commit, removed worktree path, branch cleanup status, and any residual risk.