SuperAPI AI Directory

pr-triage

General & other

View repository

Updated 10-16 09:45

About this skill

PR triage

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

  1. gh pr view <PR番号> --json title,body,headRefName,baseRefName,changedFiles Fetch PR information with
  2. gh pr diff <PR番号> --name-only Fetch the list of changed files with
  3. 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
  4. .pr-review-state.json Check whether exists (previous review state)
  5. 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
  6. Output the analysis results to the .pr-triage.json file

Incremental mode (when .pr-review-state.json exists)

Optimize the check scope using the previous review state:

  1. .pr-review-state.json の last_reviewed_commit obtain
  2. git diff <last_reviewed_commit>..HEAD --name-only Identify files changed since the previous review with
  3. Files with no changesの surface_issues are carried over as-is from the previous state ("carried_over": true is added). Do not re-check.
  4. Files with changesPerform surface checks only on
  5. Of the previous surface_issues と review_comments , include those whose corresponding locations have been fixed in resolved_issues include in
  6. 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.json If does not exist, perform a normal full triage. .pr-review-state.json If 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):

  • any Use of type (TypeScript)
  • var Use 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 .