|
| 1 | +# PR Review Squad — Work Routing |
| 2 | + |
| 3 | +## Fix Process (when told to fix a PR) |
| 4 | + |
| 5 | +> **Critical:** Follow this process exactly. Deviating — especially using rebase or force push — causes commits to land on the wrong remote. |
| 6 | +
|
| 7 | +### 1. Check out the PR branch |
| 8 | +```bash |
| 9 | +gh pr checkout <number> |
| 10 | +``` |
| 11 | +This sets the branch tracking to the correct remote automatically (fork or origin). |
| 12 | +**Never** use `git fetch origin pull/<N>/head:...` — that creates a branch with no tracking. |
| 13 | + |
| 14 | +> **Worktree conflict?** If `gh pr checkout` fails with "already checked out at...", run: |
| 15 | +> ```bash |
| 16 | +> git worktree list # find which worktree has the branch |
| 17 | +> git worktree remove <path> # remove stale worktree if safe, OR |
| 18 | +> gh pr checkout <number> -b pr-<number>-fix # use a unique local branch name |
| 19 | +> ``` |
| 20 | +
|
| 21 | +### 2. Integrate with main (MERGE, not rebase) |
| 22 | +```bash |
| 23 | +git fetch origin main |
| 24 | +git merge origin/main |
| 25 | +``` |
| 26 | +**Never** use `git rebase origin/main`. Merge adds a merge commit; no force push needed. |
| 27 | +If there are conflicts, resolve them, then `git add <files> && git merge --continue`. |
| 28 | + |
| 29 | +### 3. Make the fix |
| 30 | +- Use the `edit` tool for file changes, never `sed` |
| 31 | +- Make minimal, surgical changes |
| 32 | + |
| 33 | +### 4. Run tests |
| 34 | +Discover and run the repo's test suite. Look for test projects, Makefiles, CI scripts, or package.json test scripts. Run them and verify only pre-existing failures remain. |
| 35 | + |
| 36 | +### 5. Commit |
| 37 | +```bash |
| 38 | +git add <specific-files> # Never git add -A blindly |
| 39 | +git commit -m "fix: <description> |
| 40 | +
|
| 41 | +Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>" |
| 42 | +``` |
| 43 | + |
| 44 | +### 6. Push to the correct remote |
| 45 | + |
| 46 | +**Always verify the push target before pushing:** |
| 47 | +```bash |
| 48 | +# Get expected owner/branch from the PR |
| 49 | +gh pr view <N> --json headRepositoryOwner,headRefName \ |
| 50 | + --jq '"Expected: " + .headRepositoryOwner.login + "/" + .headRefName' |
| 51 | + |
| 52 | +# Confirm branch tracking matches |
| 53 | +git config branch.$(git branch --show-current).remote |
| 54 | +``` |
| 55 | +These must agree. If they don't, stop and investigate before pushing. |
| 56 | + |
| 57 | +Once verified: |
| 58 | +```bash |
| 59 | +git push |
| 60 | +``` |
| 61 | +`gh pr checkout` sets branch tracking correctly, so bare `git push` lands on the right remote. |
| 62 | + |
| 63 | +**If `git push` fails** (e.g., tracking not set up correctly), push explicitly using the owner's remote. |
| 64 | +`gh pr checkout` registers the fork owner's GitHub login as a named remote — use it directly: |
| 65 | +```bash |
| 66 | +# Discover the owner's remote name |
| 67 | +OWNER=$(gh pr view <N> --json headRepositoryOwner --jq '.headRepositoryOwner.login') |
| 68 | +BRANCH=$(gh pr view <N> --json headRefName --jq '.headRefName') |
| 69 | +git remote -v | grep "$OWNER" # confirm remote exists |
| 70 | + |
| 71 | +git push "$OWNER" HEAD:"$BRANCH" |
| 72 | +``` |
| 73 | +Alternatively, use `.squad/push-to-pr.sh <N>` which automates the above. |
| 74 | + |
| 75 | +### 7. Verify the push landed |
| 76 | +```bash |
| 77 | +gh pr view <N> --json commits --jq '.commits[-1].messageHeadline' |
| 78 | +``` |
| 79 | +The last commit headline should match your fix commit message. |
| 80 | + |
| 81 | +### 8. Re-review |
| 82 | +Dispatch 5 parallel sub-agent reviews with the updated diff (include previous findings for status tracking). |
| 83 | + |
| 84 | +--- |
| 85 | + |
| 86 | +## Review Process (no fix) |
| 87 | + |
| 88 | +Use `gh pr diff <N>` — **never** check out the branch for review-only tasks. |
| 89 | + |
| 90 | +Dispatch 5 parallel reviews: |
| 91 | +- claude-opus-4.6 |
| 92 | +- claude-opus-4.6 |
| 93 | +- claude-sonnet-4.6 |
| 94 | +- gemini-3-pro-preview |
| 95 | +- gpt-5.3-codex |
| 96 | + |
| 97 | +Synthesize with 2+ model consensus filter. |
| 98 | + |
| 99 | +--- |
| 100 | + |
| 101 | +## Why `gh pr checkout` + merge beats manual fetch + rebase |
| 102 | + |
| 103 | +`gh pr checkout` reads PR metadata and configures the branch to track the correct remote (fork or origin). Bare `git fetch pull/<N>/head:...` creates a local branch with no upstream — `git push` then defaults to `origin`, silently pushing to the base repository instead of the author's fork. |
0 commit comments