Skip to content

Commit aaf8539

Browse files
authored
🤠 [claude] Add Claude Code GitHub Workflow (#60)
* "Claude PR Assistant workflow" * "Claude Code Review workflow" * fix global permisions for new GHAs * get rid of unneeded empty line at end of file
1 parent 622c03a commit aaf8539

File tree

2 files changed

+112
-0
lines changed

2 files changed

+112
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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+
13+
# global permissions
14+
permissions: {}
15+
16+
jobs:
17+
claude-review:
18+
# Optional: Filter by PR author
19+
# if: |
20+
# github.event.pull_request.user.login == 'external-contributor' ||
21+
# github.event.pull_request.user.login == 'new-developer' ||
22+
# github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'
23+
24+
runs-on: ubuntu-latest
25+
permissions:
26+
contents: read
27+
pull-requests: read
28+
issues: read
29+
id-token: write
30+
31+
steps:
32+
- name: Checkout repository
33+
uses: actions/checkout@v4
34+
with:
35+
fetch-depth: 1
36+
37+
- name: Run Claude Code Review
38+
id: claude-review
39+
uses: anthropics/claude-code-action@v1
40+
with:
41+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
42+
prompt: |
43+
REPO: ${{ github.repository }}
44+
PR NUMBER: ${{ github.event.pull_request.number }}
45+
46+
Please review this pull request and provide feedback on:
47+
- Code quality and best practices
48+
- Potential bugs or issues
49+
- Performance considerations
50+
- Security concerns
51+
- Test coverage
52+
53+
Use the repository's CLAUDE.md for guidance on style and conventions. Be constructive and helpful in your feedback.
54+
55+
Use `gh pr comment` with your Bash tool to leave your review as a comment on the PR.
56+
57+
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
58+
# or https://docs.claude.com/en/docs/claude-code/sdk#command-line for available options
59+
claude_args: '--allowed-tools "Bash(gh issue view:*),Bash(gh search:*),Bash(gh issue list:*),Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr list:*)"'
60+
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
# global permissions
14+
permissions: {}
15+
16+
jobs:
17+
claude:
18+
if: |
19+
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
20+
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
21+
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
22+
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
23+
runs-on: ubuntu-latest
24+
permissions:
25+
contents: read
26+
pull-requests: read
27+
issues: read
28+
id-token: write
29+
actions: read # Required for Claude to read CI results on PRs
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 1
35+
36+
- name: Run Claude Code
37+
id: claude
38+
uses: anthropics/claude-code-action@v1
39+
with:
40+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
41+
42+
# This is an optional setting that allows Claude to read CI results on PRs
43+
additional_permissions: |
44+
actions: read
45+
46+
# Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it.
47+
# prompt: 'Update the pull request description to include a summary of changes.'
48+
49+
# Optional: Add claude_args to customize behavior and configuration
50+
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
51+
# or https://docs.claude.com/en/docs/claude-code/sdk#command-line for available options
52+
# claude_args: '--model claude-opus-4-1-20250805 --allowed-tools Bash(gh pr:*)'

0 commit comments

Comments
 (0)