Skip to content

Commit 3e8e238

Browse files
committed
Claude
1 parent 22aaf15 commit 3e8e238

2 files changed

Lines changed: 67 additions & 54 deletions

File tree

.github/workflows/claude-code-review.yml

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# .github/workflows/claude-code-review.yml
2-
name: Claude code review (strict)
2+
# Non-blocking strict review: comments on the PR using gh CLI; never fails the job.
3+
name: Claude code review (strict, non-blocking)
34

45
on:
56
pull_request:
@@ -14,7 +15,7 @@ jobs:
1415
runs-on: ubuntu-latest
1516
permissions:
1617
contents: read
17-
pull-requests: write
18+
pull-requests: write # needed for gh pr comment
1819
id-token: write
1920

2021
steps:
@@ -31,33 +32,38 @@ jobs:
3132
sed -n '1,6000p' CLAUDE.md >> "$GITHUB_OUTPUT"
3233
echo 'EOF' >> "$GITHUB_OUTPUT"
3334
34-
- name: Run Claude (repo-wide checklist, file-by-file)
35+
- name: Run claude (repo-wide checklist, then publish via gh CLI)
3536
id: claude
3637
uses: anthropics/claude-code-action@v1
3738
with:
3839
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
3940
prompt: |
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.
41+
You are a STRICT reviewer enforcing every rule in CLAUDE.md across the repository.
4242
4343
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).
44+
- Enumerate:
45+
git ls-files '*.scala' '*.sbt' '.scalafmt.conf' 'build.sbt' 'project/*.sbt' 'project/*.scala' 'project/build.properties'
46+
- Apply ALL rules to each file (not just diffs).
4747
4848
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:
49+
- One markdown report grouped by file.
50+
- For each rule: ✅ PASS or ❌ FAIL with minimal patch/diff.
51+
- A short "Top 10 Fixes" section.
52+
- Final line MUST be:
5353
CLAUDE_RULES_STATUS: PASS # or FAIL
5454
55+
PUBLISHING (MANDATORY):
56+
- Use the PR number from $PR_NUMBER.
57+
- Post your full markdown report as a single PR comment with one Bash command:
58+
gh pr comment "$PR_NUMBER" --body-file - <<'MD'
59+
<PASTE YOUR FULL MARKDOWN REPORT HERE>
60+
MD
61+
5562
Rules to enforce:
5663
---
5764
${{ steps.rules.outputs.guidelines }}
5865
---
5966
60-
# Use GA-style CLI flags; give Claude deterministic tools for repo-wide scans.
6167
claude_args: >-
6268
--allowedTools
6369
"Read"
@@ -74,17 +80,13 @@ jobs:
7480
--verbose
7581
7682
env:
77-
GH_TOKEN: ${{ github.token }}
83+
GH_TOKEN: ${{ github.token }} # gh CLI auth
84+
PR_NUMBER: ${{ github.event.pull_request.number }}
7885

79-
- name: Fail the job unless all rules passed
86+
- name: Soft gate summary (never fail)
8087
if: always()
81-
shell: bash
8288
env:
8389
GH_TOKEN: ${{ github.token }}
8490
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'
91+
echo "### Claude strict review" >> "$GITHUB_STEP_SUMMARY"
92+
echo "Report should be posted via gh pr comment on PR #${{ github.event.pull_request.number }}." >> "$GITHUB_STEP_SUMMARY"

.github/workflows/claude.yml

Lines changed: 43 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ on:
66
types: [created]
77
pull_request_review_comment:
88
types: [created]
9-
issues:
10-
types: [opened, assigned, edited]
119
pull_request_review:
1210
types: [submitted]
1311

@@ -17,18 +15,13 @@ concurrency:
1715

1816
jobs:
1917
claude-assistant:
20-
if: |
21-
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
22-
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
23-
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
24-
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
2518
runs-on: ubuntu-latest
2619
permissions:
2720
contents: read
28-
pull-requests: write
29-
issues: write
21+
pull-requests: write # needed for gh pr comment
22+
issues: write # fallback to issue comment when not a PR
3023
id-token: write
31-
actions: read # allow reading CI results/status on PRs
24+
actions: read
3225

3326
steps:
3427
- name: Checkout repository
@@ -42,43 +35,51 @@ jobs:
4235
run: |
4336
echo 'guidelines<<EOF' >> "$GITHUB_OUTPUT"
4437
if [ -f CLAUDE.md ]; then
45-
sed -n '1,6000p' CLAUDE.md >> "$GITHUB_OUTPUT"
38+
sed -n '1,6000p' CLAUDE.md
4639
else
47-
echo 'No CLAUDE.md present.' >> "$GITHUB_OUTPUT"
48-
fi
40+
echo 'No CLAUDE.md present.'
41+
fi >> "$GITHUB_OUTPUT"
4942
echo 'EOF' >> "$GITHUB_OUTPUT"
5043
51-
- name: Run Claude Code Action
44+
- name: Run Claude Code Action (auto-detects @claude)
5245
id: claude
5346
uses: anthropics/claude-code-action@v1
5447
with:
5548
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
5649

57-
# Let Claude read CI status in context (optional but handy)
58-
additional_permissions: |
59-
actions: read
60-
61-
# If a comment says "full audit" OR PR has label full-audit, do a repo-wide CLAUDE.md audit.
50+
# IMPORTANT: Explicitly instruct Claude to publish via gh pr comment
6251
prompt: |
63-
You are the repository’s assistant and reviewer.
64-
If triggered by an @claude mention, reply in-thread with helpful, actionable guidance.
52+
You are the repository’s assistant/reviewer. When you see the phrase "full audit"
53+
in the triggering comment, run a repository-wide CLAUDE.md audit and **publish the
54+
results using the GitHub CLI**.
6555
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:
56+
Audit scope:
57+
- Enumerate files:
58+
git ls-files '*.scala' '*.sbt' '.scalafmt.conf' 'build.sbt' 'project/*.sbt' 'project/*.scala' 'project/build.properties'
59+
- Apply ALL rules from CLAUDE.md to each file.
60+
- Produce a single markdown report grouped by file, with ✅/❌ per rule and minimal patch suggestions.
61+
- At the end of the report, include:
7462
CLAUDE_RULES_STATUS: PASS # or FAIL
7563
76-
Repository standards (from CLAUDE.md):
64+
PUBLISHING (MANDATORY):
65+
- Determine the PR number from the environment:
66+
use $PR_NUMBER if set; else use $ISSUE_NUMBER.
67+
- If a PR number is available:
68+
run exactly one Bash command to post your report:
69+
gh pr comment "$PR_NUMBER" --body-file - <<'MD'
70+
<PASTE YOUR FULL MARKDOWN REPORT HERE>
71+
MD
72+
- Else (issue context), post to the issue instead:
73+
gh issue comment "$ISSUE_NUMBER" --body-file - <<'MD'
74+
<PASTE YOUR FULL MARKDOWN REPORT HERE>
75+
MD
76+
77+
Project standards (from CLAUDE.md):
7778
---
7879
${{ steps.rules.outputs.guidelines }}
7980
---
8081
81-
# CLI passthrough (GA style). Use camelCase --allowedTools per Anthropic CLI.
82+
# Allow Claude to enumerate files and publish via gh CLI
8283
claude_args: >-
8384
--allowedTools
8485
"Read"
@@ -89,8 +90,18 @@ jobs:
8990
"Bash(find:*)"
9091
"Bash(gh pr view:*)"
9192
"Bash(gh pr comment:*)"
93+
"Bash(gh issue comment:*)"
9294
--max-turns 8
9395
--verbose
9496
9597
env:
96-
GH_TOKEN: ${{ github.token }}
98+
GH_TOKEN: ${{ github.token }} # gh CLI auth
99+
# Provide both; prompt explains which to use
100+
PR_NUMBER: ${{ github.event.pull_request.number }}
101+
ISSUE_NUMBER: ${{ github.event.issue.number }}
102+
103+
- name: Job summary (non-blocking)
104+
if: always()
105+
run: |
106+
echo "### Claude on-mention run" >> "$GITHUB_STEP_SUMMARY"
107+
echo "If you requested a 'full audit', the report should now be posted via gh CLI." >> "$GITHUB_STEP_SUMMARY"

0 commit comments

Comments
 (0)