AgentSkillsCN

test-triage

当测试失败或结果不稳定时使用。目标是通过最小化行为变化,快速恢复到稳定的绿色构建状态。除非有充分理由,否则切勿通过弱化断言来“修复”问题。

SKILL.md
--- frontmatter
name: test-triage
description: Use when tests fail or are flaky. Goal: get back to a stable green build with minimal behavior change. Do NOT "fix" by weakening assertions unless justified.

Workflow:

  1. Reproduce
  • Run the repo standard test command(s)
  • Re-run with verbosity and isolate to failing project/suite
  • If flaky: run failing tests multiple times to confirm nondeterminism
  1. Classify failure
  • Logic/assertion mismatch (product bug vs test bug)
  • Race condition / timing / async ordering
  • Environment/config differences (timezone, culture, file paths, OS)
  • Data dependence / test order dependence
  • Snapshot/golden file drift
  • External dependency (network, DB, file system) not isolated
  1. Minimize
  • Reduce to smallest repro:
    • single test
    • single project
    • single seed dataset
  • Identify the first bad commit if possible (git bisect guidance if needed)
  1. Fix
  • Prefer product fix over changing expected outputs
  • Make tests deterministic:
    • freeze time (clock abstraction)
    • remove random seeds or seed them deterministically
    • isolate shared mutable state
    • ensure proper awaits and synchronization
  • Add regression coverage (or strengthen existing coverage)
  1. Prevent recurrence
  • Add guardrails (timeouts, retries only for known flaky external issues)
  • Document root cause in a short comment or test name if helpful

Finish with:

  • Root cause (1–3 bullets)
  • Fix summary (what changed)
  • Commands run + results
  • Remaining flakes/todos (if any)