Skip to content

Commit 7323c80

Browse files
committed
refactor: Update Claude Code Review workflow to trigger on issue comments and enhance permissions
Signed-off-by: Eden Reich <eden.reich@gmail.com>
1 parent 6ca9e85 commit 7323c80

File tree

2 files changed

+75
-86
lines changed

2 files changed

+75
-86
lines changed
Lines changed: 26 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,24 @@
11
name: Claude Code Review
22

33
on:
4-
pull_request:
5-
types: [opened, synchronize]
6-
# Optional: Only run on specific file changes
7-
# paths:
8-
# - "src/**/*.ts"
9-
# - "src/**/*.tsx"
10-
# - "src/**/*.js"
11-
# - "src/**/*.jsx"
4+
issue_comment:
5+
types:
6+
- created
127

138
jobs:
149
claude-review:
15-
# Optional: Filter by PR author
16-
# if: |
17-
# github.event.pull_request.user.login == 'external-contributor' ||
18-
# github.event.pull_request.user.login == 'new-developer' ||
19-
# github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'
20-
21-
runs-on: ubuntu-latest
10+
if: |
11+
github.event_name == 'issue_comment' &&
12+
github.event.issue.pull_request &&
13+
contains(github.event.comment.body, '@claude /review')
14+
runs-on: ubuntu-24.04
2215
permissions:
2316
contents: read
24-
pull-requests: read
25-
issues: read
17+
pull-requests: write
18+
issues: write
2619
id-token: write
27-
20+
actions: read
21+
2822
steps:
2923
- name: Checkout repository
3024
uses: actions/checkout@v4
@@ -36,43 +30,25 @@ jobs:
3630
uses: anthropics/claude-code-action@beta
3731
with:
3832
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
39-
40-
# Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4)
41-
# model: "claude-opus-4-20250514"
42-
43-
# Direct prompt for automated review (no @claude mention needed)
33+
use_commit_signing: true
34+
base_branch: main
35+
branch_prefix: 'claude/'
36+
mcp_config: |
37+
{
38+
"mcpServers": {
39+
"context7": {
40+
"command": "npx",
41+
"args": ["-y", "@upstash/context7-mcp@latest"],
42+
"env": {}
43+
}
44+
}
45+
}
4446
direct_prompt: |
4547
Please review this pull request and provide feedback on:
4648
- Code quality and best practices
4749
- Potential bugs or issues
4850
- Performance considerations
4951
- Security concerns
5052
- Test coverage
51-
52-
Be constructive and helpful in your feedback.
53-
54-
# Optional: Use sticky comments to make Claude reuse the same comment on subsequent pushes to the same PR
55-
# use_sticky_comment: true
56-
57-
# Optional: Customize review based on file types
58-
# direct_prompt: |
59-
# Review this PR focusing on:
60-
# - For TypeScript files: Type safety and proper interface usage
61-
# - For API endpoints: Security, input validation, and error handling
62-
# - For React components: Performance, accessibility, and best practices
63-
# - For tests: Coverage, edge cases, and test quality
64-
65-
# Optional: Different prompts for different authors
66-
# direct_prompt: |
67-
# ${{ github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' &&
68-
# 'Welcome! Please review this PR from a first-time contributor. Be encouraging and provide detailed explanations for any suggestions.' ||
69-
# 'Please provide a thorough code review focusing on our coding standards and best practices.' }}
70-
71-
# Optional: Add specific tools for running tests or linting
72-
# allowed_tools: "Bash(npm run test),Bash(npm run lint),Bash(npm run typecheck)"
73-
74-
# Optional: Skip review for certain conditions
75-
# if: |
76-
# !contains(github.event.pull_request.title, '[skip-review]') &&
77-
# !contains(github.event.pull_request.title, '[WIP]')
7853
54+
Be constructive and helpful in your feedback.

.github/workflows/claude.yml

Lines changed: 49 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,63 +2,76 @@ name: Claude Code
22

33
on:
44
issue_comment:
5-
types: [created]
5+
types:
6+
- created
67
pull_request_review_comment:
7-
types: [created]
8+
types:
9+
- created
810
issues:
9-
types: [opened, assigned]
11+
types:
12+
- opened
13+
- assigned
1014
pull_request_review:
11-
types: [submitted]
15+
types:
16+
- submitted
1217

1318
jobs:
1419
claude:
1520
if: |
16-
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
17-
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
18-
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
21+
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude') && !contains(github.event.comment.body, '@claude /review')) ||
22+
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude') && !contains(github.event.comment.body, '@claude /review')) ||
23+
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude') && !contains(github.event.review.body, '@claude /review')) ||
1924
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
20-
runs-on: ubuntu-latest
25+
runs-on: ubuntu-24.04
2126
permissions:
22-
contents: read
23-
pull-requests: read
24-
issues: read
27+
contents: write
28+
pull-requests: write
29+
issues: write
2530
id-token: write
26-
actions: read # Required for Claude to read CI results on PRs
31+
actions: read
2732
steps:
2833
- name: Checkout repository
2934
uses: actions/checkout@v4
3035
with:
3136
fetch-depth: 1
3237

38+
- name: Install task
39+
run: |
40+
curl -s https://taskfile.dev/install.sh | sh -s -- -b /usr/local/bin v3.44.1
41+
3342
- name: Run Claude Code
3443
id: claude
3544
uses: anthropics/claude-code-action@beta
3645
with:
3746
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
38-
39-
# This is an optional setting that allows Claude to read CI results on PRs
4047
additional_permissions: |
4148
actions: read
42-
43-
# Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4)
44-
# model: "claude-opus-4-20250514"
45-
46-
# Optional: Customize the trigger phrase (default: @claude)
47-
# trigger_phrase: "/claude"
48-
49-
# Optional: Trigger when specific user is assigned to an issue
50-
# assignee_trigger: "claude-bot"
51-
52-
# Optional: Allow Claude to run specific commands
53-
# allowed_tools: "Bash(npm install),Bash(npm run build),Bash(npm run test:*),Bash(npm run lint:*)"
54-
55-
# Optional: Add custom instructions for Claude to customize its behavior for your project
56-
# custom_instructions: |
57-
# Follow our coding standards
58-
# Ensure all new code has tests
59-
# Use TypeScript for new files
60-
61-
# Optional: Custom environment variables for Claude
62-
# claude_env: |
63-
# NODE_ENV: test
49+
use_commit_signing: true
50+
base_branch: main
51+
branch_prefix: 'claude/'
52+
custom_instructions: |
53+
IMPORTANT: You must NEVER push directly to the main branch. Always:
54+
1. Create a new feature branch (claude/feature-name)
55+
2. Make your changes on the feature branch
56+
3. Open a pull request to main
57+
4. Wait for review and approval before merging
58+
59+
COMMIT MESSAGE FORMAT: Always use conventional commits with capital letters.
60+
Follow the format: "type(scope): Description" where the description starts with a capital letter.
61+
Examples: "feat(a2a): Add retry mechanism for agent connections", "fix(auth): Resolve token validation issue"
6462
63+
Follow the development workflow specified in the coding instructions.
64+
mcp_config: |
65+
{
66+
"mcpServers": {
67+
"context7": {
68+
"command": "npx",
69+
"args": ["-y", "@upstash/context7-mcp@latest"],
70+
"env": {}
71+
}
72+
}
73+
}
74+
allowed_tools: |
75+
Bash(task:*)
76+
Bash(gh:*)
77+
Bash(git:*)

0 commit comments

Comments
 (0)