‹ 首页

context-engineering

@owl-listener · 收录于 5 天前 · 上游提交 1 个月前

Designing what information goes into the context window and in what order.

适合你,如果你需要优化AI模型的输入上下文以提升输出质量。

/ 通过 npx 安装 校验哈希
npx oh-my-skill add owl-listener/ai-design-skills/context-engineering
/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- owl-listener/ai-design-skills/context-engineering
/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify owl-listener/ai-design-skills/context-engineering
安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
144GitHub stars
~606上下文体积 · 单文件
索引托管

怎么用

商店整理自技能原文 · 版本 f41b650 · 表述以原文为准
它做什么

Claude 会根据上下文工程原则,自动管理令牌预算,将最重要的指令放在开头,用户输入放在末尾,并使用摘要、优先级历史等策略优化信息架构,提升输出相关性。

什么时候触发

当对话上下文接近令牌限制,或用户提供大量文档、复杂指令时,Claude 会主动应用上下文工程策略来优化信息和顺序。

装好后可以这样说
Claude 会压缩旧内容,释放空间。
Claude 会调整信息顺序。
技能原文 SKILL.md作者撰写 · MIT · f41b650

Context Engineering

The context window is finite. What goes into it — and in what order — determines the quality of every output. Context engineering is the practice of deliberately designing the information architecture of the context window.

The Context Budget

Every context window has a token budget. Allocate it deliberately:

  • System prompt: The foundational instructions (typically 5-20% of the budget)
  • Retrieved context: Documents, data, and information pulled in for the current task
  • Conversation history: Previous turns in the conversation
  • User input: The current request
  • Working space: Room for the model to generate its response

These compete for space. More retrieved context means less conversation history. A longer system prompt means less room for everything else.

Information Architecture in Context

Order matters. The model pays different amounts of attention to different positions:

  • Beginning: High attention. Put your most important instructions here.
  • Middle: Lower attention. This is where information can get lost in long contexts.
  • End: High attention. The most recent information (user input) naturally goes here.
  • Adjacent to the task: Information placed right before the user's question gets more attention than information earlier in the context.
Context Selection

Not everything should go into the context. Design selection criteria:

  • Relevance: Does this information help answer the current question?
  • Recency: Is this the most up-to-date information available?
  • Specificity: Is this specific enough to be useful, or is it too generic?
  • Redundancy: Is this information already covered elsewhere in the context?
  • Authority: Is this from a reliable source?
Context Strategies
  • Retrieval-augmented generation (RAG): Pull relevant documents into the context dynamically
  • Summarisation: Compress older context into summaries to free up space
  • Prioritised history: Keep recent and important conversation turns, drop less important ones
  • Structured context: Organise information with clear headers and sections so the model can navigate it
  • Context caching: Pre-compute and cache frequently used context blocks
Context Quality Signals

How to tell if your context engineering is working:

  • Output relevance: Do outputs address the actual question using the provided context?
  • Hallucination rate: Is the model making things up because the context is insufficient?
  • Context utilisation: Is the model actually using the provided context, or ignoring it?
  • Consistency: Are outputs consistent when the same context is provided?
Design Artefacts
  • Context budget allocation documents
  • Information architecture diagrams for the context window
  • Context selection criteria per feature
  • Retrieval strategy specifications
  • Context quality monitoring metrics
按 MIT 许可原样转载,未经改动 · 在 GitHub 查看 →

评论

登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。