GitHub Integration: Pull Requests, Issues, and Actions
Integrate Claude Code with GitHub workflows. Automate PRs, manage issues, and build custom actions with this comprehensive integration guide.
Integrate Claude Code with GitHub workflows. Automate PRs, manage issues, and build custom actions with this comprehensive integration guide.
GitHub is where code lives. Issues track work. PRs gate changes. Actions automate pipelines. Yet developers spend significant time on GitHub mechanics—creating issues, reviewing PRs, managing releases.
Claude Code integrates deeply with GitHub, automating these workflows while keeping you in control. This tutorial shows you how to build a complete GitHub integration that saves hours every week.
Claude Code uses the GitHub CLI (gh) for GitHub operations. Verify it's installed and authenticated:
# Check installation
gh --version
# Check authentication
gh auth status
If not authenticated:
gh auth login
Ensure your project is a Git repository with a GitHub remote:
git remote -v
# Should show origin pointing to github.com
.claude/commands/issue.md:
---
description: Create GitHub issues from natural language
arguments:
- name: description
description: Issue description or title
required: true
- name: labels
description: Comma-separated labels
required: false
- name: assignee
description: GitHub username to assign
required: false
---
# GitHub Issue Creator
When the user runs /issue [description], create a well-structured GitHub issue.
## Parse Description
Extract from the user's description:
- Issue type: bug, feature, documentation, chore
- Priority: if mentioned
- Affected area: which part of codebase
## Generate Issue Content
### Title
- Clear, concise (under 72 characters)
- Start with type prefix: [Bug], [Feature], [Docs]
### Body
```markdown
## Description
[Detailed description of the issue]
## Context
[Why this matters, background information]
## Acceptance Criteria
- [ ] Criterion 1
- [ ] Criterion 2
- [ ] Criterion 3
## Technical Notes
[Any technical details, affected files, approaches]
## Related
- Related issue #X
- Related PR #Y
Use GitHub CLI:
gh issue create \
--title "[Type] Title Here" \
--body "Body content" \
--label "label1,label2" \
--assignee "@me"
Created issue #42: [Feature] Add user authentication
URL: https://github.com/user/repo/issues/42
Labels: feature, priority:high
Assignee: @username
Would you like to:
1. Start working on this issue (/worktree 42)
2. Add more details
3. Create related issues
### Issue Templates
**.claude/commands/issue-template.md:**
```markdown
---
description: Create issue from template
arguments:
- name: template
description: Template type (bug, feature, epic)
required: true
---
# Issue Template Creator
Generate issues from predefined templates.
## Bug Template
```markdown
## Bug Report
### Description
[Clear description of the bug]
### Steps to Reproduce
1. Step 1
2. Step 2
3. Step 3
### Expected Behavior
[What should happen]
### Actual Behavior
[What actually happens]
### Environment
- OS:
- Browser/Runtime:
- Version:
### Screenshots
[If applicable]
### Additional Context
[Any other relevant information]
## Feature Request
### Summary
[One paragraph summary]
### Motivation
[Why is this needed? What problem does it solve?]
### Proposed Solution
[How should this work?]
### Alternatives Considered
[Other approaches you've thought about]
### Acceptance Criteria
- [ ] Criterion 1
- [ ] Criterion 2
### Technical Considerations
[Implementation notes, breaking changes, etc.]
## Epic: [Title]
### Overview
[High-level description]
### Goals
- Goal 1
- Goal 2
### Success Metrics
- Metric 1
- Metric 2
### Sub-Issues
#### Phase 1: Foundation
- [ ] Issue description 1 #
- [ ] Issue description 2 #
#### Phase 2: Implementation
- [ ] Issue description 3 #
- [ ] Issue description 4 #
#### Phase 3: Polish
- [ ] Issue description 5 #
### Timeline
- Start: [Date]
- Phase 1: [Date]
- Phase 2: [Date]
- Complete: [Date]
### Risks
- Risk 1: Mitigation
- Risk 2: Mitigation
### Issue Triage
**.claude/commands/triage.md:**
```markdown
---
description: Triage open issues
---
# Issue Triage
Review and organize open issues.
## Gather Issues
```bash
gh issue list --state open --limit 50
For each issue:
Suggest labels based on content:
Based on:
Find issues that might be duplicates:
Flag issues that:
Issue Triage Report
===================
Total open issues: 47
## Needs Labels (15)
#42 - "Login broken" → Suggested: bug, auth, priority:high
#38 - "Add dark mode" → Suggested: feature, ui
## Potential Duplicates (3 pairs)
#40 and #32 - Both about password reset
#35 and #28 - Both about slow loading
## Stale (8)
#15 - Last activity: 45 days ago
#12 - Last activity: 60 days ago
## Ready to Work (5)
#41 - Well-defined, labeled, estimated
#39 - Clear acceptance criteria
## Needs Clarification (7)
#44 - Missing reproduction steps
#43 - Unclear expected behavior
Actions:
1. Label issues (/label-issues)
2. Close stale issues (/close-stale)
3. Comment for clarification (/request-info)
## Pull Request Workflows
### PR Creation Skill
**.claude/commands/pr.md:**
```markdown
---
description: Create a pull request
arguments:
- name: title
description: PR title (optional, will generate from commits)
required: false
- name: draft
description: Create as draft PR
required: false
default: false
---
# Pull Request Creator
When the user runs /pr, create a well-structured pull request.
## Pre-flight Checks
1. Verify on feature branch (not main/master)
2. Check for uncommitted changes
3. Verify remote is up to date
4. Run tests if configured
If any check fails, report and ask how to proceed.
## Analyze Changes
1. Get commits since branching:
`git log main..HEAD --oneline`
2. Get changed files:
`git diff main --name-only`
3. Categorize changes:
- Features added
- Bugs fixed
- Refactoring done
- Tests added
- Docs updated
## Generate PR Content
### Title
If not provided, generate from:
- Branch name
- Commit messages
- Type of changes
Format: `[Type] Brief description`
### Body
```markdown
## Summary
[2-3 sentence summary of what this PR does]
## Changes
### Added
- New feature X
### Changed
- Modified behavior Y
### Fixed
- Bug where Z
## Testing
### Automated
- [x] Unit tests pass
- [x] Integration tests pass
- [ ] E2E tests (manual)
### Manual Testing
1. Step to test feature 1
2. Step to test feature 2
## Screenshots
[If UI changes]
## Checklist
- [ ] Code follows project style
- [ ] Tests added for changes
- [ ] Documentation updated
- [ ] No breaking changes (or documented)
## Related
- Fixes #42
- Related to #38
gh pr create \
--title "PR title" \
--body "PR body" \
--draft # if draft flag set
Created PR #15: [Feature] Add user authentication
URL: https://github.com/user/repo/pull/15
Status: Draft / Ready for Review
Base: main ← feature/auth
Reviewers: (none yet)
Labels: (none yet)
Next steps:
1. Add reviewers: gh pr edit 15 --add-reviewer @username
2. Add labels: gh pr edit 15 --add-label "feature"
3. Mark ready: gh pr ready 15
### PR Review Skill
**.claude/commands/review-pr.md:**
```markdown
---
description: Review a pull request
arguments:
- name: pr
description: PR number
required: true
- name: depth
description: Review depth (quick, standard, thorough)
required: false
default: standard
---
# Pull Request Reviewer
Perform a comprehensive code review of a PR.
## Fetch PR Details
```bash
gh pr view [pr] --json title,body,author,additions,deletions,files
gh pr diff [pr]
gh pr checks [pr]
If requested, submit to GitHub:
gh pr review [pr] --approve --body "Review comment"
# or
gh pr review [pr] --request-changes --body "Review comment"
# or
gh pr review [pr] --comment --body "Review comment"
PR Review: #15 - Add user authentication
## Summary
This PR adds a complete authentication system with login, logout,
and session management.
## Verdict: APPROVE with suggestions
## Findings
### Must Address
(none)
### Suggestions
- Consider adding rate limiting to login endpoint
- Password validation could be stricter
### Praise
- Clean separation of concerns
- Good test coverage
- Clear documentation
## Metrics
- +450 lines added
- -23 lines removed
- 12 files changed
- 15 tests added
Review submitted to GitHub: Yes
### PR Merge Skill
**.claude/commands/merge.md:**
```markdown
---
description: Merge a pull request
arguments:
- name: pr
description: PR number
required: true
- name: method
description: Merge method (merge, squash, rebase)
required: false
default: squash
---
# Pull Request Merger
Safely merge a pull request.
## Pre-merge Checks
1. PR is approved
2. All checks pass
3. No merge conflicts
4. Branch is up to date with base
If any check fails, report and ask how to proceed.
## Merge
```bash
gh pr merge [pr] --squash --delete-branch
Options:
--merge: Create a merge commit--squash: Squash and merge--rebase: Rebase and merge--delete-branch: Delete branch after merge# Update local main
git checkout main
git pull origin main
# Delete local feature branch
git branch -d feature-branch
# Prune remote tracking branches
git fetch --prune
Merged PR #15: Add user authentication
Merge method: Squash
Merge commit: abc123
Branch deleted: feature/auth
Related issues updated:
- #42 marked as closed (Fixes #42)
Local cleanup:
- main updated
- feature/auth branch deleted
Next:
- Deploy to staging? (/deploy staging)
- Create release? (/release)
## GitHub Actions Integration
### Workflow Trigger Skill
**.claude/commands/run-workflow.md:**
```markdown
---
description: Trigger GitHub Actions workflow
arguments:
- name: workflow
description: Workflow name or file
required: true
- name: inputs
description: Workflow inputs as JSON
required: false
---
# GitHub Actions Runner
Trigger a GitHub Actions workflow.
## List Available Workflows
```bash
gh workflow list
gh workflow run [workflow] --ref [branch]
With inputs:
gh workflow run [workflow] -f input1=value1 -f input2=value2
After triggering:
gh run list --workflow=[workflow] --limit 1
gh run watch [run-id]
Triggered workflow: deploy.yml
Run ID: 12345678
Branch: main
Status: In progress...
Jobs:
- build: ✓ Complete (2m 30s)
- test: ▶ Running...
- deploy: ⏳ Waiting
Live logs: https://github.com/user/repo/actions/runs/12345678
### CI Status Skill
**.claude/commands/ci.md:**
```markdown
---
description: Check CI/CD status
arguments:
- name: ref
description: Branch, PR, or commit to check
required: false
---
# CI/CD Status Checker
Check status of CI/CD pipelines.
## Check Status
### For current branch:
```bash
gh run list --limit 5
gh run view --web # Opens latest in browser
gh pr checks [pr]
gh run list --commit [sha]
If failures exist:
gh run view [run-id] --log-failed
CI Status for: main (commit abc1234)
## Latest Runs
| Workflow | Status | Duration | Triggered |
|----------|--------|----------|-----------|
| CI | ✓ Pass | 4m 23s | 10 min ago |
| Deploy | ✓ Pass | 2m 15s | 10 min ago |
| Nightly | ✗ Fail | 15m 02s | 8 hours ago |
## Failed: Nightly
Job: integration-tests
Step: Run integration tests
Error:
FAIL src/tests/integration/auth.test.ts × should handle concurrent logins Timeout after 30000ms
Suggested fix:
- Increase timeout for concurrent test
- Or: Check for race condition in auth handler
View details: gh run view 12345678 --log-failed
## Complete Workflow Example
### Feature Development Flow
**.claude/commands/feature.md:**
```markdown
---
description: Complete feature development workflow
arguments:
- name: issue
description: Issue number to work on
required: true
---
# Feature Development Workflow
Complete workflow from issue to merged PR.
## Phase 1: Setup
1. Fetch issue details:
```bash
gh issue view [issue]
Create feature branch:
git checkout main
git pull
git checkout -b feature/[issue]-[short-description]
Update issue status:
gh issue edit [issue] --add-label "in-progress"
Guide the user through development:
Before creating PR:
gh pr create \
--title "[Feature] Description from issue" \
--body "Closes #[issue]\n\n[Generated body]" \
--assignee @me
After approval:
gh pr merge --squash --delete-branch
Report progress and next steps at each phase.
## Best Practices
### 1. Use Templates Consistently
Create issue and PR templates in `.github/`:
- `ISSUE_TEMPLATE/bug_report.md`
- `ISSUE_TEMPLATE/feature_request.md`
- `PULL_REQUEST_TEMPLATE.md`
### 2. Automate What's Safe
Safe to automate:
- Issue creation
- PR creation
- Status checks
- Branch cleanup
Requires human:
- PR approval
- Force pushes
- Protected branch changes
### 3. Link Everything
- PRs reference issues
- Issues reference PRs
- Commits reference issues
- Documentation references PRs
### 4. Fail Fast, Fix Fast
If CI fails:
- Get logs immediately
- Understand the failure
- Fix quickly
Don't let failing CI linger.
## Summary
GitHub integration with Claude Code automates the mechanical parts of Git workflows while keeping you in control of decisions.
### Skills Created
| Skill | Purpose |
|-------|---------|
| `/issue` | Create issues from descriptions |
| `/issue-template` | Use structured templates |
| `/triage` | Organize open issues |
| `/pr` | Create pull requests |
| `/review-pr` | Review pull requests |
| `/merge` | Merge pull requests |
| `/run-workflow` | Trigger GitHub Actions |
| `/ci` | Check CI/CD status |
| `/feature` | Complete feature workflow |
### Integration Points
- Issue management
- PR creation and review
- GitHub Actions
- Branch management
- Release automation
---
*Want to integrate team communication? Check out [Slack Integration](/blog/slack-integration-claude-code) for team notification skills.*
Build Model Context Protocol (MCP) servers and integrations. Create custom tools and capabilities for Claude.
Git Commit Helper skill for Claude
Create and manage command structures for agent workflows.
Creates isolated git worktrees with smart directory selection and safety verification.