ln-311-agent-reviewer

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
Paths: File paths (
shared/
,
references/
,
../ln-*
) are relative to skills repo root. If not found at CWD, locate this SKILL.md directory and go up one level for repo root.
路径: 文件路径(
shared/
references/
../ln-*
)是相对于技能仓库根目录的。如果在当前工作目录(CWD)中未找到,请定位到本SKILL.md所在目录,然后向上一级即为仓库根目录。

Agent Reviewer (Story)

Agent评审器(Story版)

Runs parallel external agent reviews on validated Story and Tasks, critically verifies suggestions, returns editorial improvements.
对已验证的Story和任务执行并行外部Agent评审,严格验证建议内容,返回编辑优化方案。

Purpose & Scope

目标与范围

  • Worker in ln-310 validation pipeline (invoked in Phase 5)
  • Run codex-review + gemini-review as background tasks in parallel
  • Process results as they arrive (first-finished agent processed immediately)
  • Critically verify each suggestion; debate with agent if Claude disagrees
  • Return filtered, deduplicated, verified suggestions for Story/Tasks improvement
  • Health check + prompt execution in single invocation
  • ln-310验证流水线中的工作组件(在第5阶段调用)
  • 以后台任务形式并行运行codex-review与gemini-review
  • 结果到达即处理(先完成的Agent结果立即处理)
  • 严格验证每条建议;若Claude持不同意见,则与Agent展开辩论
  • 返回经过筛选、去重、验证的Story/任务优化建议
  • 单次调用即可完成健康检查与提示词执行

When to Use

使用时机

  • Invoked by ln-310-story-validator Phase 5 (Agent Review)
  • After Phase 4 auto-fixes applied, Penalty Points = 0
  • Story and Tasks are in their final form before approval
  • 由ln-310-story-validator在第5阶段(Agent评审)调用
  • 第4阶段自动修复完成后,罚分(Penalty Points)= 0
  • Story和任务处于批准前的最终版本状态

Inputs (from parent skill)

输入(来自父技能)

  • storyId
    : Linear Story identifier (e.g., "PROJ-123")
  • storyId
    : Linear Story的唯一标识(例如:"PROJ-123")

Workflow

工作流程

MANDATORY READ: Load
shared/references/agent_delegation_pattern.md
for Reference Passing Pattern, Review Persistence Pattern, Agent Timeout Policy, and Debate Protocol (Challenge Round 1 + Follow-Up Round).
  1. Health check:
    python shared/agents/agent_runner.py --health-check
    • Filter output by
      skill_groups
      containing "311"
    • If 0 agents available -> return
      {verdict: "SKIPPED", reason: "no agents available"}
    • Display:
      "Agent Health: codex-review OK, gemini-review OK"
      (or similar)
  2. Get references: Call Linear MCP
    get_issue(storyId)
    -> extract URL + identifier. Call
    list_issues(filter: {parent: {id: storyId}})
    -> extract child Task URLs/identifiers.
    • If project stores tasks locally (e.g.,
      docs/tasks/
      ) -> use local file paths instead of Linear URLs.
  3. Ensure .agent-review/:
    • If
      .agent-review/
      exists -> reuse as-is, do NOT recreate
      .gitignore
    • If
      .agent-review/
      does NOT exist -> create it +
      .agent-review/.gitignore
      (content:
      *
      +
      !.gitignore
      )
    • Create
      .agent-review/{agent}/
      subdirs only if they don't exist
    • Do NOT add
      .agent-review/
      to project root
      .gitignore
  4. Build prompt: Read template
    shared/agents/prompt_templates/story_review.md
    .
    • Replace
      {story_ref}
      with
      - Linear: {url}
      or
      - File: {path}
    • Replace
      {task_refs}
      with bullet list:
      - {identifier}: {url_or_path}
      per task
    • Save to
      .agent-review/{agent}/{identifier}_storyreview_prompt.md
      (one copy per agent — identical content)
  5. Run agents (background, process-as-arrive):
    a) Launch BOTH agents as background Bash tasks (run_in_background=true):
    • python shared/agents/agent_runner.py --agent codex-review --prompt-file .agent-review/codex/{identifier}_storyreview_prompt.md --output-file .agent-review/codex/{identifier}_storyreview_result.md --cwd {cwd}
    • python shared/agents/agent_runner.py --agent gemini-review --prompt-file .agent-review/gemini/{identifier}_storyreview_prompt.md --output-file .agent-review/gemini/{identifier}_storyreview_result.md --cwd {cwd}
    b) When first agent completes (background task notification):
    • Read its result file from
      .agent-review/{agent}/{identifier}_storyreview_result.md
    • Parse JSON between
      <!-- AGENT_REVIEW_RESULT -->
      /
      <!-- END_AGENT_REVIEW_RESULT -->
      markers
    • Parse
      session_id
      from runner JSON output; write
      .agent-review/{agent}/{identifier}_session.json
      :
      {"agent": "...", "session_id": "...", "review_type": "storyreview", "created_at": "..."}
    • Proceed to Step 6 (Critical Verification) for this agent's suggestions
    c) When second agent completes:
    • Read its result file, parse suggestions
    • Run Step 6 for second batch
    • Merge verified suggestions from both agents
    d) If an agent fails: log failure, continue with available results
  6. Critical Verification + Debate (per Debate Protocol in
    shared/references/agent_delegation_pattern.md
    ):
    For EACH suggestion from agent results:
    a) Claude Evaluation: Independently assess — is the issue real? Actionable? Conflicts with project patterns?
    b) AGREE → accept as-is. DISAGREE/UNCERTAIN → initiate challenge.
    c) Challenge + Follow-Up (with session resume): Follow Debate Protocol (Challenge Round 1 → Follow-Up Round if not resolved). Resume agent's review session for full context continuity:
    • Read
      session_id
      from
      .agent-review/{agent}/{identifier}_session.json
    • Run with
      --resume-session {session_id}
      — agent continues in same session, preserving file analysis and reasoning
    • If
      session_resumed: false
      in result → log warning, result still valid (stateless fallback)
    • {review_type}
      = "Story/Tasks"
    • Challenge files:
      .agent-review/{agent}/{identifier}_storyreview_challenge_{N}_prompt.md
      /
      _result.md
    • Follow-up files:
      .agent-review/{agent}/{identifier}_storyreview_followup_{N}_prompt.md
      /
      _result.md
    d) Persist: all challenge and follow-up prompts/results in
    .agent-review/{agent}/
  7. Aggregate + Return: Collect ACCEPTED suggestions only (after verification + debate). Deduplicate by
    (area, issue)
    — keep higher confidence. Filter:
    confidence >= 90
    AND
    impact_percent > 2
    . Return JSON with suggestions + agent_stats + debate_log to parent skill. NO cleanup/deletion.
必读要求: 加载
shared/references/agent_delegation_pattern.md
,参考其中的引用传递模式、评审持久化模式、Agent超时策略,以及辩论协议(第一轮质疑 + 跟进轮次)。
  1. 健康检查: 执行
    python shared/agents/agent_runner.py --health-check
    • 按包含"311"的
      skill_groups
      过滤输出结果
    • 若可用Agent数量为0 → 返回
      {verdict: "SKIPPED", reason: "no agents available"}
    • 显示内容:
      "Agent健康状态:codex-review正常,gemini-review正常"
      (或类似格式)
  2. 获取参考信息: 调用Linear MCP的
    get_issue(storyId)
    接口 → 提取URL与唯一标识。调用
    list_issues(filter: {parent: {id: storyId}})
    → 提取子任务的URL/唯一标识。
    • 若项目将任务存储在本地(例如:
      docs/tasks/
      )→ 改用本地文件路径而非Linear URL
  3. 确保.agent-review/目录存在:
    • .agent-review/
      已存在 → 直接复用,不要重新创建
      .gitignore
    • .agent-review/
      不存在 → 创建该目录及
      .agent-review/.gitignore
      (内容为:
      *
      +
      !.gitignore
    • 仅在子目录不存在时,创建
      .agent-review/{agent}/
      子目录
    • 不要
      .agent-review/
      添加到项目根目录的
      .gitignore
  4. 构建提示词: 读取模板文件
    shared/agents/prompt_templates/story_review.md
    • {story_ref}
      替换为
      - Linear: {url}
      - 文件: {path}
    • {task_refs}
      替换为项目符号列表:每个任务对应
      - {唯一标识}: {url或路径}
    • 将构建好的提示词保存到
      .agent-review/{agent}/{identifier}_storyreview_prompt.md
      (每个Agent一份,内容完全相同)
  5. 运行Agent(后台执行,到达即处理):
    a) 以Bash后台任务形式启动两个Agent(
    run_in_background=true
    ):
    • python shared/agents/agent_runner.py --agent codex-review --prompt-file .agent-review/codex/{identifier}_storyreview_prompt.md --output-file .agent-review/codex/{identifier}_storyreview_result.md --cwd {cwd}
    • python shared/agents/agent_runner.py --agent gemini-review --prompt-file .agent-review/gemini/{identifier}_storyreview_prompt.md --output-file .agent-review/gemini/{identifier}_storyreview_result.md --cwd {cwd}
    b) 当第一个Agent完成时(后台任务通知):
    • .agent-review/{agent}/{identifier}_storyreview_result.md
      读取结果文件
    • 解析
      <!-- AGENT_REVIEW_RESULT -->
      /
      <!-- END_AGENT_REVIEW_RESULT -->
      标记之间的JSON内容
    • 从运行器的JSON输出中解析
      session_id
      ,并写入
      .agent-review/{agent}/{identifier}_session.json
      {"agent": "...", "session_id": "...", "review_type": "storyreview", "created_at": "..."}
    • 针对该Agent的建议,进入步骤6(严格验证)
    c) 当第二个Agent完成时:
    • 读取其结果文件,解析建议内容
    • 对第二批次建议执行步骤6
    • 合并两个Agent的已验证建议
    d) 若某个Agent执行失败:记录失败日志,继续处理可用结果
  6. 严格验证 + 辩论(遵循
    shared/references/agent_delegation_pattern.md
    中的辩论协议):
    针对Agent结果中的每条建议:
    a) Claude评估: 独立评估——该问题是否真实存在?是否可执行?是否与项目模式冲突?
    b) 同意 → 直接采纳该建议。不同意/不确定 → 发起质疑
    c) 质疑 + 跟进(会话续接): 遵循辩论协议(第一轮质疑 → 若未解决则进入跟进轮次)。续接Agent的评审会话以保持上下文连续性:
    • .agent-review/{agent}/{identifier}_session.json
      读取
      session_id
    • 执行命令时添加
      --resume-session {session_id}
      参数——Agent将在同一会话中继续,保留文件分析与推理过程
    • 若结果中
      session_resumed: false
      → 记录警告,结果依然有效(无状态回退)
    • {review_type}
      = "Story/任务"
    • 质疑相关文件:
      .agent-review/{agent}/{identifier}_storyreview_challenge_{N}_prompt.md
      /
      _result.md
    • 跟进相关文件:
      .agent-review/{agent}/{identifier}_storyreview_followup_{N}_prompt.md
      /
      _result.md
    d) 持久化: 所有质疑与跟进的提示词/结果均保存在
    .agent-review/{agent}/
    目录中
  7. 聚合 + 返回: 仅收集已采纳的建议(经过验证 + 辩论环节后) 按
    (领域, 问题)
    维度去重——保留置信度更高的建议 过滤规则:
    confidence >= 90
    impact_percent > 2
    返回包含建议、agent_stats、debate_log的JSON数据给父技能。不执行清理/删除操作

Output Format

输出格式

yaml
verdict: STORY_ACCEPTABLE | SUGGESTIONS | SKIPPED
suggestions:
  - area: "security | performance | architecture | feasibility | best_practices | risk_analysis"
    issue: "What is wrong or could be improved"
    suggestion: "Specific change to Story or Tasks"
    confidence: 95
    impact_percent: 15
    source: "codex-review"
    resolution: "accepted | accepted_after_debate | accepted_after_followup | rejected"
agent_stats:
  - name: "codex-review"
    duration_s: 8.2
    suggestion_count: 2
    accepted_count: 1
    challenged_count: 1
    followup_count: 1
    status: "success | failed | timeout"
debate_log:
  - suggestion_summary: "Missing rate limiting on POST /api/users"
    agent: "codex-review"
    rounds:
      - round: 1
        claude_position: "Rate limiting exists in nginx config"
        agent_decision: "DEFEND"
        resolution: "follow_up"
      - round: 2
        claude_position: "Nginx config covers /api/* routes, agent cited only app-level"
        agent_decision: "MODIFY"
        resolution: "accepted_after_followup"
    final_resolution: "accepted_after_followup"
yaml
verdict: STORY_ACCEPTABLE | SUGGESTIONS | SKIPPED
suggestions:
  - area: "security | performance | architecture | feasibility | best_practices | risk_analysis"
    issue: "What is wrong or could be improved"
    suggestion: "Specific change to Story or Tasks"
    confidence: 95
    impact_percent: 15
    source: "codex-review"
    resolution: "accepted | accepted_after_debate | accepted_after_followup | rejected"
agent_stats:
  - name: "codex-review"
    duration_s: 8.2
    suggestion_count: 2
    accepted_count: 1
    challenged_count: 1
    followup_count: 1
    status: "success | failed | timeout"
debate_log:
  - suggestion_summary: "Missing rate limiting on POST /api/users"
    agent: "codex-review"
    rounds:
      - round: 1
        claude_position: "Rate limiting exists in nginx config"
        agent_decision: "DEFEND"
        resolution: "follow_up"
      - round: 2
        claude_position: "Nginx config covers /api/* routes, agent cited only app-level"
        agent_decision: "MODIFY"
        resolution: "accepted_after_followup"
    final_resolution: "accepted_after_followup"

Fallback Rules

回退规则

ConditionAction
Both agents succeedAggregate verified suggestions from both
One agent failsUse successful agent's verified suggestions, log failure
Both agents failReturn
{verdict: "SKIPPED", reason: "agents failed"}
Parent skill (ln-310)Falls back to Self-Review (native Claude)
条件操作
两个Agent均成功执行聚合两个Agent的已验证建议
一个Agent执行失败使用成功Agent的已验证建议,记录失败日志
两个Agent均执行失败返回
{verdict: "SKIPPED", reason: "agents failed"}
父技能(ln-310)回退至自评审模式(原生Claude)

Verdict Escalation

结论升级规则

  • No escalation. Suggestions are editorial only — they modify Story/Tasks text.
  • Parent skill (ln-310) Gate verdict remains unchanged by agent suggestions.
  • 无升级流程。建议仅为编辑层面——仅修改Story/任务的文本内容
  • 父技能(ln-310)的 gate 结论不会因Agent建议而改变

Critical Rules

核心规则

  • Read-only review — agents must NOT modify project files (enforced by prompt CRITICAL CONSTRAINTS)
  • Same prompt to all agents (identical input for fair comparison)
  • JSON output schema required from agents (via
    --json
    /
    --output-format json
    )
  • Log all attempts for user visibility (agent name, duration, suggestion count)
  • Persist prompts, results, and challenge artifacts in
    .agent-review/{agent}/
    — do NOT delete
  • Ensure
    .agent-review/.gitignore
    exists before creating files (only create if
    .agent-review/
    is new)
  • MANDATORY INVOCATION: Parent skills MUST invoke this skill. Returns SKIPPED gracefully if agents unavailable. Parent must NOT pre-check and skip.
  • NO TIMEOUT KILL — WAIT FOR RESPONSE: Do NOT kill agent background tasks. WAIT until agent completes and delivers its response — do NOT proceed without it, do NOT use TaskStop. Agents are instructed to respond within 10 minutes via prompt constraint, but the hard behavior is: wait for completion or crash. Only a hard crash (non-zero exit code, connection error) is treated as failure. TaskStop is FORBIDDEN for agent tasks.
  • CRITICAL VERIFICATION: Do NOT trust agent suggestions blindly. Claude MUST independently verify each suggestion and debate if disagreeing. Accept only after verification.
  • 只读评审——Agent不得修改项目文件(通过提示词中的核心约束强制执行)
  • 所有Agent使用相同的提示词(输入完全一致,确保公平对比)
  • 要求Agent返回JSON格式的输出(通过
    --json
    /
    --output-format json
    参数指定)
  • 记录所有尝试操作,便于用户查看(Agent名称、耗时、建议数量)
  • 持久化提示词、结果与质疑相关文件至
    .agent-review/{agent}/
    目录——不得删除
  • 在创建文件前,确保
    .agent-review/.gitignore
    已存在(仅当
    .agent-review/
    为新目录时才创建该文件)
  • 强制调用要求: 父技能必须调用本技能。若Agent不可用,将优雅返回SKIPPED状态。父技能不得提前检查并跳过调用。
  • 禁止超时终止——等待响应: 不得终止Agent的后台任务。必须等待Agent完成并返回响应——不得提前继续流程,不得使用TaskStop。提示词约束中已要求Agent在10分钟内响应,但硬性规则为:等待完成或崩溃。仅当出现严重崩溃(非零退出码、连接错误)时才判定为失败。Agent任务禁止使用TaskStop。
  • 严格验证: 不得盲目信任Agent的建议。Claude必须独立验证每条建议,若有不同意见则发起辩论。仅在验证通过后采纳建议。

Definition of Done

完成标准

  • All available agents launched as background tasks (or gracefully failed with logged reason)
  • Prompts persisted in
    .agent-review/{agent}/
    for each agent
  • Raw results persisted in
    .agent-review/{agent}/
    (no cleanup)
  • Each suggestion critically verified by Claude; challenges executed for disagreements
  • Follow-up rounds executed for suggestions rejected after Round 1 (DEFEND+weak / MODIFY+disagree)
  • Challenge and follow-up prompts/results persisted alongside review artifacts
  • Accepted suggestions filtered by confidence >= 90 AND impact_percent > 2
  • Deduplicated verified suggestions returned to parent skill with verdict, agent_stats, and debate_log
  • .agent-review/.gitignore
    exists (created only if
    .agent-review/
    was new)
  • Session files persisted in
    .agent-review/{agent}/{identifier}_session.json
    for debate resume
  • 所有可用Agent均已作为后台任务启动(或因不可用而优雅失败,并记录原因)
  • 每个Agent的提示词均已持久化至
    .agent-review/{agent}/
    目录
  • 原始结果已持久化至
    .agent-review/{agent}/
    目录(未执行清理)
  • 每条建议均已由Claude严格验证;对有分歧的建议已执行辩论环节
  • 对第一轮质疑后被拒绝的建议已执行跟进轮次(DEFEND+弱支持 / MODIFY+不同意的情况)
  • 质疑与跟进的提示词/结果已与评审文件一起持久化
  • 已采纳的建议经过过滤(confidence >= 90 且 impact_percent > 2)
  • 已去重的已验证建议与verdict、agent_stats、debate_log一起返回给父技能
  • .agent-review/.gitignore
    已存在(仅当
    .agent-review/
    为新目录时创建)
  • 会话文件已持久化至
    .agent-review/{agent}/{identifier}_session.json
    ,用于辩论续接

Reference Files

参考文件

  • Agent delegation pattern:
    shared/references/agent_delegation_pattern.md
  • Prompt template (review):
    shared/agents/prompt_templates/story_review.md
  • Prompt template (challenge):
    shared/agents/prompt_templates/challenge_review.md
  • Agent registry:
    shared/agents/agent_registry.json
  • Agent runner:
    shared/agents/agent_runner.py
  • Challenge schema:
    shared/agents/schemas/challenge_review_schema.json

Version: 2.0.0 Last Updated: 2026-02-11
  • Agent委托模式:
    shared/references/agent_delegation_pattern.md
  • 评审提示词模板:
    shared/agents/prompt_templates/story_review.md
  • 质疑提示词模板:
    shared/agents/prompt_templates/challenge_review.md
  • Agent注册表:
    shared/agents/agent_registry.json
  • Agent运行器:
    shared/agents/agent_runner.py
  • 质疑 schema:
    shared/agents/schemas/challenge_review_schema.json

版本: 2.0.0 最后更新时间: 2026-02-11