GitHub CLI for pull requests, issues, repositories, Actions, releases, and authenticated API calls.
$brew install gh
Agent Compatibility
JSON Output
Agent Skill
MCP Support
AI Analysis
gh is GitHub's official CLI for working with repositories, pull requests, issues, releases, Actions, and search from the shell. It also includes gh api for direct REST and GraphQL calls when the built-in subcommands do not cover a workflow cleanly.
What It Enables
- Create, review, merge, check out, and inspect pull requests; create, edit, comment on, and close issues without leaving the terminal.
- Create or inspect repositories, releases, secrets, variables, projects, gists, and workflow runs, including reruns, cancellations, and artifact downloads.
- Search across GitHub and send authenticated REST or GraphQL requests with
gh apifor repo-specific automation or gaps in higher-level commands.
Agent Fit
- Repo-aware defaults and a broad noun-verb command surface make common GitHub tasks easy to compose in shell scripts and agent loops.
- Real structured output is available across many commands via
--json,--jq, and--template, andgh apican return raw API JSON when there is no dedicated subcommand. - Headless automation works best with tokens and explicit flags; browser login, confirmation prompts, and
--webor watch-style commands are less suitable for unattended runs.
Caveats
- JSON coverage is broad but not universal, so some workflows still fall back to
gh apior plain-text parsing. - Authentication needs to be set up first;
gh auth logindefaults to browser-based flow, while CI or headless usage should rely on tokens in environment variables.