22# - Auto-reviews PRs targeting main (excludes drafts and forks)
33# - Responds to @claude mentions from org members only
44# - Uses OIDC auth with Claude GitHub App (id-token: write)
5+ #
6+ # Tip: you can pick a model by tagging it directly in a comment:
7+ # @claude-opus → claude-opus-latest (always latest opus, best for complex/security-critical PRs)
8+ # @claude-sonnet → claude-sonnet-latest (default)
9+ # @claude-haiku → claude-haiku-latest (always latest haiku, fast/cheap for quick questions)
510
611name : Claude review
712
@@ -113,7 +118,7 @@ jobs:
113118 # --system-prompt "If you inspect CI logs, never paste raw logs. Summarize likely cause only. Redact tokens, keys, credentials, or URLs with credentials. If unsure, say log may contain sensitive data and stop."
114119 # --max-turns 15
115120
116- # Job 2: @claude mentions in any PR comment (members only)
121+ # Job 2: @claude / @claude-opus / @claude-sonnet / @claude-haiku mentions in any PR comment (members only)
117122 # - issue_comment: PR conversation comments (no fork info available, member-check is sufficient)
118123 # - pull_request_review_comment: inline review comments (fork check added)
119124 # - pull_request_review: review submissions (fork check added)
@@ -234,11 +239,40 @@ jobs:
234239 gh pr comment "$PR_NUMBER" --repo "${{ github.repository }}" \
235240 --body "<!-- claude-apply-fail -->Skipped: PR diff failed to apply. Rebase and re-push."
236241
242+ - name : Resolve model and inline instructions from comment
243+ id : comment_parse
244+ if : steps.prmeta.outputs.is_fork != 'true' && steps.apply_diff.outputs.apply_ok != 'false'
245+ env :
246+ # pull_request_review uses .review.body; the others use .comment.body
247+ COMMENT_BODY : ${{ github.event.comment.body || github.event.review.body }}
248+ run : |
249+ set -euo pipefail
250+
251+ # Detect model qualifier (case-insensitive)
252+ if echo "$COMMENT_BODY" | grep -qi '@claude-opus'; then
253+ MODEL="claude-opus-latest"
254+ elif echo "$COMMENT_BODY" | grep -qi '@claude-haiku'; then
255+ MODEL="claude-haiku-latest"
256+ else
257+ # Covers both bare @claude and @claude-sonnet
258+ MODEL="claude-sonnet-latest"
259+ fi
260+
261+ # Strip the @claude* tag and surrounding whitespace to get any extra instructions
262+ INLINE_INSTRUCTIONS="$(echo "$COMMENT_BODY" | sed 's/@claude-[a-zA-Z0-9_-]*//gi; s/@claude//gi' | sed 's/^[[:space:]]*//; s/[[:space:]]*$//' | tr -s ' ')"
263+
264+ echo "model=$MODEL" >> "$GITHUB_OUTPUT"
265+ echo "inline_instructions<<EOF" >> "$GITHUB_OUTPUT"
266+ echo "$INLINE_INSTRUCTIONS" >> "$GITHUB_OUTPUT"
267+ echo "EOF" >> "$GITHUB_OUTPUT"
268+ echo "Selected model: $MODEL"
269+
237270 - uses : anthropics/claude-code-action@70e16deb18402428bd09e08d1ec3662a872e3c72 # v1
238271 # Skip Claude entirely on fork PRs or when diff apply fails.
239272 if : steps.prmeta.outputs.is_fork != 'true' && steps.apply_diff.outputs.apply_ok != 'false'
240273 with :
241274 anthropic_api_key : ${{ secrets.ORG_ANTHROPIC_API_KEY }}
275+ model : ${{ steps.comment_parse.outputs.model }}
242276 additional_permissions : " actions: read"
243277 track_progress : true
244278 prompt : |
@@ -248,10 +282,20 @@ jobs:
248282 REPO: ${{ github.repository }}
249283 PR NUMBER: ${{ steps.prmeta.outputs.pr_num }}
250284
285+ Look at the PR type from the title (feat|fix|docs|test|refactor|ci|perf|style|chore|release):
286+ - feat/fix: full review - correctness, security, edge cases, gas, events, test coverage
287+ - perf: focus on gas optimization correctness and no functional regressions
288+ - test: check assertions are correct, edge cases covered, no false positives
289+ - docs: check accuracy against actual code behavior
290+ - style/refactor: no functional changes - verify behavior is preserved
291+ - chore/ci/release: light review - check for unintended side effects
292+
251293 For Solidity changes, check:
252- 1. **Correctness**: Does it work? Edge cases handled? Invariants preserved?
253- 2. **Security**: Access control, reentrancy, overflow, unsafe external calls
254- 3. **Integration**: How do changes affect other contracts that interact with this one?
294+ 1. Correctness: does it work? edge cases handled? invariants preserved?
295+ 2. Security: access control, reentrancy, overflow, unsafe external calls
296+ 3. Gas: avoidable SLOADs/SSTOREs, tight loops, unnecessary memory copies
297+ 4. Events: emitted for all state changes with the right indexed fields
298+ 5. Integration: how do changes affect other contracts that interact with this one?
255299
256300 For each issue found:
257301 - Use inline comment on the specific line
@@ -264,6 +308,8 @@ jobs:
264308
265309 Use top-level comment for summary only.
266310
311+ ${{ steps.comment_parse.outputs.inline_instructions }}
312+
267313 claude_args : |
268314 --allowedTools "Read,Glob,Grep,mcp__github_inline_comment__create_inline_comment,Bash(git fetch:*),Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr checks:*),Bash(gh run list:*),Bash(gh run view:*)"
269315 --system-prompt "If you inspect CI logs, never paste raw logs. Summarize likely cause only. Redact tokens, keys, credentials, or URLs with credentials. If unsure, say log may contain sensitive data and stop."
0 commit comments