From 7fe225703aae3f72967f41e1183678c439c8c240 Mon Sep 17 00:00:00 2001 From: Ravali Namburi Date: Thu, 19 Feb 2026 11:04:27 +0530 Subject: [PATCH] chore: claude workflows Signed-off-by: Ravali Namburi --- .github/workflows/claude.yml | 53 +++++++++++++ .github/workflows/code-review.yml | 124 ++++++++++++++++++++++++++++++ 2 files changed, 177 insertions(+) create mode 100644 .github/workflows/claude.yml create mode 100644 .github/workflows/code-review.yml diff --git a/.github/workflows/claude.yml b/.github/workflows/claude.yml new file mode 100644 index 0000000..44fb1ac --- /dev/null +++ b/.github/workflows/claude.yml @@ -0,0 +1,53 @@ +# GitHub Action: Claude Code Review +# Feature: 023-code-review-action +# Purpose: Automated code review using Claude on pull requests + +name: Claude Code + +on: + issue_comment: + types: [created] + pull_request_review_comment: + types: [created] + issues: + types: [opened, assigned] + pull_request_review: + types: [submitted] + +jobs: + claude: + if: | + (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) || + (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) || + (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) || + (github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude'))) + runs-on: arc-runner-set + permissions: + contents: write # Read repository files and create commits when requested + pull-requests: write # Post PR comments + issues: write # Comment on issues (@claude mentions) + id-token: write # OIDC authentication (Bedrock/Vertex/Foundry) + actions: read # Required for Claude to read CI results on PRs + steps: + - name: Checkout repository + uses: actions/checkout@v5 + with: + fetch-depth: 10 # Non-shallow clone to account for multiple commits for the same PR + + - name: Respond to comments addressing @claude + uses: qcom-eng-qswat/claude-code-action@v1.0.30 + id: claude + env: + ANTHROPIC_BASE_URL: ${{ vars.ANTHROPIC_BASE_URL }} + ANTHROPIC_AUTH_TOKEN: ${{ secrets.ANTHROPIC_API_KEY }} + ANTHROPIC_DEFAULT_HAIKU_MODEL: ${{ vars.ANTHROPIC_DEFAULT_HAIKU_MODEL }} + ANTHROPIC_DEFAULT_SONNET_MODEL: ${{ vars.ANTHROPIC_DEFAULT_SONNET_MODEL }} + ANTHROPIC_DEFAULT_OPUS_MODEL: ${{ vars.ANTHROPIC_DEFAULT_OPUS_MODEL }} + with: + # This is necessary for GitHub MCP server + github_token: ${{ secrets.GITHUB_TOKEN }} + # Authentication (required) + anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} + # Tool restrictions (security) + claude_args: | + --allowedTools "mcp__github_inline_comment__create_inline_comment,Edit,MultiEdit,Write,Read,Glob,Grep,LS,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(bun:*),Bash(npx:*),Bash(npm:*)" diff --git a/.github/workflows/code-review.yml b/.github/workflows/code-review.yml new file mode 100644 index 0000000..fe3e43c --- /dev/null +++ b/.github/workflows/code-review.yml @@ -0,0 +1,124 @@ +# GitHub Action: Claude Code Review +# Feature: 023-code-review-action +# Purpose: Automated code review using Claude on pull requests + +name: Claude Code Review + +on: + pull_request: + types: [opened, synchronize, ready_for_review, reopened] + +jobs: + review: + runs-on: arc-runner-set + permissions: + contents: read # Read repository files + pull-requests: write # Post PR comments + issues: write # Comment on issues (@claude mentions) + id-token: write # OIDC authentication (Bedrock/Vertex/Foundry) + actions: read + steps: + - name: Checkout repository + uses: actions/checkout@v5 + with: + fetch-depth: 10 # Non-shallow clone to account for multiple commits for the same PR + + - name: Run Claude Code Review + id: claude + uses: qcom-eng-qswat/claude-code-action@v1.0.30 + env: + ANTHROPIC_BASE_URL: ${{ vars.ANTHROPIC_BASE_URL }} + ANTHROPIC_DEFAULT_HAIKU_MODEL: ${{ vars.ANTHROPIC_DEFAULT_HAIKU_MODEL }} + ANTHROPIC_DEFAULT_SONNET_MODEL: ${{ vars.ANTHROPIC_DEFAULT_SONNET_MODEL }} + ANTHROPIC_DEFAULT_OPUS_MODEL: ${{ vars.ANTHROPIC_DEFAULT_OPUS_MODEL }} + with: + # This is necessary for GitHub MCP server + github_token: ${{ secrets.GITHUB_TOKEN }} + # Authentication (required) + anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} + + # Custom prompt (recommended) + prompt: | + REPO: ${{ github.repository }} + PR NUMBER: ${{ github.event.pull_request.number }} + + ## IMPORTANT: Avoid Duplicate Comments + + Before posting ANY comment, you MUST check for existing review comments to avoid duplicates: + + 1. **Fetch existing PR comments first**: + ```bash + gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/comments + ``` + This returns all inline review comments on the PR. + + 2. **Fetch existing issue comments**: + ```bash + gh api repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments + ``` + This returns all top-level PR comments. + + 3. **Before posting each comment**: + - Check if a comment with substantially similar content already exists + - Check if a comment on the same file and line already exists addressing the same issue + - If a similar comment exists, DO NOT post a duplicate + - Only post NEW issues not already covered by existing comments + + 4. **Comment deduplication rules**: + - Same file + same line + same issue type = DUPLICATE (skip) + - Same general feedback already in top-level comment = DUPLICATE (skip) + - New issue on a line with existing comment = OK to add if different concern + - Issue on newly added code not previously reviewed = OK to add + + ## Code Review Focus Areas + + 1. **Code Quality** + - Clean code principles and best practices + - Proper error handling and edge cases + - Code readability and maintainability + + 2. **Security** + - Check for potential security vulnerabilities + - Validate input sanitization + - Review authentication/authorization logic + + 3. **Performance** + - Identify potential performance bottlenecks + - Review database queries for efficiency + - Check for memory leaks or resource issues + + 4. **Testing** + - Verify adequate test coverage + - Review test quality and edge cases + - Check for missing test scenarios + + 5. **Documentation** + - Ensure code is properly documented + - Verify README updates for new features + - Check API documentation accuracy + + ## Output Instructions + + Provide detailed feedback using inline comments for specific issues. + Use top-level comments for general observations or praise. + + Note: The PR branch is already checked out in the current working directory. + + Use `gh pr comment` for top-level feedback. + Use `mcp__github_inline_comment__create_inline_comment` to highlight specific code issues. + Only post GitHub comments - don't submit review text as messages. + + # Tool restrictions (security) + claude_args: | + --allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh api:*),Read" + + # Optional features (uncomment to enable) + track_progress: true # Enable visual progress tracking + # include_fix_links: true # Add "Fix this" links (default: true) + # use_sticky_comment: false # Single comment for all feedback + # trigger_phrase: "@claude" # Customize mention trigger + + # Optional: Advanced configuration + # claude_args: | + # --max-turns 10 # Limit conversation length + # --timeout 300000 # 5 minutes timeout