A typical PR workflow involves: write code → write PR description → get review → fix issues → merge. Claude Code can handle most of the non-coding parts.
1. PR Description Generation
After finishing your changes:
git diff main...HEAD | claude -p "Write a PR description for these changes. Include:
- Summary (2-3 sentences)
- What changed and why
- Testing done
- Screenshots needed? (check if UI changes)
- Breaking changes (if any)
Format as GitHub markdown."
Or for a specific PR:
Generate a PR description for these changes.
Changed files:
- src/services/user.service.ts — Added email verification
- src/routes/auth.ts — Added /verify-email endpoint
- tests/services/user.service.test.ts — Tests for verification
The goal was to add email verification before users can access protected routes.
2. Pre-PR Code Review
Before opening a PR, run a self-review:
git diff main...HEAD | claude -p "Review these changes as a senior engineer would.
Focus on:
1. Correctness (bugs, edge cases)
2. Security (injection, auth, secrets)
3. Performance (N+1, unnecessary queries)
4. Missing tests
5. Code style violations vs CLAUDE.md rules
Be specific. Reference file:line numbers."
3. GitHub Actions: Auto-Review on PR Open
Add to .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
with:
fetch-depth: 0
- name: Get changed files
id: diff
run: |
git diff origin/main...HEAD > /tmp/pr.diff
echo "files=$(git diff --name-only origin/main...HEAD | tr '\n' ',')" >> $GITHUB_OUTPUT
- name: Run Claude Code Review
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: |
pip install anthropic
python .github/scripts/claude_review.py /tmp/pr.diff
- name: Comment review on PR
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const review = fs.readFileSync('/tmp/review.md', 'utf8');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: review
});
4. Merge Conflict Resolution
When you hit merge conflicts:
I have a merge conflict. Here's the conflicted section:
<<<<<<< HEAD
[your version]
=======
[their version]
>>>>>>> feature/other-branch
Context: both branches added user profile functionality but took
different approaches. The HEAD version uses the UserProfile class,
the other branch used a plain object. We want to keep the class approach.
Providing context about why both versions exist leads to much better resolution.
5. PR Review Response
When reviewers leave comments:
A reviewer left this comment on my PR:
"This query will cause N+1 problems when the user list grows. Consider
using a join or eager loading."
Here's the code they're referring to:
[paste the code]
How should I fix this? Write the corrected version.
6. Release Notes Generation
Generate release notes for version 2.3.0.
PRs merged since 2.2.0:
[paste list of PR titles and descriptions]
Format: user-facing changelog. No internal/refactoring entries.
Group by: Features / Bug Fixes / Breaking Changes.
CLAUDE.md for PR Workflows
## PR Workflow
### Before Opening a PR
1. Run /code-review on changed files
2. Check test coverage hasn't dropped
3. Update CHANGELOG.md if user-facing change
4. Verify .env.example is updated if new env vars added
### PR Description Template
- Problem: what issue this solves
- Solution: approach taken
- Testing: how you verified it works
- Breaking changes: none / describe impact
/code-review for pre-PR review is in Code Review Pack (¥980) on PromptWorks.
Myouga (@myougatheaxo) — Security-focused Claude Code engineer.
Top comments (0)