“全部迁移完了”(其实没有)
"Fully migrated" (it wasn't)
智能体声称一次全局改动(重命名、迁移、换 API)已经全部完成,实际上只改了它碰巧看到的那些地方。
适用于: Claude Code · Cursor · Codex · Copilot agent
症状
“已更新全部 8 处调用。”其实有 9 处;第 9 处藏在 shell 字符串、配置文件或搜索结果截断之后,没改,也没提。
为什么会这样
搜索结果会被截断,动态引用(字符串、模板、配置)在符号搜索里也找不到。智能体把“我找到的全部”当成了“全部”。agent-failure-modes 称之为 AFM-12 覆盖率夸大。
示例
示意。
bash# Agent: "Renamed getUser -> fetchUser everywhere."
$ rg -n "getUser" .
scripts/backfill.sh:12: node -e "require('./dist/api').getUser(process.argv[1])"
复制即用的修复
按你用的智能体挑选文件。规则片段用英文写,放进任何仓库都能用。
规则
Claude Code:加入 CLAUDE.md
CLAUDE.md## Sweeping changes need a count, before and after
- For any rename, migration or "replace everywhere" task, first run a repo-wide search and report the
total count and the list of locations (include strings, configs, scripts and docs).
- After the change, re-run the same search and show it returns zero (or explain each remaining hit).
- Never say "all" or "everywhere" without that before/after evidence. If a search output was truncated, say so.
规则
Codex、Copilot 编码智能体等:加入 AGENTS.md
AGENTS.md## Sweeping changes need a count, before and after
- For any rename, migration or "replace everywhere" task, first run a repo-wide search and report the
total count and the list of locations (include strings, configs, scripts and docs).
- After the change, re-run the same search and show it returns zero (or explain each remaining hit).
- Never say "all" or "everywhere" without that before/after evidence. If a search output was truncated, say so.
Cursor 规则
Cursor:项目规则
.cursor/rules/coverage-overclaim.mdc---
description: "AgentFails: 'Fully migrated' (it wasn't)"
alwaysApply: true
---
## Sweeping changes need a count, before and after
- For any rename, migration or "replace everywhere" task, first run a repo-wide search and report the
total count and the list of locations (include strings, configs, scripts and docs).
- After the change, re-run the same search and show it returns zero (or explain each remaining hit).
- Never say "all" or "everywhere" without that before/after evidence. If a search output was truncated, say so.
技能
团队共享的 /verify 技能(Claude Code)
把它提交进仓库,让整个团队(以及每个智能体会话)跑同一套检查。把命令换成你项目里真实的命令。
.claude/skills/verify/SKILL.md---
name: verify
description: Verify the current change before calling it done. Use before every commit, PR, or "done" message.
---
# Verify
Run every step and paste the real output. Never summarize a step you did not run.
1. **Scope**: run `git diff --stat` and `git status --short`. For every changed file, say which part
of the request needs it. Any file you cannot justify gets reverted, or listed under
"Unrequested changes" for the user to decide.
2. **Build and types**: `npm run build` (or the project's build command).
3. **Tests**: `npm test`. Report pass/fail counts. If a test was edited, skipped or deleted,
say so explicitly with the reason.
4. **Behavior**: exercise the changed behavior once for real (a curl, a CLI run, a screenshot)
and show what happened.
5. **Report** in this format:
- Requested: <one line>
- Changed files: <list, each with its reason>
- Checks run: <command -> result>
- Not done / unsure: <list, or "none">