Skip to content

Claude Code

Claude Code #25

Workflow file for this run

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: ubuntu-latest
permissions:
contents: write
pull-requests: write
issues: write
id-token: write
actions: read # Required for Claude to read CI results on PRs
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 1
- name: PR Review with Progress Tracking
uses: anthropics/claude-code-action@v1
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
# Enable progress tracking
track_progress: true
# Your custom review instructions
prompt: |
REPO: ${{ github.repository }}
PR NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }}
Review this pull request and provide inline feedback using the GitHub review system. Follow these steps:
1. Start a review: Use `mcp__github__create_pending_pull_request_review` to start a pending review.
2. Get diff information: Use `mcp__github__get_pull_request_diff` to see the code changes and line numbers.
- If the pull request has many changes, paginate the diff using the `page` and `per_page` parameters.
- Example: To get the first 100 lines, call `mcp__github__get_pull_request_diff` with `per_page=100` and `page=1`. For the next 100 lines, use `page=2`, and so on.
- Continue fetching pages until all changes are retrieved.
3. Add inline comments: Use `mcp__github__add_comment_to_pending_review` to provide feedback on specific lines of code snippets.
- **When suggesting code changes, format them as GitHub suggestion blocks so they can be committed directly:**
- For single-line suggestions, use:
```suggestion
suggested code here
```
- For multi-line suggestions, use:
```suggestion:-0+1
suggested code here
```
(Adjust the numbers to match how many lines to remove and add)
- Only provide suggestion blocks when you have a concrete, actionable fix
- Include explanation text before or after the suggestion block
4. Submit for review: Use `mcp__github__submit_pending_pull_request_review` with the event type set to "COMMENT" (not "REQUEST_CHANGES") to publish all comments for non-blocking review.
Focus on the following focus areas:
1. **Code Quality**
- Clean code principles and best practices
- Proper error handling and edge cases
- Code readability and maintainability
- **Provide suggestion blocks for improvements when possible**
2. **Security**
- Check for potential security vulnerabilities
- Validate input sanitization
- Review authentication/authorization logic
- **Suggest secure alternatives with suggestion blocks**
3. **Performance**
- Identify potential performance bottlenecks
- Review database queries for efficiency
- Check for memory leaks or resource issues
- **Offer optimized code via suggestion blocks**
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
Provide detailed feedback using inline comments for specific issues.
Use suggestion blocks liberally to make it easy for developers to apply fixes.
Use top-level comments for general observations or praise.
# Tools for comprehensive PR review
claude_args: |
--allowedTools "mcp__github__get_pull_request,mcp__github__create_pending_pull_request_review,mcp__github__add_comment_to_pending_review,mcp__github__submit_pending_pull_request_review,mcp__github__get_pull_request_diff"
# When track_progress is enabled:
# - Creates a tracking comment with progress checkboxes
# - Includes all PR context (comments, attachments, images)
# - Updates progress as the review proceeds
# - Marks as completed when done