PR反馈分类器Skill pr-feedback-classifier

这个技能用于获取和分类PR(拉取请求)的审查反馈,通过上下文隔离返回结构化的JSON输出,帮助开发者在处理评论前进行分析。它适用于自动化代码审查流程,提升开发效率。关键词:PR反馈、代码审查、分类、自动化、DevOps、结构化JSON。

DevOps 0 次安装 0 次浏览 更新于 3/18/2026

name: pr-feedback-classifier description: > 获取并分类PR审查反馈,具有上下文隔离。 返回带有线程ID的结构化JSON以便确定性解决。 在解决PR评论前分析时使用。 argument-hint: “[–pr <number>] [–include-resolved]” context: fork agent: general-purpose model: sonnet

PR反馈分类器

获取和分类当前分支PR的所有审查反馈。

参数

  • --pr <number>: 指定PR号(默认:当前分支的PR)
  • --include-resolved: 包含已解决的线程(供参考)

检查 $ARGUMENTS 获取标志。

步骤

  1. 获取当前分支和PR信息:

    • 如果在 $ARGUMENTS 中指定了 --pr <number>

      gh pr view <number> --json number,title,url -q '{number: .number, title: .title, url: .url}'
      
    • 如果未指定 --pr(使用当前分支):

      git rev-parse --abbrev-ref HEAD
      gh pr view --json number,title,url -q '{number: .number, title: .title, url: .url}'
      
  2. 获取所有评论:

    # 如果 $ARGUMENTS 中包含 --include-resolved:
    erk exec get-pr-review-comments [--pr <number>] --include-resolved
    # 否则:
    erk exec get-pr-review-comments [--pr <number>]
    
    erk exec get-pr-discussion-comments [--pr <number>]
    

    注意:当在 $ARGUMENTS 中指定时,传递 --pr <number> 给两个exec命令。

  3. 使用下面的评论分类模型对每个评论进行分类。

  4. 按复杂性分组为批次。

  5. 输出结构化JSON(下面的模式)。

评论分类模型

对于每个评论,确定:

分类

分类决定线程如何呈现给用户,而不是是否出现。

  • 可操作的:请求代码更改、需要修复的违规、缺失的测试、请求文档更新
  • 信息性的:机器人建议(可选/可能)、CI生成的样式建议、审查线程上的确认

重要: 每个未解决的审查线程都进入 actionable_threads,无论来自机器人还是人类。classification 字段区分用户应如何处理。

纯粹信息性的讨论评论(CI状态更新、Graphite堆栈评论、PR描述摘要)仍计入 informational_count,并且不出现在 actionable_threads 中。

复杂性

  • local:指定位置的单行更改
  • single_file:一个文件中的多个更改
  • cross_cutting:跨多个文件的更改
  • complex:需要架构更改或相关重构

批次排序

  1. 本地修复 (auto_proceed: true):单行更改
  2. 单文件 (auto_proceed: true):一个文件中的多位置
  3. 跨切 (auto_proceed: false):多个文件
  4. 复杂 (auto_proceed: false):架构更改
  5. 信息性 (auto_proceed: false):分类为 informational 的线程 — 用户决定操作或忽略

输出格式

仅输出以下JSON(无散文、无Markdown、无代码块):

{
  "success": true,
  "pr_number": 5944,
  "pr_title": "Feature: Add new API endpoint",
  "pr_url": "https://github.com/owner/repo/pull/5944",
  "actionable_threads": [
    {
      "thread_id": "PRRT_kwDOPxC3hc5q73Ne",
      "type": "review",
      "path": "src/api.py",
      "line": 42,
      "is_outdated": false,
      "classification": "actionable",
      "action_summary": "Add integration tests for new endpoint",
      "complexity": "local",
      "original_comment": "This needs integration tests"
    },
    {
      "thread_id": "PRRT_kwDOPxC3hc5q73Nf",
      "type": "review",
      "path": "src/utils.py",
      "line": 10,
      "is_outdated": false,
      "classification": "informational",
      "action_summary": "Bot suggestion: extract helper function (optional)",
      "complexity": "local",
      "original_comment": "Consider extracting this into a helper"
    }
  ],
  "discussion_actions": [
    {
      "comment_id": 12345678,
      "action_summary": "Update API documentation",
      "complexity": "cross_cutting",
      "original_comment": "Please update the docs to reflect..."
    }
  ],
  "informational_count": 12,
  "batches": [
    {
      "name": "Local Fixes",
      "complexity": "local",
      "auto_proceed": true,
      "item_indices": [0]
    },
    {
      "name": "Cross-Cutting",
      "complexity": "cross_cutting",
      "auto_proceed": false,
      "item_indices": [0]
    },
    {
      "name": "Informational",
      "complexity": "informational",
      "auto_proceed": false,
      "item_indices": [1]
    }
  ],
  "error": null
}

字段注释:

  • thread_id: 用于 erk exec resolve-review-thread 所需的ID
  • comment_id: 用于 erk exec reply-to-discussion-comment 所需的ID
  • classification: "actionable""informational" — 决定用户如何处理线程
  • item_indices: 引用 actionable_threads (type=review) 或 discussion_actions (type=discussion) 中的索引
  • original_comment: 评论文本的前200个字符
  • informational_count: 仅信息性讨论评论的计数(CI状态、Graphite堆栈)。审查线程始终以 classification 字段出现在 actionable_threads

错误情况

如果分支没有PR或API失败:

{
  "success": false,
  "pr_number": null,
  "pr_title": null,
  "pr_url": null,
  "actionable_threads": [],
  "discussion_actions": [],
  "informational_count": 0,
  "batches": [],
  "error": "No PR found for branch feature-xyz"
}

无评论情况

如果PR存在但没有未解决评论:

{
  "success": true,
  "pr_number": 5944,
  "pr_title": "Feature: Add new API endpoint",
  "pr_url": "https://github.com/owner/repo/pull/5944",
  "actionable_threads": [],
  "discussion_actions": [],
  "informational_count": 0,
  "batches": [],
  "error": null
}