PULSE
AI 认知方法 HOWTO重要度 58

提示词里写明代码归属,模型才会重构

Simon Willison · 2026-11-10 · 原题《A quote from Prompting Claude Fable 5.2》 · 原文约 1 分钟 · 阅读原文 ↗
提示词中的代码归属 → 模型行为 不提归属 / 说成别人的 倾向在现有结构上追加 即使重复已有代码 合并重复代码的比例 不到 1/10 声明代码库归模型所有 用途与构建方式由它决定 它将持续在此基础上开发 主动重构、合并重复代码 约 1/2 的尝试 同一小规模编码任务测试 归属表述是可操作杠杆,而非无关措辞
作者引用 Anthropic 文档指出:提示词是否声明代码归模型所有,会显著影响模型是重复现有结构还是主动重构。

做法与步骤

  1. Anthropic 在小规模编码任务测试中发现:若提示词不提归属、或把代码库说成别人的,模型倾向于在现有结构上追加,即使重复已有代码。
  2. 若希望模型在写代码时改进结构,应在提示词中明确声明代码库归模型所有,并说明用途和构建方式由它决定、它会持续在此基础上开发。
  3. 同一测试中,加入这句归属声明后,模型约一半的尝试会合并重复代码;不加时这一比例不到十分之一。
  4. 因此,提示词中对代码归属的表述是影响模型行为的一个可操作杠杆,而非无关紧要的措辞。

对实践的启示

做 AI 编码助手或写提示词的人,若想让模型主动重构、去重,应在提示词里明确把代码库的所有权交给模型;若只想让它做增量修改,则可不提或强调代码属于他人。

原文摘引

This codebase is yours: what it's for and how it's built are your call, and you'll keep building on it.
the model merged repeated code in about half of the tries with this sentence, and in under a tenth of the tries without it.
▸ 展开原文全文(11 段,抓取自 Simon Willison)

10th November 2026

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

Recent articles

- Locating the source of a mysterious beep with Claude - 9th November 2026

- Hide your slop PR descriptions behind <details><summary> - 9th November 2026

- Qwen 3.8 27B on my laptop can interpret model weights, too - 3rd November 2026

- The U.S. Census Bureau and “Super Intelligence” - 2nd November 2026