Skip to content

Commit 1940e18

Browse files
authored
Add Claude Code action workflows for PR reviews and documentation sync (#2034)
* Add Claude Code action workflows for PR reviews and documentation sync * Add id-token: write permission to all Claude workflows
1 parent 10a6f59 commit 1940e18

File tree

5 files changed

+304
-0
lines changed

5 files changed

+304
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: API Documentation Sync
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
paths:
7+
- 'src/ipc-handlers.ts'
8+
- 'src/preload.ts'
9+
- 'common/types/**/*.ts'
10+
11+
jobs:
12+
sync-api-docs:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
pull-requests: write
17+
id-token: write
18+
19+
steps:
20+
- name: Checkout PR branch
21+
uses: actions/checkout@v5
22+
with:
23+
ref: ${{ github.event.pull_request.head.ref }}
24+
fetch-depth: 0
25+
token: ${{ secrets.GITHUB_TOKEN }}
26+
27+
- name: Update API Documentation
28+
uses: anthropics/claude-code-action@v1
29+
with:
30+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
31+
track_progress: true
32+
prompt: |
33+
The IPC API or type definitions have changed in this PR. Please:
34+
35+
1. Review the changes in:
36+
- src/ipc-handlers.ts (IPC handler implementations)
37+
- src/preload.ts (IPC API surface exposed to renderer)
38+
- common/types/**/*.ts (TypeScript type definitions)
39+
40+
2. Update docs/ai-instructions.md to document:
41+
- New IPC handlers or changes to existing handler signatures
42+
- New type definitions or breaking changes to types
43+
- Changes to the IPC communication pattern or architecture
44+
- Examples of how to use new or changed APIs
45+
- Any security implications of the changes
46+
47+
3. Ensure documentation follows the existing format in docs/ai-instructions.md's "IPC Communication Pattern" section
48+
49+
4. If significant changes are made, commit with message:
50+
"docs: Update API documentation for IPC changes"
51+
52+
Only commit if documentation updates are actually needed. If changes are minor or already documented, explain why no update is needed.
53+
54+
claude_args: |
55+
--allowedTools "Read,Write,Edit,Grep,Glob,Bash(git add:*),Bash(git commit:*),Bash(git push:*),Bash(git status:*),Bash(git diff:*)"
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Architecture Documentation Sync
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
paths:
7+
- 'src/lib/wordpress-provider/**/*.ts'
8+
- 'src/site-server.ts'
9+
- 'src/stores/**/*.ts'
10+
- 'vite.*.config.ts'
11+
- 'electron-forge.config.ts'
12+
- 'src/index.ts'
13+
14+
jobs:
15+
sync-architecture-docs:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: write
19+
pull-requests: write
20+
id-token: write
21+
22+
steps:
23+
- name: Checkout PR branch
24+
uses: actions/checkout@v5
25+
with:
26+
ref: ${{ github.event.pull_request.head.ref }}
27+
fetch-depth: 0
28+
token: ${{ secrets.GITHUB_TOKEN }}
29+
30+
- name: Update Architecture Documentation
31+
uses: anthropics/claude-code-action@v1
32+
with:
33+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
34+
track_progress: true
35+
prompt: |
36+
Core architecture files have changed in this PR. Please:
37+
38+
1. Review changes to:
39+
- WordPress providers (src/lib/wordpress-provider/**/*.ts)
40+
- Site server management (src/site-server.ts)
41+
- Redux stores (src/stores/**/*.ts)
42+
- Build configuration (vite.*.config.ts, electron-forge.config.ts)
43+
- Main process entry point (src/index.ts)
44+
45+
2. Update docs/ai-instructions.md if any of the following changed:
46+
- New architectural patterns introduced
47+
- WordPress Provider interface or implementation changes
48+
- Redux store structure modifications
49+
- Build configuration changes affecting development workflow
50+
- New critical dependencies affecting architecture
51+
- Process architecture changes (Main/Renderer/Preload)
52+
- Site management patterns
53+
54+
3. Ensure these sections in docs/ai-instructions.md are accurate:
55+
- "High-Level Architecture" diagram and description
56+
- "Key Architecture Patterns" section
57+
- "WordPress Provider Pattern" if providers changed
58+
- "Redux Store Architecture" if stores changed
59+
- "Site Management" if SiteServer changed
60+
- "Build & Distribution" if build configs changed
61+
62+
4. If significant changes are made, commit with message:
63+
"docs: Update architecture documentation"
64+
65+
Only commit if documentation updates are actually needed. If changes don't affect architecture documentation, explain why.
66+
67+
claude_args: |
68+
--allowedTools "Read,Write,Edit,Grep,Glob,Bash(git add:*),Bash(git commit:*),Bash(git push:*),Bash(git status:*),Bash(git diff:*)"
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: CLI Documentation Sync
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
paths:
7+
- 'cli/**/*.ts'
8+
9+
jobs:
10+
sync-cli-docs:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
pull-requests: write
15+
id-token: write
16+
17+
steps:
18+
- name: Checkout PR branch
19+
uses: actions/checkout@v5
20+
with:
21+
ref: ${{ github.event.pull_request.head.ref }}
22+
fetch-depth: 0
23+
token: ${{ secrets.GITHUB_TOKEN }}
24+
25+
- name: Update CLI Documentation
26+
uses: anthropics/claude-code-action@v1
27+
with:
28+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
29+
track_progress: true
30+
prompt: |
31+
CLI commands or implementation have changed in this PR. Please:
32+
33+
1. Review changes in the cli/ directory:
34+
- New commands added (cli/commands/**/*.ts)
35+
- Changes to existing command implementations
36+
- New CLI options or flags
37+
- Changes to CLI entry point (cli/index.ts)
38+
39+
2. Update docs/ai-instructions.md to reflect:
40+
- New CLI commands with syntax and examples
41+
- Changes to existing command options or behavior
42+
- Updated usage examples in "Common Development Commands" section
43+
- New command categories if applicable
44+
45+
3. Ensure the CLI documentation in docs/ai-instructions.md includes:
46+
- Command syntax: `npm run cli:build && node dist/cli/main.js <command>`
47+
- Description of what the command does
48+
- Available options and flags
49+
- Usage examples
50+
51+
4. Verify the "Running a Single Test" or other CLI-related sections are current
52+
53+
5. If significant changes are made, commit with message:
54+
"docs: Update CLI documentation"
55+
56+
Only commit if documentation updates are actually needed. If changes are internal refactoring with no user-facing impact, explain why.
57+
58+
claude_args: |
59+
--allowedTools "Read,Write,Edit,Grep,Glob,Bash(git add:*),Bash(git commit:*),Bash(git push:*),Bash(git status:*),Bash(git diff:*)"
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Claude Interactive Assistant
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
pull_request_review_comment:
7+
types: [created]
8+
issues:
9+
types: [opened, labeled]
10+
pull_request:
11+
types: [opened]
12+
pull_request_review:
13+
types: [submitted]
14+
15+
jobs:
16+
claude-assistant:
17+
runs-on: ubuntu-latest
18+
# Only run if @claude is mentioned or specific labels are applied
19+
if: |
20+
contains(github.event.comment.body, '@claude') ||
21+
contains(github.event.issue.body, '@claude') ||
22+
contains(github.event.pull_request.body, '@claude') ||
23+
contains(github.event.review.body, '@claude') ||
24+
contains(github.event.label.name, 'claude-help')
25+
26+
permissions:
27+
contents: write
28+
issues: write
29+
pull-requests: write
30+
id-token: write
31+
32+
steps:
33+
- name: Checkout repository
34+
uses: actions/checkout@v5
35+
with:
36+
fetch-depth: 0
37+
38+
- name: Respond to Claude mention
39+
uses: anthropics/claude-code-action@v1
40+
with:
41+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
42+
# No prompt = interactive mode - Claude responds to the comment/issue
43+
claude_args: |
44+
--allowedTools "Read,Write,Edit,Grep,Glob,Bash(npm:*),Bash(node:*),Bash(git:*),Bash(gh:*)"
45+
--system-prompt "You are helping with WordPress Studio development. This is an Electron desktop app for creating and managing WordPress sites locally. Follow the coding standards and architecture patterns documented in docs/ai-instructions.md. For npm commands, use the scripts defined in package.json (npm start, npm test, npm run cli:build, etc.). Remember that the app must be compatible with both macOS and Windows environments - always consider cross-platform implications when suggesting code changes or solutions."
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Claude PR Code Review
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, ready_for_review, reopened]
6+
7+
jobs:
8+
code-review:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
pull-requests: write
13+
id-token: write
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v5
18+
with:
19+
fetch-depth: 1
20+
21+
- name: Comprehensive PR Review
22+
uses: anthropics/claude-code-action@v1
23+
with:
24+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
25+
track_progress: true
26+
prompt: |
27+
REPO: ${{ github.repository }}
28+
PR NUMBER: ${{ github.event.pull_request.number }}
29+
30+
Perform a comprehensive code review for WordPress Studio, focusing on:
31+
32+
1. **Cross-Platform Compatibility (macOS & Windows)**
33+
- Path separators: Use `path.join()` or `path.resolve()` instead of hardcoded `/` or `\`
34+
- File system differences: Case sensitivity, path length limits, reserved filenames
35+
- Platform-specific APIs: Check `process.platform` usage and platform guards
36+
- Environment variables: HOME vs USERPROFILE, temp directories
37+
- Line endings: Ensure .gitattributes handles CRLF/LF correctly
38+
- Electron platform code: Verify macOS and Windows-specific implementations work correctly
39+
- Testing: Flag code that needs testing on both platforms
40+
41+
2. **Code Quality**
42+
- Clean code principles and TypeScript best practices
43+
- Proper error handling and edge cases
44+
- Code readability and maintainability
45+
- Following patterns in docs/ai-instructions.md
46+
47+
3. **Security (OWASP Top 10)**
48+
- SQL injection, XSS, authentication/authorization flaws
49+
- Sensitive data exposure, hardcoded secrets
50+
- Input validation and sanitization
51+
- Electron-specific: Node integration disabled, context isolation, IPC validation, CSP
52+
- External content handling security
53+
54+
4. **Performance**
55+
- Identify potential bottlenecks
56+
- Database query efficiency
57+
- Memory leaks or resource issues
58+
- Bundle size impact for Electron app
59+
60+
5. **Testing**
61+
- Adequate test coverage (Jest unit tests)
62+
- Test quality and edge cases
63+
- Missing test scenarios
64+
- E2E test considerations (Playwright)
65+
66+
6. **Documentation**
67+
- Code properly documented
68+
- docs/ai-instructions.md updates for new features or architectural changes
69+
- API documentation accuracy
70+
- README updates if needed
71+
72+
Provide detailed feedback using inline comments for specific issues.
73+
Use top-level comments for general observations or praise.
74+
Be thorough but constructive in your feedback.
75+
76+
claude_args: |
77+
--allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*)"

0 commit comments

Comments
 (0)