Skip to content

Commit 22aaf15

Browse files
committed
Claude
1 parent a370e08 commit 22aaf15

3 files changed

Lines changed: 408 additions & 48 deletions

File tree

Lines changed: 70 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,90 @@
1-
name: Claude Code Review
1+
# .github/workflows/claude-code-review.yml
2+
name: Claude code review (strict)
23

34
on:
45
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"
6+
types: [opened, synchronize, reopened, ready_for_review]
7+
8+
concurrency:
9+
group: claude-review-${{ github.event.pull_request.number }}
10+
cancel-in-progress: true
1211

1312
jobs:
1413
claude-review:
15-
# Optional: Filter by PR author
16-
# if: |
17-
# github.event.pull_request.user.login == 'external-contributor' ||
18-
# github.event.pull_request.user.login == 'new-developer' ||
19-
# github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'
20-
2114
runs-on: ubuntu-latest
2215
permissions:
2316
contents: read
24-
pull-requests: read
25-
issues: read
17+
pull-requests: write
2618
id-token: write
2719

2820
steps:
2921
- name: Checkout repository
3022
uses: actions/checkout@v4
3123
with:
32-
fetch-depth: 1
24+
fetch-depth: 0
25+
26+
- name: Load CLAUDE.md rules
27+
id: rules
28+
shell: bash
29+
run: |
30+
echo 'guidelines<<EOF' >> "$GITHUB_OUTPUT"
31+
sed -n '1,6000p' CLAUDE.md >> "$GITHUB_OUTPUT"
32+
echo 'EOF' >> "$GITHUB_OUTPUT"
3333
34-
- name: Run Claude Code Review
35-
id: claude-review
34+
- name: Run Claude (repo-wide checklist, file-by-file)
35+
id: claude
3636
uses: anthropics/claude-code-action@v1
3737
with:
3838
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
3939
prompt: |
40-
Please review this pull request and provide feedback on:
41-
- Code quality and best practices
42-
- Use the repository's CLAUDE.md for more detail instructions
43-
- Potential bugs or issues
44-
- Performance considerations
45-
- Security concerns
46-
- Test coverage
47-
48-
Use `gh pr comment` with your Bash tool to leave your review as a comment on the PR.
49-
50-
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
51-
# or https://docs.anthropic.com/en/docs/claude-code/sdk#command-line for available options
52-
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:*)"'
40+
You are a STRICT reviewer. Enforce every rule in CLAUDE.md across the entire repo.
41+
Build a YES/NO checklist for each rule per file. Include focused patch suggestions.
42+
43+
Scope:
44+
- Enumerate Scala/SBT files: git ls-files '*.scala' '*.sbt'
45+
- Also consider configs affecting Scala builds: git ls-files '.scalafmt.conf' 'build.sbt' 'project/*.scala' 'project/*.sbt' 'project/build.properties'
46+
- Apply ALL rules from CLAUDE.md to each discovered file (not just PR diffs).
47+
48+
Output:
49+
- One markdown report grouped by file
50+
- For each rule: ✅ PASS or ❌ FAIL with a minimal diff/patch
51+
- A short "Top 10 Fixes" summary
52+
- Final line MUST be exactly:
53+
CLAUDE_RULES_STATUS: PASS # or FAIL
54+
55+
Rules to enforce:
56+
---
57+
${{ steps.rules.outputs.guidelines }}
58+
---
59+
60+
# Use GA-style CLI flags; give Claude deterministic tools for repo-wide scans.
61+
claude_args: >-
62+
--allowedTools
63+
"Read"
64+
"Edit"
65+
"MultiEdit"
66+
"Bash(git ls-files:*)"
67+
"Bash(rg:*)"
68+
"Bash(find:*)"
69+
"Bash(sed:*)"
70+
"Bash(xargs:*)"
71+
"Bash(gh pr view:*)"
72+
"Bash(gh pr comment:*)"
73+
--max-turns 10
74+
--verbose
75+
76+
env:
77+
GH_TOKEN: ${{ github.token }}
78+
79+
- name: Fail the job unless all rules passed
80+
if: always()
81+
shell: bash
82+
env:
83+
GH_TOKEN: ${{ github.token }}
84+
run: |
85+
pr="${{ github.event.pull_request.number }}"
86+
# Aggregate all comments and look for the sentinel line.
87+
body="$(gh pr view "$pr" --json comments -q '.comments[].body' || true)"
88+
echo "=== Tail of PR comments ==="
89+
echo "$body" | tail -n 40 || true
90+
echo "$body" | grep -q 'CLAUDE_RULES_STATUS: PASS'

.github/workflows/claude.yml

Lines changed: 62 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
1-
name: Claude Code
1+
# .github/workflows/claude.yml
2+
name: Claude (on-mention assistant)
23

34
on:
45
issue_comment:
56
types: [created]
67
pull_request_review_comment:
78
types: [created]
89
issues:
9-
types: [opened, assigned]
10+
types: [opened, assigned, edited]
1011
pull_request_review:
1112
types: [submitted]
1213

14+
concurrency:
15+
group: claude-on-mention-${{ github.event.pull_request.number || github.event.issue.number || github.run_id }}
16+
cancel-in-progress: true
17+
1318
jobs:
14-
claude:
19+
claude-assistant:
1520
if: |
1621
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
1722
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
@@ -20,31 +25,72 @@ jobs:
2025
runs-on: ubuntu-latest
2126
permissions:
2227
contents: read
23-
pull-requests: read
24-
issues: read
28+
pull-requests: write
29+
issues: write
2530
id-token: write
26-
actions: read # Required for Claude to read CI results on PRs
31+
actions: read # allow reading CI results/status on PRs
32+
2733
steps:
2834
- name: Checkout repository
2935
uses: actions/checkout@v4
3036
with:
31-
fetch-depth: 1
37+
fetch-depth: 0
38+
39+
- name: Load CLAUDE.md (optional rules)
40+
id: rules
41+
shell: bash
42+
run: |
43+
echo 'guidelines<<EOF' >> "$GITHUB_OUTPUT"
44+
if [ -f CLAUDE.md ]; then
45+
sed -n '1,6000p' CLAUDE.md >> "$GITHUB_OUTPUT"
46+
else
47+
echo 'No CLAUDE.md present.' >> "$GITHUB_OUTPUT"
48+
fi
49+
echo 'EOF' >> "$GITHUB_OUTPUT"
3250
33-
- name: Run Claude Code
51+
- name: Run Claude Code Action
3452
id: claude
3553
uses: anthropics/claude-code-action@v1
3654
with:
3755
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
56+
57+
# Let Claude read CI status in context (optional but handy)
4058
additional_permissions: |
4159
actions: read
4260
43-
# Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it.
44-
# prompt: 'Update the pull request description to include a summary of changes.'
61+
# If a comment says "full audit" OR PR has label full-audit, do a repo-wide CLAUDE.md audit.
62+
prompt: |
63+
You are the repository’s assistant and reviewer.
64+
If triggered by an @claude mention, reply in-thread with helpful, actionable guidance.
65+
66+
If the comment text contains "full audit" OR the PR has the label "full-audit":
67+
- Perform a repository-wide audit against the standards below.
68+
- Enumerate files with: git ls-files '*.scala' '*.sbt'
69+
- Also include key build/config files:
70+
- .scalafmt.conf, build.sbt, project/*.sbt, project/*.scala, project/build.properties
71+
- For each file, check every rule and propose minimal, focused patches.
72+
- Post a single markdown report summarizing results by file.
73+
- Final line MUST be exactly:
74+
CLAUDE_RULES_STATUS: PASS # or FAIL
75+
76+
Repository standards (from CLAUDE.md):
77+
---
78+
${{ steps.rules.outputs.guidelines }}
79+
---
4580
46-
# Optional: Add claude_args to customize behavior and configuration
47-
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
48-
# or https://docs.anthropic.com/en/docs/claude-code/sdk#command-line for available options
49-
# claude_args: '--model claude-opus-4-1-20250805 --allowed-tools Bash(gh pr:*)'
81+
# CLI passthrough (GA style). Use camelCase --allowedTools per Anthropic CLI.
82+
claude_args: >-
83+
--allowedTools
84+
"Read"
85+
"Edit"
86+
"MultiEdit"
87+
"Bash(git ls-files:*)"
88+
"Bash(rg:*)"
89+
"Bash(find:*)"
90+
"Bash(gh pr view:*)"
91+
"Bash(gh pr comment:*)"
92+
--max-turns 8
93+
--verbose
5094
95+
env:
96+
GH_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)