From dfdcd65213f3b6217648d4a9df18f1168ab7e51c Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 21 Dec 2025 12:38:02 +0000 Subject: [PATCH] ci: add Claude code review GitHub Action - Add automated code review workflow that triggers on PRs - Support on-demand reviews via @claude mentions - Configure review to check code quality, architecture, testing, and performance - Add comprehensive setup documentation in docs/github-actions-setup.md - Review focuses on project-specific conventions from CLAUDE.md --- .github/workflows/claude-code-review.yml | 78 ++++++++++++++++++++++++ docs/github-actions-setup.md | 61 ++++++++++++++++++ 2 files changed, 139 insertions(+) create mode 100644 .github/workflows/claude-code-review.yml create mode 100644 docs/github-actions-setup.md diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml new file mode 100644 index 0000000..d58d1f5 --- /dev/null +++ b/.github/workflows/claude-code-review.yml @@ -0,0 +1,78 @@ +name: Claude Code Review + +on: + pull_request: + types: [opened, synchronize, reopened] + issue_comment: + types: [created] + +permissions: + contents: read + pull-requests: write + issues: write + +jobs: + code-review: + # Only run on PRs or when @claude is mentioned in a comment + if: | + github.event_name == 'pull_request' || + (github.event_name == 'issue_comment' && + github.event.issue.pull_request && + contains(github.event.comment.body, '@claude')) + runs-on: ubuntu-latest + timeout-minutes: 15 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.ref || github.event.pull_request.head.sha }} + + - name: Run Code Review with Claude + id: code-review + uses: anthropics/claude-code-base-action@beta + with: + prompt: | + Review the PR changes with focus on: + + ## Code Quality + - Check for bugs, edge cases, and potential runtime errors + - Verify proper error handling and validation + - Look for security vulnerabilities (XSS, injection, etc.) + - Ensure TypeScript types are properly defined + + ## Architecture & Best Practices + - Verify adherence to CLAUDE.md project conventions + - Check for proper use of singleton EventStore/RelayLiveness + - Ensure pure functions in src/core/logic.ts for state mutations + - Validate proper use of Applesauce reactive patterns + - Check for over-engineering or unnecessary complexity + + ## Testing + - Verify parsers and pure functions have tests + - Check that test descriptions are clear and meaningful + + ## Performance + - Look for potential performance issues + - Check for unnecessary re-renders or subscriptions + - Verify proper cleanup in useEffect hooks + + Write your review as constructive feedback in markdown format. + If changes look good, say so! Focus on significant issues. + allowed_tools: "Bash(git diff --name-only HEAD~1),Bash(git diff HEAD~1),Read,Glob,Grep" + anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} + + - name: Comment on PR + if: success() && github.event_name == 'pull_request' + uses: actions/github-script@v7 + with: + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: '## 🤖 Claude Code Review\n\n' + process.env.REVIEW_OUTPUT + }) + env: + REVIEW_OUTPUT: ${{ steps.code-review.outputs.result }} diff --git a/docs/github-actions-setup.md b/docs/github-actions-setup.md new file mode 100644 index 0000000..388c413 --- /dev/null +++ b/docs/github-actions-setup.md @@ -0,0 +1,61 @@ +# GitHub Actions Setup + +This document describes the GitHub Actions workflows configured for this repository. + +## Claude Code Review + +The repository is configured with automated code reviews powered by Claude AI. + +### How It Works + +The Claude Code Review action triggers: +- **Automatically** on all pull requests (opened, synchronized, or reopened) +- **On-demand** when you comment `@claude` on a pull request + +### Setup Requirements + +#### 1. Add Anthropic API Key + +You need to add your Anthropic API key as a repository secret: + +1. Go to your repository Settings +2. Navigate to **Secrets and variables** → **Actions** +3. Click **New repository secret** +4. Name: `ANTHROPIC_API_KEY` +5. Value: Your Anthropic API key (get one at https://console.anthropic.com) +6. Click **Add secret** + +#### 2. Install Claude GitHub App (Optional) + +For the easiest setup, you can install the official Claude GitHub app: +- Visit https://github.com/apps/claude +- Click "Install" +- Select your repository + +Alternatively, use the CLI: Open Claude Code and run `/install-github-app` + +### Review Focus Areas + +Claude reviews focus on: + +- **Code Quality**: Bugs, edge cases, error handling, security vulnerabilities +- **Architecture**: Adherence to project conventions (CLAUDE.md), proper use of EventStore/RelayLiveness singletons +- **Testing**: Coverage of parsers and pure functions +- **Performance**: Unnecessary re-renders, subscription leaks, optimization opportunities + +### Permissions + +The workflow uses these permissions: +- `contents: read` - Read repository code +- `pull-requests: write` - Post review comments on PRs +- `issues: write` - Respond to @claude mentions + +### Customizing Reviews + +To customize the review behavior, edit the `prompt` section in `.github/workflows/claude-code-review.yml`. + +### Resources + +- [Claude Code GitHub Actions Documentation](https://code.claude.com/docs/en/github-actions) +- [How to Use Claude Code for PRs and Code Reviews](https://skywork.ai/blog/how-to-use-claude-code-for-prs-code-reviews-guide/) +- [Integrating Claude Code with GitHub Actions](https://stevekinney.com/courses/ai-development/integrating-with-github-actions)