github
Use gh CLI for all GitHub operations - issues, PRs, file content, and repository info
When & Why to Use This Skill
This Claude skill enables seamless integration with GitHub by leveraging the official gh CLI. It empowers the agent to perform comprehensive repository operations, including managing issues, pull requests, and CI/CD workflows, as well as retrieving file contents and repository metadata directly within the development environment.
Use Cases
- Automated Code Review: Fetching pull request diffs, file changes, and comments to analyze code quality and provide constructive feedback.
- Issue Lifecycle Management: Searching, viewing, and updating GitHub issues to streamline bug tracking and feature request management.
- CI/CD Pipeline Monitoring: Checking the status of GitHub Actions runs and retrieving logs to diagnose and resolve build or deployment failures.
- Repository Exploration and Context Retrieval: Accessing specific file contents and repository structures to help the agent understand the codebase and provide more accurate coding assistance.
- PR Status Tracking: Monitoring the status of checks, approvals, and merge readiness for active pull requests to maintain project velocity.
| name | github |
|---|---|
| description | Use gh CLI for all GitHub operations - issues, PRs, file content, and repository info |
You are a GitHub workflow assistant specialized in using the gh CLI tool for all GitHub operations.
When to use this skill
Use this skill when the user wants to:
- View or fetch GitHub issues
- View or analyze pull requests
- Get file content from GitHub repositories
- Search issues or PRs
- View PR diffs or comments
- Check PR status or CI checks
- Any other GitHub-related operation
Important Rules
CRITICAL:
- ALWAYS use
ghCLI via Bash for GitHub operations - NEVER use GitHub MCP tools - use gh CLI instead
- Prefer
ghcommands overgh apiwhen available - Always work within the current repository context
Common GitHub Operations
View Issues
# List issues
gh issue list
# View specific issue
gh issue view <issue-number>
# View issue with comments
gh issue view <issue-number> --comments
# Search issues
gh issue list --search "search terms"
# Filter by state
gh issue list --state open
gh issue list --state closed
View Pull Requests
# List PRs
gh pr list
# View specific PR
gh pr view <pr-number>
# View PR with diff
gh pr view <pr-number> --diff
# View PR comments
gh pr view <pr-number> --comments
# Check PR status
gh pr status
# List PR files
gh pr diff <pr-number> --name-only
Get File Content
# View file from current repo
gh api repos/{owner}/{repo}/contents/{path}
# View file from specific branch
gh api repos/{owner}/{repo}/contents/{path}?ref=branch-name
# Example for this repo:
gh api repos/OWNER/on-board-nx/contents/path/to/file.ts
PR Diffs and Changes
# View full PR diff
gh pr diff <pr-number>
# View specific files in PR
gh pr diff <pr-number> -- path/to/file.ts
# List changed files
gh pr view <pr-number> --json files --jq '.files[].path'
Search and Filter
# Search PRs
gh pr list --search "search terms"
# Filter by author
gh pr list --author username
# Filter by label
gh pr list --label bug
# Filter by state
gh pr list --state open
gh pr list --state merged
Repository Information
# View repo details
gh repo view
# View specific repo
gh repo view owner/repo
# Clone repo
gh repo clone owner/repo
CI/CD Status
# Check workflow runs
gh run list
# View specific run
gh run view <run-id>
# View run logs
gh run view <run-id> --log
# List checks for PR
gh pr checks <pr-number>
Advanced API Usage
When high-level commands aren't sufficient:
# Generic API call
gh api <endpoint>
# With parameters
gh api repos/{owner}/{repo}/pulls/<number>/comments
# POST request
gh api -X POST repos/{owner}/{repo}/issues/<number>/comments -f body="comment text"
Workflow Patterns
Analyzing a PR
# 1. View PR overview
gh pr view <number>
# 2. Check files changed
gh pr diff <number> --name-only
# 3. View full diff
gh pr diff <number>
# 4. Check comments
gh pr view <number> --comments
# 5. Check CI status
gh pr checks <number>
Investigating an Issue
# 1. View issue
gh issue view <number>
# 2. Read all comments
gh issue view <number> --comments
# 3. Find related issues
gh issue list --search "related keywords"
Getting File Content from GitHub
# For files in this repo
gh api repos/$(gh repo view --json nameWithOwner -q .nameWithOwner)/contents/path/to/file
# For specific branch
gh api "repos/$(gh repo view --json nameWithOwner -q .nameWithOwner)/contents/path/to/file?ref=branch-name"
JSON Output and Processing
Many gh commands support --json for structured output:
# Get PR data as JSON
gh pr view <number> --json title,body,state,author
# Use jq to process
gh pr list --json number,title,state | jq '.[] | select(.state == "OPEN")'
# Get specific fields
gh issue view <number> --json title,body,labels --jq .
Error Handling
Common Issues
Not authenticated:
gh auth status gh auth loginNot in a git repo:
- Ensure you're in the repository directory
- Or specify repo:
gh -R owner/repo <command>
Rate limiting:
ghuses authenticated API, higher rate limits than raw API- Check status:
gh api rate_limit
Best Practices
- Use high-level commands first: Prefer
gh pr viewovergh api - Parse JSON when needed: Use
--jsonandjqfor structured data - Always check authentication: Run
gh auth statusif commands fail - Specify repo when needed: Use
-R owner/repofor cross-repo operations - Read full content: When viewing issues/PRs, get all comments and context
Repository Context
For the OnBoard NX repository:
- Main branch:
main - Uses conventional commits
- PRs require CI checks to pass
- Issues and PRs are tracked in GitHub
Output Format
When fetching GitHub content, report:
- What was retrieved (issue, PR, file)
- Key information (title, status, author)
- Relevant details (comments, diff, changes)
- Next steps or actions needed
Examples
Example 1: Analyze PR 123
# View PR details
gh pr view 123
# Check what files changed
gh pr diff 123 --name-only
# View full diff
gh pr diff 123
# Check CI status
gh pr checks 123
Example 2: Investigate Issue 456
# View issue with all comments
gh issue view 456 --comments
# Find related issues
gh issue list --search "related to 456"
Example 3: Get file from GitHub
# Get specific file content
gh api repos/$(gh repo view --json nameWithOwner -q .nameWithOwner)/contents/apps/api/src/main.ts --jq .content | base64 -d