跳转至

Claude 5 时代上下文工程新法则:为新一代大模型解除束缚

The New Rules of Context Engineering for Claude 5 Generation Models

作者: Thariq Shihipar
发布时间: 2026 年 7 月 24 日
阅读时长: 约 7 分钟

Author: Thariq Shihipar
Published: Jul 24, 2026
Reading Time: 7 min

文章背景与核心概要

随着 Anthropic 推出新一代 Claude 5 系列大语言模型 (Large Language Model, LLM),传统的上下文工程 (Context Engineering) 迎来了颠覆性的演化。过去为了防范旧模型犯错而层层堆叠的繁复系统提示词,在面对能力跃迁的新模型时,反而演变成了拖累性能并消耗认知开销的束缚。Anthropic 团队在将 Claude Code 的系统提示词精简 80% 以上的工程实践中发现,新一代模型不仅无需手把手的条条框框约束,反而在获得更大自主权后表现更加出色。本文系统梳理了从严苛规则转向自主判断、从海量示例转向精致接口设计等六大新时代法则,为开发者构建高效、敏捷的 AI 智能体 (AI Agent) 提供了清晰的上下文工程实践指引。


核心概要

Summary

我们在向 Claude 发送提示词时,实际键入的那段消息其实只占模型所接收总上下文的很小一部分。剩余的大量信息,往往是由系统提示词、专业技能、配置文件 (例如 CLAUDE.md) 以及记忆系统动态拼装而成的——这套系统化注入上下文的技术实践,便被称为上下文工程 (Context Engineering)。

When prompting Claude, the message you send is only a small fraction of the total context it receives. The rest is assembled from system prompts, skills, configuration files (like CLAUDE.md), and memory—a practice known as context engineering.

在 Anthropic 研发新一代 Claude 5 系列模型 (例如 Claude Opus 5 与 Claude Fable 5) 的过程中,工程师们发现:能力越先进的大模型,越不需要开发者像保姆一样事无巨细地指手画脚。令人惊讶的是,团队在删减掉 Claude Code 超过 80% 的系统提示词后,其编程表现竟没有出现丝毫下降;这一实验为团队带来了极为关键的启示:我们应当彻底摆脱过度严苛的防线约束,转向充分释放模型的自主性。本文将深入探讨如何为你的智能体“松绑解缚”,从那些早已过时的提示词迷思中抽身,转向现代最佳实践,并合理重塑你的上下文工程架构。

As Anthropic developed the Claude 5 generation models (such as Claude Opus 5 and Claude Fable 5), engineers discovered that advanced models require significantly less hand-holding. By removing over 80% of Claude Code’s system prompt without any drop in coding performance, the team learned crucial lessons about shifting away from restrictive guardrails toward model autonomy. This article explores how to unhobble your agents, transition from outdated prompting myths to modern best practices, and rightsize your own context engineering.


为 Claude 解除束缚

Unhobbling Claude

Anthropic 的内部使用数据表明,过去的 Claude Code 往往被系统提示词、技能以及用户请求中相互冲突的指令严重束缚 (例如,在某处要求 Claude “酌情保留文档”,而在另一处却又严词规定 “绝对不要添加注释”)。

Anthropic's internal usage data revealed that Claude Code was heavily overconstrained by conflicting instructions across system prompts, skills, and user requests (for example, telling Claude to “leave documentation as appropriate” in one place while enforcing “DO NOT add comments” in another).

尽管新一代模型已经具备足够的推理能力来理清这些彼此矛盾的死结,但强迫模型去化解此类矛盾,不仅毫无意义,还会平白消耗宝贵的认知开销。在早期大模型时代,为了防止模型出现极端恶性表现,开发者必须设立严密的安全护栏;但面对当下的新模型,这些护栏早已不再必要。此外,随着自动记忆 (Auto-Memory)、工件 (Artifacts) 以及定制化技能 (Skills) 等新特性的加入,Claude 在跨会话保持上下文时,也已完全不必单纯依赖像 CLAUDE.md 这样的静态文件了。

While newer models possess the reasoning capabilities to untangle these contradictions, forcing them to do so consumes unnecessary cognitive overhead. Guardrails that were once vital for older models to prevent worst-case scenarios are no longer necessary. Furthermore, with the introduction of new features like auto-memory, artifacts, and specialized skills, Claude no longer relies solely on static files like CLAUDE.md to retain information across sessions.


今昔对比:上下文工程的演化法则

Then and Now: Evolving Context Engineering Practices

随着 Claude 5 系列模型的登场,以往被视作上下文工程最佳实践的一系列法则,如今许多已沦为过时的技术迷思:

Several historical best practices for context engineering have become myths with the arrival of Claude 5 models:

1. 刻板规则 vs 自主判断

1. Rules vs. Judgement

  • 过去的做法: 给 Claude 制定极其死板的规则 (例如严禁使用多行注释块,或禁止生成方案设计文档)。
  • 现在的做法: 充分信任并赋予 Claude 自主判断权。新一代模型能够根据周遭的代码语境动态调整自身的生成风格。例如,如今的系统提示词改为了更为简洁自然的指引:“编写与周围代码风格高度融洽的代码:主动匹配其现有的注释密度、命名风格与惯用语法。”
  • Then: Give Claude strict rules (e.g., prohibiting multi-line comment blocks or planning documents).
  • Now: Let Claude use judgement. Newer models can adapt dynamically to surrounding code. For instance, the system prompt now instructs: "Write code that reads like the surrounding code: match its comment density, naming, and idiom."

2. 详尽示例 vs 优雅的接口设计

2. Examples vs. Interface Design

  • 过去的做法: 为工具的使用编写大量巨细靡遗的调用演示示例。
  • 现在的做法: 设计表达清晰、自明性高的工具接口。提供过多的示例反而会画地为牢,限制模型的探索与求解空间。相比之下,借助定义明晰的状态枚举 (Status Enums) 和精确的参数配置,便能优雅地引导模型的行为 (例如限制待办事项工具同时只能有一个处于 in_progress 进行中的任务)。
  • Then: Provide extensive worked examples for tool usage.
  • Now: Design expressive interfaces. Providing too many examples can constrain the model's exploration space. Instead, use clean status enums and precise parameters to gently guide behavior (e.g., restricting a Todo tool to one in_progress task at a time).

Before: a TodoWrite tool description of about 9,100 characters of when-to-use lists and worked examples. After: a short description, “Create and update a task list for the current session”, with a status enum of pending, in_progress and completed and one rule, only one task in_progress at a time.

3. 一次性灌入 vs 渐进式呈现

3. All Upfront vs. Progressive Disclosure

  • 过去的做法: 在一开始就倾倒式加载所有可能用到的代码审查与验证指令。
  • 现在的做法: 采用渐进式呈现 (Progressive Disclosure) 原则。将特定场景的专用指令抽离成模块化的技能,以及延迟加载的工具;仅在任务明确需要时,才通过 ToolSearch 按需检索加载。同时,将 CLAUDE.md 与技能文件拆解为结构清晰、易于导航的文件目录树,而非堆砌在单一庞杂的巨石文档中。
  • Then: Load every possible code review and verification instruction upfront.
  • Now: Use progressive disclosure. Move specialized instructions into modular skills and deferred-loading tools that are only fetched via ToolSearch when explicitly needed. Organize CLAUDE.md and skill files into navigable file trees rather than monolithic repositories.

4. 啰嗦复读 vs 精简聚焦的工具描述

4. Repetition vs. Simple Tool Descriptions

  • 过去的做法: 在主系统提示词和各个独立工具的说明文档中反反复复强调同一套指令,以此确保模型服从执行。
  • 现在的做法: 仅依赖各工具自身简洁、聚焦且局部的说明描述即可。
  • Then: Repeat instructions across the main system prompt and individual tool descriptions to ensure compliance.
  • Now: Rely on simple, localized tool descriptions.

5. 人工记录记忆 vs 自动记忆能力

5. Manual Memory vs. Auto-Memory

  • 过去的做法: 依靠快捷键将上下文信息手动摘抄并持久化到 CLAUDE.md 文件中。
  • 现在的做法: 让 Claude 自主捕获、归纳并应用与当前开发工作流息息相关的关键记忆。
  • Then: Manually save information into CLAUDE.md files using hotkeys.
  • Now: Let Claude automatically capture and apply memories relevant to your workflow.

6. 单薄的纯文本规范 vs 高信息密度的富引用

6. Simple Specs vs. Rich References

  • 过去的做法: 仅依赖普通的 Markdown 纯文本文件来撰写项目规划与规格说明。
  • 现在的做法: 充分利用高信息密度的富引用材料 (Rich References),例如 HTML 工件、完备的测试用例集、可直接运行的代码,或是搭配验证器智能体 (Verifier Agents) 使用的动态评估量规 (Dynamic Rubrics)。
  • Then: Rely solely on plain Markdown files for project plans and specifications.
  • Now: Leverage rich references such as HTML artifacts, comprehensive test suites, executable code, or dynamic rubrics paired with verifier agents.

Six old rules struck through, each pointing to its replacement: give Claude rules → give Claude judgement; give Claude examples → design interfaces; put it all upfront → use progressive disclosure; repeat yourself → simple tool descriptions; memory in CLAUDE.md files → auto-memory; simple specs → rich references.


将新法则落地到你的上下文架构中

Applying This to Your Context

在为你的智能体搭建上下文窗口时,需要深思熟虑地规划每一层信息的布局:

When assembling your agent's context window, structure your layers thoughtfully:

The context window drawn as a stack: your prompt on top, then references such as @-mentioned files, specs, mockups, codebases and artifacts, then the system prompt, CLAUDE.md files, skills and memory.

  • 系统提示词 (System Prompt) : 与产品业务的专属语境深度绑定。若你在自研智能体运行框架 (Harness),这一层至关重要。
  • CLAUDE.md: 保持极致轻量。清晰阐明代码仓库的核心定位与用途,把宝贵的 Token 额度优先留给代码库特有的“隐形陷阱” (Gotchas),切忌在此赘述人尽皆知的常识。同时运用渐进式呈现策略,将其按需链接到外部的代码验证技能中。
  • 技能 (Skills) : 视其为轻量化、模块化的操作手册。避免对其施加过度约束;应当让技能承载团队特定的工程规范或产品设计主张。
  • 参考资料 (References) : 善用 @ 语法直接精准引入高保真度的参考资料,例如已有代码库、测试用例、HTML 原型界面或技术规范,而非依赖单薄的纯文本叙述。
  • System Prompt: Tied directly to product context. Essential if building your own agent harness.
  • CLAUDE.md: Keep it lightweight. Describe the repository's core purpose and focus tokens on unique codebase "gotchas" rather than stating the obvious. Use progressive disclosure to link out to verification skills.
  • Skills: Treat them as lightweight, modular guides. Avoid overconstraining them; let them encode specific team or product opinions.
  • References: Use @-mentions to bring in high-fidelity references like codebases, tests, HTML mockups, or specs instead of plain-text descriptions.

尝试做减法

Try Simplifying

如果你希望精简目前那些日趋臃肿庞杂的配置,可以在终端中直接运行 claude doctor (或在 Claude Code 内部执行 /doctor 命令),系统便会自动帮你规范瘦身并合理优化技能与 CLAUDE.md 文件。

If you need help scaling back bloated configurations, you can run claude doctor (or use the /doctor command inside Claude Code) to automatically rightsize your skills and CLAUDE.md files.