mirror of
https://github.com/pacnpal/Claude-code-review.git
synced 2025-12-20 04:11:04 -05:00
Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d1c6a98994 | ||
|
|
e6777037d5 | ||
|
|
c6c00d8c95 | ||
|
|
45e3331bcb | ||
|
|
dd1b18e57a | ||
|
|
1b84aff159 | ||
|
|
5fb151d172 | ||
|
|
4e1bd4b9e5 | ||
|
|
7276f1e2c5 | ||
|
|
2c57b7a5ba | ||
|
|
096a52cda5 | ||
|
|
0356960aa8 | ||
|
|
a5bd0e4bcf | ||
|
|
e49cf9d908 | ||
|
|
a4b8566177 | ||
|
|
fc5d87701c | ||
|
|
eb556a6d23 | ||
|
|
7e5914e90c | ||
|
|
6c6cbaba84 | ||
|
|
9f9953664f | ||
|
|
ada4f6b4ed | ||
|
|
a5a4083f00 | ||
|
|
782f8cccd0 | ||
|
|
6a73dbfff6 | ||
|
|
52219d4d98 | ||
|
|
c555f5511a | ||
|
|
bd3279eb92 |
8
.github/workflows/release.yml
vendored
8
.github/workflows/release.yml
vendored
@@ -25,6 +25,14 @@ jobs:
|
||||
- name: Build
|
||||
run: npm run build
|
||||
|
||||
- name: Commit built files
|
||||
run: |
|
||||
git config --global user.name 'github-actions[bot]'
|
||||
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
|
||||
git add -f dist
|
||||
git commit -m 'Add built files'
|
||||
git push origin HEAD:main
|
||||
|
||||
- name: Create Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
|
||||
31
README.md
31
README.md
@@ -1,6 +1,6 @@
|
||||
# Claude Code Review Action
|
||||
|
||||
A GitHub Action that performs automated code reviews using Claude AI.
|
||||
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
|
||||
@@ -13,29 +13,44 @@ A GitHub Action that performs automated code reviews using Claude AI.
|
||||
Add this to your GitHub workflow file (e.g. `.github/workflows/review.yml`):
|
||||
|
||||
```yaml
|
||||
name: Code Review
|
||||
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:
|
||||
review:
|
||||
code-review:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
environment: development_environment
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- uses: your-username/claude-code-review-action@v1
|
||||
- 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 }}
|
||||
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
|
||||
|
||||
|
||||
27
action.js
27
action.js
@@ -48,26 +48,7 @@ async function getDiff(baseSha, headSha) {
|
||||
}
|
||||
});
|
||||
|
||||
// Filter for relevant files
|
||||
const lines = diffContent.split('\n');
|
||||
let filtered = '';
|
||||
let keep = false;
|
||||
|
||||
for (const line of lines) {
|
||||
if (line.startsWith('diff --git')) {
|
||||
keep = false;
|
||||
// Check if file type should be included
|
||||
if (line.match(/\.(js|ts|py|cpp|h|java|cs)$/) &&
|
||||
!line.match(/(package-lock\.json|yarn\.lock|\.md|\.json)/)) {
|
||||
keep = true;
|
||||
}
|
||||
}
|
||||
if (keep) {
|
||||
filtered += line + '\n';
|
||||
}
|
||||
}
|
||||
|
||||
return filtered;
|
||||
return diffContent;
|
||||
} catch (error) {
|
||||
throw new Error(`Failed to generate diff: ${error.message}`);
|
||||
}
|
||||
@@ -94,7 +75,9 @@ For each issue found:
|
||||
- Provide specific recommendations for fixes
|
||||
- Include code examples where helpful
|
||||
|
||||
If no issues are found in a particular area, explicitly state that.
|
||||
- If no issues are found in a particular area, explicitly state that.
|
||||
- If it's a dependency update, evaluate with strict scrutiny the implications of the change.
|
||||
- No matter your findings, give a summary of the pull request.
|
||||
|
||||
Here is the code diff to review:
|
||||
|
||||
@@ -111,7 +94,7 @@ ${diffContent}
|
||||
'anthropic-version': '2023-06-01'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
model: 'claude-3-sonnet-20240229',
|
||||
model: 'claude-3-5-sonnet-20241022',
|
||||
max_tokens: 4096,
|
||||
temperature: 0.7,
|
||||
messages: [{
|
||||
|
||||
@@ -18,4 +18,4 @@ outputs:
|
||||
description: 'Generated code review'
|
||||
runs:
|
||||
using: 'node20'
|
||||
main: 'action.js'
|
||||
main: 'dist/index.js'
|
||||
32046
dist/index.js
vendored
Normal file
32046
dist/index.js
vendored
Normal file
File diff suppressed because one or more lines are too long
4
package-lock.json
generated
4
package-lock.json
generated
@@ -3241,7 +3241,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/undici": {
|
||||
"version": "5.28.4",
|
||||
"version": "5.28.5",
|
||||
"resolved": "https://registry.npmjs.org/undici/-/undici-5.28.5.tgz",
|
||||
"integrity": "sha512-zICwjrDrcrUE0pyyJc1I2QzBkLM8FINsgOrt6WjA+BgajVq9Nxu2PbFFXUrAggLfDXlZGZBVZYw7WNV5KiBiBA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@fastify/busboy": "^2.0.0"
|
||||
|
||||
Reference in New Issue
Block a user