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
1816jobs :
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"
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