Glean 拾遗
Daily /2026-09-01 / The new rules of context engineering for Claude 5 generation models

The new rules of context engineering for Claude 5 generation models

Source claude.com Glean’d 2026-09-01 06:00 Read 7 min
AI summary

Thariq Shihipar, a member of technical staff at Anthropic, explains how context engineering for Claude Code has changed with Claude 5-generation models. The old playbook—hard rules, examples, everything upfront, repeated instructions, CLAUDE.md as memory, and simple markdown specs—is now partly myth. New guidance: let the model use judgement (the system prompt now says 'match the surrounding code' instead of banning multiline comments); design expressive tool interfaces instead of stuffing examples; adopt progressive disclosure by loading verification and review skills on demand and letting tools defer their definitions until ToolSearch finds them. CLAUDE.md should stay lightweight, holding repo-specific gotchas, while skills encode team-specific opinions. Specs can become rich references: HTML mockups, test suites, code to port, or rubrics with verifier agents. Anthropic also ships `claude doctor` to auto-simplify contexts. No benchmarks are included, and the article is vendor-authored, but it offers immediately actionable patterns for agent harness and Claude Code users.

Original · 7 min
claude.com ↗
§ 1

Then and now

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

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 避免最坏的情况,比如删除文件。这意味着我们会给出非常强硬的指导,这些指导并不总是正确。例如,我们曾在系统提示词中说:

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

但对于某些提示词,这种指导是错误的。就文档而言,用户可能有自己的偏好,或者非常复杂的代码的某些部分可能需要多行注释块。

不过,如果没有这些护栏,旧模型的注释在很多情况下会写错,我们不得不接受这种取舍。但较新的模型有更好的判断力,即使没有明确规定也能很好地处理这些决策。

在新的系统提示词中我们说:写出像周围代码一样可读的代码:匹配它的注释密度、命名和惯用法。

§ 2

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.

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 示例

现在:设计接口

工具使用的第一法则是给 Claude 示例,告诉它如何使用。而对于我们最新的模型,我们发现给示例实际上会把它们限制在某个探索空间内。

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

例如,在 Todo 工具的示例中,仅仅把状态列为 pending、in_progress 和 completed 的枚举,就能暗示 Claude 如何使用它。而“保持一个 in_progress 项”的指令帮助我们定义了所要求的行为。

§ 3

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 可以有选择地调用。

但渐进式披露不仅用于技能,我们也将其用于工具。我们的一些工具是“延迟加载”的,这意味着智能体必须先使用 ToolSearch 搜索它们的完整定义,然后才能使用它们。这让我们可以拥有更多工具(比如我们的 Task 工具),它们不会在需要之前占用上下文。

同样的方法也可以应用到你的 CLAUDE.mdSkill.md 文件中。一个常见的误区是,你想把它们变成所有已知实践的中央仓库,因为否则 Claude 就找不到这些实践。相反,考虑建立一个可以在正确时间加载的文件树。

§ 4

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 模型有时需要重复的指令,或者更倾向于听从上下文窗口末尾的指令,而不是开头的。这意味着我们的系统提示词有时在主提示词中提到工具,同时又在工具描述中给出指令。

我们发现可以删除这些重复的示例,把如何使用工具的说明放到工具描述中,而不是系统提示词里。

§ 5

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 的记忆中。而现在,Claude 会自动保存与工作和与你相关的记忆。

§ 6

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 设计应该是什么样的)。

§ 7

Applying this to your context

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

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,你可能永远不会修改它,但如果你在构建自己的智能体框架,你应该在这里投入大量时间。

§ 8

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 heavily, 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 花在代码库内部的注意事项(gotchas)上。例如,你可能把代码组织成将所有类型放在一个单体文件中,其他任何地方都没有。避免陈述 Claude 通过查看文件系统或仓库就能知道的“显而易见”的事情。

大量使用渐进式披露,例如,如果你有几条关于如何验证工作的独特指令,创建一个验证技能,并从你的 CLAUDE.md 中引用它。

§ 9

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 在需要时找到信息。除非在非常重要的领域,否则避免过度约束它们。

对于长技能,尽可能使用渐进式披露——把它分成多个文件并拆开。

当技能编码了特定于你、你的团队或产品的特定观点、知识或最佳实践时,效果最好。

§ 10

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 模型通常比设计的文字描述或截图产生更好的结果。

§ 11

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.

This article was written by Thariq Shihipar, member of technical staff, Anthropic.

尝试简化

在你的系统提示词、技能和 CLAUDE.md 文件中,你可能需要像我们这样进行简化。我们推出了一条名为 claude doctor, 的新命令,它也能帮你自动完成这项工作。关于如何针对更先进的模型进行提示,更多细节请参阅我们的 Fable field guide。

本文由 Anthropic 技术团队成员 Thariq Shihipar 撰写。

Open source ↗