GitHub CLI
Use when a task names gh, GitHub CLI, a GitHub remote surface, or stacked pull requests. Route to the smallest owning reference.
Preflight live operations
- Run
gh --versionbefore relying on installed capabilities. - Establish the target with explicit
[HOST/]OWNER/REPOfor--repo, or verify the local repository and remote. NEVER guess from the current directory. - Check
gh auth statusfor the selected host. UseGH_HOSTorGH_REPOonly when values are known, safe, and intentional. Usegh help <command>for missing flags or version differences. - Separate read stdout from stderr. Prefer
--json <fields>, then--jqor--template; discover fields with the command's bare--jsonform.
Safety gates
- Treat
--web,browse, browser/editor/pager launches, prompts, and TUI commands as interactive side effects. Prefer noninteractive flags and state user actions. - Require explicit user authorization immediately before external writes to issues, pull requests, projects, repositories, secrets, variables, releases, API mutations, pushes, merges, extension installs, or account changes.
- NEVER print, persist, or echo tokens, credentials, key material, or auth headers.
- After every authorized write, re-read the resulting resource and report failures.
- Route
gh apithroughreferences/api.md. Parameters can change its default GET to POST; make method and mutation intent explicit. - Treat documented exit codes and command-specific failures as evidence. After failure, do not retry destructively, force, prune, merge, or fall back silently.
Route by intent; required follow-up
Read the listed reference whenever its trigger applies. Use references/core.md before any command family when router rules are insufficient.
- Shared invocation, hosts, auth, aliases, config, completion, output, prompts, exits →
references/core.md. - Repository discovery, cloning, browsing, search, gists, organizations, or Codespaces →
references/repositories.md; keep local Git/worktree actions local. - Issues, pull requests, discussions, projects, reviews, or labels →
references/collaboration.md; ordinary contribution policy →gh-contrib. - Actions, workflows, caches, secrets, or variables →
references/automation.md; keep account and repository writes gated. - Releases, artifact attestations, rulesets, keys, or licenses →
references/release-security.md; preserve key and permission boundaries. - REST, GraphQL, pagination, previews, or custom endpoints; any
gh apisurface →references/api.md; usegh apionly with explicit target and method. - Extensions, agent tasks, skills, Copilot, or preview-only tooling →
references/agent-platform.md; check installed capability before invoking. - Planning a dependent-PR chain or deciding whether work belongs in one stack →
references/stack-design.mdfor invariants, layer design, and ownership. - Publishing a branch, creating a PR, or linking a PR to a stack →
references/stacked-pr-workflow.mdfor the branch/PR-to-stack handoff. - Executing or planning
gh stack, or stack-aware integration →references/stack-commands.mdfor commands, capability gates, merge/API semantics, and CI state. - Stack failure, partial landing, divergence, lock, interop, or recovery →
references/stack-troubleshooting.md; preserve state and NEVER auto-repair.
Stacked PR boundary
For explicit stack intent, read all three stack references (references/stack-design.md, references/stacked-pr-workflow.md, and references/stack-commands.md) before branch or PR mutation. If the focused github/gh-stack agent skill is installed and active, defer to it; otherwise use local references. Check gh extension list and gh skill list; NEVER auto-install either. Missing capability, 404, or stack exit 9 means availability/rollout failure, not permission to silently use ordinary PR commands.
Ownership: git-worktrees owns worktree lifecycle; commit owns staging and history; gh-contrib owns contribution policy and ordinary PR review; hunk owns Hunk sessions; go/do own delegation. This skill owns GitHub CLI routing and stack-specific remote state only.