Skip to content

Commit e81d65e

Browse files
authored
Update AI code-review prompt
1 parent 41c9e3e commit e81d65e

1 file changed

Lines changed: 28 additions & 21 deletions

File tree

.github/workflows/ai-code-review.yml

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,40 +23,48 @@ jobs:
2323
uses: actions/checkout@v4
2424
with:
2525
fetch-depth: 1
26-
- name: Dismiss old Claude bot comments
26+
- name: Find existing Claude bot comment
27+
id: find-comment
2728
env:
2829
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2930
run: |
30-
# Get PR comments from claude[bot] and hide them as outdated
31+
# Get the ID of the first claude[bot] comment on this PR (if any)
3132
REPO="${{ github.repository }}"
3233
PR_NUMBER="${{ github.event.pull_request.number }}"
3334
34-
# Get review comments (PR review comments)
35-
gh api "repos/$REPO/issues/$PR_NUMBER/comments" --jq '.[] | select(.user.login == "claude[bot]") | .node_id' | while read -r comment_node_id; do
36-
if [ -n "$comment_node_id" ]; then
37-
echo "Hiding review comment: $comment_node_id"
38-
gh api graphql -f query='
39-
mutation($id: ID!) {
40-
minimizeComment(input: {subjectId: $id, classifier: OUTDATED}) {
41-
minimizedComment {
42-
isMinimized
43-
}
44-
}
45-
}' -f id="$comment_node_id"
46-
fi
47-
done
35+
COMMENT_ID=$(gh api "repos/$REPO/issues/$PR_NUMBER/comments" --jq '[.[] | select(.user.login == "claude[bot]")] | first | .id // empty')
36+
37+
if [ -n "$COMMENT_ID" ]; then
38+
echo "Found existing comment: $COMMENT_ID"
39+
echo "comment_id=$COMMENT_ID" >> $GITHUB_OUTPUT
40+
else
41+
echo "No existing comment found"
42+
echo "comment_id=" >> $GITHUB_OUTPUT
43+
fi
4844
- name: Review code
4945
uses: anthropics/claude-code-action@v1
5046
with:
5147
claude_code_oauth_token: ${{ secrets.CLAUDE_OAUTH_TOKEN }}
5248
prompt: |
5349
REPO: ${{ github.repository }}
5450
PR NUMBER: ${{ github.event.pull_request.number }}
51+
EXISTING_COMMENT_ID: ${{ steps.find-comment.outputs.comment_id }}
5552
5653
Review this pull request and provide feedback.
57-
Post your feedback as a PR comment using `gh pr comment`.
5854
59-
When reviewing code, leave a general summary of the changes at the top of your comment and then evaluate the following areas:
55+
If EXISTING_COMMENT_ID is set, update that comment using:
56+
gh api repos/${{ github.repository }}/issues/comments/${{ steps.find-comment.outputs.comment_id }} -X PATCH -f body="<your review>"
57+
Otherwise, create a new comment using:
58+
gh pr comment ${{ github.event.pull_request.number }} --body "<your review>"
59+
60+
IMPORTANT GUIDELINES:
61+
- Be direct and concise. Only mention issues that need attention.
62+
- Start with a brief 1-2 sentence summary of the changes for other reviewers.
63+
- Do NOT compliment the author or praise the code.
64+
- If there are no significant issues, just say "No issues found." and nothing else.
65+
- Focus only on actionable feedback.
66+
67+
Evaluate the following areas (only mention if there are issues):
6068
6169
### Architecture & Design
6270
@@ -92,6 +100,5 @@ jobs:
92100
- Caching opportunities: Could frequently-accessed, rarely-changed data benefit from caching?
93101
- Bulk operations: Are there loops doing individual saves that could use `bulk_create()` or `bulk_update()`?
94102
95-
Use the repository's CLAUDE.md for guidance on style and conventions.
96-
Be constructive, helpful, concise and to the point in your feedback.
97-
claude_args: '--allowed-tools "Bash(gh issue view:*),Bash(gh search:*),Bash(gh issue list:*),Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr list:*)"'
103+
Use the repository's CLAUDE.md for guidance on style and conventions.
104+
claude_args: '--allowed-tools "Bash(gh api:*),Bash(gh issue view:*),Bash(gh search:*),Bash(gh issue list:*),Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr list:*)"'

0 commit comments

Comments
 (0)