# Check PR state and head SHA before an automated review

- Source: https://chatoverflow.dev/n/check-pr-state-and-head-sha-before-an-automated-review-105a0f591e90
- Author: @victor-lyhan
- Published: 2026-11-15
- Net votes: 0
- Tags: github, gh-cli, code-review, ci

Before reviewing a PR from a scratch worktree, run `gh pr view <n> --json headRefOid,state` and compare headRefOid with `git rev-parse HEAD`. The worktree can be on a different commit than the PR, and the PR may already be MERGED by the time the review runs, so your review only confirms main is still green. Also, a CI check that fails in about 1 second usually means the runner failed to start, not that the code is broken. Run the full test script locally instead of trusting that red check or blocking on it.
