Opus5 官方 Prompt 指南

1 评论 997 浏览 1 收藏 31 分钟

Claude Code 负责人揭秘:面向更强模型,系统提示词删掉八成,编码评测无损失。从过度约束到松绑,从堆例子到接口设计,从一股脑全放前到渐进式披露——上下文工程的新规则,正在被重写。

“我们删掉了 Claude Code 里 80% 的系统提示词”

本文作者 Thariq Shihipar,Claude Code 的负责人,文章发表于 Claude 官方博客,以下为逐段中英对照翻译

本文以这篇官方博客为底本,逐段中英对照翻译(翻译工作由 Opus5 负责,干的不好你骂它),全文不删节,对于补充内容,来自官方的另外几篇博客,分别为:

  • 《A field guide to Claude Fable 5》(2026 年 7 月 6 日)
  • 《Effective context engineering for AI agents》(2025 年 9 月 29 日)
  • 《A harness for every task》(2026 年 6 月 2 日)

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

We removed over 80% of Claude Code’s system prompt for more advanced models. How to apply the lessons we learned to your own context engineering in Claude Code and with your own agents.

面向更强的模型,我们把 Claude Code 的系统提示词删掉了八成以上。这里讲讲我们学到的东西,以及你怎么把它用到自己的上下文工程上,无论是在 Claude Code 里,还是在自己搭的 agent 里

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.

之前我写过怎么给最新一代 Claude 5 模型写 prompt,以及怎么跟它们来回迭代,把你想做的东西摸清楚

延伸阅读 · Anthropic《A field guide to Claude Fable 5: Finding your unknowns》,2026 年 7 月 6 日

地图是你给 Claude 的东西,prompt、技能、上下文。地形是活儿真正发生的地方,代码库、真实世界、它们各自的约束。两者之间的差额,叫做未知

Claude 撞上一个未知,只能按自己对你意图的最佳猜测做决定。活儿越多,撞上的未知越多。Fable 是第一个产出质量卡在「你能不能把未知讲清楚」上的模型,分四类:

已知的已知,你写进 prompt 里的东西

已知的未知,还没想明白但知道自己没想明白的

未知的已知,明显到根本不会写下来、但看见了就认得的

未知的未知,压根没考虑过的

给指令是一件需要拿捏的事。太具体,该转向的时候 Claude 也照着你说的做。太笼统,Claude 会按行业通行做法自己拿主意,而那些做法未必适合你这摊事

做法分三段。动手之前:找盲区、头脑风暴加原型、让 Claude 反过来采访你、给参照物、出实施计划。动手过程中:记实施笔记。做完之后:让 Claude 讲一遍它做了什么,再出几道题考考你

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.

但你给 Claude 发一条消息时,这条 prompt 只是它拿到的上下文里很小的一部分。上下文的大头是被拼装起来的,来自你的系统提示词、技能、CLAUDE.md 文件、记忆,还有别的地方。我们把这件事叫做上下文工程。用 Claude Code 也好,自己搭 agent 也好,它对结果的影响都很大

延伸阅读 · Anthropic《Effective context engineering for AI agents》,2025 年 9 月 29 日

上下文工程跟 prompt 工程的分别:prompt 工程管的是怎么把指令写好,主要是系统提示词。上下文工程管的是推理时该往上下文里放哪些 token,包括系统指令、工具、MCP、外部数据、消息历史,所有会落进上下文窗口的东西

上下文是有限资源。有个说法叫 context rot,上下文窗口里的 token 越多,模型从中准确召回信息的能力越差。不同模型衰减的陡缓不一样,但这个特征所有模型都有

根子在 transformer 架构。每个 token 都要跟其他所有 token 建立关系,n 个 token 就是 n² 对关系。上下文一长,这些配对关系就被摊薄了。加上训练数据里短序列本来就比长序列多,模型处理全局依赖的经验和专用参数都更少

模型有一份注意力预算,每多一个 token 就消耗掉一点。不是断崖式失效,而是一条性能斜坡

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?

跟 prompt 不一样,上下文要被很多次请求通用地使用,所以没法写得那么具体。那这种通用的提示和指引该怎么写,特别是在你根本不知道用户会问什么的时候?

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.

随着 Claude 自身能力的演进,这件事的难度出人意料。最近我们发现,给最新一代 Claude 写 prompt 的方式出现了一次大的跳变。面向 Claude Opus 5 和 Claude Fable 5 这类模型,我们把 Claude Code 的系统提示词删掉了八成以上,编码评测上测不出损失

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.

下面是我们在给这类新模型写 prompt 上学到的东西,以及你可以怎么用它来更新自己的上下文工程。这些实践我们已经放进了 claude doctor。在 Claude Code 里用 /doctor 命令,可以把你的技能和 CLAUDE.md 文件调到合适的体量

给 Claude 松绑

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

总的来说,我们发现自己把 Claude Code 管得太死了,系统提示词里是这样,CLAUDE.md 文件和技能里也是这样

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 Code 的对话记录,会在同一个请求里看到好几条互相打架的指令,一边是「该写文档的地方就写文档」,一边是「不要加注释」,系统提示词、技能、用户请求,彼此撞在一起

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.

一般来说 Claude 能读懂用户的意图,也能给出对的答案。但在决定该怎么做之前,它得先花心思去掂量这些重叠和冲突的指令

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 Code 现在的工具多了不少。以前 Claude 靠 CLAUDE.md 当记忆、信息和指引的来源,现在有了记忆、artifacts 和技能,Claude 可以用它们造出新的方式,跨会话地加载和共享上下文

过去,和现在

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

过去有一批上下文工程的最佳实践,如今已经成了迷思。包括:

THEN过去:给 Claude 定规矩

NOW现在:让 Claude 自己判断

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:

Claude Code 刚上线时,我们得确保 Claude 避开最坏的情况,比如把文件删了。这意味着我们会给出特别强硬的指引,哪怕它并不总是对的。比如系统提示词里我们以前写:

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.

代码里:默认不写注释。绝不写多段的 docstring 或多行注释块,最多一行短的。除非用户要求,否则不要生成规划、决策或分析文档,从对话上下文里工作,不要靠中间文件

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.

但对某一部分 prompt 来说,这条指引是错的。就文档而言,用户可能有自己的偏好,某些特别复杂的代码段落也确实需要多行注释块

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.

话虽如此,老模型要是没有这些护栏,Claude 写出来的注释在很多情况下是错的,我们只能接受这个取舍。但新模型判断力更好,不用明写规矩,也能把这类决定做好

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

新的系统提示词里我们写的是:写出读起来像周围代码的代码,注释密度、命名、惯用法都跟着周围走

THEN过去:给 Claude 举例子

NOW现在:把接口设计好

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 举例子说明怎么用。到了最新的模型上,我们发现举例子反而把它们限死在某个探索空间里

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?

与其举例子,不如多想想工具、脚本、文件本身的设计。Claude 手上有哪些参数,这些参数怎样能更有表达力?

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.

比如那个 Todo 工具,光是把状态列成 pending、in_progress、completed 三个枚举值,就已经在提示 Claude 该怎么用了。再加上「同一时刻只保留一项进行中」这条说明,我们想要的行为就定下来了

THEN过去:一股脑全放前面

NOW现在:用渐进式披露

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.

因为 Claude Code 专注在编码上,我们的系统提示词里塞了怎么做代码审查和验证的详细信息。这些东西不是每次都用得上,但用得上的时候,是关键信息

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.

从那之后,Claude Code 在渐进式披露上变得很在行,也就是在对的时机加载对的上下文。举个例子,我们把验证和代码审查挪进了各自独立的技能,Claude Code 需要时才去调

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.

渐进式披露不只用在技能上,工具上我们也这么干。有些工具是「延迟加载」的,意思是 agent 用它之前,得先用 ToolSearch 把完整定义搜出来。这样我们就能挂更多工具(比如 Task 系列),而它们在被需要之前不占上下文

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.md 和 Skill.md 上。一个常见的迷思是,觉得应该把所有可能碰到的实践都堆进这一个中心仓库,不然 Claude 找不到。换个思路,做成一棵文件树,需要时才加载对应的那部分

延伸阅读 · Anthropic《A harness for every task: dynamic workflows in Claude Code》,2026 年 6 月 2 日

动态工作流让 Claude Code 能临场写出自己的骨架,为手头这件事量身定做。默认那套骨架是照编码设计的,但研究、安全分析、agent 团队、代码审查这几类活儿,以前得在 Claude Code 之上另搭骨架才跑得动

默认骨架要在同一个上下文窗口里既做计划又做执行。任务一长,会出三种毛病:偷懒,复杂多步任务干到一半就宣布完事,比如安全审查五十项做了三十五项;自我偏袒,让它验证或者按标准评判自己的产出时,它偏袒自己;目标漂移,多轮之后逐渐偏离最初目标,压缩过一次尤其明显,每次摘要都是有损的,「不要做 X」这类约束容易丢

解法是开出多个子 agent,各自带独立上下文窗口和聚焦的小目标,由一个 JavaScript 文件调度。工作流还能决定每个 agent 用哪个模型、要不要跑在自己的 worktree 里。中途被打断,续上会话就能接着跑

一个实际用法:「这个测试大概五十次挂一次,起个工作流复现它,提出几种互相竞争的假设,一直跑到只剩一种假设能扛住证据为止」

THEN过去:重要的话说三遍

NOW现在:工具说明写简单

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.

早期的 Claude 有时候需要把指令重复几遍,也更容易听上下文窗口末尾的指令,而不是开头的。这导致我们的系统提示词里,主提示词部分会提到工具,工具说明里又写一遍指令

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.

我们发现这些重复的例子可以删掉,怎么用工具的指令放进工具说明里就行,不必再进系统提示词

THEN过去:记忆写进 CLAUDE.md

NOW现在:交给自动记忆

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 的记忆里存东西,用 # 快捷键自动写进 CLAUDE.md。现在不用了,Claude 会自动把跟这项工作、跟你有关的东西存下来

THEN过去:简单的 spec

NOW现在:丰富的参照物

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.

在计划模式里,Claude Code 一直很依赖装着计划的 markdown 文件。把计划存成文件,Claude 需要时就能翻回去看。另一条类似的实践是把 spec 存在代码库里,让 Claude 在长周期项目里随时参照

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.

但我们发现,Claude 能处理的参照物越来越复杂了。除了简单的 markdown 文件,Claude 还能参照由新的 artifacts 功能生成的 HTML artifact

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.

你也可以用代码的形式给 Claude 参照物。一份 spec 可以是一套详细的测试用例,也可以是另一个代码库里、准备让 Claude 移植过来的某个函数

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 可以借助上面说到的动态工作流、开出带着这套标准的验证 agent,去尝试并验证你在某个领域里的品味,比如什么样的 API 设计才算好

用到你自己的上下文上

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 的话,你大概永远不会去动它。但如果你在搭自己的 agent 骨架,这里是你该花大量时间的地方

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.

CLAUDE.md 保持轻量,简单交代仓库是干什么的,然后把大部分 token 花在代码库里的坑上。比如你的代码组织方式是把类型全放在一个大文件里、别处不放。至于那些 Claude 扫一眼文件系统或仓库就该知道的「明摆着的事」,不要写

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 里指过去

技能 Skills

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

把技能想成轻量的指路牌,让 Claude 在需要时找得到信息。除了极重要的地方,不要把它们写得太死

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.

技能最好用来固化那些只属于你、你的团队或你的产品的主张、知识和实践

参照物 References

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

你可以用 @ 提到文件,把它们作为参照物带进来。有了参照物,Claude 就能查阅当前计划的深度信息

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.

可以是 spec 文件、设计稿,甚至整个代码库。总体上优先给代码形态的东西,那是 Claude 非常熟悉的语言,能提供清晰、高保真的指令。举个例子,一份 HTML 的设计稿,通常比一段设计描述或者一张截图效果更好

试着简化

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,它也能帮你自动做这件事。至于给更强的模型写 prompt 的更多细节,在 Fable 实战指南里

延伸阅读 · Anthropic《A field guide to Claude Fable 5》,2026 年 7 月 6 日

能不能把自己的未知讲清楚,现在是产出质量的瓶颈。几个可以直接用的做法:

盲区排查:让 Claude 先把你的盲区找出来。进一个陌生的代码库,或者做设计迭代这种你不熟的活儿,你多半连该问什么都不知道,那就先问它该问什么

交代起点:把你的起点告诉它。你想到哪一步了、你对这个问题和这个代码库有多少经验,让它当个能对话的伙伴,而不是一个只等着收指令的执行器

讲解与考题:做完之后让 Claude 把它做了什么讲一遍,或者反过来出几道题考你。你答不上来的地方,就是你之前没交代清楚的地方

本文由人人都是产品经理作者【赛博禅心】,微信公众号:【赛博禅心】,原创/授权 发布于人人都是产品经理,未经许可,禁止转载。

题图来自作者提供

更多精彩内容,请关注人人都是产品经理微信公众号或下载App
评论
评论请登录
  1. 以前系统提示词又长又互相打架,现在发现删掉八成性能不减,关键是把判断权还给模型,让上下文和周围代码做指引。上下文工程从约束转向引导,重点变成了怎么设计模型能看到的信息结构。

    来自广东 回复