diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml index ab07e492..deeefd50 100644 --- a/.github/workflows/claude-code-review.yml +++ b/.github/workflows/claude-code-review.yml @@ -12,11 +12,8 @@ on: jobs: claude-review: - # Optional: Filter by PR author - # if: | - # github.event.pull_request.user.login == 'external-contributor' || - # github.event.pull_request.user.login == 'new-developer' || - # github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' + # Skip review for automated "Version Packages" PRs created by changesets + if: github.event.pull_request.title != 'Version Packages' runs-on: ubuntu-latest permissions: @@ -37,21 +34,34 @@ jobs: with: anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} prompt: | - REPO: ${{ github.repository }} - PR NUMBER: ${{ github.event.pull_request.number }} + Review PR #${{ github.event.pull_request.number }}. - Please review this pull request and provide feedback on: - - Code quality and best practices - - Potential bugs or issues - - Performance considerations - - Security concerns - - Test coverage + Read CLAUDE.md for project conventions and architecture patterns. Focus on substantive issues: + - Code quality, potential bugs, architecture alignment + - Testing coverage - Use the repository's CLAUDE.md for guidance on style and conventions. Be constructive and helpful in your feedback. + BE CONCISE. Only report actual issues worth addressing - skip generic praise and obvious observations. + If the PR looks good, just say so briefly. - Use `gh pr comment` with your Bash tool to leave your review as a comment on the PR. + **Posting your review:** + 1. First, check if you've already posted a review comment on this PR (find the comment ID): + ```bash + COMMENT_ID=$(gh api repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments --jq '.[] | select(.user.login == "claude[bot]" or .user.login == "github-actions[bot]") | select(.body | startswith("## Claude Code Review")) | .id' | head -1) + ``` + + 2. If COMMENT_ID exists (non-empty), UPDATE that comment: + ```bash + gh api repos/${{ github.repository }}/issues/comments/$COMMENT_ID -X PATCH -f body="YOUR_REVIEW_CONTENT_HERE" + ``` + + 3. If COMMENT_ID is empty, create a new comment: + ```bash + gh pr comment ${{ github.event.pull_request.number }} --body "YOUR_REVIEW_CONTENT_HERE" --repo ${{ github.repository }} + ``` + + Start your review with "## Claude Code Review" heading so it can be identified and updated on subsequent runs. # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md # or https://docs.claude.com/en/docs/claude-code/cli-reference for available options - 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:*)"' + 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:*),Bash(gh api:*)"' diff --git a/.github/workflows/claude.yml b/.github/workflows/claude.yml index 2b6c87da..f8188951 100644 --- a/.github/workflows/claude.yml +++ b/.github/workflows/claude.yml @@ -35,13 +35,21 @@ jobs: uses: anthropics/claude-code-action@v1 with: anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} + track_progress: true # This is an optional setting that allows Claude to read CI results on PRs additional_permissions: | actions: read - # Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it. - # prompt: 'Update the pull request description to include a summary of changes.' + # Custom prompt that ensures Claude reads CLAUDE.md first + prompt: | + REPO: ${{ github.repository }} + ISSUE/PR: #${{ github.event.issue.number || github.event.pull_request.number }} + + IMPORTANT: Before starting any work, read the CLAUDE.md file at the root of this repository. It contains critical project conventions, architecture patterns, and development guidelines that you must follow. + + After reading CLAUDE.md, proceed with the following task: + ${{ github.event.comment.body || github.event.issue.body || github.event.review.body }} # Optional: Add claude_args to customize behavior and configuration # See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md