Skip to content

Commit 86afb38

Browse files
natemcmasterclaude
andcommitted
chore: improve Claude Code review workflow and command
Revert pull_request_target back to pull_request (OIDC token exchange doesn't support pull_request_target events). Align workflow with claude-code-action docs: write permission for pull-requests, camelCase --allowedTools, inline comment tool. Improve code-review command with GitHub posting instructions and test adequacy checks. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 34abf6d commit 86afb38

2 files changed

Lines changed: 19 additions & 19 deletions

File tree

.claude/commands/code-review.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
Review the pull request: $ARGUMENTS
44

5-
Use `gh pr diff` to fetch the changes, then review them according to the guidelines below.
5+
Use `gh pr diff` to fetch the changes and `gh pr view` to understand the PR description and context, then review according to the guidelines below.
66

77
---
88

9-
You are a senior software engineer performing code review for an open source C# .NET project. Your role is to identify **substantive issues** that could cause bugs, security vulnerabilities, or correctness problems. Provide only high-value feedback.
9+
You are performing code review for an open source C# .NET project. Your role is to identify **substantive issues** that could cause bugs, security vulnerabilities, or correctness problems. Provide only high-value feedback.
1010

1111
## Project Context
1212

@@ -47,6 +47,7 @@ Focus exclusively on:
4747
8. **Data integrity** - Lost updates, incorrect state transitions, violated invariants
4848
9. **Async/await issues** - Missing ConfigureAwait where needed, deadlock potential, fire-and-forget without error handling
4949
10. **Nullability issues** - Incorrect null-forgiving operators (`!`), missing null checks, nullability annotation mismatches
50+
11. **Test adequacy** - If the PR adds or changes behavior, do the tests actually cover the new/changed code paths? Missing assertions that would catch regressions? (Don't nitpick test style.)
5051

5152
## What to Ignore
5253

@@ -59,16 +60,12 @@ Do NOT comment on:
5960
- Performance optimizations unless there's a clear, significant problem
6061
- Pre-existing issues in unchanged code
6162

62-
## Output Format
63+
## How to Post Feedback
6364

64-
For each issue found:
65-
- **File and line**: Specify the exact location
66-
- **Severity**: Critical / High / Medium
67-
- **Issue**: One sentence describing the problem
68-
- **Why it matters**: Brief explanation of the consequence (bug, crash, security hole, data loss)
69-
- **Suggested fix**: Concrete recommendation (optional, only if non-obvious)
70-
71-
If the code looks correct, respond with a brief thank-you and confirmation, such as: "Thanks for this contribution! The changes look correct—no substantive issues found."
65+
- **Top-level summary**: Use `gh pr comment` to post your overall review summary.
66+
- **Specific code issues**: Use `mcp__github_inline_comment__create_inline_comment` (with `confirmed: true`) to annotate specific lines in the diff. This is preferred for file/line-specific feedback since it appears directly in the code context.
67+
- **Only post GitHub comments** - don't submit review text as chat messages.
68+
- If the code looks correct, post a brief thank-you and confirmation via `gh pr comment`. A clean "no issues" review is a good outcome.
7269

7370
## Guiding Principles
7471

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
name: Claude Code Review
22

33
on:
4-
pull_request_target:
4+
pull_request:
55
types: [opened, synchronize]
66

77
jobs:
88
claude-review:
99
runs-on: ubuntu-latest
1010
permissions:
1111
contents: read
12-
pull-requests: read
13-
issues: read
12+
pull-requests: write
1413
id-token: write
1514

1615
steps:
@@ -24,13 +23,17 @@ jobs:
2423
uses: anthropics/claude-code-action@v1
2524
with:
2625
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
26+
plugins: "code-review@claude-plugins-official"
2727
prompt: |
2828
REPO: ${{ github.repository }}
29-
/code-review ${{ github.event.pull_request.number }}
29+
PR NUMBER: ${{ github.event.pull_request.number }}
3030
31-
Use `gh pr comment` with your Bash tool to leave your review as a comment on the PR.
31+
Read .claude/commands/code-review.md and follow its instructions to review PR ${{ github.event.pull_request.number }}.
3232
33-
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
34-
# or https://code.claude.com/docs/en/cli-reference for available options
35-
claude_args: '--model opus --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:*)"'
33+
Note: The PR branch is already checked out in the current working directory.
3634
35+
Use `gh pr comment` for top-level feedback.
36+
Use `mcp__github_inline_comment__create_inline_comment` (with `confirmed: true`) to highlight specific code issues.
37+
Only post GitHub comments - don't submit review text as messages.
38+
39+
claude_args: '--model opus --allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*)"'

0 commit comments

Comments
 (0)