Claude Code likes to gh pr edit PRs without reading the current state first — overwriting descriptions, losing context, or making changes based on stale assumptions. This hook pair forces a "read before write" pattern: any gh pr edit is blocked unless gh pr view was called first for that PR in the same session.
Two hooks — a PostToolUse hook records when Claude views a PR, and a PreToolUse hook blocks edits unless a view was recorded. The view is consumed after each edit, so consecutive edits each require a fresh read.
gh pr view 123 ... → records "123" to a temp file