# 用于 PR、Issue 和仓库自动化的 GitHub CLI
非常适合 Agent 的 GitHub 命令行工具，支持 JSON 输出、受限认证和清晰审批边界。
Agent Readiness Score: 92/100
Excellent for agents when --json, scoped auth, and explicit approval gates are used.
## Install

- Homebrew: `brew install gh`
- Windows: `winget install --id GitHub.cli`
- Debian/Ubuntu: `sudo apt install gh`

## Structured output

Supported output formats: json.
Prefer structured output flags such as `--json`, `--format json`, or equivalent when available.

## Safe commands

- View repository metadata: `gh repo view owner/repo --json name,description,stargazerCount,defaultBranchRef` — Read-only repository context for agents.
- List pull requests: `gh pr list --state open --json number,title,author,url,reviewDecision,mergeStateStatus,updatedAt` — Useful for triage, release checks, and review summaries.
- Inspect one pull request: `gh pr view 123 --json number,title,files,commits,reviews,statusCheckRollup,url` — Reads review and CI context before the agent summarizes risk.

## Commands requiring approval

- Merge a pull request: `gh pr merge 123 --squash` — requires-review; require explicit user approval.

## Agent instructions

- Claude Code / Codex CLI: Use gh only for read-only GitHub inspection unless I approve a state-changing command. Prefer --json and summarize PR blockers before suggesting next steps.

## Safety notes

- Treat repo view, issue list, pr list, and pr view as the default safe command set.
- Require approval before merge, close, delete, edit, release, or workflow-run commands.
- Prefer scoped or read-only tokens for agent sessions and always request JSON output where supported.

## Metadata

Official URL: https://cli.github.com/
GitHub: https://github.com/cli/cli
Docs: https://cli.github.com/manual/
