--- name: github-cli description: Apply when using the gh CLI to manage pull requests, issues, releases, or CI workflows on GitHub. license: MIT version: 1.0.0 tokens_target: 1200 triggers: - gh cli - github pr create - github issues loads_after: [git-conventions] supersedes: [] --- # Sub-Skill: GitHub CLI (`gh`) Conventions **Purpose:** Consistent, auditable use of the `gh` CLI for PRs, issues, releases, and CI — preventing gate bypasses and silent failures. --- ## Rules ### Authentication & Scopes 1. **Check auth scope before scripting.** Before running `gh` in CI or scripts, always verify the required scopes are granted with `gh auth status`; missing scopes produce silent 404s rather than auth errors. 2. **Use token env var in CI.** Always pass `GH_TOKEN` (or `GITHUB_TOKEN`) via environment variable in CI pipelines; never hard-code tokens or use `gh auth login --with-token` interactively in automated contexts. ### Pull Requests 3. **Include all required labels on PR creation.** Always pass `--label` for every gate-required label when running `gh pr create`; omitting a label silently bypasses automated approval gates. Reference: ERR-2026-023 4. **Set reviewer on creation.** Always use `--reviewer ` when creating PRs that require CODEOWNERS approval; adding reviewers after creation delays the review clock. 5. **Open as draft when work is incomplete.** Use `gh pr create --draft` for PRs not yet ready for review; never open a ready-for-review PR on a branch with failing CI. 6. **Link issues explicitly.** Always include `--body "Closes #"` or `--body "Fixes #"` so GitHub auto-closes the linked issue on merge; never rely on branch name alone for issue linkage. ### Issues 7. **Assign and label on creation.** Use `gh issue create --assignee @me --label