Skip to content

Commit 4874b36

Browse files
authored
Sync Claude workflows from workspace (#1774)
## Summary This PR synchronizes the Claude Code workflows from the workspace repository templates with repository-specific customizations for the TypeScript/React gaming wallet codebase. ### Changes Made - **Updated `.github/workflows/claude-code-review.yml`**: - Applied latest template structure with updated review flow - Enhanced with TypeScript/React specific review focus areas - Added redundancy checks for existing reviews/comments - Configured for gaming wallet and blockchain integration patterns - **Updated `.github/workflows/claude.yml`**: - Applied latest template structure with ast-grep support - Preserved repository-specific pnpm and monorepo development commands - Updated custom instructions for TypeScript/React best practices - Added Node.js setup for ast-grep integration ### Key Features - **Review Workflow**: Focuses on TypeScript/React quality, wallet/blockchain integration, UI/UX, testing, monorepo, and security - **Interactive Workflow**: Supports pnpm commands, Turbo build system, and monorepo structure - **Template Synchronization**: Maintains consistency with workspace standards while preserving repository-specific needs ### Test Plan - [ ] Verify workflows trigger correctly on PR creation - [ ] Test Claude Code review functionality with sample PR - [ ] Confirm pnpm and monorepo commands work as expected 🤖 Generated via workspace coordination from [cartridge-gg/workspace#27](cartridge-gg/workspace#27)
1 parent 4652407 commit 4874b36

File tree

2 files changed

+115
-95
lines changed

2 files changed

+115
-95
lines changed
Lines changed: 90 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,44 @@
1-
name: claude-code-review
1+
name: claude
22

33
on:
44
pull_request:
55
types: [opened, synchronize]
66

77
jobs:
88
claude-review:
9+
# Optional: Filter by PR author
10+
# if: |
11+
# github.event.pull_request.user.login == 'external-contributor' ||
12+
# github.event.pull_request.user.login == 'new-developer' ||
13+
# github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'
14+
915
runs-on: ubuntu-latest
1016
permissions:
1117
contents: read
12-
pull-requests: read
18+
pull-requests: write
1319
issues: read
1420
id-token: write
1521

1622
steps:
1723
- name: Checkout repository
1824
uses: actions/checkout@v4
1925
with:
20-
fetch-depth: 1
26+
fetch-depth: 2
27+
28+
- name: Check if commit is from Claude
29+
id: check-author
30+
run: |
31+
AUTHOR_EMAIL=$(git log -1 --pretty=format:'%ae')
32+
AUTHOR_NAME=$(git log -1 --pretty=format:'%an')
33+
if [[ "$AUTHOR_EMAIL" == *"claude[bot]"* ]] || [[ "$AUTHOR_NAME" == *"claude[bot]"* ]]; then
34+
echo "skip=true" >> $GITHUB_OUTPUT
35+
else
36+
echo "skip=false" >> $GITHUB_OUTPUT
37+
fi
2138
2239
- name: Run Claude Code Review
2340
id: claude-review
41+
if: steps.check-author.outputs.skip != 'true'
2442
uses: anthropics/claude-code-action@beta
2543
with:
2644
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
@@ -30,33 +48,72 @@ jobs:
3048

3149
# Direct prompt for automated review (no @claude mention needed)
3250
direct_prompt: |
33-
Please review this pull request and provide feedback on:
34-
- Code quality and best practices
35-
- Potential bugs or issues
36-
- Performance considerations
37-
- Security concerns
38-
- Test coverage
39-
40-
Be constructive and helpful in your feedback.
41-
42-
# Optional: Customize review based on file types
43-
# direct_prompt: |
44-
# Review this PR focusing on:
45-
# - For TypeScript files: Type safety and proper interface usage
46-
# - For API endpoints: Security, input validation, and error handling
47-
# - For React components: Performance, accessibility, and best practices
48-
# - For tests: Coverage, edge cases, and test quality
49-
50-
# Optional: Different prompts for different authors
51-
# direct_prompt: |
52-
# ${{ github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' &&
53-
# 'Welcome! Please review this PR from a first-time contributor. Be encouraging and provide detailed explanations for any suggestions.' ||
54-
# 'Please provide a thorough code review focusing on our coding standards and best practices.' }}
55-
56-
# Optional: Add specific tools for running tests or linting
57-
# allowed_tools: "Bash(npm run test),Bash(npm run lint),Bash(npm run typecheck)"
58-
59-
# Optional: Skip review for certain conditions
60-
# if: |
61-
# !contains(github.event.pull_request.title, '[skip-review]') &&
62-
# !contains(github.event.pull_request.title, '[WIP]')
51+
Please review this TypeScript/React gaming wallet PR and provide inline feedback using the GitHub review system. Follow these steps:
52+
53+
1. **Check for existing reviews**: First, use `mcp__github__get_pull_request_reviews` to check if you have any existing pending or submitted reviews on this PR
54+
2. **Check existing comments**: Use `mcp__github__get_pull_request_comments` to see what comments have already been made to avoid redundancy
55+
3. **Start a fresh review**: Use `mcp__github__create_pending_pull_request_review` to begin a new pending review
56+
4. **Get diff information**: Use `mcp__github__get_pull_request_diff` to understand the code changes
57+
5. **Add unique inline comments**: Only add comments for issues that haven't been addressed in existing reviews
58+
6. **Add inline comments**: Use `mcp__github__add_pull_request_review_comment_to_pending_review` for each specific piece of feedback on particular lines, including code change suggestions where appropriate using multiline comments and the suggestion syntax:
59+
60+
```suggestion
61+
const ExampleComponent: React.FC<Props> = ({ children }) => {
62+
return <div>{children}</div>;
63+
};
64+
```
65+
66+
7. **Submit the review**: Use `mcp__github__submit_pending_pull_request_review` with event type "COMMENT" (not "REQUEST_CHANGES") to publish all comments as a non-blocking review
67+
68+
Only comment when something is off, wrong, or could be improved but don't be overly pedantic; if a given implementation is already good, do not comment on it.
69+
70+
Focus your review on:
71+
72+
**TypeScript/React Code Quality:**
73+
- Type safety and proper TypeScript usage
74+
- React hooks usage and lifecycle management
75+
- Component composition and reusability
76+
- Props interface design and validation
77+
- State management patterns
78+
79+
**Wallet & Blockchain Integration:**
80+
- StarkNet integration best practices
81+
- Account abstraction implementation
82+
- Session token management
83+
- WebAuthn/Passkeys security patterns
84+
- Iframe communication security
85+
86+
**UI/UX & Accessibility:**
87+
- Component API consistency
88+
- Storybook story completeness
89+
- TailwindCSS usage patterns
90+
- Responsive design considerations
91+
- Accessibility best practices
92+
93+
**Testing & Quality:**
94+
- Jest unit test coverage and quality
95+
- Storybook visual regression tests
96+
- Playwright E2E test completeness
97+
- Mock usage and test isolation
98+
- Error boundary implementation
99+
100+
**Monorepo & Build:**
101+
- Package interdependencies
102+
- Turbo build configuration
103+
- Workspace protocol usage
104+
- Bundle size considerations
105+
- Performance optimizations
106+
107+
**Security:**
108+
- Input validation and sanitization
109+
- XSS prevention
110+
- Secure iframe communication
111+
- Sensitive data handling
112+
- Authentication flow security
113+
114+
Provide specific, actionable feedback with inline comments and suggestions for line-specific issues. Include an concise overall summary when submitting the review.
115+
116+
**Important**: Submit as "COMMENT" type so the review doesn't block the PR.
117+
118+
# Add MCP GitHub tools for inline comments and project-specific testing
119+
allowed_tools: "mcp__github__create_pending_pull_request_review,mcp__github__get_pull_request_comments,mcp__github__get_pull_request_reviews,mcp__github__add_pull_request_review_comment_to_pending_review,mcp__github__submit_pending_pull_request_review,mcp__github__get_pull_request_diff,Bash(pnpm install),Bash(pnpm run build),Bash(pnpm run test:*),Bash(pnpm run lint:*),Bash(pnpm run format),Bash(pnpm run dev),Bash(pnpm run storybook),Bash(pnpm run e2e:*),Bash(pnpm --filter *),Bash(pnpm run clean),Bash(corepack enable pnpm)"

.github/workflows/claude.yml

Lines changed: 25 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: claude
1+
name: Claude Code
22

33
on:
44
issue_comment:
@@ -19,15 +19,26 @@ jobs:
1919
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
2020
runs-on: ubuntu-latest
2121
permissions:
22-
contents: read
23-
pull-requests: read
24-
issues: read
22+
contents: write
23+
pull-requests: write
24+
issues: write
2525
id-token: write
2626
steps:
2727
- name: Checkout repository
2828
uses: actions/checkout@v4
2929
with:
3030
fetch-depth: 1
31+
token: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Setup Node.js
34+
uses: actions/setup-node@v4
35+
with:
36+
node-version: "20"
37+
38+
- name: Install ast-grep
39+
run: |
40+
npm install -g @ast-grep/cli
41+
ast-grep --version
3142
3243
- name: Run Claude Code
3344
id: claude
@@ -44,64 +55,16 @@ jobs:
4455
# Optional: Trigger when specific user is assigned to an issue
4556
assignee_trigger: "claude-bot"
4657

47-
# Add MCP GitHub tools for inline comments and TypeScript/React testing
48-
allowed_tools: "mcp__github__create_pending_pull_request_review,mcp__github__add_pull_request_review_comment_to_pending_review,mcp__github__submit_pending_pull_request_review,mcp__github__get_pull_request_diff,Bash(pnpm install),Bash(pnpm run build),Bash(pnpm run test:*),Bash(pnpm run lint:*),Bash(pnpm run format),Bash(pnpm run dev),Bash(pnpm run storybook),Bash(pnpm run e2e:*),Bash(pnpm --filter *),Bash(pnpm run clean),Bash(corepack enable pnpm)"
49-
50-
# Custom instructions for Claude to provide comprehensive TypeScript/React reviews
51-
direct_prompt: |
52-
Please review this TypeScript/React gaming wallet PR and provide inline feedback using the GitHub review system. Follow these steps:
53-
54-
1. **Start a review**: Use `mcp__github__create_pending_pull_request_review` to begin a pending review
55-
2. **Get diff information**: Use `mcp__github__get_pull_request_diff` to understand the code changes and line numbers
56-
3. **Add inline comments**: Use `mcp__github__add_pull_request_review_comment_to_pending_review` for each specific piece of feedback on particular lines, including code change suggestions where appropriate
57-
4. **Submit the review**: Use `mcp__github__submit_pending_pull_request_review` with event type "COMMENT" (not "REQUEST_CHANGES") to publish all comments as a non-blocking review
58+
# Customize allowed tools and commands for your repository
59+
allowed_tools: "mcp__github__create_pull_request,Bash,Glob,Grep,LS,Read,Edit,MultiEdit,Write"
5860

59-
Focus your review on:
60-
61-
**TypeScript/React Code Quality:**
62-
- Type safety and proper TypeScript usage
63-
- React hooks usage and lifecycle management
64-
- Component composition and reusability
65-
- Props interface design and validation
66-
- State management patterns
67-
68-
**Wallet & Blockchain Integration:**
69-
- StarkNet integration best practices
70-
- Account abstraction implementation
71-
- Session token management
72-
- WebAuthn/Passkeys security patterns
73-
- Iframe communication security
74-
75-
**UI/UX & Accessibility:**
76-
- Component API consistency
77-
- Storybook story completeness
78-
- TailwindCSS usage patterns
79-
- Responsive design considerations
80-
- Accessibility best practices
81-
82-
**Testing & Quality:**
83-
- Jest unit test coverage and quality
84-
- Storybook visual regression tests
85-
- Playwright E2E test completeness
86-
- Mock usage and test isolation
87-
- Error boundary implementation
88-
89-
**Monorepo & Build:**
90-
- Package interdependencies
91-
- Turbo build configuration
92-
- Workspace protocol usage
93-
- Bundle size considerations
94-
- Performance optimizations
95-
96-
**Security:**
97-
- Input validation and sanitization
98-
- XSS prevention
99-
- Secure iframe communication
100-
- Sensitive data handling
101-
- Authentication flow security
61+
# Add custom instructions specific to your codebase
62+
custom_instructions: |
63+
Always review the instructions in the CLAUDE.md file before proceeding.
10264
103-
Provide specific, actionable feedback with inline comments for line-specific issues and include an overall summary when submitting the review. **Important**: Submit as "COMMENT" type so the review doesn't block the PR.
65+
IMPORTANT: When you make changes to files, you must create a Pull Request:
66+
1. Use mcp__github__create_pull_request to create a PR
67+
2. If responding to an issue, include "Closes #[ISSUE_NUMBER]" in the PR description
68+
3. Provide a clear title and description explaining what was changed and why
10469
105-
# Optional: Custom environment variables for Claude
106-
# claude_env: |
107-
# NODE_ENV: test
70+
Never commit directly to main branch. Always create PRs for changes.

0 commit comments

Comments
 (0)