gh
CLI>=2.0GitHub's official CLI for managing repos, PRs, issues, and more.
GitHub CLI for PRs, issues, repos, and Actions from the terminal
Verified commands
Executed by our harness on the platforms shown; the assertion checked the actual result, not just the exit code.
List open pull requests as JSON
gh pr list --repo OWNER/REPO --state open --limit 5 --json number,titleCommon failures (1)
- fatal: not a git repositoryoutside a checkout gh cannot infer the repo: pass --repo OWNER/REPO
List open issues as JSON
gh issue list --repo OWNER/REPO --state open --limit 5 --json number,titleShow recent CI runs
gh run list --repo OWNER/REPO --limit 3 --json status,conclusion,nameGet the conclusion of the latest CI run
gh run list --repo OWNER/REPO --limit 1 --json databaseId --jq '.[0].databaseId' | xargs -I{} gh run view {} --repo OWNER/REPO --json conclusionRead one field from the GitHub API
gh api repos/OWNER/REPO --jq .default_branchInspect a pull request
gh pr view 42 --repo OWNER/REPO --json state,titleMore recipes
Curated from documentation and usage. Percentages are estimates, not measurements.
Create a pull request with a multi-line body
gh pr create --title 'feat: add feature' --body-file pr.mdCommon failures (1)
- body shows literal \nwrite the body to a file and pass --body-file instead of --body
Watch the current CI run until it finishes
gh run watch --exit-statusClone a repo
gh repo clone owner/repoInstall
Homebrew
brew install ghAgent notes
- When to use
- Managing GitHub workflows without the browser
- Quick examples
gh pr creategh issue list --label buggh run watch
Use from an agent
curl -s https://clihub.com/api/tools/gh | jq '.agentHints.provenRecipes[] | {task, command, verified}'Or call get_tool with slug gh on the MCP server at https://clihub.com/mcp.