This is a skill that analyzes the PR changes and outputs structured information necessary for the subsequent code review phase. It is intended to run on a lightweight model (Haiku), contributing to cost optimization in CI environments.
Procedure
gh pr view <PR番号> --json title,body,headRefName,baseRefName,changedFilesFetch PR information withgh pr diff <PR番号> --name-onlyFetch the list of changed files with- Fetch the diff (If changedFiles is 15 or more, skip step 3 and analyze using only file names and the PR description):
- Only if changedFiles is less than 15,
gh pr diff <PR番号>fetch the code diff with - If there are many files requiring surface checks (.ts, .js, .tsx, .jsx), individually fetch with
gh pr diff <PR番号> -- <file>fetch with
- Only if changedFiles is less than 15,
.pr-review-state.jsonCheck whether exists (previous review state)- Perform the following analysis:
- Category classification of changed files (added/modified/deleted)
- Detection of languages/frameworks used
- Determination of change categories (authorization changes, DB changes, RLS changes, API changes, test changes, configuration changes, skill changes)
- Determination of required reference files
- Detection of Minor/Suggestion-level surface issues (in incremental mode, only changed files)
- Summary of the diff (within 200 characters)
- Points to focus on during review
- Output the analysis results to the
.pr-triage.jsonfile
Incremental mode (when .pr-review-state.json exists)
Optimize the check scope using the previous review state:
.pr-review-state.jsonのlast_reviewed_commitobtaingit diff <last_reviewed_commit>..HEAD --name-onlyIdentify files changed since the previous review with- Files with no changesの
surface_issuesare carried over as-is from the previous state ("carried_over": trueis added). Do not re-check. - Files with changesPerform surface checks only on
- Of the previous
surface_issuesとreview_comments, include those whose corresponding locations have been fixed inresolved_issuesinclude in - Add the following fields to the output
.pr-triage.jsonに"incremental": true、"base_commit"、"changed_since_last_review"、"unchanged_since_last_review"、"resolved_issues"field
resolved_issues format:
{
"comment_id": 12345678,
"file": "<ファイルパス>",
"line": 42,
"issue": "<元の問題の説明>",
"resolution": "fixed"
}
.pr-review-state.jsonIf does not exist, perform a normal full triage..pr-review-state.jsonIf is in an invalid format (JSON parse error, etc.), output a warning and perform a full triage. Do not run incremental mode based on a corrupted state file.
Criteria for determining required references
Only when the following conditions apply, include the corresponding reference in required_references include in:
- TypeScript/JavaScript file changes present →
typescript-best-practices.md - Code changes related to authentication/authorization present (keywords such as auth, permission, role, session, token) →
authorization-review-general.md - Changes related to PostgreSQL RLS present (keywords such as RLS, row level security, policy) →
authorization-review-postgres-rls.md - SKILL.md file changes present →
skill-review.md - GitHub posting required in CI environment →
github-pr-review-actions.md(always include)
Surface-level check items (Minor/Suggestion)
Review the diff and detect the following issues (only those that apply):
anyUse of type (TypeScript)varUse of keyword (TypeScript/JavaScript)- Empty interface definition
- Use of magic numbers
- Naming convention violations (camelCase/PascalCase/UPPER_CASE)
- Tests not added (there are new files but no test files)
Output format
.pr-triage.json Output in the following JSON structure:
{
"pr_number": 123,
"incremental": false,
"base_commit": "<前回レビュー時のコミットSHA(インクリメンタル時のみ)>",
"summary": "<変更の概要(1-2文)>",
"files": {
"added": ["<追加ファイルパス>"],
"modified": ["<変更ファイルパス>"],
"deleted": ["<削除ファイルパス>"]
},
"changed_since_last_review": ["<前回から変更があったファイル(インクリメンタル時のみ)>"],
"unchanged_since_last_review": ["<前回から変更がないファイル(インクリメンタル時のみ)>"],
"languages": ["<検出された言語>"],
"frameworks": ["<検出されたフレームワーク>"],
"change_categories": {
"has_auth_changes": false,
"has_db_changes": false,
"has_rls_changes": false,
"has_api_changes": false,
"has_test_changes": false,
"has_config_changes": true,
"has_skill_changes": true
},
"required_references": ["<必要なリファレンスファイル名>"],
"surface_issues": [
{
"severity": "Minor|Suggestion",
"file": "<ファイルパス>",
"line": 15,
"issue": "<問題の説明>",
"suggestion": "<改善案>",
"carried_over": true
}
],
"resolved_issues": [
{
"comment_id": 12345678,
"file": "<ファイルパス>",
"line": 42,
"issue": "<元の問題の説明>",
"resolution": "fixed"
}
],
"diff_summary": "<差分の要約(200文字以内)>",
"estimated_complexity": "low|medium|high",
"focus_areas": ["<レビュー時の注目ポイント>"]
}
Important:
- Keep text output to a minimum and focus on the output of
.pr-triage.json.