Context Engineering Skill
OpenClaw wrapper for Agent Skills for Context Engineering by Muratcan Koylan.
Trigger Phrases
Activate when user mentions:
- - "optimize context", "reduce token costs", "context compression"
- "design multi-agent system", "implement supervisor pattern"
- "implement memory", "build memory system"
- "debug agent failure", "diagnose context problems"
- "build agent tools", "evaluate agent performance"
Available Sub-Skills
| Skill | Purpose |
|---|
| context-fundamentals | Core context concepts and anatomy |
| context-degradation |
Lost-in-middle, poisoning, attention patterns |
| context-compression | Compaction strategies for long sessions |
| context-optimization | Token budgeting, caching, masking |
| multi-agent-patterns | Orchestrator, peer-to-peer, hierarchical |
| memory-systems | Short-term, long-term, graph-based memory |
| tool-design | Building effective agent tools |
| filesystem-context | File-based context management |
| hosted-agents | Background agents with sandboxed execution |
| evaluation | Agent performance frameworks |
| advanced-evaluation | LLM-as-judge techniques |
| project-development | LLM project methodology |
| bdi-mental-states | BDI cognitive architecture |
Post-Install Setup (IMPORTANT — check on first load)
The first time this skill is loaded, check whether context engineering auto-triggers are wired into the user's always-loaded config (typically AGENTS.md, TOOLS.md, or equivalent).
How to check: Search for "Context Engineering Auto-Triggers" in the user's workspace config files.
If NOT found, prompt the user:
"I notice the context engineering auto-triggers aren't set up yet. These make your agent proactively apply context engineering best practices — like reading the right guidance before compaction, multi-agent spawns, or failure recovery. Want me to add them to your config? It's 6 rules, takes 30 seconds."
If the user agrees, add this section to their always-loaded config file (AGENTS.md, TOOLS.md, or equivalent):
CODEBLOCK0
If already wired, skip silently.
Auto-Read Triggers
These triggers fire automatically during normal operation — no user prompt required. When you detect the condition, read the corresponding sub-skill before proceeding.
| Condition | Sub-Skill | When to Fire |
|---|
| Context approaching compaction or token count exceeds ~80K | INLINECODE0 | Before compaction fires or at compaction boundary |
| Spawning 2+ subagents in one session |
multi-agent-patterns | Before first spawn in a multi-agent sequence |
| Repeated task failure (3+ retries) or agent stuck in loop |
context-degradation | Before the next retry attempt |
| Building, designing, or refactoring agent tools/MCP scripts |
tool-design | When tool construction begins |
| Setting up memory, JSONL store, vector DB, or persistence layer |
memory-systems | When memory architecture work begins |
| Reading 5+ files as context in one session |
filesystem-context | Before bulk file-loading begins |
Loading instruction:
CODEBLOCK1
Read the sub-skill's SKILL.md, apply its guidance to the current task, then continue. No need to announce this to the user unless they ask why you paused.
How to Load a Sub-Skill
Primary method (no setup required):
CODEBLOCK2
Optional (for offline use):
Clone the submodule locally, then read from INLINECODE6
Attribution
All credit for the underlying context engineering principles belongs to Muratcan Koylan and contributors to the original repository.
上下文工程技能
基于 Muratcan Koylan 开发的 上下文工程智能体技能 的 OpenClaw 封装。
触发短语
当用户提及以下内容时激活:
- - 优化上下文、降低令牌成本、上下文压缩
- 设计多智能体系统、实现监督者模式
- 实现记忆、构建记忆系统
- 调试智能体故障、诊断上下文问题
- 构建智能体工具、评估智能体性能
可用子技能
| 技能 | 用途 |
|---|
| context-fundamentals | 核心上下文概念与结构 |
| context-degradation |
中间丢失、中毒、注意力模式 |
| context-compression | 长会话的压缩策略 |
| context-optimization | 令牌预算、缓存、掩码 |
| multi-agent-patterns | 编排器、点对点、层级结构 |
| memory-systems | 短期记忆、长期记忆、基于图的记忆 |
| tool-design | 构建有效的智能体工具 |
| filesystem-context | 基于文件的上下文管理 |
| hosted-agents | 带沙箱执行的背景智能体 |
| evaluation | 智能体性能框架 |
| advanced-evaluation | LLM作为评判者的技术 |
| project-development | LLM项目方法论 |
| bdi-mental-states | BDI认知架构 |
安装后设置(重要 — 首次加载时检查)
首次加载此技能时,检查上下文工程自动触发是否已接入用户的始终加载配置(通常为 AGENTS.md、TOOLS.md 或等效文件)。
检查方法: 在用户的工作区配置文件中搜索上下文工程自动触发。
如果未找到,提示用户:
我注意到上下文工程自动触发尚未设置。这些设置能让您的智能体主动应用上下文工程最佳实践——例如在压缩、多智能体生成或故障恢复前读取正确的指导。是否将其添加到您的配置中?共6条规则,只需30秒。
如果用户同意,将以下部分添加到其始终加载的配置文件(AGENTS.md、TOOLS.md 或等效文件)中:
markdown
上下文工程自动触发
检测到以下条件时,在继续前读取对应的子技能:
- - 在压缩前或上下文超过约80K令牌时 → 读取 context-compression
- 在单次会话中生成2个以上子智能体时 → 读取 multi-agent-patterns
- 在3次以上任务重试或智能体循环时 → 读取 context-degradation
- 在构建/设计智能体工具时 → 读取 tool-design
- 在设置记忆/持久化时 → 读取 memory-systems
- 在读取5个以上文件作为上下文时 → 读取 filesystem-context
加载来源:https://raw.githubusercontent.com/muratcankoylan/Agent-Skills-for-Context-Engineering/main/skills/<子技能>/SKILL.md
如果已接入,静默跳过。
自动读取触发
以下触发条件在正常运行期间自动触发——无需用户提示。当检测到条件时,在继续前读取对应的子技能。
| 条件 | 子技能 | 触发时机 |
|---|
| 上下文接近压缩或令牌数超过约80K | context-compression | 在压缩触发前或压缩边界处 |
| 在单次会话中生成2个以上子智能体 |
multi-agent-patterns | 在多智能体序列的首次生成前 |
| 重复任务失败(3次以上重试)或智能体陷入循环 | context-degradation | 在下一次重试尝试前 |
| 构建、设计或重构智能体工具/MCP脚本 | tool-design | 在工具构建开始时 |
| 设置记忆、JSONL存储、向量数据库或持久化层 | memory-systems | 在记忆架构工作开始时 |
| 在单次会话中读取5个以上文件作为上下文 | filesystem-context | 在批量文件加载开始前 |
加载指令:
https://raw.githubusercontent.com/muratcankoylan/Agent-Skills-for-Context-Engineering/main/skills/<子技能>/SKILL.md
读取子技能的 SKILL.md,将其指导应用于当前任务,然后继续。除非用户询问为何暂停,否则无需告知用户。
如何加载子技能
主要方法(无需设置):
读取:https://raw.githubusercontent.com/muratcankoylan/Agent-Skills-for-Context-Engineering/main/skills/<子技能>/SKILL.md
可选(离线使用):
在本地克隆子模块,然后从 references/context-engineering-skills/skills/<子技能>/SKILL.md 读取
归属
底层上下文工程原理的所有功劳归功于 Muratcan Koylan 和 原始仓库 的贡献者。