| name | github |
| description | Comprehensive GitHub operations using the gh CLI tool. Supports pull requests, issues, workflows/actions, releases, repositories, gists, and local git operations with deterministic porcelain output. Use when working with GitHub PRs, issues, actions, releases, repos, or agentic git workflows. Triggers: gh, GitHub, pull request, PR, issue, workflow, actions, release, gist, git status, git diff, git log.
|
| allowed-tools | Bash Read |
GitHub Operations with gh CLI
You are an expert in GitHub operations using the gh CLI tool. You help users manage
pull requests, issues, workflows, repositories, releases, and other GitHub resources.
Core Capabilities
Pull Request Management
gh pr list
gh pr list --state closed
gh pr list --author @me
gh pr list --assignee @me
gh pr list --label bug
gh pr list --limit 100
gh pr list --search "is:open is:pr"
gh pr view 123
gh pr view
gh pr view --json title,body,author
gh pr view --web
gh pr create --title "Fix bug" --body "Description" --base main
gh pr create --draft
gh pr create --assignee @me --label "enhancement"
gh pr create --reviewer user1,user2
gh pr checkout 123
gh pr edit 123 --title "New title"
gh pr edit 123 --add-label "bug" --remove-label "help wanted"
gh pr comment 123 --body "LGTM!"
gh pr review 123 --approve
gh pr review 123 --request-changes
gh pr review 123 --comment -F file.md
gh pr merge 123 --merge
gh pr merge 123 --squash
gh pr merge 123 --rebase
gh pr merge 123 --delete-branch
gh pr close 123
gh pr reopen 123
gh pr diff 123
gh pr diff 123 --color=never
Issue Management
gh issue list
gh issue list --state all
gh issue list --author @me
gh issue list --assignee @me
gh issue list --label "bug,urgent"
gh issue list --limit 50
gh issue view 456
gh issue view --json title,body,comments,labels
gh issue view --web
gh issue create --title "Bug found" --body "Steps to reproduce"
gh issue create --label "bug,high-priority"
gh issue create --assignee @me
gh issue edit 456 --title "Updated title"
gh issue edit 456 --add-label "confirmed" --remove-label "needs-triage"
gh issue comment 456 --body "Working on this"
gh issue close 456
gh issue reopen 456
gh issue transfer 456 owner/repo
GitHub Actions & Workflows
gh run list
gh run list --limit 50
gh run list --workflow=ci.yml
gh run list --branch main
gh run view 456
gh run view --log
gh run view --log-failed
gh run view --web
gh run watch 456
gh run watch 456 --interval 2
gh run rerun 456
gh run rerun 456 --failed
gh workflow list
gh workflow view ci.yml
gh workflow view ci.yml --web
gh workflow view ci.yml --yaml
gh workflow run ci.yml --raw-field delay=10
gh workflow run deploy.yml --ref main
gh run view 456 --log-failed --json artifacts
Repository Management
gh repo view
gh repo view owner/repo
gh repo view --json name,description,stars,forks
gh repo create my-new-repo
gh repo create my-repo --public
gh repo create my-repo --source .
gh repo create my-repo --clone
gh repo clone owner/repo
gh repo clone owner/repo my-dir
gh repo fork owner/repo
gh repo fork owner/repo --clone
gh repo view --web
gh repo settings
gh repo delete owner/repo
Release Management
gh release list
gh release view v1.0.0
gh release view latest
gh release view --web
gh release create v1.0.0 --notes "Release notes"
gh release create v1.0.0 --title "Version 1.0.0"
gh release create v1.0.0 --notes-from-tag
gh release create v1.0.0 --draft
gh release delete v1.0.0
gh release upload v1.0.0 ./file.tar.gz
Gist Management
gh gist list
gh gist list --public
gh gist view abc123
gh gist view --web
gh gist create file.py
gh gist create file.py --desc "My gist"
gh gist create file.py --public
gh gist edit abc123 --desc "Updated description"
gh gist delete abc123
Git Operations via GitHub
gh status
gh api /repos/owner/repo/commits
gh commit list
gh repo sync
gh api /repos/owner/repo/branches
Authentication & Configuration
gh auth status
gh auth login
gh auth login --with-token < token.txt
gh auth logout
gh auth token
gh auth refresh
gh config set editor vim
gh config set git_protocol ssh
gh config set prompt disabled
Local Git CLI Patterns
Use stable Git output formats when local repository state matters alongside GitHub operations.
git status --porcelain=v2 --branch
git status --short --branch
git diff --numstat
git diff --cached --numstat
git diff --name-status
git log --format='%h %s' -n 10
git log --format='%H|%an|%ae|%s' -n 10
git branch -vv
git branch --show-current
git remote -v
git add path/to/file
git add -A
git restore --staged path/to/file
git restore path/to/file
Prefer:
git status --porcelain=v2 --branch for machine-readable status
git diff --numstat when counting or summarizing changes
git log --format=... when extracting specific commit fields
git restore over checkout-based discard flows
Git Worktrees and Parallel Exploration
git worktree add ../explorations/feature-check -b explore/feature-check
git worktree list
git worktree remove ../explorations/feature-check
Combining Git and gh
gh repo view --json nameWithOwner --jq '.nameWithOwner'
gh pr view --json headRefName --jq '.headRefName'
git push origin HEAD:$(gh pr view --json headRefName --jq '.headRefName')
Search & Discovery
gh search repos
gh search repos --language python
gh search repos --stars >1000
gh search repos "topic:ai"
gh search prs --state open
gh search issues --label "bug"
gh search code lambda
Advanced Operations
gh api /user
gh api /repos/owner/repo/issues
gh api /repos/owner/repo/issues -f title='New issue' -f body='Description'
gh pr view --json title,number,author | jq '.title'
gh repo set-default owner/repo
gh repo create my-repo --template owner/template-repo
Best Practices
- Always check status first: Use
gh auth status and gh repo view to verify setup
- Use flags for automation:
--json output for parsing, --quiet to suppress prompts
- Web integration: Use
--web flag to open items in browser for visual review
- Workflows: Use
gh run watch to monitor CI/CD execution in real-time
- Bulk operations: Use shell loops with gh for batch operations
- Error handling: Check exit codes
echo $? after gh commands
Common Workflows
Implement and Create PR (From Main Branch)
When user asks to implement something and create a PR, you MUST detect if on main/master branch and follow proper workflow:
CURRENT_BRANCH=$(git branch --show-current)
if [ "$CURRENT_BRANCH" = "main" ] || [ "$CURRENT_BRANCH" = "master" ]; then
BRANCH_NAME="feature/$(echo 'feature description' | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g' | sed 's/-\+/-/g' | sed 's/^-\|-$//g')"
git checkout -b "$BRANCH_NAME"
fi
git add .
git commit -m "feat: descriptive commit message"
git push -u origin "$BRANCH_NAME"
gh pr create --title "Feature title" --body "Feature description"
Important: Always check current branch before implementing. Never commit directly to main/master when creating a PR.
PR Management Workflow
git commit -am "Add new feature"
git push origin feature/new-feature
gh pr create --title "Add new feature" --body "Implements #123"
CI/CD Monitoring
gh run watch --interval 1
gh run view --log-failed
gh run rerun --failed
Issue Triage
gh issue list --label "needs-triage" --assignee @me
gh issue create --title "Bug: X fails" --body "..."
gh pr create --body "Closes #123"
Agentic Patterns (JSON Output)
For AI agent consumption, always use --json <fields> for machine-readable output. The --jq filter is built-in.
gh pr checks $PR_NUMBER --json name,state,conclusion,detailsUrl
gh pr checks $PR_NUMBER --json name,state,conclusion --jq '.[] | select(.conclusion == "FAILURE")'
gh pr view $PR_NUMBER --json title,state,mergeable,reviewDecision,statusCheckRollup
gh issue list --json number,title,state,labels --jq '.[].number'
Notes
gh respects your current Git repository context
- Use
--help with any command for detailed options
- GitHub token can be set via
GH_TOKEN environment variable
- For enterprise GitHub, use
gh auth login --hostname enterprise.com