技巧多源确认

提示词里一句话让 Claude Fable 5.2 主动重构代码

Quoting Prompting Claude Fable 5.2

精选理由

写提示词的人应该看看这个:Anthropic 官方文档实测,一句“代码库是你的”能让 Claude Fable 5.2 合并重复代码的比例从不到 10% 提到约 50%。维护老项目的开发者直接抄这句就行,比写一堆“请优化代码”管用。

Anthropic 在 Claude Fable 5.2 的官方文档中给出一个提示词实验结果:提示词中对代码所有权的表述会直接影响模型的改动倾向。在小规模编码任务测试中,当提示词不提及所有权、或把代码库说成是别人的时,模型倾向于在现有结构上追加代码,即使这会造成重复代码。

正文

解决办法是在提示词里明确写“这个代码库是你的:它的用途和构建方式由你决定,你会继续在它上面开发”。加上这句话后,模型在约一半的测试里合并了重复代码;不加时这个比例低于十分之一。对经常让模型维护存量代码库的开发者来说,这是一个可以直接复制的具体写法。

原文 · Simon Willison’s Weblog

Quoting Prompting Claude Fable 5.2

Claude Fable 5.2 responds closely to what the prompt says about who owns the code it works on. In Anthropic’s testing on small coding tasks, when a prompt said nothing about ownership or presented the code base as someone else’s, the model tended to add to the existing structure, even when that repeated existing code. [...] If you want the model to improve the structure as it works, say that the code is its own: This codebase is yours: what it's for and how it's built are your call, and you'll keep building on it. In Anthropic’s testing on small coding tasks, the model merged repeated code in about half of the tries with this sentence, and in under a tenth of the tries without it. — Prompting Claude Fable 5.2 , Anthropic documentation Tags: prompt-engineering , anthropic , generative-ai , ai , llms , claude-mythos-fable

产业坐标与信源核验

本条情报归属 AITOP「技巧」核心栏目,重点聚焦北美前沿实验室与硅谷科技巨头。在跨区域产业观察坐标中,该动态直接关联「AI 开发者工具链、Coding Agent 与工程化实践」研究主线,反映出当前技术演进与商业落地的最新风向。涉及核心实体与技术议题包括:Claude、Anthropic、提示词工程、编程助手,读者可通过下方标签进入对应专题页查阅历史脉络与关联对比。

信源核验说明:本文原始线索采编自「Simon Willison’s Weblog」,经 AITOP 多维评分管线结构化提炼。截至目前,全网已有 11 家独立信源对该事件进行交叉印证与跟进报道(含 Alex Albert、rohanpaul_ai、AI Engineer 等),属于近期高关注度行业信号。