1---2name: gh-pr-workflow3description: Working with GitHub pull requests, issues, and the API through the gh CLI. Use whenever the task involves reviewing, creating, or commenting on a PR or issue, or calling the GitHub API.4---56# GitHub PR workflow781. **Use `gh` for GitHub operations.** Structured queries beat scraping:9 `gh pr view 12 --json title,body,files,comments`, `gh pr checks 12`,10 `gh issue list --limit 10`.112. **Big diffs go to a file, not the conversation.**12 `gh pr diff 12 > /tmp/pr12.diff`, then search and read slices of that file.13 Never print a whole PR diff into the chat.143. **Draft first, post on approval.** Write the review or comment body to a15 scratch file, show it to the user, and only after they approve post it:16 `gh api repos/{owner}/{repo}/pulls/12/reviews --method POST --input review.json`.17 Never post to GitHub as a side effect of being asked to "review".184. **One PR at a time, one comment per issue found.** Do not batch several19 PRs' feedback into one pass, and do not stack multiple problems into one20 comment.215. **Auth errors are a full stop.** A 401 or `gh auth status` failure means22 tell the user to run `gh auth login`. Retrying, or switching to raw git23 pushes, will not help.246. **PR bodies: summary plus test plan.** Short paragraphs over prose walls.25 No attribution footers unless asked.267. **Know which subcommands write.** Reads (`view`, `list`, `diff`, `checks`,27 `api` GET, `search`) run freely; writes (`create`, `edit`, `merge`, `close`,28 `comment`, `review`, any `--method POST/PATCH/PUT/DELETE`, `pr checkout`,29 `release create`) change state and will ask the user for approval. Batch30 reads first, then propose the writes as one step instead of interleaving.