Appearance
GitHub Integration & PR Reviews
Claude Code works directly with git. It stages changes, writes commit messages, creates branches, and opens pull requests. It can review PRs from a diff, from a PR number, or automatically triggered by GitHub events. This lesson covers the full GitHub integration.

What you'll learn
claude -p "commit my changes"stages, commits, and writes a descriptive messageclaude --from-pr 42reviews a specific PR by number- GitHub Actions and GitHub Code Review automate PR reviews on every push
The problem
Manual code review is the bottleneck in every team's workflow. A PR sits for hours waiting for a human to look at it. Claude Code can review PRs in seconds, catching security issues, missing tests, and style violations before a human ever sees the code. The human reviews the review, not the raw diff.
Build it
Step 1: Review a PR from the terminal
Use these terminal commands to instruct Claude to review a specific pull request, either by comparing branches or providing the PR number.
bash
# Review a PR branch against main
claude -p "Review this PR for bugs, security issues, and style problems. Be thorough." \
--max-turns 10
# Review from a PR number
claude -p "Review this PR thoroughly" --from-pr 42 --max-turns 10Step 2: Commit and create a PR
In an interactive session:
/commitClaude stages changes, writes a commit message, and pushes. Or from print mode:
bash
claude -p "commit my changes with a descriptive message following conventional commits"Step 3: GitHub Actions for automated PR review
Integrate this workflow into your repository to trigger an automated Claude review whenever a pull request is opened or updated.
yaml
# .github/workflows/claude-review.yml
name: Claude Code Review
on:
pull_request:
types: [opened, synchronize]
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
curl -fsSL https://claude.ai/install.sh | bash
claude -p "Review this PR for bugs, security issues, missing tests, and style problems. Post findings as a PR review." \
--max-turns 10 --allowedTools "Read,Grep" --output-format jsonStep 4: GitHub Code Review (automatic on every PR)
Configure in your repo settings to enable Claude Code's GitHub Code Review integration. Every PR automatically gets a Claude review posted as a comment.
What goes wrong
| Mistake | How you notice it | The fix |
|---|---|---|
--from-pr can't find the PR | Error: PR not found | Make sure you're in the repo directory and the PR number is correct. The branch must exist locally or be fetchable |
| Commit message is generic | Claude writes "update code" instead of a descriptive message | Add a CLAUDE.md rule: "Use conventional commits format: type(scope): description" |
| GitHub Actions review fails auth | 401 error in CI | Set ANTHROPIC_API_KEY as a GitHub Secret. The OAuth flow doesn't work in CI |
Confirm it worked
Run these steps locally to generate a mock change and verify that Claude can successfully format and commit the resulting diff.
bash
# 1. Make a change, commit it
echo "# test" >> README.md
claude -p "commit this change with a conventional commit message"
# 2. Verify the commit
git log -1
# 3. Clean up
git reset HEAD~1Next: CI/CD Pipelines