pr-triage
xtone/ai_development_tools
Analyze PR changes and classify them by category, surface issues, and required references for cost-optimized CI review.
What is pr-triage?
Triages pull request changes by analyzing diffs, classifying modification types, detecting surface-level issues, and identifying required reference documents. Outputs structured JSON (`.pr-triage.json`) for downstream code review phases, optimized for lightweight model execution in CI environments.
- Classifies changed files by category (added/modified/deleted) and detects change types (auth, DB, RLS, API, tests, config, skills)
- Detects programming languages and frameworks from file changes
- Identifies surface-level issues (Minor/Suggestion severity) like `any` types, `var` usage, magic numbers, and naming violations
- Determines required reference documents based on change content (TypeScript best practices, authorization, RLS, skill review, GitHub actions)
- Supports incremental mode: reuses previous review state to check only modified files and track resolved issues
- Generates diff summary, complexity estimate, and focus areas for downstream reviewers
How to install pr-triage
npx skills add https://github.com/xtone/ai_development_tools --skill pr-triage- GitHub CLI (`gh`) installed and authenticated
- Git repository with PR history
- Optional: `.pr-review-state.json` from previous review cycle for incremental mode
How to use pr-triage
- 1.Run the skill on a PR number: it fetches PR metadata and diffs using `gh pr` commands
- 2.For PRs with <15 changed files, full diffs are analyzed; larger PRs use filename and description only
- 3.Skill detects change categories, languages, frameworks, and surface issues
- 4.If `.pr-review-state.json` exists, incremental mode activates to check only modified files and track resolved issues
- 5.Output `.pr-triage.json` contains classification, issues, required references, and focus areas for review
Use cases
- Reduce CI costs by running lightweight triage before expensive full code reviews
- Identify high-risk changes (auth, DB, RLS) that need specialized review early
- Track which surface issues have been fixed across multiple review cycles using incremental mode
- Provide structured metadata to downstream review automation tools
- Detect missing tests or documentation for new code changes
- CI/CD pipeline operators optimizing review costs
- Development teams using multi-stage code review workflows
- Projects with frequent PRs needing automated triage
- Teams using lightweight models (Haiku) for initial analysis
pr-triage FAQ
Diffs are skipped; analysis uses only filenames and PR description to avoid excessive token usage. This is intentional for cost optimization.
If `.pr-review-state.json` exists from a previous review, the skill checks only files changed since last review, carries over unchanged file issues, and tracks which issues were resolved.
Minor/Suggestion level problems detected in diffs: `any` types, `var` usage, empty interfaces, magic numbers, naming violations, and missing tests.
Determined by change content: TypeScript files need `typescript-best-practices.md`; auth changes need `authorization-review-general.md`; RLS changes need `authorization-review-postgres-rls.md`; SKILL.md changes need `skill-review.md`; GitHub actions always included.
No; the skill requires `gh pr view` and `gh pr diff` commands to fetch PR data and diffs.
Full instructions (SKILL.md)
Source of truth, from xtone/ai_development_tools.
name: pr-triage
description: PRの変更内容をトリアージし、変更カテゴリ分類・表層チェック・必要リファレンス判定を行います。結果を.pr-triage.jsonに出力し、後続のコードレビューフェーズで活用します。CI環境でのコスト最適化に使用してください。
PRトリアージ
PRの変更内容を分析し、後続のコードレビューフェーズに必要な情報を構造化して出力するスキルです。 軽量モデル(Haiku)での実行を想定しており、CI環境でのコスト最適化に寄与します。
手順
gh pr view <PR番号> --json title,body,headRefName,baseRefName,changedFilesでPR情報を取得gh pr diff <PR番号> --name-onlyで変更ファイル一覧を取得- 差分の取得(changedFilesが15以上の場合、手順3はスキップしてファイル名とPR説明のみで分析する):
- changedFilesが15未満の場合のみ
gh pr diff <PR番号>でコード差分を取得 - 表層チェックが必要なファイル(.ts, .js, .tsx, .jsx)が多い場合は個別に
gh pr diff <PR番号> -- <file>で取得
- changedFilesが15未満の場合のみ
.pr-review-state.jsonが存在するか確認する(前回レビュー状態)- 以下の分析を行う:
- 変更ファイルのカテゴリ分類(added/modified/deleted)
- 使用言語・フレームワークの検出
- 変更カテゴリの判定(認可変更、DB変更、RLS変更、API変更、テスト変更、設定変更、スキル変更)
- 必要なリファレンスファイルの判定
- Minor/Suggestionレベルの表層的問題の検出(インクリメンタルモード時は変更ファイルのみ)
- 差分の要約(200文字以内)
- レビュー時に注目すべきポイント
- 分析結果を
.pr-triage.jsonファイルに出力する
インクリメンタルモード(.pr-review-state.json が存在する場合)
前回のレビュー状態を活用してチェック範囲を最適化する:
.pr-review-state.jsonのlast_reviewed_commitを取得するgit diff <last_reviewed_commit>..HEAD --name-onlyで前回レビュー以降に変更されたファイルを特定する- 変更のないファイルの
surface_issuesは前回の状態からそのまま引き継ぐ("carried_over": trueを付与)。再チェックしない。 - 変更があったファイルのみ表層チェックを実行する
- 前回の
surface_issuesとreview_commentsのうち、該当箇所が修正されたものをresolved_issuesに含める - 出力の
.pr-triage.jsonに"incremental": true、"base_commit"、"changed_since_last_review"、"unchanged_since_last_review"、"resolved_issues"フィールドを追加する
resolved_issues のフォーマット:
{
"comment_id": 12345678,
"file": "<ファイルパス>",
"line": 42,
"issue": "<元の問題の説明>",
"resolution": "fixed"
}
.pr-review-state.jsonが存在しない場合は、通常のフルトリアージを実行する。.pr-review-state.jsonが不正な形式(JSONパースエラー等)の場合は、警告を出力してフルトリアージを実行する。破損した状態ファイルに基づいてインクリメンタルモードを実行してはならない。
必要なリファレンスの判定基準
以下の条件に該当する場合のみ、対応するリファレンスを required_references に含める:
- TypeScript/JavaScript ファイルの変更あり →
typescript-best-practices.md - 認証・認可に関わるコード変更あり(auth, permission, role, session, token等のキーワード) →
authorization-review-general.md - PostgreSQL RLS に関わる変更あり(RLS, row level security, policy等のキーワード) →
authorization-review-postgres-rls.md - SKILL.md ファイルの変更あり →
skill-review.md - CI環境でのGitHub投稿が必要 →
github-pr-review-actions.md(常に含める)
表層チェック項目(Minor/Suggestion)
差分を確認し、以下の問題を検出する(該当するもののみ):
any型の使用(TypeScript)varキーワードの使用(TypeScript/JavaScript)- 空のインターフェイス定義
- マジックナンバーの使用
- 命名規則違反(camelCase/PascalCase/UPPER_CASE)
- テストの未追加(新規ファイルがあるのにテストファイルがない)
出力フォーマット
.pr-triage.json に以下のJSON構造で出力すること:
{
"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": ["<レビュー時の注目ポイント>"]
}
重要:
- テキスト出力は最小限にし、
.pr-triage.jsonの出力に集中してください。
Related skills
More from xtone/ai_development_tools and the wider catalog.

code-review
Systematic code review for PRs and changes across languages, evaluating quality, security, and design.

agnes-ai-generation
Call Agnes AI text, image, and video generation APIs through apihub.agnes-ai.com

401-403-bypass-techniques
401/403 access control bypass techniques for admin panels and restricted endpoints.

active-directory-acl-abuse
Exploit misconfigured Active Directory ACL permissions for privilege escalation and lateral movement.

active-directory-certificate-services
AD CS attack playbook covering ESC1-ESC13 template abuse, NTLM relay, and certificate-based persistence.

active-directory-kerberos-attacks
Kerberos attack playbook for Active Directory: AS-REP roasting, Kerberoasting, ticket forging, and delegation abuse.