GitHub CLI Integration
Claude Code can seamlessly integrate with GitHub CLI (gh
) for creating issues, opening Pull Requests, reading comments, and more.
Installing GitHub CLI
macOS
brew install gh
Ubuntu/Debian
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/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
Windows
winget install --id GitHub.cli
Configure Authentication
Login to GitHub
gh auth login
Choose authentication method:
- Login through browser
- Use Personal Access Token
Verify Configuration
gh auth status
gh api user
Usage in Claude Code
Basic Operations
Claude can directly use gh
commands:
Please use gh command to view current repository issues
Claude will execute:
gh issue list
Creating Issues
Create a GitHub issue for the user login functionality bug
Claude will execute:
gh issue create \
--title "User login functionality bug fix" \
--body "Detailed description of login issues..." \
--label "bug,priority-high"
Pull Request Management
Create a Pull Request for the current branch
Claude will execute:
gh pr create \
--title "Implement user authentication feature" \
--body "## Changes\n- Add login page\n- Implement JWT authentication\n- Add unit tests"
Common Workflows
1. Issue-Driven Development
View issues labeled 'enhancement' and select one to start development
Claude execution flow:
gh issue list --label enhancement
- Analyze issue content
- Create feature branch
- Implement functionality
- Create Pull Request
2. Code Review Response
Check latest comments on my PR and handle feedback
Claude execution flow:
gh pr list --author @me
gh pr view <PR-ID> --comments
- Analyze comment feedback
- Modify code
- Push updates
Permission Configuration
Allow gh commands in Claude Code:
{
"allowedTools": [
"Bash(gh:*)",
"Bash(gh issue:*)",
"Bash(gh pr:*)",
"Bash(gh repo:*)"
]
}
Next: Bash Tools - Learn how to work with command-line tools.
Last updated on: