Skip to content
Merged
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
27 changes: 7 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,17 @@ on:
pull_request:

jobs:
lint:
name: Lint Workflows
pre-commit:
name: Pre-commit Checks
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Run actionlint
uses: reviewdog/action-actionlint@v1
- name: Setup Python
uses: actions/setup-python@v5
with:
reporter: github-pr-review
fail_level: error
python-version: '3.12'

format:
name: Check Formatting
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'

- name: Check formatting
run: npx prettier --check "**/*.{yml,yaml,md}"
- name: Run pre-commit
uses: pre-commit/action@v3.0.1
181 changes: 54 additions & 127 deletions .github/workflows/code-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,20 @@ name: Code Review
on:
workflow_call:
inputs:
trigger_type:
description:
'How the review was triggered: "comment" for /review command, "auto"
for PR open/ready'
type: string
required: false
default: 'comment'
allowed_tools:
description: 'Comma-separated list of allowed tools for Claude'
type: string
required: false
default:
'Read,Grep,Glob,LS,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr
view:*),Bash(gh run view:*)'
view:*),Bash(gh run list:*),Bash(gh run view:*)'
prompt:
description:
'Custom prompt to override the default review behavior (leave empty
Expand Down Expand Up @@ -37,6 +44,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: React to comment
if: inputs.trigger_type == 'comment'
uses: actions/github-script@v7
with:
script: |
Expand All @@ -52,38 +60,19 @@ jobs:
with:
fetch-depth: 1

- name: Gather PR context and create check run
id: context
- name: Create check run
if: inputs.trigger_type == 'comment'
id: check
uses: actions/github-script@v7
with:
script: |
const prNumber = context.issue.number;

// Get PR details
const pr = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber
pull_number: context.issue.number
});

// Get workflow runs for this PR
const workflowRuns = await github.rest.actions.listWorkflowRunsForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
branch: pr.data.head.ref,
per_page: 10
});

// Get check runs for the head commit
const checkRuns = await github.rest.checks.listForRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: pr.data.head.sha,
per_page: 100
});

// Create the review check run
const reviewCheck = await github.rest.checks.create({
const check = await github.rest.checks.create({
owner: context.repo.owner,
repo: context.repo.repo,
name: 'Code Review',
Expand All @@ -92,40 +81,7 @@ jobs:
started_at: new Date().toISOString()
});

// Format workflow runs for easy reference
const formattedWorkflows = workflowRuns.data.workflow_runs
.filter(run => run.event === 'pull_request' || run.event === 'push')
.map(run => ({
id: run.id,
name: run.name,
status: run.status,
conclusion: run.conclusion,
html_url: run.html_url,
created_at: run.created_at
}));

// Format check runs for easy reference
const formattedChecks = checkRuns.data.check_runs.map(check => ({
id: check.id,
name: check.name,
status: check.status,
conclusion: check.conclusion,
html_url: check.html_url,
started_at: check.started_at
}));

// Output everything
core.setOutput('check_run_id', reviewCheck.data.id);
core.setOutput('pr_number', prNumber);
core.setOutput('pr_title', pr.data.title);
core.setOutput('pr_author', pr.data.user.login);
core.setOutput('pr_branch', pr.data.head.ref);
core.setOutput('pr_base_branch', pr.data.base.ref);
core.setOutput('pr_head_sha', pr.data.head.sha);
core.setOutput('workflow_runs', JSON.stringify(formattedWorkflows, null, 2));
core.setOutput('check_runs', JSON.stringify(formattedChecks, null, 2));

return reviewCheck.data.id;
core.setOutput('check_run_id', check.data.id);

- name: Claude Code Review
uses: anthropics/claude-code-action@v1
Expand All @@ -135,80 +91,62 @@ jobs:
track_progress: true
claude_args: --allowedTools "${{ inputs.allowed_tools }}"
prompt: |
**PR Context:**
- Repo: ${{ github.repository }}
- PR: #${{ steps.context.outputs.pr_number }} - "${{ steps.context.outputs.pr_title }}"
- Author: ${{ steps.context.outputs.pr_author }}
- Branch: ${{ steps.context.outputs.pr_branch }} -> ${{ steps.context.outputs.pr_base_branch }}
- Head SHA: ${{ steps.context.outputs.pr_head_sha }}
- Check Run ID: ${{ steps.context.outputs.check_run_id }}
- Triggered by: Manual `/review` comment

**Workflow Runs:**
```json
${{ steps.context.outputs.workflow_runs }}
```

**Check Runs:**
```json
${{ steps.context.outputs.check_runs }}
```

**Instructions:**
Use the workflow run IDs above with `gh run view <run-id> --log` to analyze test results.
Use `gh pr diff ${{ steps.context.outputs.pr_number }}` or `gh pr view ${{ steps.context.outputs.pr_number }} --json files` to see changed files.

${{ inputs.prompt || 'A PR review has been triggered. Review the current state of the PR
to determine if a review has already occured. If it has, review the
feedback and any changes made since then to see if they address the
feedback of the original review. Your purpose is to continue the
review and not start over. If no review has occured, perform a
comprehensive code review based on the following focus areas:
**Context:**
- Triggered by: ${{ inputs.trigger_type == 'comment' && 'Manual `/review` comment' || 'Automatic (PR opened/ready)' }}
**Task:**
You are Claude, reviewing this PR. Your previous comments may appear as the github-actions[bot] user.

First, check the existing PR details and review comments to understand what has already been discussed.
If there are previous reviews or feedback, continue from where the conversation left off - address any new changes,
follow up on outstanding items, and avoid repeating points already made.

Use `gh` CLI to get PR details, check CI status, and view workflow results.

${{ inputs.prompt || 'Perform a code review based on the following focus areas:

1. **Code Quality**
- Clean code principles and best practices
- Proper error handling and edge cases
- Code readability and maintainability
- Code follows KISS and DRY principles
- Consistenty with the project style and conventions
- KISS and DRY principles
- Consistency with project style

2. **Security**
- Check for potential security vulnerabilities
- Validate input sanitization
- Review authentication/authorization logic
- Verify no secrets are commited to the repository
- Potential vulnerabilities
- Input sanitization
- Authentication/authorization logic
- No secrets committed

3. **Performance**
- Identify potential performance bottlenecks
- Review database queries for efficiency
- Check for memory leaks or resource issues
- Follows serverless best practices
- Bottlenecks
- Database query efficiency, O(n) vs O(log n)
- Memory leaks or resource issues
- Serverless best practices

4. **Testing & Coverage**
- Verify adequate test coverage
- Review test quality and edge cases
- Check for missing test scenarios
- Analyze workflow run logs using the IDs provided above
- Look for critical coverage regressions or gaps
- Adequate test coverage
- Test quality and edge cases
- Missing test scenarios
- Check CI results with `gh run list` and `gh run view`

5. **Documentation**
- Ensure code is properly documented
- Verify README updates for new features
- Check API documentation accuracy
- Code documentation
- README updates for new features
- API documentation accuracy

Provide detailed feedback using inline comments for specific issues.
Use top-level comments for general observations.
Provide feedback using inline comments for specific issues and top-level comments for general observations.

Always include a tldr; summary of the review. Remember developers do not like to read.
Responses should be focused on significant improvements, not nitpicks or congratulations.

Be concise and to the point. Do not repeat previous comments.
Be witty and engaging.' }}

- name: Complete check run
if: always()
if: always() && inputs.trigger_type == 'comment'
uses: actions/github-script@v7
with:
script: |
const checkId = ${{ steps.context.outputs.check_run_id }};

const checkId = ${{ steps.check.outputs.check_run_id }};
const conclusion = '${{ job.status }}' === 'success' ? 'success' : 'failure';

await github.rest.checks.update({
Expand All @@ -220,26 +158,15 @@ jobs:
completed_at: new Date().toISOString()
});

- name: React on success
if: success()
uses: actions/github-script@v7
with:
script: |
await github.rest.reactions.createForIssueComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: context.payload.comment.id,
content: 'rocket'
});

- name: React on failure
if: failure()
- name: React to completion
if: always() && inputs.trigger_type == 'comment'
uses: actions/github-script@v7
with:
script: |
const emoji = '${{ job.status }}' === 'success' ? 'rocket' : 'confused';
await github.rest.reactions.createForIssueComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: context.payload.comment.id,
content: 'confused'
content: emoji
});
14 changes: 7 additions & 7 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ Claude Code into other repositories. It contains three workflows that wrap
## Commands

```bash
# Format YAML and Markdown files
npx prettier --write "**/*.{yml,yaml,md}"
# Setup pre-commit hooks (run once)
pip install pre-commit
pre-commit install

# Check formatting (used in CI)
npx prettier --check "**/*.{yml,yaml,md}"
# Run all checks manually
pre-commit run --all-files

# Lint GitHub Actions workflows
actionlint

# Setup pre-commit hooks
pip install pre-commit
pre-commit install
# Format YAML and Markdown files
npx prettier --write "**/*.{yml,yaml,md}"
```

## Architecture
Expand Down
Loading