首页
/ Files to Review

Files to Review

2026-09-06 23:54:13作者:范垣楠Rhoda

Files to Review

BEFORE analyzing, read these files:

  1. [List specific files that changed in the diff]
  2. [Files referenced by changes but not modified]

Use Read tool to load each file.

If you cannot find a file:

  • Check exact path from diff
  • Try alternate locations
  • Report: "Cannot locate [path] - please verify file exists"

DO NOT proceed with review until you've read the actual code.


显式指令直接消解了问题 6 中的"文件不存在"误报。这一机制的演进形态可以在当前仓库的 [code-reviewer.md 模板](https://gitcode.com/GitHub_Trending/su/superpowers/blob/44c9b2d6e889982ac18c27d05a19fefe335194e1/skills/requesting-code-review/code-reviewer.md?utm_source=gitcode_repo_files) 中看到:模板现在明确要求审查基于 `git diff` 范围进行,并规定"Give feedback on code you didn't actually read"是 DON'T 清单中的行为——"只评论你真正读过的代码"已被写进审查纪律。

### 改进 6:testing-anti-patterns 增加"Mock 源自实现"反模式

针对问题 5,新增 Anti-Pattern 6:**Mocks Derived from Implementation(从实现推导的 Mock)**。错误形态与问题 5 相同:Mock 编码了 bug(mock 有 `cleanup()`、接口定义的是 `close()`),测试通过正是因为代码和 Mock 一起错。修复方式是**从接口推导 Mock**:

```typescript
// ✅ GOOD: Derive mock from interface

// Step 1: Open interface definition (PlatformAdapter)
// Step 2: List methods defined there (close, initialize, etc.)
// Step 3: Mock EXACTLY those methods

const mock = {
  initialize: vi.fn().mockResolvedValue(undefined),
  close: vi.fn().mockResolvedValue(undefined),  // From interface!
};

// Now test FAILS because code calls cleanup() which doesn't exist
// That failure reveals the bug BEFORE runtime

配套的 Gate Function 把顺序固化下来:

BEFORE writing any mock:

  1. STOP - Do NOT look at the code under test yet
  2. FIND: The interface/type definition for the dependency
  3. READ: The interface file
  4. LIST: Methods defined in the interface
  5. MOCK: ONLY those methods with EXACTLY those names
  6. DO NOT: Look at what your code calls

  IF your test fails because code calls something not in mock:
    ✅ GOOD - The test found a bug in your code
    Fix the code to call the correct interface method
    NOT the mock

  Red flags:
    - "I'll mock what the code calls"
    - Copying method names from implementation
    - Mock written without reading interface
    - "The test is failing so I'll add this method to the mock"

还附带了检测路径:当出现"测试通过但运行时报 X is not a function"时,检查 X 是否被 Mock、比对 Mock 方法与接口方法、寻找方法名不匹配。

改进 7:subagent-driven-development 强制测试类 subagent 读取技能

当任务涉及测试时,提示词模板中加入强制项:

BEFORE writing any tests:

1. Read testing-anti-patterns skill:
   Use Skill tool: superpowers:testing-anti-patterns

2. Apply gate functions from that skill when:
   - Writing mocks
   - Adding methods to production classes
   - Mocking dependencies

This is NOT optional. Tests that violate anti-patterns will be rejected in review.

设计意图是"确保技能被真正使用,而不只是存在";权衡是每个任务多花时间,但能拦截一整类 bug。

改进 8:允许实施者修复自己发现的问题

修改 Step 2 的回报协议,消除问题 7 的多余往返:

Subagent performs self-reflection, then:

IF self-reflection identifies fixable issues:
  1. Fix the issues
  2. Re-run verification
  3. Report: "Initial implementation + self-reflection fix"

ELSE:
  Report: "Implementation complete"

Include in report:
- Self-reflection findings
- Whether fixes were applied
- Final verification results
登录后查看全文
热门项目推荐
相关项目推荐