gh-cli

A rule requiring all GitHub work to use the gh command-line tool. GitHub is a service for hosting code, issues, pull requests, releases, and automated workflows.

In plain words
What is it for?
Use it when creating or reviewing pull requests, managing issues and releases, checking automated workflow runs, calling the GitHub API, or working across repositories.
Why use it?
It gives GitHub tasks one consistent command-line workflow instead of mixing tools or using the website directly.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/cdbattags/ai/gh-cli
Clone the repo
git clone --depth 1 https://github.com/cdbattags/ai
Per session 559 This file is loaded in full into every session.
When invoked 559 The same file — it is already loaded in full.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00559 $0.00559
Opus 5 $0.00280 $0.00280
Sonnet 5 $0.00112 $0.00112
Haiku 4.5 $0.00056 $0.00056

Measured yesterday against content hash 21d4c5e75d39, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

gh-cli scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

Use `gh` instead of raw `curl`/API calls or the GitHub web UI for all GitHub operations.
src/rules/gh-cli.mdc · 56 lines

What it actually says

GitHub CLI (gh)

Use gh instead of raw curl/API calls or the GitHub web UI for all GitHub operations.

Sandbox Permissions

gh commands require network access. Always use required_permissions: ["full_network"] in Shell tool calls.

Key Commands

Task Command
Create PR gh pr create --title "..." --body "..."
View PR gh pr view <number>
List PRs gh pr list
PR checks gh pr checks <number>
Merge PR gh pr merge <number>
Create issue gh issue create --title "..." --body "..."
List issues gh issue list
Workflow runs gh run list, gh run view <id>
Releases gh release create <tag>, gh release list
Arbitrary API gh api <endpoint>
Cross-repo Add -R OWNER/REPO to any command

Read vs Write Operations

Read-only commands do not require user approval — just run them. These include any command that only fetches or displays data:

  • gh pr list, gh pr view, gh pr checks, gh pr diff
  • gh issue list, gh issue view
  • gh run list, gh run view
  • gh release list, gh release view
  • gh search issues/prs/code/repos
  • gh api GET requests (the default method)

Write commands do require explicit user approval before executing:

  • gh pr create, gh pr merge, gh pr review, gh pr close
  • gh issue create, gh issue close, gh issue comment
  • gh run rerun
  • gh release create, gh release upload, gh release delete
  • gh api with -X POST, -X PATCH, -X PUT, -X DELETE, or -f/--input

Conventions

  • Pass long bodies via HEREDOC: --body "$(cat <<'EOF' ... EOF)"
  • Use --jq or --template to extract specific fields from output
  • Use gh api with {owner} and {repo} placeholders for the current repo
  • For detailed patterns and examples, read the gh-cli skill
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 56 lines · 559 tokens per session scan A 21d4c5e75d39

Subscribe to this mod's changes

gh-cli is a cursor rule published in the GitHub repository cdbattags/ai (4 stars, last pushed 6mo ago), licensed MIT. It adds 559 tokens to every session, about $0.0028 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.