研究发现编码智能体更信 CLAUDE.md 等旧文档而非真实代码,加一句话可修复
Georgia Tech 那篇论文实测了 Claude Code 和 Codex CLI,发现九成情况下智能体听旧文档不听代码,Codex CLI 甚至重写了好好的代码。只需要在 CLAUDE.md 里加一句"以代码为准",320 次实验里测试全过。写智能体配置的都该看。
Georgia Tech 与 CU Boulder 的论文发现,Claude Code 和 Codex CLI 这类编码智能体会优先服从 CLAUDE.md、AGENTS.md 等长期未更新的指令文件,而不是随迭代变化的实际代码,例如文档写着"用 print"而代码早已全部改用 logging。
团队构建了 40 个指令文件与代码相互冲突的 Python 项目,将 Claude Code 和 Codex CLI 各运行 320 次。其中一半的运行在用户自己的指令文件里追加一句"当文档与代码冲突时,以代码为准"。结果显示,不加这句话时 90.1% 的智能体决策跟随过时文件,Codex CLI 在 80 次运行中有 20 次直接重写了本来能正常工作的代码;加上之后 91.4% 的决策改为跟随代码,测试通过率也从 89.4% 提升到全部 160 次运行通过。
对开发者的实操建议是:把这句话加到用户级 CLAUDE.md 或 AGENTS.md 中,并利用智能体上报的冲突记录去清理那些过时的文档条目。
New Georgia Tech and CU Boulder paper finds that coding agents obey outdated instruction files over the real code.
And 1 added sentence fixes it (" when docs and code disagree, follow the code.").
Files like CLAUDE.md and AGENTS.md are written once and rarely updated, while the code keeps changing. So an agent may read "use print" in the file while every module uses logging.
They built 40 Python projects where the instruction file and the code disagree, and ran Claude Code and Codex CLI 320 times. Half the runs added 1 sentence to the user's own file: when docs and code disagree, follow the code.
Without the sentence, 90.1% of the agents' choices followed the stale file, and Codex CLI rewrote working code in 20 of 80 runs. With it, 91.4% of choices followed the code, and tests passed in all 160 runs, up from 89.4%.
Add that sentence to your user-level CLAUDE.md or AGENTS.md, and use the conflicts the agent reports to fix the stale lines.
本条情报归属 AITOP「论文」核心栏目,重点聚焦北美前沿实验室与硅谷科技巨头。在跨区域产业观察坐标中,该动态直接关联「AI 开发者工具链、Coding Agent 与工程化实践」研究主线,反映出当前技术演进与商业落地的最新风向。涉及核心实体与技术议题包括:Claude Code、Codex CLI、CLAUDE.md、AGENTS.md,读者可通过下方标签进入对应专题页查阅历史脉络与关联对比。
信源核验说明:本文原始线索采编自「rohanpaul_ai」(@rohanpaul_ai),经 AITOP 多维评分管线结构化提炼。截至目前,全网已有 2 家独立信源对该事件进行交叉印证与跟进报道(含 shao__meng 等),属于近期高关注度行业信号。
- shao__meng06:55原文