A GitHub Action that performs automated code reviews using Claude AI.
- Analyzes code changes in pull requests
- Provides detailed feedback on code quality
- Identifies potential issues and suggests improvements
- Checks for security issues and best practices
Add this to your GitHub workflow file (e.g. .github/workflows/review.yml
):
name: Claude Code Review
permissions:
contents: read
pull-requests: write
on:
# Run on new/updated PRs
pull_request:
types: [opened, reopened, synchronize]
# Allow manual triggers for existing PRs
workflow_dispatch:
inputs:
pr_number:
description: 'Pull Request Number'
required: true
type: string
jobs:
code-review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run Claude Review
uses: pacnpal/claude-code-review@v1.0.7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
anthropic-key: ${{ secrets.ANTHROPIC_API_KEY }}
pr-number: ${{ github.event.pull_request.number || inputs.pr_number }}
- Click on "Claude Code Review" Action under Actions tab.
- Click "Run Workflow"
- Fill in branch and pull request ID and click "Run Workflow"
- Create repository secret
ANTHROPIC_API_KEY
with your Claude API key from Anthropic - The
GITHUB_TOKEN
is automatically provided by GitHub Actions
Input | Description | Required | Default |
---|---|---|---|
github-token |
GitHub token for API access | Yes | N/A |
anthropic-key |
Anthropic API key for Claude | Yes | N/A |
pr-number |
Pull request number to review | Yes | N/A |
Output | Description |
---|---|
diff_size |
Size of the relevant code changes |
review |
Generated code review content |
The action provides detailed code reviews covering:
- Potential conflicts with existing codebase
- Code correctness and potential bugs
- Security vulnerabilities and risks
- Performance implications
- Maintainability and readability issues
- Adherence to best practices
- Suggestions for improvements
Each issue found includes:
- Clear problem explanation
- Severity rating (Critical/High/Medium/Low)
- Specific recommendations
- Code examples where helpful
# Claude Code Review
1. **Potential conflicts with existing codebase**:
- No apparent conflicts identified
2. **Code correctness and potential bugs**:
- **Medium Severity**: Potential null pointer in user handling
- Recommendation: Add null check before accessing user object
3. **Security vulnerabilities and risks**:
- **High Severity**: SQL injection vulnerability in query construction
- Recommendation: Use parameterized queries
- Clone the repository
- Install dependencies:
npm install
-
Make changes to
action.js
-
Build the action:
npm run build
- Run tests:
npm test
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests
- Submit a pull request
MIT License - see the LICENSE file for details
- Open an issue for bugs/feature requests
- Submit a PR to contribute
- Contact maintainers for other questions