😊
スコアとサジェストが付くClaudeCodeActionsプロンプト
Claude Code Actionsを用いたレビューエージェントへのプロンプトメモ.
動機
Qudo Mergeが結構好きだった.
claude code actionsを公式Doc通りに入れてレビューさせた場合と比較すると,Qudo Mergeのほうが簡潔で,より鋭いレビューという印象を受けた.
ただ,あれこれ課金しているとキリがないので,なんとか同様のクオリティをClaudeCodeActionsで担保できないかと思い,Gemini CLIにqudo mergeのコードを解析させたら,どうやらreflectionステップ入れてるとのこと
第一ステップ
内省ステップ
プロンプト
これを元に,以下のようなプロンプトにしたところある程度にたレビューが行えるようになった
`ci-workflow/.github/workflows/claude-code-review.yml`
# Placed in common CI repository. .github/workflows/claude-code-review.yml
name: Claude Code Review
on:
workflow_call:
inputs:
claude-model:
required: false
type: string
default: 'claude-sonnet-4'
description: 'Claude AI model to use for code review'
secrets:
CLAUD_TOKEN: # Name it something generic like CLAUD_TOKEN
required: true
description: 'The authentication token for Claude AI Code Review.'
jobs:
claude-review:
# Only run on non-draft PRs
if: |
github.event.pull_request.draft == false &&
!contains(github.event.pull_request.title, '[skip-review]') &&
!contains(github.event.pull_request.title, '[WIP]')
# Optional: Filter by PR author
# if: |
# github.event.pull_request.user.login == 'external-contributor' ||
# github.event.pull_request.user.login == 'new-developer' ||
# github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
issues: read
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Run Claude Code Review
id: claude-review
uses: anthropics/claude-code-action@beta
with:
claude_code_oauth_token: ${{ secrets.CLAUD_TOKEN }}
model: ${{ inputs.claude-model }}
# Direct prompt for automated review (no @claude mention needed)
direct_prompt: |
You are a senior software engineer assigned to review a pull request. Your primary goal is to ensure the codebase remains consistent, cohesive, decoupled, clean, and simple. │
│
Your review process should follow these two steps: │
│
**Step 1: Initial Code Review and Suggestion Generation** │
│
First, thoroughly review the code changes in the pull request. Based on your analysis, generate a list of suggestions to improve the code. For each suggestion, provide the following information: │
│
- **`one_sentence_summary`**: A concise, single-sentence overview of the suggested improvement. │
- **`suggestion_content`**: A detailed explanation of the suggestion, including what the issue is and why it's a concern. │
- **`relevant_file`**: The file where the suggested change should be applied. │
- **`existing_code`**: The code snippet that needs to be improved. │
- **`improved_code`**: The suggested code to replace the existing snippet. │
- **`label`**: A category for the suggestion (e.g., Bug, Performance, Security, Readability). │
│
**Step 2: Self-Reflection and Scoring** │
│
After generating the initial suggestions, you will critically review your own suggestions. For each suggestion, you must provide: │
│
- **`suggestion_score`** (1-10): A score indicating the importance of the suggestion. │
- **`why`**: A brief justification for the score. │
- **`relevant_lines_start`** and **`relevant_lines_end`**: The exact line numbers where the suggestion should be applied. │
│
**Output Format** │
│
Please provide your final review in the following structured format: │
│
## PR Code Suggestions ✨ │
│
Explore these optional code suggestions: │
│
<table><thead><tr><td><strong>Category</strong></td><td align=left><strong>Suggestion</strong></td><td align=center><strong>Impact</strong></td></tr></thead><tbody> │
│
[For each actionable suggestion, use this format:] │
<tr><td rowspan=1>[label]</td> │
<td> │
│
<details><summary>[one_sentence_summary]</summary> │
│
___ │
│
**[suggestion_content]** │
│
[relevant_file] │
│
```diff │
--- a/[relevant_file] │
+++ b/[relevant_file] │
@@ -[relevant_lines_start],[relevant_lines_end] +[relevant_lines_start],[relevant_lines_end] @@ │
-[existing_code] │
+[improved_code] │
``` │
│
<details><summary>Suggestion importance[1-10]: [suggestion_score]</summary> │
│
__ │
│
Why: [why] │
│
</details></details></td><td align=center>[Impact Level] │
│
</td></tr> │
│
</tbody></table> │
│
### Review Focus Areas: │
- Code quality and best practices (Martin Fowler principles) │
- Potential bugs or issues │
- Performance considerations │
- Security concerns │
- Test coverage (t-wada approach) │
- Business logic placement and cohesion │
- File organization and architecture │
- YAGNI, KISS, DRY, SOLID principles │
│
If no significant issues are found, simply state "No significant issues found" under Detailed Findings. │
If no code suggestions are needed, omit the "PR Code Suggestions" section entirely. │
│
Be constructive and helpful in your feedback.
# Optional: Use sticky comments to make Claude reuse the same comment on subsequent pushes to the same PR
use_sticky_comment: true
これを共通のワークフローレポジトリにおいて,あとは利用するレポジトリから呼び出すだけ.
`my-service/.github/workflows/review.yaml`
# Placed in each repository .github/workflows/
name: Claude Code Review
on:
pull_request:
types: [opened, synchronize]
jobs:
claude-review:
uses: <your org>/ci-workflows/.github/workflows/claude-code-review.yml@main
permissions:
contents: read
pull-requests: write
issues: write
id-token: write
with:
claude-model: "claude-opus-4-20250514"
secrets:
CLAUD_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
一応Gist
レビュー結果の例
こんな感じにトリアージしてカテゴライズ,サジェストしてくれる

Discussion