What Claude Code Does with GitHub
Claude Code has deep integration with git and the gh CLI. It can manage your entire GitHub workflow from the terminal:
Git Basics with Claude Code
Claude Code understands your git repository context automatically. It reads your commit history, branch state, and staged changes to provide relevant assistance.
Committing Changes
After Claude makes changes, ask it to commit:
Claude will:
- Run
git statusandgit diffto see all changes - Check recent commit messages to match your repo's style
- Stage relevant files (individually, not with
git add -A) - Write a descriptive commit message
- Run the commit and verify success
Add your preferred format to CLAUDE.md: Write commit messages in conventional commit format: type(scope): description
Reviewing Changes
> show me the diff for the last 3 commits
> summarize recent changes to the auth module
Branch Operations
> what branch am I on?
> merge main into my current branch and resolve conflicts
Creating Pull Requests
Claude Code creates comprehensive PRs with a single prompt:
Claude will:
- Analyze all commits since branching from main
- Generate a descriptive title (under 70 chars)
- Write a structured PR body with summary, changes, and test plan
- Push to remote if needed
- Create the PR using
gh pr create
Example PR body Claude generates:
Advanced PR Options
> create a PR targeting the develop branch, assign to @teammate, add the "enhancement" label
# Create draft PR
> create a draft PR for my work in progress
# Update existing PR description
> update PR #42 description to include the new caching changes
AI Code Review
Claude Code can review any PR, whether yours or a teammate's:
> review PR #42
# Review a PR by URL
> review https://github.com/org/repo/pull/42
# Review with focus area
> review PR #42, focus on security and error handling
Claude's review covers:
| Category | What Claude Checks |
|---|---|
| Bugs | Logic errors, off-by-one, null handling, race conditions, edge cases |
| Security | Injection, XSS, auth issues, secrets exposure, OWASP Top 10 |
| Performance | N+1 queries, unnecessary re-renders, memory leaks, algorithm complexity |
| Quality | DRY violations, naming, error handling, test coverage |
| Conventions | Matches your CLAUDE.md rules, project patterns, and coding standards |
Issue Management
Claude Code can interact with GitHub issues using the gh CLI:
> read issue #15 and suggest a fix
# List open issues
> show me open bugs labeled "high priority"
# Fix an issue end-to-end
> fix issue #15, create a branch, implement the fix, and open a PR
# Create an issue
> create a GitHub issue for the memory leak I just found in the WebSocket handler
The most powerful command: "fix issue #N and create a PR." Claude will read the issue, understand the problem, create a branch, implement the fix, write tests, commit, and open a pull request referencing the issue.
GitHub Actions Integration
Run Claude Code in your CI/CD pipeline for automated code review, issue resolution, and PR management.
Automated PR Review
Add Claude as an automated reviewer that comments on every PR:
Issue Auto-Fix
Have Claude automatically fix issues when they're labeled:
CI Failure Auto-Fix
Each CI run uses API tokens. Set budget limits and consider running Claude reviews only on PRs targeting main, or use the cheaper Haiku model for triage.
Common Workflows
Feature Development Flow
> read issue #23 and create a branch for it
# 2. Implement the feature
> implement the feature described in issue #23
# 3. Review your own changes
> review my changes for issues before I submit a PR
# 4. Commit and create PR
> commit and create a PR that closes #23
Bug Fix Flow
Merge Conflict Resolution
Claude will analyze the conflicting changes, understand the intent of both sides, and produce a clean merge resolution. It explains its choices so you can verify.
Changelog Generation
Git Safety & Best Practices
Claude Code has built-in safety measures for git operations:
| Rule | Why |
|---|---|
| Never force-pushes to main/master | Prevents overwriting shared branch history |
Stages files individually (not git add -A) |
Prevents committing secrets, .env files, or large binaries |
| Creates new commits instead of amending | Preserves git history, avoids overwriting previous work |
| Never runs destructive commands without asking | reset --hard, branch -D, clean -f require explicit approval |
| Never skips pre-commit hooks | Respects your CI/linting setup |
| Asks before pushing | Push affects shared state, so Claude confirms first |
Customize Git Behavior in CLAUDE.md
Troubleshooting
gh not found
Install the GitHub CLI: brew install gh (macOS) or see cli.github.com. Then run gh auth login.
Permission denied on push
Ensure you have write access to the repository. Check your SSH keys (ssh -T git@github.com) or personal access token. For GitHub Actions, verify the GITHUB_TOKEN has the right permissions.
PR creation fails
Common causes: branch not pushed to remote (Claude should push automatically), no commits ahead of base branch, or missing gh authentication. Run gh auth status to verify.
GitHub Actions not triggering
Check that the workflow file is in .github/workflows/, the trigger events match, and the ANTHROPIC_API_KEY secret is set in the repo settings.
Frequently Asked Questions
Does Claude Code push code automatically?
No. Claude Code always asks for confirmation before pushing. Pushing affects shared state (remote branches, PRs), so Claude treats it as a high-risk action that requires explicit approval.
Can I use Claude Code with GitHub Enterprise?
Yes. Configure the GH_HOST environment variable to point to your GitHub Enterprise instance. The gh CLI supports GHE natively with gh auth login --hostname your-ghe.example.com.
How do I limit API costs in GitHub Actions?
Use conditional triggers (only run on PRs targeting main), set the max-tokens parameter, use the cheaper Haiku model for triage, and add a budget limit via the ANTHROPIC_MAX_SPEND environment variable.
Can Claude Code handle monorepo PRs?
Yes. Claude analyzes the full diff and understands which packages are affected. For large PRs, it focuses on the most critical changes first. Use path filters in GitHub Actions to only trigger Claude for specific packages.