| name | gh-cli |
| description | Use GitHub CLI (gh) for common operations like creating PRs, viewing GitHub Actions logs, managing issues, reviewing PRs, and more. Use this when you need to interact with GitHub repositories directly from the command line. |
| license | MIT |
GitHub CLI Operations
This skill provides quick access to common GitHub CLI operations for managing repositories, pull requests, issues, and GitHub Actions.
Requirements
gh (GitHub CLI) - must be authenticated with your GitHub account
- Run
gh auth login if not already authenticated
Common operations
Pull requests
Create a new PR:
gh pr create --title "Your PR title" --body "Description of changes"
Create a PR with auto-fill (from commit messages):
gh pr create --fill
Create a draft PR:
gh pr create --draft --title "WIP: Feature X"
Create a PR with a rich markdown body (shell-escaping workaround):
PR bodies with backticks, parentheses (), dollar signs, or other shell-special
characters fail when passed inline via --body "..." because zsh/bash
interprets them. This is the most common failure when creating PRs with code
blocks, markdown links like [text](url), or any non-trivial formatting.
Use --body-file instead — write the body to a temp file first:
cat > /tmp/pr-body.md <<'EOF'
Rich markdown with `backticks` and [links](https://example.com) here.
EOF
gh pr create --title "Title" --body-file /tmp/pr-body.md
The --body-file flag is supported by gh pr create, gh pr edit,
gh issue create, gh issue comment, and gh pr review. Use it as the
DEFAULT whenever the body is more than a simple one-liner — it avoids all
shell-escaping surprises.
List PRs:
gh pr list
gh pr list --state all
gh pr list --author @me
View a PR:
gh pr view 123
gh pr view 123 --web
Check out a PR locally:
gh pr checkout 123
Review a PR:
gh pr review 123 --approve
gh pr review 123 --request-changes --body "Please fix the typo"
gh pr review 123 --comment --body "Looks good overall"
Merge a PR:
gh pr merge 123
gh pr merge 123 --squash
gh pr merge 123 --rebase
gh pr merge 123 --auto --squash
GitHub Actions
List workflow runs:
gh run list
gh run list --workflow "CI"
gh run list --status failure
View run details:
gh run view 1234567890
View run logs:
gh run view 1234567890 --log
gh run view 1234567890 --log --job "build"
Download run logs:
gh run download 1234567890
Re-run a workflow:
gh run rerun 1234567890 --failed
gh run rerun 1234567890
Watch a running workflow:
gh run watch 1234567890
Trigger a workflow manually:
gh workflow run workflow-name.yml
Issues
Create an issue:
gh issue create --title "Bug: Something broken" --body "Description here"
List issues:
gh issue list
gh issue list --assignee @me
gh issue list --label bug
View an issue:
gh issue view 456
Comment on an issue:
gh issue comment 456 --body "Thanks for reporting this!"
Close/reopen an issue:
gh issue close 456
gh issue reopen 456
Repository operations
Clone a repository:
gh repo clone owner/repo
Create a repository:
gh repo create my-repo --public
gh repo create my-repo --private --add-readme
View repository info:
gh repo view owner/repo
Fork a repository:
gh repo fork owner/repo --clone
Set default branch:
gh repo set-default owner/repo
Status and monitoring
Check CI status:
gh pr checks
gh pr checks 123
View your notifications:
gh notify
Advanced usage
Use with specific repository:
gh pr list --repo owner/repo
Output as JSON for scripting:
gh pr list --json number,title,author,state
Use custom queries:
gh pr list --label "needs-review"
gh issue list --assignee @me --state open
Tips
Check command help: Add --help to any command to see all options:
gh pr create --help
Interactive mode: Many commands support interactive prompts when you don't provide required flags:
gh pr create
Aliases: Create custom aliases for frequently used commands:
gh alias set prc 'pr create --fill'
Default repository: Run gh repo set-default in a repo to avoid specifying --repo flag.
Common workflows
Creating a PR from current branch:
git push -u origin feature-branch
gh pr create --fill
Checking why a PR failed:
gh pr checks 123
gh run view <run-id> --log
Quick PR review workflow:
gh pr list
gh pr view 123
gh pr checkout 123
gh pr review 123 --approve
Monitoring a deployment:
gh run list --workflow "Deploy"
gh run watch <latest-run-id>