Skip to content

SYSTEM Cited by 1 source

GitHub CLI (gh)

gh is GitHub's official command-line interface for interacting with repositories, issues, pull requests, releases, actions, and almost every other GitHub surface that also exists in the web UI / REST API / GraphQL API.

Role on this wiki

gh shows up on the wiki primarily as an agent-ergonomic CLI surface for reaching GitHub — the same shape as flyctl, kubectl, aws, gcloud, wrangler, etc. The common property: a CLI that already exists for human operators is trivially useful to an LLM agent when the agent shares the operator's shell + auth context. See concepts/agent-ergonomic-cli and patterns/wrap-cli-as-mcp-server.

Concrete production instance in the wiki corpus: Phoenix.new pre-installs gh in every per-session VM (2025-06-20). "Github's gh CLI is installed by default. So the agent knows how to clone any repo, or browse issues, and you can even authorize it for internal repositories to get it working with your team's existing projects and dependencies." This is what makes the patterns/agentic-pr-triage pattern (agent picks issues from a tracker, opens PRs) executable — the agent doesn't need a GitHub-specific tool schema; it can run gh issue list, gh issue view, gh pr create, etc., directly.

Surface areas agents commonly use

  • Repository: gh repo clone, gh repo fork.
  • Issues: gh issue list, gh issue view <n>, gh issue create.
  • Pull requests: gh pr create, gh pr checkout <n>, gh pr view, gh pr review, gh pr merge.
  • Authentication: gh auth login / gh auth status for scoping.
  • Org / enterprise: works equally against github.com, GHEC, and self-hosted GHES.

Caveats

  • Auth scoping for agent use is the load-bearing security concern: a broad repo scope gives the agent write access to every repo the operator can touch. Per-repo fine-grained personal-access tokens, GitHub-App installation tokens, or short-lived OIDC federation are safer postures; the 2025-06-20 post doesn't disclose how Phoenix.new scopes gh.
  • gh output is human-friendly by default; structured agent consumption wants --json flags (present on many subcommands) or the sibling gh api direct-query path — same producer-side structured-output consideration as concepts/structured-output-reliability.

Seen in

Last updated · 200 distilled / 1,178 read