How-toMulti-source

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

Quoting Prompting Claude Fable 5.2

Why we picked it

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

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

Body

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

Original · 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

Industry Coordinates & Source Verification

This report is categorized under AITOP's "How-to" desk, focusing on US frontier AI labs and Silicon Valley technology leaders. Within our cross-regional analytical framework, it directly maps to AI developer toolchains, coding agents, and engineering workflows. Key entities and technical topics under continuous tracking include Claude, Anthropic, 提示词工程, 编程助手.

Source attribution: curated from Simon Willison’s Weblog. Cross-source corroboration: 11 independent sources have covered this development (including Alex Albert, rohanpaul_ai, AI Engineer), confirming industry-wide signal strength.