GitHub CLI Skill
Quick Start
Authentication
bash
1# Interactive authentication (recommended)
2gh auth login
3
4# Check authentication status
5gh auth status
6
7# Login with token
8gh auth login --with-token < token.txt
9
10# Login to enterprise
11gh auth login --hostname github.example.com
Configuration
bash
1# Set default editor
2gh config set editor "code --wait"
3
4# Set default browser
5gh config set browser "firefox"
6
7# Set default git protocol
8gh config set git_protocol ssh
9
10# View all settings
11gh config list
Essential Commands (Most Common First)
1. Issues
bash
1# Create issue
2gh issue create --title "Bug: something broken" --body "Description here"
3
4# Create with labels
5gh issue create --title "Feature request" --label "enhancement,priority:high"
6
7# List issues
8gh issue list # Open issues
9gh issue list --state all # All issues
10gh issue list --assignee @me # Assigned to me
11gh issue list --label "bug" # By label
12
13# View issue
14gh issue view 123 # By number
15gh issue view 123 --comments # With comments
16
17# Edit issue
18gh issue edit 123 --title "New title"
19gh issue edit 123 --add-label "in-progress"
20gh issue edit 123 --assignee username
21
22# Close/reopen
23gh issue close 123
24gh issue close 123 --comment "Fixed in PR #456"
25gh issue reopen 123
26
27# Comment
28gh issue comment 123 --body "This is a comment"
2. Pull Requests
bash
1# Create PR
2gh pr create --title "Feature: new thing" --body "Description"
3gh pr create --draft # Create as draft
4gh pr create --fill # Auto-fill from commits
5
6# List PRs
7gh pr list # Open PRs
8gh pr list --state merged # Merged PRs
9gh pr list --author @me # My PRs
10gh pr list --search "review:required"
11
12# View PR
13gh pr view 123 # By number
14gh pr view # Current branch PR
15gh pr diff 123 # View diff
16gh pr checks 123 # View CI status
17
18# Review PRs
19gh pr review 123 --approve
20gh pr review 123 --request-changes --body "Please fix X"
21gh pr review 123 --comment --body "Looks good overall"
22
23# Merge
24gh pr merge 123 # Interactive
25gh pr merge 123 --squash # Squash merge
26gh pr merge 123 --rebase # Rebase merge
27gh pr merge 123 --auto # Auto-merge when checks pass
28
29# Mark ready
30gh pr ready 123 # Convert draft to ready
31
32# Comment
33gh pr comment 123 --body "Comment text"
34
35# Close
36gh pr close 123
3. Repository
bash
1# Clone
2gh repo clone owner/repo
3gh repo clone owner/repo -- --depth 1 # Shallow clone
4
5# Create
6gh repo create my-repo --public
7gh repo create my-repo --private --clone
8
9# View
10gh repo view # Current repo
11gh repo view owner/repo # Specific repo
12gh repo view --web # Open in browser
13
14# Fork
15gh repo fork owner/repo
16gh repo fork owner/repo --clone # Fork and clone
17
18# Sync fork
19gh repo sync # Sync fork with upstream
20
21# List repos
22gh repo list # Your repos
23gh repo list owner # Organization repos
4. Workflow (GitHub Actions)
bash
1# List workflows
2gh workflow list
3
4# View workflow runs
5gh run list # Recent runs
6gh run list --workflow ci.yml # By workflow
7gh run list --status failure # Failed runs
8
9# View run details
10gh run view 123456 # By run ID
11gh run view 123456 --log # With logs
12gh run view 123456 --log-failed # Only failed logs
13
14# Trigger workflow
15gh workflow run ci.yml
16gh workflow run ci.yml -f param=value
17
18# Watch run
19gh run watch # Watch current branch run
20gh run watch 123456 # Watch specific run
21
22# Cancel/rerun
23gh run cancel 123456
24gh run rerun 123456
25gh run rerun 123456 --failed # Rerun only failed jobs
5. Search
bash
1# Search issues/PRs
2gh search issues "bug in:title"
3gh search issues "label:bug state:open"
4gh search prs "author:username is:merged"
5
6# Search repos
7gh search repos "language:python stars:>1000"
8
9# Search code
10gh search code "function handleError"
11gh search code "filename:config.json org:myorg"
Advanced Commands
Releases
bash
1# Create release
2gh release create v1.0.0 --title "Version 1.0" --notes "Release notes"
3gh release create v1.0.0 --generate-notes # Auto-generate notes
4gh release create v1.0.0 ./dist/* # Upload assets
5
6# List/view
7gh release list
8gh release view v1.0.0
9
10# Download assets
11gh release download v1.0.0
12gh release download v1.0.0 --pattern "*.zip"
Gists
bash
1# Create gist
2gh gist create file.txt
3gh gist create --public file.txt
4gh gist create -d "Description" file1.txt file2.txt
5
6# List/view
7gh gist list
8gh gist view gist_id
9
10# Edit
11gh gist edit gist_id
API Access
bash
1# GraphQL query
2gh api graphql -f query='{ viewer { login } }'
3
4# REST API
5gh api repos/owner/repo/issues
6gh api repos/owner/repo/issues --method POST -f title="Issue title"
7
8# Paginate
9gh api repos/owner/repo/issues --paginate
SSH Keys & GPG
bash
1# SSH keys
2gh ssh-key add ~/.ssh/id_ed25519.pub --title "My laptop"
3gh ssh-key list
4
5# GPG keys
6gh gpg-key add key.asc
7gh gpg-key list
Common Patterns
Issue-to-PR Workflow
bash
1# 1. Create issue
2gh issue create --title "Feature: X" --label "enhancement"
3# Returns issue #123
4
5# 2. Create branch and work
6git checkout -b feat/issue-123-x
7
8# 3. Create PR linking to issue
9gh pr create --title "Feature: X" --body "Closes #123"
Code Review Flow
bash
1# Check out PR locally
2gh pr checkout 456
3
4# Run tests, review code...
5
6# Approve or request changes
7gh pr review 456 --approve --body "LGTM!"
CI Failure Investigation
bash
1# List failed runs
2gh run list --status failure
3
4# Get logs
5gh run view RUN_ID --log-failed
6
7# Rerun after fix
8gh run rerun RUN_ID
Re-enabling GitHub MCP Server
If you need the full GitHub MCP server for advanced operations (e.g., complex GraphQL queries, bulk operations), you can ask:
"Please use the GitHub MCP server" or "Re-enable GitHub MCP"
To re-enable manually:
- Edit
~/.copilot/github-copilot/mcp.json
- Remove or set
"disabled": false for github-mcp-server:
json
1{
2 "mcpServers": {
3 "github-mcp-server": {
4 "disabled": false
5 }
6 }
7}
- Restart the Copilot CLI session
When to use MCP vs gh CLI:
| Use gh CLI | Use GitHub MCP |
|---|
| Standard issue/PR operations | Complex multi-step GitHub operations |
| CI/CD workflow management | Bulk operations across many repos |
| Quick lookups and status checks | Advanced GraphQL queries |
| Script automation | Operations requiring persistent state |
| Most daily GitHub interactions | Rare, specialized GitHub integrations |
Troubleshooting
bash
1# Check auth
2gh auth status
3
4# Refresh token
5gh auth refresh
6
7# Clear cache
8gh cache delete --all
9
10# Debug mode
11GH_DEBUG=api gh issue list
Environment Variables
bash
1GH_TOKEN # Auth token (alternative to gh auth)
2GH_HOST # Default host (for enterprise)
3GH_REPO # Default repo (owner/repo format)
4GH_EDITOR # Editor for interactive commands
5GH_BROWSER # Browser for --web commands
6GH_DEBUG # Enable debug output (api, oauth)
7NO_COLOR # Disable colored output