Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/claude.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# GitHub Action: Claude Code Review
# Feature: 023-code-review-action
# Purpose: Automated code review using Claude on pull requests

name: Claude Code

on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
issues:
types: [opened, assigned]
pull_request_review:
types: [submitted]

jobs:
claude:
if: |
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
runs-on: arc-runner-set
permissions:
contents: write # Read repository files and create commits when requested
pull-requests: write # Post PR comments
issues: write # Comment on issues (@claude mentions)
id-token: write # OIDC authentication (Bedrock/Vertex/Foundry)
actions: read # Required for Claude to read CI results on PRs
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 10 # Non-shallow clone to account for multiple commits for the same PR

- name: Respond to comments addressing @claude
uses: qcom-eng-qswat/claude-code-action@v1.0.30
id: claude
env:
ANTHROPIC_BASE_URL: ${{ vars.ANTHROPIC_BASE_URL }}
ANTHROPIC_AUTH_TOKEN: ${{ secrets.ANTHROPIC_API_KEY }}
ANTHROPIC_DEFAULT_HAIKU_MODEL: ${{ vars.ANTHROPIC_DEFAULT_HAIKU_MODEL }}
ANTHROPIC_DEFAULT_SONNET_MODEL: ${{ vars.ANTHROPIC_DEFAULT_SONNET_MODEL }}
ANTHROPIC_DEFAULT_OPUS_MODEL: ${{ vars.ANTHROPIC_DEFAULT_OPUS_MODEL }}
with:
# This is necessary for GitHub MCP server
github_token: ${{ secrets.GITHUB_TOKEN }}
# Authentication (required)
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
# Tool restrictions (security)
claude_args: |
--allowedTools "mcp__github_inline_comment__create_inline_comment,Edit,MultiEdit,Write,Read,Glob,Grep,LS,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(bun:*),Bash(npx:*),Bash(npm:*)"
124 changes: 124 additions & 0 deletions .github/workflows/code-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# GitHub Action: Claude Code Review
# Feature: 023-code-review-action
# Purpose: Automated code review using Claude on pull requests

name: Claude Code Review

on:
pull_request:
types: [opened, synchronize, ready_for_review, reopened]

jobs:
review:
runs-on: arc-runner-set
permissions:
contents: read # Read repository files
pull-requests: write # Post PR comments
issues: write # Comment on issues (@claude mentions)
id-token: write # OIDC authentication (Bedrock/Vertex/Foundry)
actions: read
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 10 # Non-shallow clone to account for multiple commits for the same PR

- name: Run Claude Code Review
id: claude
uses: qcom-eng-qswat/claude-code-action@v1.0.30
env:
ANTHROPIC_BASE_URL: ${{ vars.ANTHROPIC_BASE_URL }}
ANTHROPIC_DEFAULT_HAIKU_MODEL: ${{ vars.ANTHROPIC_DEFAULT_HAIKU_MODEL }}
ANTHROPIC_DEFAULT_SONNET_MODEL: ${{ vars.ANTHROPIC_DEFAULT_SONNET_MODEL }}
ANTHROPIC_DEFAULT_OPUS_MODEL: ${{ vars.ANTHROPIC_DEFAULT_OPUS_MODEL }}
with:
# This is necessary for GitHub MCP server
github_token: ${{ secrets.GITHUB_TOKEN }}
# Authentication (required)
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}

# Custom prompt (recommended)
prompt: |
REPO: ${{ github.repository }}
PR NUMBER: ${{ github.event.pull_request.number }}

## IMPORTANT: Avoid Duplicate Comments

Before posting ANY comment, you MUST check for existing review comments to avoid duplicates:

1. **Fetch existing PR comments first**:
```bash
gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/comments
```
This returns all inline review comments on the PR.

2. **Fetch existing issue comments**:
```bash
gh api repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments
```
This returns all top-level PR comments.

3. **Before posting each comment**:
- Check if a comment with substantially similar content already exists
- Check if a comment on the same file and line already exists addressing the same issue
- If a similar comment exists, DO NOT post a duplicate
- Only post NEW issues not already covered by existing comments

4. **Comment deduplication rules**:
- Same file + same line + same issue type = DUPLICATE (skip)
- Same general feedback already in top-level comment = DUPLICATE (skip)
- New issue on a line with existing comment = OK to add if different concern
- Issue on newly added code not previously reviewed = OK to add

## Code Review Focus Areas

1. **Code Quality**
- Clean code principles and best practices
- Proper error handling and edge cases
- Code readability and maintainability

2. **Security**
- Check for potential security vulnerabilities
- Validate input sanitization
- Review authentication/authorization logic

3. **Performance**
- Identify potential performance bottlenecks
- Review database queries for efficiency
- Check for memory leaks or resource issues

4. **Testing**
- Verify adequate test coverage
- Review test quality and edge cases
- Check for missing test scenarios

5. **Documentation**
- Ensure code is properly documented
- Verify README updates for new features
- Check API documentation accuracy

## Output Instructions

Provide detailed feedback using inline comments for specific issues.
Use top-level comments for general observations or praise.

Note: The PR branch is already checked out in the current working directory.

Use `gh pr comment` for top-level feedback.
Use `mcp__github_inline_comment__create_inline_comment` to highlight specific code issues.
Only post GitHub comments - don't submit review text as messages.

# Tool restrictions (security)
claude_args: |
--allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh api:*),Read"

# Optional features (uncomment to enable)
track_progress: true # Enable visual progress tracking
# include_fix_links: true # Add "Fix this" links (default: true)
# use_sticky_comment: false # Single comment for all feedback
# trigger_phrase: "@claude" # Customize mention trigger

# Optional: Advanced configuration
# claude_args: |
# --max-turns 10 # Limit conversation length
# --timeout 300000 # 5 minutes timeout
Loading