Imported from devon-systems/hoenn (
nix/modules/aly/skills/gh-cli/SKILL.md). Install upstream withnpx skills add devon-systems/hoenn --skill gh-cli. Copyright stays with the author.
GitHub gh CLI
Overview
Use gh for GitHub operations with explicit repo targeting, JSON output, and command help-driven discovery of flags/fields. Avoid scraping human-readable output and avoid raw REST calls unless you must (use gh api as the controlled fallback).
Quick start
- Verify
ghis installed and authenticated (once per session, or when debugging auth/repo targeting):gh --version gh auth status - Set explicit repo context:
# One-off target gh <noun> <verb> -R OWNER/REPO ... # Repeated work in a checkout gh repo set-default OWNER/REPO - Discover flags/fields on demand:
gh <command> --help gh help formatting
Operating rules (do not skip)
-
Prefer first-class commands over APIs.
- Use
gh issue,gh pr,gh repo,gh run,gh workflow,gh release, etc. - Use
gh apionly when the CLI lacks a dedicated command (document the endpoint and why).
- Use
-
Avoid guessing flags/fields; discover them.
- Use
gh <command> --helpto find flags and supported--jsonfields. - Use
gh help formattingfor--json,--jq, and--templatepatterns.
- Use
-
Prefer machine-readable output.
- Use
--json <fields> -q '<jq>'instead of parsing table output. - When you need just one value, return only that value (not the full blob).
- Use
-
Make repo targeting explicit.
- Prefer
-R OWNER/REPOwhen not operating in a known local checkout. - If you infer repo from the current directory, confirm it via
gh repo view --json nameWithOwner -q .nameWithOwner.
- Prefer
-
Treat state changes as production-impacting.
- Ask for confirmation before destructive or hard-to-reverse changes: closing/merging/deleting, resolving or unresolving review threads, and modifying branch protections or permissions.
- Routine, easily-reversed workflow output — posting a review reply, commenting, or checking out a PR branch (
gh pr checkout) — does not require an extra gate. - When modifying settings, make changes small and reversible.
Common tasks
See references/gh-commands.md for a concise command cookbook covering repos, issues, PRs, Actions, releases, search patterns, and gh api fallbacks. Prefer gh <command> --help for exhaustive flag/field lists.
Tooling
Run a quick environment/context capture when debugging auth/repo targeting problems:
scripts/gh_context.sh
This prints gh version/auth status and tries to identify the active repo (when run inside a checkout).
Fetch a PR’s full review feedback bundle as JSON:
scripts/pr_feedback.sh -R OWNER/REPO PR_NUMBER > pr-feedback.json
Reply to review feedback:
# Inline review comment (REST)
scripts/pr_review_comment_reply.sh -R OWNER/REPO PR_NUMBER COMMENT_ID --body "..."
# Review thread (GraphQL)
scripts/pr_review_thread_reply.sh PRRT_... --body "..."
# Resolve a review thread (state change; --yes required)
scripts/pr_review_thread_resolve.sh --yes PRRT_...
# Reopen a resolved thread (state change; --yes required)
scripts/pr_review_thread_unresolve.sh --yes PRRT_...