Skip to content

Commit 1c65975

Browse files
authored
chore: add Claude Code GitHub Workflow (#2641)
1 parent 93e8c52 commit 1c65975

File tree

3 files changed

+477
-0
lines changed

3 files changed

+477
-0
lines changed
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Claude Code Review
2+
3+
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'
12+
- 'package.json'
13+
- 'package-lock.json'
14+
15+
jobs:
16+
claude-review:
17+
# Optional: Skip review for specific conditions
18+
if: |
19+
!contains(github.event.pull_request.title, '[skip-review]') &&
20+
!contains(github.event.pull_request.title, '[WIP]')
21+
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: read
25+
pull-requests: read
26+
issues: read
27+
id-token: write
28+
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 1
34+
35+
- name: Run Claude Code Review
36+
id: claude-review
37+
uses: anthropics/claude-code-action@beta
38+
with:
39+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
40+
41+
# Specify model for consistency with main workflow
42+
model: 'claude-opus-4-20250514'
43+
44+
# Direct prompt for automated review (no @claude mention needed)
45+
direct_prompt: |
46+
Review this YDB Embedded UI pull request focusing on:
47+
48+
1. **Code Standards**:
49+
- TypeScript type safety and proper interface usage (prefixed with 'T')
50+
- React best practices and Gravity UI component usage
51+
- Redux Toolkit patterns with RTK Query
52+
- BEM naming convention with cn() utility
53+
54+
2. **Critical Requirements**:
55+
- All user-facing text must use i18n (no hardcoded strings)
56+
- API calls must go through window.api, never direct calls
57+
- No state mutations in RTK Query
58+
- Route params validation (React Router v5)
59+
60+
3. **Performance & Security**:
61+
- Virtual scrolling for large tables (PaginatedTable)
62+
- React.memo for expensive renders
63+
- No exposed secrets or keys
64+
- Proper error handling and loading states
65+
66+
4. **Testing**:
67+
- Unit tests in __test__ directories
68+
- E2E tests follow page object pattern
69+
70+
Be constructive and reference specific files with file_path:line_number format.
71+
72+
# Use sticky comments to make Claude reuse the same comment on subsequent pushes to the same PR
73+
use_sticky_comment: true
74+
75+
# Optional: Customize review based on file types
76+
# direct_prompt: |
77+
# Review this PR focusing on:
78+
# - For TypeScript files: Type safety and proper interface usage
79+
# - For API endpoints: Security, input validation, and error handling
80+
# - For React components: Performance, accessibility, and best practices
81+
# - For tests: Coverage, edge cases, and test quality
82+
83+
# Optional: Different prompts for different authors
84+
# direct_prompt: |
85+
# ${{ github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' &&
86+
# 'Welcome! Please review this PR from a first-time contributor. Be encouraging and provide detailed explanations for any suggestions.' ||
87+
# 'Please provide a thorough code review focusing on our coding standards and best practices.' }}
88+
89+
# Add specific tools for running tests or linting
90+
allowed_tools: |
91+
Bash(npm run lint)
92+
Bash(npm run typecheck)
93+
Bash(npm test -- --no-watch)
94+
Bash(npm run unused)
95+
Bash(git diff)
96+
Bash(git log)
97+
98+
# Optional: Skip review for certain conditions
99+
# if: |
100+
# !contains(github.event.pull_request.title, '[skip-review]') &&
101+
# !contains(github.event.pull_request.title, '[WIP]')

.github/workflows/claude.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Claude Code
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
pull_request_review_comment:
7+
types: [created]
8+
issues:
9+
types: [opened, assigned]
10+
pull_request_review:
11+
types: [submitted]
12+
13+
jobs:
14+
claude:
15+
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')) ||
19+
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: read
23+
pull-requests: read
24+
issues: read
25+
id-token: write
26+
actions: read # Required for Claude to read CI results on PRs
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 1
32+
33+
- name: Run Claude Code
34+
id: claude
35+
uses: anthropics/claude-code-action@beta
36+
with:
37+
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
40+
additional_permissions: |
41+
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: |
54+
Bash(npm ci)
55+
Bash(npm run dev)
56+
Bash(npm run build:*)
57+
Bash(npm run lint)
58+
Bash(npm run typecheck)
59+
Bash(npm run unused)
60+
Bash(npm test)
61+
Bash(npm run test:*)
62+
Bash(docker run*)
63+
Bash(git log*)
64+
Bash(git diff*)
65+
Bash(git status)
66+
67+
# Optional: Add custom instructions for Claude to customize its behavior for your project
68+
custom_instructions: |
69+
Follow the CLAUDE.md guidelines in the repository
70+
Use Gravity UI components for any UI changes
71+
Always use i18n for user-facing strings following i18n-naming-ruleset.md
72+
Run npm run lint and npm run typecheck before committing
73+
Use RTK Query for API calls, never call APIs directly
74+
Follow BEM naming convention with cn() utility
75+
Use PaginatedTable for large datasets
76+
TypeScript types should be prefixed with 'T' (e.g., TTenantInfo)
77+
78+
# Optional: Custom environment variables for Claude
79+
claude_env: |
80+
NODE_VERSION: 18
81+
REACT_APP_BACKEND: http://localhost:8765

0 commit comments

Comments
 (0)