| name | github-cli |
| description | GitHub CLI (gh) integration for managing issues, pull requests, branches, commits, and code reviews directly from the terminal. Use when Claude needs to create, list, view, or update GitHub issues; create draft branches and pull requests; make commits and push changes; review pull request diffs and changes; approve or merge PRs; manage GitHub Actions workflows; or work with GitHub repositories without switching to a browser. Requires gh CLI installed and authenticated.
|
GitHub CLI (gh) Skill
Use the gh CLI to interact with GitHub repositories, issues, pull requests, and Actions workflows from the terminal.
Prerequisites
Verify gh is installed and authenticated:
gh --version
gh auth status
If not authenticated, run gh auth login and follow prompts.
Core Workflows
Issue Management
gh issue list
gh issue list --state all
gh issue list --assignee @me
gh issue list --label "bug"
gh issue create -t "Title" -b "Description"
gh issue create -t "Title" --label "bug" --milestone "milestone-1"
gh issue create
gh issue view 123
gh issue view 123 --web
gh issue edit 123 --add-label "in-progress"
gh issue close 123
gh issue reopen 123
gh issue comment 123 -b "Working on this now"
Branch & Commit Workflow
git checkout -b feature/my-feature
git checkout -b fix/issue-123
git checkout -b draft/wip-experiment
git add .
git commit -m "feat: add new feature"
git commit -m "fix: resolve issue #123"
git push -u origin feature/my-feature
Pull Request Management
gh pr create
gh pr create --fill
gh pr create --draft
gh pr create --draft --fill
gh pr create -t "Title" -b "Description" --base main
gh pr create --label "review-needed" --assignee @me
gh pr list
gh pr list --assignee @me
gh pr list --reviewer @me
gh pr list --draft
gh pr view 45
gh pr view 45 --web
Code Review Workflow
gh pr checkout 45
gh pr diff 45
gh pr diff
gh pr review 45 --comment -b "LGTM, minor suggestion on line 42"
gh pr review --comment -b "Please add tests"
gh pr review 45 --approve
gh pr merge 45
gh pr merge 45 --squash
gh pr merge 45 --rebase
gh pr merge 45 --auto
Update Existing PR
gh pr edit 45 --title "New title"
gh pr edit 45 --body "Updated description"
gh pr edit 45 --base develop
gh pr edit 45 --add-label "ready-for-review"
gh pr ready 45
GitHub Actions Workflow Management
gh run list
gh run list --status failure
gh run view
gh run view 12345
gh workflow run ci.yml
gh workflow run ci.yml --ref feature/x
gh run rerun 12345
gh run rerun 12345 --failed-only
gh run watch 12345
gh run view 12345 --log
gh run list --branch main
Common Flag Reference
| Flag | Description |
|---|
-R, --repo OWNER/REPO | Target different repository |
--base | Base branch for PR |
--head | Head branch for PR |
-t, --title | Title for issue/PR |
-b, --body | Body for issue/PR |
-l, --label | Labels (comma-separated) |
-a, --assignee | Assignee username |
-m, --milestone | Milestone name |
--draft | Create as draft PR |
--fill | Auto-fill from commit messages |
--web | Open in browser |
-y, --yes | Skip confirmation prompts |
Environment Variables
export GH_TOKEN="ghp_xxxx"
export GH_HOST="github.example.com"
export GH_REPO="owner/repo"
Tips & Gotchas
Multi-line Descriptions with Markdown
When creating issues or PRs with long descriptions containing markdown (code blocks, backticks), avoid heredocs which can fail due to shell interpretation. Instead:
gh issue create -t "Title" -b "$(cat temp_description.txt)"
rm temp_description.txt
This avoids issues with:
- Backticks in code blocks conflicting with command substitution
- Special characters being interpreted by the shell
- Heredoc delimiter conflicts
Sourcing Description from Existing Files
To create an issue or PR from a markdown plan file:
gh issue create -t "Title" -b "$(cat docs/plans/my-plan.md)"
gh pr create -t "Title" -b "$(cat docs/plans/my-plan.md)"
Detailed Reference
For comprehensive command options and examples, see references/commands.md.