Skip to content

Commit e6608ae

Browse files
kaze-cowfedgiac
andauthored
Add Claude Code GitHub Workflow (#10)
## 🤖 Installing Claude Code GitHub App This PR adds a GitHub Actions workflow that enables Claude Code integration in our repository. ### What is Claude Code? [Claude Code](https://claude.com/claude-code) is an AI coding agent that can help with: - Bug fixes and improvements - Documentation updates - Implementing new features - Code reviews and suggestions - Writing tests - And more! ### Context Our team is currently constrained in capacity, and frequent code reviews have been a burden. In order to increase the quality of code before it reaches human reviewers, we should use AI to try and catch things earlier on. I have used claude code review previously on Cannon, and I found it effective. It often identifies major deficienies or easily missed issues by the author and can work with a variety of changes. Here is I think a good representative example (keep in mind this is an older version and I suspect this newer version will work a lot better) usecannon/cannon#1835 (comment) The AI will be using my (@kaze-cow )'s CoW account API key for now. The commits and initial files were generated from `/install-github-app` command in claude code and following the wizard and selecting all default options. I then updated the claude code review file using [anthropic's official examples](https://github.com/anthropics/claude-code-action/blob/main/examples/pr-review-comprehensive.yml) ### How it works Once this PR is merged, we'll be able to interact with Claude by mentioning @claude in a pull request or issue comment. Once the workflow is triggered, Claude will analyze the comment and surrounding context, and execute on the request in a GitHub action. ### Important Notes - **This workflow won't take effect until this PR is merged** - **@claude mentions won't work until after the merge is complete** - The workflow runs automatically whenever Claude is mentioned in PR or issue comments - Claude gets access to the entire PR or issue context including files, diffs, and previous comments ### Security - Our Anthropic API key is securely stored as a GitHub Actions secret - Only users with write access to the repository can trigger the workflow - All Claude runs are stored in the GitHub Actions run history - Claude's default tools are limited to reading/writing files and interacting with our repo by creating comments, branches, and commits. - We can add more allowed tools by adding them to the workflow file like: ``` allowed_tools: Bash(npm install),Bash(npm run build),Bash(npm run lint),Bash(npm run test) ``` There's more information in the [Claude Code action repo](https://github.com/anthropics/claude-code-action). After merging this PR, let's try mentioning @claude in a comment on any PR to get started! --------- Co-authored-by: Federico Giacon <[email protected]>
1 parent fa7d2b7 commit e6608ae

File tree

2 files changed

+128
-0
lines changed

2 files changed

+128
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Mostly copied from https://github.com/anthropics/claude-code-action/blob/main/examples/pr-review-comprehensive.yml
2+
3+
name: Claude Code Review
4+
5+
# This example demonstrates how to use the track_progress feature to get
6+
# visual progress tracking for PR reviews, similar to v0.x agent mode.
7+
8+
on:
9+
pull_request:
10+
types: [opened, synchronize, ready_for_review, reopened]
11+
12+
jobs:
13+
review-with-tracking:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
pull-requests: write
18+
id-token: write
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 1
24+
25+
- name: PR Review with Progress Tracking
26+
uses: anthropics/claude-code-action@v1
27+
with:
28+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
29+
30+
# Enable progress tracking
31+
track_progress: true
32+
33+
# Your custom review instructions
34+
prompt: |
35+
REPO: ${{ github.repository }}
36+
PR NUMBER: ${{ github.event.pull_request.number }}
37+
38+
Perform a comprehensive code review with the following focus areas:
39+
40+
1. **Code Quality**
41+
- Clean code principles and best practices
42+
- Proper error handling and edge cases
43+
- Code readability and maintainability
44+
45+
2. **Security**
46+
- Check for potential security vulnerabilities
47+
- Validate input sanitization
48+
- Review authentication/authorization logic
49+
50+
3. **Performance**
51+
- Identify potential performance bottlenecks
52+
- Review database queries for efficiency
53+
- Check for memory leaks or resource issues
54+
55+
4. **Testing**
56+
- Verify adequate test coverage
57+
- Review test quality and edge cases
58+
- Check for missing test scenarios
59+
60+
5. **Documentation**
61+
- Ensure code is properly documented
62+
- Verify README updates for new features
63+
- Check API documentation accuracy
64+
65+
Provide detailed feedback using inline comments for specific issues.
66+
Use top-level comments for general observations or praise.
67+
68+
# Tools for comprehensive PR review
69+
claude_args: |
70+
--allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*)"
71+
72+
# When track_progress is enabled:
73+
# - Creates a tracking comment with progress checkboxes
74+
# - Includes all PR context (comments, attachments, images)
75+
# - Updates progress as the review proceeds
76+
# - Marks as completed when done

.github/workflows/claude.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Mostly copied from https://github.com/anthropics/claude-code-action/blob/main/examples/claude.yml
2+
3+
name: Claude Code
4+
5+
on:
6+
issue_comment:
7+
types: [created]
8+
pull_request_review_comment:
9+
types: [created]
10+
issues:
11+
types: [opened, assigned]
12+
pull_request_review:
13+
types: [submitted]
14+
15+
jobs:
16+
claude:
17+
if: |
18+
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
19+
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
20+
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
21+
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: read
25+
pull-requests: read
26+
issues: read
27+
id-token: write
28+
actions: read # Required for Claude to read CI results on PRs
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 1
34+
35+
- name: Run Claude Code
36+
id: claude
37+
uses: anthropics/claude-code-action@v1
38+
with:
39+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
40+
41+
# This is an optional setting that allows Claude to read CI results on PRs
42+
additional_permissions: |
43+
actions: read
44+
45+
# Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it.
46+
# prompt: 'Update the pull request description to include a summary of changes.'
47+
48+
# Optional: Add claude_args to customize behavior and configuration
49+
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
50+
# or https://docs.claude.com/en/docs/claude-code/cli-reference for available options
51+
# claude_args: '--allowed-tools Bash(gh pr:*)'
52+

0 commit comments

Comments
 (0)