Skip to content

Test: GitHub App Integration Verification #1388

Test: GitHub App Integration Verification

Test: GitHub App Integration Verification #1388

# Claude Code Review with Fork Support
#
# Manual @claude reviews only - automatic reviews now handled by amber-auto-review.yml
# Uses default workflow token for GitHub operations (comments appear from github-actions[bot])
# Supports fork PRs and automatically minimizes old review comments
#
# Required GitHub Secret:
# - CLAUDE_CODE_OAUTH_TOKEN: OAuth token for Claude Code
name: Claude Code Review
on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
jobs:
claude-review:
# Only run when @claude is mentioned
if: |
contains(github.event.comment.body, '@claude')
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
issues: write
id-token: write
actions: read
steps:
- name: Checkout PR head
uses: actions/checkout@v5
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
- name: Minimize old Claude review comments
continue-on-error: true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
REPO="${{ github.repository }}"
PR_NUMBER="${{ github.event.pull_request.number }}"
echo "Finding previous Claude Code Review comments to minimize..."
# Get all comment IDs from github-actions[bot] with "Claude Code Review" at the start
# Using startswith() to avoid matching code blocks or inline mentions
COMMENT_IDS=$(gh api "repos/$REPO/issues/$PR_NUMBER/comments" \
--jq '.[] | select(.user.login == "github-actions[bot]" and (.body | startswith("# Claude Code Review"))) | .node_id')
if [ -z "$COMMENT_IDS" ]; then
echo "No old Claude Code Review comments found"
exit 0
fi
# Minimize each comment with error handling
# Use here-string to avoid subshell variable scoping issues with pipe
COUNT=0
ERRORS=0
while read -r id; do
if [ -n "$id" ]; then
if gh api graphql -f query='mutation($id: ID!) { minimizeComment(input: {subjectId: $id, classifier: OUTDATED}) { minimizedComment { isMinimized } } }' -f id="$id" 2>&1; then
echo "✓ Minimized $id"
((COUNT++))
else
echo "✗ Failed to minimize $id" >&2
((ERRORS++))
fi
fi
done <<< "$COMMENT_IDS"
echo "Minimized $COUNT comment(s), $ERRORS error(s)"
- name: Run Claude Code Review
id: claude-review
uses: anthropics/claude-code-action@v1
with:
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
allowed_non_write_users: '*'
claude_args: |
--allowedTools "Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh issue list:*)"
prompt: |
REPO: ${{ github.repository }}
PR NUMBER: ${{ github.event.pull_request.number }}
Perform a comprehensive code review with the following focus areas:
1. **Code Quality & Best Practices**
- Follow repository's CLAUDE.md guidelines
- Clean code principles and design patterns
- Proper error handling and edge cases
- Code readability and maintainability
- TypeScript/Go best practices (see CLAUDE.md)
2. **Security**
- Potential security vulnerabilities
- Input validation and sanitization
- Authentication/authorization logic
- Sensitive data handling
- API security concerns
3. **Performance**
- Performance bottlenecks
- Database query efficiency
- Memory leaks or resource issues
- React rendering optimizations
- API response times
4. **Testing**
- Test coverage adequacy
- Test quality and edge cases
- Missing test scenarios
- Integration test needs
5. **Architecture & Design**
- Component structure and organization
- API design and contracts
- State management patterns
- Separation of concerns
6. **Documentation**
- Code comments and clarity
- README updates for new features
- API documentation accuracy
- Type definitions completeness
---
**Review Instructions:**
- Use `gh pr comment` for the review comment with this format:
# Claude Code Review
## Summary
[Brief overview and overall assessment]
## Issues by Severity
Categorize findings by severity (omit empty sections):
### 🚫 Blocker Issues
[Must fix before merge - security vulnerabilities, breaking changes, data loss risks]
### 🔴 Critical Issues
[Should fix before merge - major bugs, performance issues, significant security concerns]
### 🟡 Major Issues
[Important to address - code quality, maintainability, test coverage gaps]
### 🔵 Minor Issues
[Nice-to-have - style, minor optimizations, documentation]
## Positive Highlights
[Things done well]
## Recommendations
[Prioritized action items]
Focus on substance. Be constructive and specific.
- name: Add workflow link to review
if: steps.claude-review.conclusion == 'success'
uses: actions/github-script@v8
env:
RUN_ID: ${{ github.run_id }}
GITHUB_SERVER_URL: ${{ github.server_url }}
GITHUB_REPOSITORY: ${{ github.repository }}
with:
script: |
const prNumber = context.payload.pull_request.number;
const runId = process.env.RUN_ID;
const serverUrl = process.env.GITHUB_SERVER_URL;
const repository = process.env.GITHUB_REPOSITORY;
// Find Claude Code Review comment
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber
});
const reviewComment = comments.data
.filter(c => c.user.login === 'github-actions[bot]' && c.body.startsWith('# Claude Code Review'))
.sort((a, b) => new Date(b.created_at) - new Date(a.created_at))[0];
if (!reviewComment || reviewComment.body.includes('View AI decision process')) {
console.log('No review comment found or already has workflow link');
return;
}
const updatedBody = reviewComment.body + `\n\n---\n🔍 [View AI decision process](${serverUrl}/${repository}/actions/runs/${runId}) (logs available for 90 days)`;
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: reviewComment.id,
body: updatedBody
});