# GitHub CLI
<!--
ref: @integrations/gh
tags: [GitHub, CLI, development, automation]
triggers: [create pull request, list issues, clone repository, trigger workflow]
trigger_prompt: When you need to perform GitHub operations like managing pull requests, issues, or repositories without using the web interface.
category: integration
last_reviewed: 2026-04-30
complements: [@integrations/curly, @integrations/notion, @protocol/agent-config-integration]
audience: [claude-code-user, agent-author, terminal-only]
version: 6
updated_at: 2026-07-14T20:44:22.506Z
-->

Manage GitHub repositories, issues, and pull requests directly from the command line.

## When to Use
- **PRs**: Create, review, merge pull requests
- **Issues**: Create, list, comment on issues
- **Repos**: Clone, fork, view, manage repos
- **Actions**: View workflow runs, trigger workflows

## Cheat Sheet

### Pull Requests
| Op | Command | Notes |
|----|---------|-------|
| Create | `gh pr create -t "title" -b "body"` | From current branch |
| List | `gh pr list` | Open PRs |
| View | `gh pr view [number]` | Details + diff |
| Checkout | `gh pr checkout <number>` | Switch to PR branch |
| Merge | `gh pr merge <number>` | Merge PR |
| Review | `gh pr review <number> --approve` | Or `--comment`, `--request-changes` |

### Issues
| Op | Command | Notes |
|----|---------|-------|
| Create | `gh issue create -t "title" -b "body"` | New issue |
| List | `gh issue list` | Open issues |
| View | `gh issue view <number>` | Details |
| Close | `gh issue close <number>` | Close issue |
| Comment | `gh issue comment <number> -b "text"` | Add comment |

### Repos
| Op | Command | Notes |
|----|---------|-------|
| Clone | `gh repo clone owner/repo` | Clone repo |
| Fork | `gh repo fork owner/repo` | Fork to your account |
| View | `gh repo view owner/repo` | Repo info |
| Create | `gh repo create name --public` | New repo |

### Actions
| Op | Command | Notes |
|----|---------|-------|
| List runs | `gh run list` | Recent workflow runs |
| View run | `gh run view <run_id>` | Run details |
| Watch | `gh run watch <run_id>` | Live output |
| Rerun | `gh run rerun <run_id>` | Retry failed run |

### API (raw)
| Op | Command | Notes |
|----|---------|-------|
| GET | `gh api repos/owner/repo` | Any API endpoint |
| POST | `gh api repos/o/r/issues -f title=x` | Create via API |
| GraphQL | `gh api graphql -f query='...'` | GraphQL queries |

## Auth
```
gh auth login
# GH
GH_TOKEN=ghp_xxx
```

## Patterns

### Create PR from current branch
```bash
gh pr create --fill  # Uses commit messages for title/body
```

### Review and merge
```bash
gh pr checkout 123
# review code...
gh pr review 123 --approve
gh pr merge 123 --squash --delete-branch
```

### Find and comment on issue
```bash
gh issue list --label "bug"
gh issue comment 456 -b "Looking into this"
```

### Trigger workflow
```bash
gh workflow run deploy.yml -f environment=staging
gh run watch  # Watch the run
```

## Docs
Full reference: `gh help` or `gh <command> --help`
Manual: `_gh/_full-reference.md`

---

*Related: `@protocol/protocol-api` · `@content/youtube/liam-ottley/the-end-is-near-for-claude-code-ai-operating-systems` · `@content/youtube/dan-martell/it-s-actually-pretty-easy-to-get-ahead-of-99-of-people-with-ai` · `@content/youtube/dan-martell/i-tested-500-ai-tools-these-will-make-you-rich` · `@content/youtube/tiago-forte/build-a-business-that-runs-itself-5-stages-of-ai-integration`*

---

*You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).*

*Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*