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 ghUbuntu/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 ghWindows
winget install --id GitHub.cliConfigure Authentication
Login to GitHub
gh auth loginChoose authentication method:
- Login through browser
- Use Personal Access Token
Verify Configuration
gh auth status
gh api userUsage in Claude Code
Basic Operations
Claude can directly use gh commands:
Please use gh command to view current repository issuesClaude will execute:
gh issue listCreating Issues
Create a GitHub issue for the user login functionality bugClaude 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 branchClaude 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 developmentClaude 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 feedbackClaude execution flow:
gh pr list --author @megh 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: