Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 22 additions & 18 deletions .github/workflows/claude.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,33 +69,37 @@ jobs:
# Count non-empty lines
count=0
if [ -n "$ids" ]; then
count=$(echo "$ids" | grep -c '^')
count=$(echo "$ids" | wc -l)
fi
echo "Found $count Claude comments to delete"

echo "$ids" | while read -r id; do
[ -n "$id" ] && {
echo "Removing issues/comments/ ID: $id"
if ! gh api --method DELETE "/repos/$REPO/issues/comments/$id" --silent; then
echo "Warning: Failed to delete comment ID: $id" >&2
fi
}
done
if [ -n "$ids" ]; then
echo "$ids" | while read -r id; do
[ -n "$id" ] && {
echo "Removing issues/comments/ ID: $id"
if ! gh api --method DELETE "/repos/$REPO/issues/comments/$id" --silent; then
echo "Warning: Failed to delete comment ID: $id" >&2
fi
}
done
fi

count2=0
if [ -n "$ids2" ]; then
count2=$(echo "$ids2" | grep -c '^')
count2=$(echo "$ids2" | wc -l)
fi
echo "Found $count2 Claude comments to delete"

echo "$ids2" | while read -r id; do
[ -n "$id" ] && {
echo "Removing pulls/comments/ ID: $id"
if ! gh api --method DELETE "/repos/$REPO/pulls/comments/$id" --silent; then
echo "Warning: Failed to delete comment ID: $id" >&2
fi
}
done
if [ -n "$ids2" ]; then
echo "$ids2" | while read -r id; do
[ -n "$id" ] && {
echo "Removing pulls/comments/ ID: $id"
if ! gh api --method DELETE "/repos/$REPO/pulls/comments/$id" --silent; then
echo "Warning: Failed to delete comment ID: $id" >&2
fi
}
done
fi

echo "Script completed successfully"
exit 0
Expand Down
91 changes: 91 additions & 0 deletions .github/workflows/on_pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: On Pull Request
on:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

env:
NODE_VERSION: 22

jobs:
code_review:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
issues: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Authenticate GitHub CLI
run: gh auth setup-git
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Find existing Claude comment
id: find_comment
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.number }}
REPO: ${{ github.repository }}
run: |
echo "Finding existing Claude comment on PR $PR_NUMBER in $REPO"
comment_id=$(gh api "/repos/$REPO/issues/$PR_NUMBER/comments" --jq '.[] | select(.user.login | test("claude"; "i")) | .id' | head -1)
if [ -n "$comment_id" ]; then
echo "Found existing Claude comment with ID: $comment_id"
echo "comment_id=$comment_id" >> $GITHUB_OUTPUT
else
echo "No existing Claude comment found"
echo "comment_id=" >> $GITHUB_OUTPUT
fi

- name: Run Claude Code
id: claude
uses: valorkin/claude-code-action@feat-limit-amount-of-claude-comments
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
model: claude-sonnet-4-20250514
comments_max: 2
allowed_tools: 'mcp__github__get_pull_request_diff,mcp__github__create_issue_comment,mcp__github__update_issue_comment'
comment_id: ${{ steps.find_comment.outputs.comment_id }}
direct_prompt: |
You are a senior product engineer.
Please provide a thorough review of this pull request.
Pay extra attention to coding standards, security practices,
test coverage, readability, maintainability, and performance.

Focus on:
- Correctness & hidden bugs (edge cases, race conditions, off-by-one, etc.)
- Performance hot-spots (Big-O, memory, DB queries, async misuse)
- Security implications and vulnerabilities (injection, XSS, secrets exposure)
- Readability & maintainability (naming, duplication, comments)
- Test coverage gaps (suggest unit/integration tests)
- Code quality and best practices
- Potential bugs or issues
- Performance considerations
- Documentation updates if needed
- Architecture and design decisions

Reply with:
- *One-sentence purpose summary* of the changes.
- A **table** with columns **Severity (Critical/High/Medium/Low)**, **File/Line(s)**, **Issue**, **Recommendation**.
- Concrete code samples for any non-trivial fix.
- An overall quality score **/10** and the top 3 next steps.

Provide constructive feedback with specific suggestions for improvement.
Use <details> and <summary> md tags to show summary in comment and view details on click.

Please review this PR and provide feedback as a single PR comment. Follow these steps:

1. **Get diff information**: Use `mcp__github__get_pull_request_diff` to understand the code changes and line numbers
2. **Create or update comment**:
- If a comment_id is provided, use `mcp__github__update_issue_comment` to update the existing comment
- If no comment_id is provided, use `mcp__github__create_issue_comment` to create a new comment

Provide a comprehensive review in a single comment that covers all the important aspects of the PR. Include file paths and line numbers in your feedback table for easy reference.
Loading