Claude Code + GitHub: PRs, Actions & Git Workflows

Master the integration between Claude Code and GitHub. Automate pull requests, run AI code reviews in CI/CD, manage issues, and supercharge your git workflow with AI assistance.

Updated Feb 2026 10 min read Intermediate

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:

🔀
Pull Requests
Create, review, and update PRs with auto-generated descriptions
🔍
Code Review
Analyze diffs for bugs, security issues, and best practices
📋
Issue Management
Read, create, comment on, and resolve GitHub issues
⚙️
GitHub Actions
Run Claude as a CI/CD step for automated reviews and fixes
📝
Commit Messages
Generate conventional commit messages from your diffs
🌿
Branch Management
Create feature branches, resolve conflicts, manage merges

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:

> commit these changes

Claude will:

  1. Run git status and git diff to see all changes
  2. Check recent commit messages to match your repo's style
  3. Stage relevant files (individually, not with git add -A)
  4. Write a descriptive commit message
  5. Run the commit and verify success
Commit message conventions

Add your preferred format to CLAUDE.md: Write commit messages in conventional commit format: type(scope): description

Reviewing Changes

> what changed since yesterday?
> show me the diff for the last 3 commits
> summarize recent changes to the auth module

Branch Operations

> create a branch called feat/user-auth and switch to it
> 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:

> create a pull request for my changes

Claude will:

  1. Analyze all commits since branching from main
  2. Generate a descriptive title (under 70 chars)
  3. Write a structured PR body with summary, changes, and test plan
  4. Push to remote if needed
  5. Create the PR using gh pr create

Example PR body Claude generates:

Pull Request
## Summary - Add rate limiting middleware to all public API endpoints - Implement sliding window counter using Redis - Add rate limit headers (X-RateLimit-Remaining, X-RateLimit-Reset) ## Test plan - [ ] Verify rate limiting triggers after 100 requests/minute - [ ] Check rate limit headers are present in responses - [ ] Confirm authenticated users get higher limits - [ ] Test Redis connection failure fallback

Advanced PR Options

# Create PR with specific 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 a PR by number
> 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 an issue
> 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
End-to-end workflow

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:

.github/workflows/claude-review.yml
name: Claude Code Review on: pull_request: types: [opened, synchronize] permissions: contents: read pull-requests: write jobs: review: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - uses: anthropics/claude-code-action@v1 with: anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} prompt: | Review this PR for bugs, security issues, and code quality. Focus on the diff only. Be concise and actionable. Only comment on significant issues, not style nits.

Issue Auto-Fix

Have Claude automatically fix issues when they're labeled:

.github/workflows/claude-fix.yml
name: Claude Fix Issue on: issues: types: [labeled] jobs: fix: if: github.event.label.name == 'claude-fix' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: anthropics/claude-code-action@v1 with: anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} prompt: | Fix the issue described in #${{ github.event.issue.number }}. Create a feature branch, implement the fix, write tests, and open a pull request that references the issue.

CI Failure Auto-Fix

.github/workflows/claude-ci-fix.yml
name: Claude CI Fix on: workflow_run: workflows: ["CI"] types: [completed] jobs: fix: if: github.event.workflow_run.conclusion == 'failure' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: anthropics/claude-code-action@v1 with: anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} prompt: | The CI pipeline failed. Analyze the failure logs, identify the issue, and push a fix to this branch.
API costs in CI

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

# 1. Start from an issue
> 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

> fix the bug in issue #45. Create a branch, fix it, add a regression test, and open a PR.

Merge Conflict Resolution

> merge main into my branch and resolve any conflicts

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

> generate a changelog from the commits between v1.2.0 and HEAD

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

CLAUDE.md
## Git Rules - Use conventional commits: type(scope): description - Don't use git add -A, add files individually - Always run linting before committing - Never push directly to main; use feature branches - PR titles should be under 70 characters - Include "Fixes #N" in commit messages when resolving issues

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.

Related Guides