mirror of
https://github.com/pacnpal/Claude-code-review.git
synced 2025-12-19 20:01:05 -05:00
183d49dd6a87b66937cb8988f10b0e614ca1e271
Major improvements: - Add comprehensive logging with @actions/core (info, warning, error, debug) - Implement retry logic with exponential backoff for all network operations - Add timeout handling for API calls (2 minute default) - Improve error handling with specific messages and context - Add input validation for API keys and PR numbers - Implement rate limit handling (429 responses) - Add diff size limits to prevent API token overflow - Fix flawed markdown escape logic in review posting - Add progress indicators with core.startGroup/endGroup - Mask sensitive data (API keys) in logs - Add unhandled rejection and exception handlers - Improve git operation error handling and output capture - Add JSDoc comments for all functions - Fix npm security vulnerabilities The action is now much more resilient to: - Network failures and transient errors - API rate limiting - Large diffs - Timeout issues - Invalid inputs Logging improvements provide better visibility into: - Operation progress and timing - Retry attempts - Error context and debugging information - Resource usage (diff size, review length)
Claude Code Review Action
A GitHub Action that performs automated code reviews using Claude Sonnet 3.5, an AI assistant from Anthropic.
Features
- 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
Usage
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
environment: development_environment
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run Claude Review
uses: pacnpal/claude-code-review@main
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"
Setup
- Create repository secret
ANTHROPIC_API_KEYwith your Claude API key from Anthropic - The
GITHUB_TOKENis automatically provided by GitHub Actions
Inputs
| 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 |
Outputs
| Output | Description |
|---|---|
diff_size |
Size of the relevant code changes |
review |
Generated code review content |
Review Format
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
Example Review
# 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
Development
- Clone the repository
- Install dependencies:
npm install
-
Make changes to
action.js -
Build the action:
npm run build
- Run tests:
npm test
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests
- Submit a pull request
License
MIT License - see the LICENSE file for details
Support
- Open an issue for bugs/feature requests
- Submit a PR to contribute
- Contact maintainers for other questions
Languages
JavaScript
100%