交付了一个你从没要过的功能
Shipped a feature you never asked for
一个修 bug 的 PR,顺带加了监控中间件、功能开关客户端、设置页或命令行选项。
适用于: Claude Code · Cursor · Codex · Copilot agent
症状
diff 里有需求中任何一句都没提到的新行为。它也许能正常工作,但从此要由你来负责、测试和维护。
为什么会这样
智能体喜欢泛化和预判需求。agent-review 对 AR028 的经典举例:一个“修复登录 bug”的 PR 顺带加了监控中间件和功能开关客户端。dev.to 那位作者的解法是“停车场”:想法写进一个文件,而不是写进 diff。
示例
摘自 agent-review 分类(AR028)。
textPR title: "Fix login bug"
+ src/middleware/metrics.ts (new)
+ src/lib/featureFlags.ts (new)
src/auth/login.ts (the actual 3-line fix)
复制即用的修复
按你用的智能体挑选文件。规则片段用英文写,放进任何仓库都能用。
规则
Claude Code:加入 CLAUDE.md
CLAUDE.md## Build only what was asked
- Implement exactly the requested behavior. No extra options, endpoints, settings, flags,
middleware, telemetry or UI that the request doesn't mention.
- Good ideas go to FOLLOWUPS.md with a one-line rationale, not into this change.
- In your summary, map every new behavior to the request line it serves.
规则
Codex、Copilot 编码智能体等:加入 AGENTS.md
AGENTS.md## Build only what was asked
- Implement exactly the requested behavior. No extra options, endpoints, settings, flags,
middleware, telemetry or UI that the request doesn't mention.
- Good ideas go to FOLLOWUPS.md with a one-line rationale, not into this change.
- In your summary, map every new behavior to the request line it serves.
Cursor 规则
Cursor:项目规则
.cursor/rules/unrequested-feature.mdc---
description: "AgentFails: Shipped a feature you never asked for"
alwaysApply: true
---
## Build only what was asked
- Implement exactly the requested behavior. No extra options, endpoints, settings, flags,
middleware, telemetry or UI that the request doesn't mention.
- Good ideas go to FOLLOWUPS.md with a one-line rationale, not into this change.
- In your summary, map every new behavior to the request line it serves.
模板
FOLLOWUPS.md“停车场”
“停车场”思路来自 dev.to 的 diff budget 文章:被拦下的想法要记下来,既不丢,也不偷偷上线。
FOLLOWUPS.md## Parking lot: <task id>
- <file or area>: <what you noticed>. Suggested task: <bug fix | feature | refactor>, <priority>.
技能
全新上下文的审查技能(子智能体只看 diff,不看聊天记录)
沿用 Anthropic 代码审查文章里的做法:先验证,再让一个上下文干净的子智能体审 diff。命名为 review-diff,避免和内置或流行的 /code-review 技能重名。
.claude/skills/review-diff/SKILL.md---
name: review-diff
description: Review the current diff with fresh context before a PR. Use after /verify passes.
---
# Review the diff
Start a subagent that has NOT seen this conversation. Give it only:
- the original request (one paragraph, verbatim),
- the output of `git diff origin/main...HEAD`,
- the names of the test/build commands.
Ask it to report, with file:line for each finding:
1. **Wrong feature**: does the diff do what the request asked? Quote the request line each change serves.
2. **Bugs**: logic errors, missing edge cases (empty, null, boundary), unhandled errors,
unawaited promises, invented APIs or packages, swallowed exceptions.
3. **Overreach**: changes no request line needs (refactors, renames, formatting, dependency or
config edits, public API changes, weakened tests).
4. **Evidence gaps**: claims in the PR description that no command output supports.
Then fix real findings, or list them under "Known issues" in the PR. Do not argue with the reviewer
in the PR text; either fix or explain in one line.