Directory Compare FCRS-1.0 /llms.txt
← Back to Directory

GitHub CLI

$ gh Official Med Risk
GitHub · Code & DevOps · MIT · macos / linux / windows

GitHub's official command-line interface exposes pull requests, issues, Actions runs, releases, and raw REST/GraphQL endpoints. Native --json field selection and built-in --jq querying let agents fetch exact payloads without burning context tokens.

FCRS-1.0 Score
94 /100
Excellent
Medium Confidence
Zero-Friction Install
brew install gh
CLI vs MCP Decision CLI Preferred vs MCP

Prefer gh over GitHub MCP for coding agents: --json <fields> + --jq cuts token usage dramatically and avoids loading 30+ MCP tool schemas upfront.

Agent-Readiness Checklist

✓ JSON Output
✓ Field Filtering
✓ Non-Interactive
— Dry-Run
— Read-Only Mode
✓ NO_COLOR Clean
✓ Self-Describing
— Official SKILL.md

Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.

FCRS-1.0 6-Dimension Breakdown

Agent-Readiness 24 / 25

Native --json field whitelist, embedded --jq processor, GH_PROMPT_DISABLED=1 headless mode, and clear non-zero exit codes make gh a benchmark for agent-friendly CLIs.

  • Supports --json <fields> and --jq across core subcommands
  • Supports GH_PROMPT_DISABLED=1 and NO_COLOR=1 for non-TTY execution
Trust & Safety 21 / 25

Strong credential isolation via OS keychain and fine-grained GH_TOKEN scoping, though destructive commands (repo delete, pr merge) have no global --dry-run flag.

  • OS keychain / scoped GH_TOKEN support
  • Lacks universal --dry-run on remote write subcommands
Setup & Portability 15 / 15

Single static Go binary available across Homebrew, apt, winget, and official GitHub releases on macOS, Linux, and Windows.

  • Fast single binary startup with zero language runtime dependencies
Utility & Efficiency 15 / 15

Covers daily GitHub workflows plus gh api escape hatch, consistently outperforming GitHub MCP servers on token efficiency.

  • Covers PRs, issues, Actions, releases, and raw gh api REST/GraphQL
Maintenance & Lineage 10 / 10

First-party official tool maintained by GitHub (cli/cli) with frequent releases and MIT license.

  • Official cli/cli repository under MIT license
Docs & Verifiability 9 / 10

Comprehensive manual and predictable --help hierarchy across all subcommands.

  • Structured CLI manual at cli.github.com/manual

Security, Auth & Guardrails

Auth Modes
OAuth Browser Env API Key OS Keychain
Credential Storage

Stores OAuth tokens in the OS keychain by default (or ~/.config/gh/hosts.yml), and supports scoped GH_TOKEN / GITHUB_TOKEN env vars.

Side Effects
Read-Only Local Write Remote Write Destructive
Cost & Quotas

CLI is MIT open-source and free; GitHub API rate limits apply (5,000 req/hr authenticated).

Copyable Guardrail for CLAUDE.md / AGENTS.md
# GitHub CLI (gh) Agent Rules
- Always pass `--json <fields>` when reading issues, PRs, or runs.
- Never run `gh pr merge`, `gh repo delete`, or `gh release delete` without explicit user confirmation.
- Use `GH_PROMPT_DISABLED=1` and pass all flags (`--title`, `--body`) explicitly.

Agent-Ready Command Recipes

Safe Read-Only Queries

List open PRs with minimal JSON fields
gh pr list --state open --json number,title,author,headRefName --limit 20

Returns compact structured JSON without terminal tables or wasted tokens.

Inspect failed CI run logs
gh run view <run-id> --log-failed

Streams only the failing step logs so the agent can diagnose CI failures directly.

Controlled Writes & Previews

Create a draft PR non-interactively
gh pr create --draft --title "feat: update pipeline" --body-file pr.md

Explicit --title and --body-file prevent interactive TTY prompts; --draft reduces merge risk.

Strengths for Agents

  • + Built-in --json <fields> + --jq eliminates brittle stdout scraping and saves context tokens.
  • + Supports GH_TOKEN fine-grained PATs and GH_PROMPT_DISABLED=1 for CI/agent sandboxes.
  • + gh api provides full fallback access to any GitHub REST or GraphQL endpoint.

Caveats & Pitfalls

  • ! No global --dry-run flag on mutation commands like gh pr merge or gh issue close.
  • ! Omitting explicit --title/--body flags can trigger interactive prompts unless GH_PROMPT_DISABLED=1 is set.

Tested Agent Hosts

Claude Code Codex CLI Gemini CLI