Glean 拾遗
日刊 /2026-07-26 / Claude 5 上下文工程新规则:删掉 80% 系统提示,让模型凭判断力工作

Claude 5 上下文工程新规则:删掉 80% 系统提示,让模型凭判断力工作

原文 x.com 收录 2026-07-26 06:00 阅读 10 min
AI 解读

Anthropic 分享了为 Claude 5 系列模型(如 Opus 5、Fable 5)进行上下文工程的最新经验。核心发现:之前的系统提示和约束过度了,新模型拥有更好的判断力,可以大幅简化。他们移除了 Claude Code 中 80% 的系统提示,且内部评测无性能损失。文章对比了旧实践(给规则、给例子、全部放前面、重复、记忆在 CLAUDE.md、简单规格)和新实践(让模型用判断力、设计接口、渐进式披露、简洁工具描述、自动记忆、丰富引用)。具体建议:CLAUDE.md 保持轻量,主要记录代码库的 gotcha;利用 Skills 作为按需加载的轻量指南;使用渐进式披露避免上下文爆炸;优先使用代码作为引用而非描述。文章还介绍了 `claude doctor` 命令帮助自动简化上下文。适合使用 Claude Code 或构建基于 Claude 的 Agent 的工程师阅读。

原文 10 分钟
原文 x.com ↗
§ 1

The new rules of context engineering for Claude 5 models

By @trq212 · 2026-07-24T17:45:27.000Z

I’ve written previously about how to best prompt the newest generation of Claude 5 models and work with them iteratively to discover what you want to build.

But when you send a message to Claude, the prompt is only a small part of the context it gets. Much of your context is assembled from your system prompt, Skills, CLAUDE.md files, memory, and other sources. We call this context engineering, and it makes a big impact on the results you generate when using Claude Code or in building your own agents.

Unlike a prompt, context is used generally across many requests, so it cannot be as specific. How do you build these general prompts and guidance for Claude, especially when you don’t know what a user’s prompt might be?

Claude 5 模型的上下文工程新规则

作者 @trq212 · 2026-07-24T17:45:27.000Z

我之前写过如何更好地向新代 Claude 5 模型发出提示,并迭代地与之协作,从而发现自己想要构建的内容。

但当你向 Claude 发送消息时,提示词(prompt)只是其获取上下文的一小部分。大部分上下文来自系统提示、技能(Skills)、CLAUDE.md 文件、记忆(memory)及其他来源。我们称之为上下文工程(context engineering),它对你使用 Claude Code 或构建自己的 Agent 时产生的结果影响巨大。

与提示词不同,上下文在多次请求中通用,因此不能过于具体。那么,如何为 Claude 构建这些通用提示和指导,尤其是当你不知道用户的提示会是什么时?

§ 2

The new rules of context engineering for Claude 5 models

Claude 5 模型的上下文工程新规则

§ 3

This can be surprisingly difficult as Claude’s own capabilities evolve. Most recently, we noticed a large jump in the way we prompt the newest generation of Claude models. We removed over 80% of Claude Code’s system prompt for models like Claude Opus 5 and Claude Fable 5 with no measurable loss on our coding evaluations.

Here’s what we’ve learned about prompting this new class of models, and how you can utilize it to update your context engineering. We’ve put these best practices in claude doctor, use the command /doctor in Claude Code to rightsize your skills, and CLAUDE.md files.

这其实颇具挑战性,因为 Claude 自身的能力也在不断进化。最近,我们注意到向新代 Claude 模型发出提示的方式有了巨大飞跃。对于 Claude Opus 5 和 Claude Fable 5 等模型,我们移除了 Claude Code 中超过 80% 的系统提示,而编码评估结果并无可测量的损失。

以下是我们从提示这类新模型中得到的经验,以及如何利用它们更新你的上下文工程。我们已将这些最佳实践整合进 claude doctor命令,你可以在 Claude Code 中使用 /doctor 命令来调整技能和 CLAUDE.md 文件。

§ 4

Unhobbling Claude

Overall, we found that we were over-constraining Claude Code, both through our system prompt and in our CLAUDE.md files and skills.

For example, when we read transcripts of our own internal usage of Claude Code, we see several conflicting messages in a single request like “leave documentation as appropriate,” or “DO NOT add comments” as our system prompt, skills, and user requests clash with each other.

给 Claude 松绑

总体而言,我们发现无论通过系统提示、CLAUDE.md 文件还是技能,我们都对 Claude Code 约束过度了。

例如,在回顾我们内部使用 Claude Code 的对话记录时,我们发现在单次请求中竟出现了多条相互冲突的指令,比如“酌情留档”和“禁止添加注释”,系统提示、技能和用户请求彼此矛盾。

§ 5

冲突指令示例

§ 6

Generally, Claude can interpret the user’s intent to get to the right answer, but Claude must think more carefully about these overlapping and conflicting messages before deciding what to do.

And while these constraints were once needed to avoid worst case scenarios, we have since found we can delete many of them and let the model use surrounding context and judgement instead.

Additionally, Claude Code now has many more tools. Claude used to rely on CLAUDE.md as a source of memory, information, and guidance. Now we have memory, artifacts, and skills, which Claude can use to create new ways of loading and sharing context across sessions.

通常,Claude 能够解读用户意图并给出正确答案,但在决定做什么之前,它必须更仔细地权衡这些重叠且矛盾的指令。

虽然这些约束曾一度是避免最坏情况的必要措施,但我们发现现在可以删除其中许多,让模型自行利用周围上下文和判断力。

此外,Claude Code 现在拥有了更多工具。过去,Claude 依赖 CLAUDE.md 作为记忆、信息和指导的来源。现在我们有了记忆、制品(artifacts)和技能,Claude 可以利用它们创造新的方式来跨会话加载和共享上下文。

§ 7

Then and now

There were a number of previous context engineering best practices that had become myths. Including:

过去 vs. 现在

许多以往的上下文工程最佳实践如今已沦为迷思,包括:

§ 8

新旧方法对比

§ 9

Then: Give Claude rules Now: Let Claude use judgement When we first rolled out Claude Code, we needed to be sure that Claude avoided worst case scenarios, such as deleting files. This meant we would give particularly strong guidance that might not always be true, For example, in the system prompt we used to say:

In code: default to writing no comments. Never write multi-paragraph docstrings or multi-line comment blocks — one short line max. Don't create planning, decision, or analysis documents unless the user asks for them — work from conversation context, not intermediate files.

But for a certain subset of prompts, this guidance would be wrong. In the case of documentation, the user may have their own preferences, or specific parts of very complex code might need multi-line comment blocks.

Still, without these guardrails for older models, the comments Claude wrote would be incorrect in many cases and we had to accept this tradeoff. But newer models have better judgement and can handle these decisions well without explicit rules.

In the new system prompt we say: Write code that reads like the surrounding code: match its comment density, naming, and idiom.

过去:给 Claude 定规则 现在:让 Claude 自行判断 我们最初推出 Claude Code 时,必须确保 Claude 避免最坏情况,例如删除文件。这意味着我们会给出非常强硬的指导,但这些指导并非总是正确。例如,系统提示中曾这样写:

在代码中:默认不写注释。永远不要写多段落文档串或多行注释块——最多一行短注释。除非用户要求,否则不要创建计划、决策或分析文档——根据对话上下文工作,而不是中间文件。

但对某些类型的提示,这种指导可能不适用。例如文档方面,用户可能有自己的偏好,或非常复杂的代码的特定部分可能需要多行注释块。

然而,如果没有这些防护栏,旧模型写的注释往往不正确,我们不得不接受这种权衡。但新模型拥有更好的判断力,无需显式规则就能妥善处理这些决策。

在新的系统提示中我们写道:写出与周围代码风格一致的代码——匹配其注释密度、命名习惯和惯用写法。

§ 10

Then: Give Claude examples Now: Design interfaces The number one rule for tool usage was to give Claude examples on how to use them. With our newest models, we’ve found that giving examples actually constrains them to a certain exploration space.

过去:给 Claude 提供示例 现在:设计接口 之前工具使用的首要规则是给 Claude 示例说明如何用它们。但面对最新模型,我们发现提供示例反而会将 Claude 限制在某个探索空间内。

§ 11

工具接口设计示例

§ 12

Instead of using examples, think more about the design of your tools, scripts and files- what parameters does Claude have and how can they be more expressive?

For example, in the Todo tool example, just listing status as an enumeration between pending, in_progress, and completed, hints to Claude about how to use it. The instruction on keeping one item in_progress helps define our requested behavior.

与其提供示例,不如多思考工具、脚本和文件的设计——Claude 有哪些参数?如何让它们更具表现力?

例如,在 Todo 工具的例子中,仅将状态列为 pending、in_progress 和 completed 这样的枚举,就向 Claude 暗示了如何使用。再加上“始终保持一个项处于 in_progress”这样的指令,就定义了我们需要的行为。

§ 13

Then: Put it all upfront Now: Use progressive disclosure

Because Claude Code was focused on coding, our system prompt included detailed information on how to do code review and verification. These were not always needed, but when they were, it was crucial information.

Since then, Claude Code has gotten very competent at using progressive disclosure- loading the right context at the right times. For example, we moved verification and code review into their own skills that Claude Code could selectively call.

But progressive disclosure is not just for skills, we also use it for tools. Some of our tools are ‘deferred loading,’ which means the agent must search for their full definitions using ToolSearch before using them. This allows us to have more tools (such as our Task tools) that don’t take up context until they’re needed.

The same can be applied to your own CLAUDE.md and Skill.md files. A common myth is that you want to make these a central repository for every known practice that you might run into, because Claude would not find it otherwise. Instead, consider having a tree of files that can be loaded at the right time.

过去:一股脑儿全放前面 现在:采用渐进式披露

由于 Claude Code 专注于编码,我们的系统提示中包含了如何进行代码审查和验证的详细信息。这些信息并非始终需要,但在需要时却至关重要。

此后,Claude Code 已经非常擅长渐进式披露——在适当的时候加载合适的上下文。例如,我们将验证和代码审查移入各自的技能中,让 Claude Code 可以选择性调用。

但渐进式披露不仅适用于技能,也适用于工具。我们有些工具采用“延迟加载”,即 Agent 在使用前必须通过 ToolSearch 搜索其完整定义。这让我们能拥有更多工具(如 Task 工具),而这些工具直到需要时才占用上下文。

同样的原则也适用于你自己的 CLAUDE.mdSkill.md 文件。一个常见的迷思是:你希望把这些文件变成存放所有已知实践的中央仓库,否则 Claude 就找不到它们。相反,应该考虑构建一个文件树,在适当的时候加载相应文件。

§ 14

Then: Repeat yourself Now: Simple tool descriptions

Earlier Claude models could sometimes need repeated instructions or be more likely to listen to instructions at the end of their context window than at the start. This meant our system prompt would sometimes have references to tools in the main system prompt as well as instructions in the tool description.

We found we could delete these repeat examples and put instructions on how to use tools in the tool descriptions rather than the system prompt.

过去:重复强调 现在:简洁工具描述

早期的 Claude 模型有时需要重复指令,或者更容易听取上下文窗口末尾的指令而非开头的指令。这意味着我们的系统提示有时既在主提示中引用工具,又在工具描述中重复指令。

我们发现可以删除这些重复示例,将如何用工具的说明放在工具描述中,而非系统提示里。

§ 15

Then: Memory in CLAUDE.md files Now: Auto-memory

We used to encourage users to save things to Claude’s memory, by using the # hotkey to write to their CLAUDE.md automatically. Instead, Claude now automatically saves memories that are relevant to the work and to you.

过去:将记忆存入 CLAUDE.md 文件 现在:自动记忆

我们曾鼓励用户通过 # 快捷键自动写入 CLAUDE.md 来保存信息。而现在,Claude 会自动保存与工作和用户相关的记忆。

§ 16

Then: Simple specs Now: Rich references

In plan mode, Claude Code has heavily relied on markdown files with plans. Storing these files as plans helped Claude refer to them when needed. Another similar best practice was to store specs in the codebase for Claude to refer to while working across longer projects.

But we’ve found that Claude can handle increasingly more complicated references. Instead of simple markdown files, Claude can reference HTML artifacts created by our new artifacts feature.

You may also give Claude references in the form of code. A spec may also be a detailed test suite, or a function in a different codebase that Claude might port.

Rubrics are another form of references. Rubrics allow Claude to try and verify your taste in a particular field (e.g. what does a good API design look like) by using dynamic workflows and spinning up verifier agents with those rubrics.

过去:简单规范 现在:丰富引用

在计划模式下,Claude Code 严重依赖 Markdown 格式的计划文件。将这些文件作为计划保存,有助于 Claude 在需要时引用。另一个类似的最佳实践是将规范存储在代码库中,供 Claude 在跨项目工作时参考。

但我们发现 Claude 能够处理越来越复杂的引用。除了简单的 Markdown 文件,Claude 还可以引用由新制品(artifacts)功能创建的 HTML 制品。

你也可以以代码形式为 Claude 提供引用。一个规范可能是一份详细的测试套件,或是另一个代码库中 Claude 可以移植的函数。

评分标准(Rubrics)是另一种引用形式。评分标准允许 Claude 通过动态工作流尝试验证你在特定领域的品味(例如,好的 API 设计是什么样的),并据此启动验证 Agent。

§ 17

Applying this to your context

Pulling this all together, what does this look like when you assemble your context?

将其应用到你的上下文中

综合以上,当你组装上下文时,这看起来是怎样的?

§ 18

上下文组装示意图

§ 19

System Prompt A system prompt is heavily tied to the product context. It tells Claude what product it’s operating in and what it’s doing. For Claude Code, you will likely never modify this, but if you are building your own agent harness, this is where you should spend a lot of time.

系统提示 系统提示与产品上下文紧密相关,它告诉 Claude 正在操作什么产品、在做什么。对于 Claude Code,你很可能永远不会修改它;但如果你在构建自己的 Agent 框架,这部分值得你花大量时间。

§ 20

CLAUDE.md Keep your CLAUDE.md lightweight and briefly describe what your repo is for, but spend most of the tokens on gotchas inside of the codebase. For example, you may organize your code to keep types in one monolithic file and nowhere else. Avoid stating ‘the obvious’ things Claude should know by looking at your file system or your repo.

Use progressive disclosure for more details, for example if you have several unique instructions on how to verify your work, create a verification skill and reference it from your CLAUDE.md.

CLAUDE.md 保持 CLAUDE.md 的轻量化,简要描述仓库的用途,但将大部分 token 花在代码库中的“坑”上。例如,你的代码可能将类型统一放在一个文件中,而不在其他地方。避免陈述那些 Claude 通过查看文件系统或仓库就能知道的“显而易见”的事情。

使用渐进式披露来提供更多细节:比如你有若干关于如何验证工作的特殊指令,则创建一个验证技能(verification skill),并在 CLAUDE.md 中引用它。

§ 21

Skills Think of skills as lightweight guides to let Claude find information when needed. Avoid making them overconstrained, except in highly important areas.

For long skills, try and use progressive disclosure as much as possible- divide it into many files and split them out.

It’s best when skills encode particular opinions, knowledge, or best practices that are particular to you, your team, or product.

技能 将技能视为轻量指南,让 Claude 在需要时找到信息。除非在非常重要的领域,否则避免过度限制。

对于较长的技能,尽量使用渐进式披露——将其分成多个文件并拆分开来。

技能最好能编码那些专属于你、你的团队或产品的特定观点、知识或最佳实践。

§ 22

References You can @ mention files to include them as references. References allow Claude to refer to in-depth information about the current plan.

This might be in specs files, mockups, or even entire codebases. Generally you should prefer files that are in code as it provides clear, high-fidelity instructions to Claude in a language it knows very well. For example, a HTML mockup of a design will generally produce better results than a description of the design or a screenshot.

引用 你可以通过 @ 提及文件来将其作为引用。引用让 Claude 能够获取关于当前计划的深度信息。

这可以是规范文件、设计稿,甚至整个代码库。通常,你应优先选择代码形式的文件,因为它能以 Claude 非常熟悉的语言提供清晰、高保真的指令。例如,HTML 设计稿通常比设计描述或截图效果更好。

§ 23

Try simplifying

Across your system prompt, skills, and CLAUDE.md files, you may need to simplify just like we did. We rolled out a new command called claude doctor, which will help you do this automatically as well. For more details on prompting more advanced models specifically, check out our Fable field guide.

尝试简化

在系统提示、技能和 CLAUDE.md 文件中,你可能需要像我们一样做简化。我们推出了一项新命令 claude doctor,可以帮你自动完成这一过程。有关更高级模型提示的更多详情,请查阅我们的 Fable 指南。

打开原文 ↗