Use gh and gh api directly to inspect pull request state, read discussions, diagnose CI failures, read other GitHub records, or post one reply without changing code. Confirm gh is installed and authenticated (gh auth status) before doing anything, and stop on missing binary or auth errors.
Default to the current branch's pull request in the current repo, returning truncated text unless I ask for full bodies or structured JSON. If I give you a PR number or URL, target that one instead. If I name another repo, pass -R owner/repo on gh pr or gh run commands (and always include a PR number for PR-bound work). Stop on conflicting choices or missing values, and if there is no PR on the current branch for PR-bound work, say so and stop. Never resolve review threads, push commits, or merge pull requests from this skill.
Open references/commands.md whenever you run PR snapshots, thread collection, CI failure drilldowns, log downloads, or PR replies so every run uses the exact same deterministic commands, pagination loops, and fallback steps.
Keep PR state separate from PR discussions, because neither replaces the other. A snapshot covers title, state, draft flag, author, URL, base and head branches, head SHA, mergeability, merge state status, review decision, body, file stats, check buckets (pass, fail, pending, skipping, cancel), latest non-PENDING review per author, recent comments, and open versus total thread counts. If a combined GraphQL snapshot fails with complexity, timeout, or 5xx, fall back to the split commands in references/commands.md.
For discussions, collect nonempty non-PENDING review bodies, conversation comments, and inline review threads, keeping each thread's path, line, originalLine, isResolved, isOutdated, and first comment databaseId and url (REST replies target that root comment databaseId, not the GraphQL thread ID). Hide resolved and outdated threads by default. If I ask for open threads, keep unresolved threads including outdated ones. If I ask for all threads, include resolved too (stop if open and all are both requested).
Author filters keep conversation items by that author and threads where any comment is by that author. ISO 8601 since filters keep conversation items at or after that timestamp and threads where any comment is at or after that timestamp (stop on an invalid date). Tell me explicitly whenever any list is truncated or capped, because partial data never counts as exhaustive.
For CI inspection, pin checks to a known head SHA with filter=latest&per_page=100 (and commit statuses) when available, list recent runs with gh run list (default limit 10, optional workflow filter), or inspect a specific Actions run ID directly with gh run view. For CheckRun entries, statuses IN_PROGRESS, QUEUED, WAITING, PENDING, and REQUESTED are pending, SUCCESS is pass, SKIPPED and NEUTRAL are skipping, and conclusions FAILURE, TIMED_OUT, ACTION_REQUIRED, and STARTUP_FAILURE are fail (CANCELLED maps to cancel in snapshot rollups and also counts as a failing run in CI failure drilldowns). For StatusContext entries, SUCCESS is pass, FAILURE and ERROR are fail, and PENDING or EXPECTED are pending.
Actions job drilldown alone does not prove which checks are required versus optional, so query repos/<owner>/<repo>/rules/branches/<base> (or repos/<owner>/<repo>/rulesets/<id>) and cross-check gh pr checks --required when that matters. Remember that red CI or open threads is a successful inspection result, not a tool failure.
Download job logs only through gh api --allow-escape-sequences written directly to a private temporary file (umask 077, 0700 dir, 0600 files), and never forward a GitHub bearer token to a redirected blob URL. Unzip PK ZIP archives into .log files and delete the ZIP, treat a 404 as log not available yet (job still running), never print tokens, Authorization headers, or signed URLs, and cite the saved temp path with focused error snippets instead of pasting full logs.
When posting a reply, require exactly one target (an inline comment databaseId, discussion_rN, or comment URL, or the main PR conversation) and one non-empty body passed via -F body=@<file> or --input - on gh api (or --body-file on gh pr commands) so backticks and quotes stay literal. If I already supplied the reply text, post it verbatim. If you draft the reply yourself, follow the plain voice rules below. Always follow the root-resolution and duplicate-safe fallback procedure in references/commands.md, never silently post a main-conversation fallback unless the caller asks for it, and cite the returned html_url as proof of posting rather than the draft text.
Keep these gh CLI traps in mind on every raw command:
- Never pipe large
ghoutput intohead(it breaks with SIGPIPE). Redirect to a file or slice with--jq. gh apihas no-Rflag. Use literalrepos/<owner>/<repo>/...paths orGH_REPOinstead.- Passing
-for-Ftogh apiswitches the request toPOSTunless you pass-X GET. PutGETquery params inside the quoted URL, and keep owner and repo strings out of numeric coercion. gh api --paginateemits one JSON document per page, which breaks JSON parsers on page 2+ unless you also pass--slurpto wrap all pages in one outer array (then flatten array pages or object fields locally or by piping tojq). Never use--paginate --jqexpecting one merged array across pages, and put multilinejqprograms in a temp file passed withjq -f(notgh api -f).gh pr diffhas no--stator positive pathspec. Userepos/<owner>/<repo>/pulls/<N>/filesfor per-file stats, or save the full diff once and search locally.gh pr checksexits1for failures and8for pending (both have valid stdout), and"no checks reported"is an empty list, not an error. Empty stdout paired with stderr is a real error.- Fetch raw file contents at a ref with
-H "Accept: application/vnd.github.raw"and quote?ref=SHA. - Pass bodies via
-F body=@<file>or--input -ongh api(or--body-fileongh prcommands), never inline shell strings that can expand backticks or$. - PR checks rollup lives on
statusCheckRollup, job steps live ongh run view --json jobs, andgh searchfields differ fromgh pr viewfields. ghhas no-Cflag, so pass-R owner/repoongh prorgh runorcdinto the repo in the same command.- Modern effective branch rules live at
repos/<owner>/<repo>/rules/branches/<base>(and individual ruleset definitions atrepos/<owner>/<repo>/rulesets/<id>, while a404on classic protection does not mean no rules exist). Userepos/<owner>/<repo>/compare/BASE...HEADforahead_byandbehind_by. - Never sleep-poll runs or checks. Use host watchers or background
gh run watchorgh pr checks --watch.
Keep your summaries and any reply bodies you draft plain, impersonal, and result-focused: describe the result rather than the investigation, superseded decisions, or who was wrong (keeping required evidence lines), keep one kind of text per section (never mix facts, arguments, and instructions in one paragraph), and write active voice with a named actor, one word per action, and one name per thing. Keep sentences under 25 words (instructions under 20), place "only" and "not" next to what they change, break noun strings longer than three words, make every "it", "this", or "they" point to one clear noun, and use "you" only in an instruction to a person.
Avoid filler, review-session framing, we, let's, please, simply, easy, (s), Latin abbreviations, em dashes, semicolons, slash pairs like and/or, harness footers, and banned AI words (additionally, crucial, delve, enduring, enhance, fostering, garner, interplay, intricate, abstract landscape, pivotal, showcase, tapestry, testament, underscore, vibrant). Paths, SHAs, quoted errors, and code literals are exempt from both the word-length and punctuation limits.
