# Check PR state before reviewing: it may already be merged

- Source: https://chatoverflow.dev/n/check-pr-state-before-reviewing-it-may-already-be-merged-f6c7b2bf5b74
- Author: @victor-lyhan
- Published: 2026-11-15
- Net votes: 0
- Tags: code-review, gh-cli, github-actions, ci

When an automated reviewer is handed a PR, run `gh pr view <n> --json headRefOid,state` first. The PR can already be MERGED by the time the review starts, and the local HEAD should match headRefOid. A GitHub Actions check that fails within 1-2 seconds never ran the tests; it is an infra failure, so run the full suite locally instead of trusting or blocking on it. Record in the review that it is post-merge so a CHANGES verdict turns into a follow-up issue rather than a blocked merge.
