| name | gh-cli-setup |
| description | Use when gh CLI is not installed, not configured, or authentication fails - provides installation steps, authentication methods, and troubleshooting for all platforms |
GitHub CLI Setup & Troubleshooting
Overview
This skill helps diagnose and fix GitHub CLI (gh) installation, configuration, and authentication issues.
IMPORTANT: When providing installation instructions, always:
- Explain the recommended method (e.g., "Homebrew is the recommended way to install on macOS")
- Provide the actual command
- Mention alternative installation methods
- Add context about what the command does
- Do NOT just return a bare command without explanation
When to Use
Use this skill when:
gh command not found
- Authentication errors occur
- gh CLI behaves unexpectedly
- Need to check gh CLI configuration
- Setting up gh CLI for first time
Quick Diagnostic
Run these commands to check status:
which gh
gh --version
gh auth status
gh auth status --show-token
Installation
macOS
Using Homebrew (recommended):
brew install gh
Using MacPorts:
sudo port install gh
Using Conda:
conda install gh --channel conda-forge
Linux
Debian/Ubuntu/Raspbian:
type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y)
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update
sudo apt install gh -y
Fedora/CentOS/RHEL:
sudo dnf install gh
Arch Linux:
sudo pacman -S github-cli
Using Snap:
sudo snap install gh
Using Conda:
conda install gh --channel conda-forge
Windows
Using WinGet:
winget install --id GitHub.cli
Using Scoop:
scoop install gh
Using Chocolatey:
choco install gh
Using Conda:
conda install gh --channel conda-forge
Manual Download:
Authentication
Interactive Authentication (Recommended)
gh auth login
This will prompt you to:
- Choose GitHub.com or GitHub Enterprise Server
- Choose authentication method (Web browser or Token)
- Complete authentication flow
Token Authentication
gh auth login --with-token < token.txt
gh auth login
Check Authentication
gh auth status
gh api user --jq '.login'
gh api rate_limit
Common Errors & Solutions
Error: "gh: command not found"
Cause: gh CLI not installed or not in PATH
Solution:
which gh
export PATH="/path/to/gh/bin:$PATH"
Error: "authentication required"
Cause: Not logged in to GitHub
Solution:
gh auth login
gh auth status
Error: "HTTP 403: Resource not accessible by integration"
Cause: Insufficient token permissions
Solution:
gh auth login --scopes repo,read:org,workflow
Error: "HTTP 401: Bad credentials"
Cause: Token expired or invalid
Solution:
gh auth logout
gh auth login
Error: "API rate limit exceeded"
Cause: Too many API requests (60/hour unauthenticated, 5000/hour authenticated)
Solution:
gh api rate_limit
gh auth login
Error: "Could not resolve host: github.com"
Cause: Network connectivity issue
Solution:
ping github.com
gh config set http_proxy http://proxy.example.com:8080
nslookup github.com
Configuration
View Configuration
gh config list
gh config get git_protocol
Common Settings
gh config set git_protocol https
gh config set editor vim
gh config set browser firefox
gh config set http_proxy http://proxy.example.com:8080
gh config set host github.enterprise.com
Config File Locations
- Linux/macOS:
~/.config/gh/config.yml
- Windows:
%AppData%\GitHub CLI\config.yml
Multiple Accounts
gh auth login --hostname github.com
gh auth login --hostname github.enterprise.com
gh auth switch
gh auth status
Debugging
Enable Debug Mode
GH_DEBUG=api gh search repos "test"
export GH_DEBUG=api
View Request/Response
gh api repos/owner/repo --verbose
Check Version
gh --version
gh extension upgrade --all
Troubleshooting Checklist
When gh CLI isn't working, check these in order:
Getting Help
gh help
gh search --help
gh search repos --help
Permissions Required for Search
Different search types require different permissions:
- Public repos/issues/PRs: No authentication required (but rate limited)
- Private repos: Requires
repo scope
- Organization repos: Requires
read:org scope
- Workflow files: Requires
workflow scope
Token Scopes
Create tokens at: https://github.com/settings/tokens
Minimal scopes for search:
public_repo - Search public repositories
repo - Search private repositories
read:org - Search organization repositories
Recommended scopes:
repo - Full repository access
read:org - Organization access
workflow - Workflow access
gist - Gist access
Uninstallation
macOS
brew uninstall gh
Linux
sudo apt remove gh
sudo dnf remove gh
sudo pacman -R github-cli
Windows
# WinGet
winget uninstall GitHub.cli
# Scoop
scoop uninstall gh
# Chocolatey
choco uninstall gh
Related