Skip to content

Commit 908624f

Browse files
chapati23claude
andauthored
Add Claude Code GitHub Workflow (#25)
* "Claude PR Assistant workflow" * "Claude Code Review workflow" * fix(ci): satisfy trunk checks on Claude workflows Add top-level read-only permissions (Checkov CKV2_GHA_1) and apply prettier formatting to the two Claude Code workflows added by the github-app installer. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(ci): correct code-review prompt and elevate permissions Codex review found two real issues in the generated workflow: - The PR selector `${{ github.repository }}/pull/${{ ... }}` expands to `owner/repo/pull/N`, which `gh pr view` rejects as a branch lookup. Pass the number directly so the plugin can resolve the PR. - The code-review plugin only prints findings to the Actions log unless `--comment` is supplied; without it the review never reaches the PR. - Posting PR comments requires `pull-requests: write` on the job token. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 5f4635d commit 908624f

2 files changed

Lines changed: 98 additions & 0 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Claude Code Review
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, ready_for_review, reopened]
6+
# Optional: Only run on specific file changes
7+
# paths:
8+
# - "src/**/*.ts"
9+
# - "src/**/*.tsx"
10+
# - "src/**/*.js"
11+
# - "src/**/*.jsx"
12+
13+
permissions:
14+
contents: read
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: write
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+
plugin_marketplaces: "https://github.com/anthropics/claude-code.git"
43+
plugins: "code-review@claude-code-plugins"
44+
prompt: "/code-review:code-review ${{ github.event.pull_request.number }} --comment"
45+
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
46+
# or https://code.claude.com/docs/en/cli-reference for available options

.github/workflows/claude.yml

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+
permissions:
14+
contents: read
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://code.claude.com/docs/en/cli-reference for available options
52+
# claude_args: '--allowed-tools Bash(gh pr *)'

0 commit comments

Comments
 (0)