agentleFS
sordi-aisordi-ai/skill-everything/.cursor/rules/github-cli.mdc

skill-everything / rules

Cursor rule20 starsChanged 7 months agoMITView on GitHub

Apply when using the gh CLI to manage pull requests, issues, releases, or CI workflows on GitHub.

  • Reads credentials
  • Commits and pushes

The file

Show its rules and text

We split this github-cli.mdc into the rules it gives an agent

13 rules. About 0 are common, 0 are distinctive, and 13 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 13

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Check auth scope before scripting: Before running gh in CI or scripts, always verify the required scopes are granted with gh auth status.

    line 16
  2. Very specific:

    Use token env var in CI: Always pass GH_TOKEN (or GITHUB_TOKEN) via environment variable in CI pipelines.

    line 17
  3. Very specific:

    Include all required labels on PR creation: Always pass --label for every gate-required label when running gh pr create.

    line 21
  4. Very specific:

    Set reviewer on creation: Always use --reviewer <handle> when creating PRs that require CODEOWNERS approval.

    line 22
  5. Very specific:

    Open as draft when work is incomplete: Use gh pr create --draft for PRs not yet ready for review.

    line 23
  6. Very specific:

    Link issues explicitly: Always include --body "Closes #<issue>" or --body "Fixes #<issue>" so GitHub auto-closes the linked issue on merge.

    line 24
  7. Very specific:

    Assign and label on creation: Use gh issue create --assignee @me --label <label> rather than creating bare issues and editing them in a …

    line 28
  8. Very specific:

    Use JSON output for scripting: Prefer gh issue list --json number,title,labels over parsing human-readable output.

    line 29
  9. Very specific:

    Trigger runs explicitly when needed: Use gh workflow run <workflow.yml> --ref <branch> to trigger a workflow rather than pushing an empty …

    line 33
  10. Very specific:

    Watch run status in scripts: After triggering a workflow, use gh run watch <run-id> or poll gh run view <run-id> --json conclusion rather …

    line 34
  11. Very specific:

    Create releases from tags, not branches: Always run gh release create <tag> --generate-notes after pushing the tag.

    line 38
  12. Very specific:

    Use gh api for endpoints not covered by subcommands: Prefer gh api repos/{owner}/{repo}/pulls --jq '.[].number' over raw curl with manual …

    line 39
  13. Very specific:

    Define aliases for repeated commands: Use gh alias set to capture long flag combinations used more than twice in a project.

    line 40

≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
github-cli.mdc
---
description: Apply when using the gh CLI to manage pull requests, issues, releases, or CI workflows on GitHub.
alwaysApply: false
---

# 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 <handle>` 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 #<issue>"` or `--body "Fixes #<issue>"` 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 <label>` rather than creating bare issues and editing them in a second step; unassigned, unlabelled issues fall out of triage queues.
8. **Use JSON output for scripting.** Prefer `gh issue list --json number,title,labels` over parsing human-readable output; the `--json` flag is stable across `gh` versions, plain text is not.

### CI / Workflows

9. **Trigger runs explicitly when needed.** Use `gh workflow run <workflow.yml> --ref <branch>` to trigger a workflow rather than pushing an empty commit; empty commits pollute history.
10. **Watch run status in scripts.** After triggering a workflow, use `gh run watch <run-id>` or poll `gh run view <run-id> --json conclusion` rather than sleeping for a fixed duration.

### Releases & API

11. **Create releases from tags, not branches.** Always run `gh release create <tag> --generate-notes` after pushing the tag; never target a branch directly, as branch-based releases produce non-reproducible artifacts.
12. **Use `gh api` for endpoints not covered by subcommands.** Prefer `gh api repos/{owner}/{repo}/pulls --jq '.[].number'` over raw `curl` with manual auth headers; `gh api` inherits the active auth context automatically.
13. **Define aliases for repeated commands.** Use `gh alias set` to capture long flag combinations used more than twice in a project; aliases are stored in `~/.config/gh/config.yml` and are portable across machines via dotfiles.

---

## See also

- `skills/git-conventions/SKILL.md`
- `skills/error-log/SKILL.md`

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.