1 项目简介
Context Engineering Kit (CEK) 是一套精心打造的上下文工程技术和模式集合,专注于提升 AI Agent 输出质量和可预测性,同时保持最小的 Token 开销。
该项目以插件市场形式组织,基于 agentskills.io 和 openskills 标准,通用支持多种 AI 编码代理。
| 支持的 Agent | 接入方式 | 状态 |
|---|---|---|
| Claude Code | 原生插件系统 | 原生支持 |
| Cursor | openskills → AGENTS.md | 通用支持 |
| Windsurf | openskills → AGENTS.md | 通用支持 |
| Cline | openskills → AGENTS.md | 通用支持 |
| OpenCode | 原生技能支持 | 原生支持 |
核心特色
简单易用 · Token 高效 · 质量导向 · 颗粒化安装 · 科学验证(基于论文和基准测试)
2 架构概述
目录结构
context-engineering-kit/
├── plugins/ # 所有插件源码
│ └── customaize-agent/ # Customaize Agent 插件
│ ├── .claude-plugin/
│ │ └── plugin.json # 插件清单 (v1.3.2)
│ ├── README.md # 插件文档
│ ├── commands/ # 斜杠命令 (*.md)
│ │ ├── create-agent.md
│ │ ├── create-command.md
│ │ ├── create-hook.md
│ │ ├── create-skill.md
│ │ ├── create-workflow-command.md
│ │ ├── test-prompt.md
│ │ ├── test-skill.md
│ │ └── apply-anthropic-skill-best-practices.md
│ └── skills/ # 技能定义 (SKILL.md)
│ ├── prompt-engineering/ # ★ 重点技能
│ │ └── SKILL.md
│ ├── context-engineering/
│ │ └── SKILL.md
│ ├── agent-evaluation/
│ │ └── SKILL.md
│ └── thought-based-reasoning/
│ └── SKILL.md
├── CLAUDE.md # 项目级 AI 配置
├── README.md # 项目入口文档
└── docs/ # 文档站 (GitBook)
插件设计哲学
命令优先于技能
命令按需加载;技能描述默认加载到上下文中
专用 Agent
使用聚焦上下文的 Agent 来减少幻觉
Setup 命令
使用设置命令更新 CLAUDE.md 实现持久项目上下文
最小 Token
每个 Token 都很重要,保持提示精简
3 安装配置
Claude Code 安装(推荐)
第一步:添加市场
打开 Claude Code,运行以下命令添加 Context Engineering Kit 市场:
/plugin marketplace add NeoLabHQ/context-engineering-kit
这会使所有插件可供安装,但不会将任何 Agent 或技能加载到上下文中。
第二步:安装 Customaize Agent 插件
安装包含 prompt-engineering 技能的插件:
/plugin install customaize-agent@NeoLabHQ/context-engineering-kit
安装后,插件会将其专属的 Agent、命令和技能加载到 Claude 的上下文中。
prompt-engineering 技能会自动在你编写命令、钩子、技能或子 Agent 提示时被激活。
使用 OpenSkills 安装:
npx openskills install NeoLabHQ/context-engineering-kit
npx openskills sync
Cursor 单独安装命令(项目级):
curl -fsSL https://raw.githubusercontent.com/NeoLabHQ/context-engineering-kit/refs/heads/master/.bin/install-commands.sh | bash
全局安装加 --global 参数。
4 Prompt Engineering 技能(重点)
技能定位
位于 plugins/customaize-agent/skills/prompt-engineering/SKILL.md。当你编写命令、钩子、技能或子 Agent 提示,或进行任何 LLM 交互优化时,该技能会自动激活。安装 customaize-agent 插件后即可使用。
4.1 核心能力
1. Few-Shot Learning(少样本学习)
通过展示示例而非解释规则来教导模型。包含 2-5 个输入-输出对来展示期望行为。适用于需要一致格式、特定推理模式或处理边缘情况的场景。
从支持工单中提取关键信息:
Input: "My login doesn't work and I keep getting error 403"
Output: {"issue": "authentication", "error_code": "403", "priority": "high"}
Input: "Feature request: add dark mode to settings"
Output: {"issue": "feature_request", "error_code": null, "priority": "low"}
Now process: "Can't upload files larger than 10MB, getting timeout"
2. Chain-of-Thought 提示(思维链)
要求在最终答案之前进行逐步推理。添加"Let's think step by step"(零样本)或包含示例推理轨迹(少样本)。可将分析任务准确率提升 30-50%。
分析这个 Bug 报告并确定根因。
Think step by step:
1. 期望行为是什么?
2. 实际行为是什么?
3. 最近有什么变更可能导致此问题?
4. 涉及哪些组件?
5. 最可能的根因是什么?
Bug: "用户在昨天缓存更新部署后无法保存草稿"
3. 提示优化(Prompt Optimization)
通过测试和迭代系统性改进提示。从简单开始,衡量性能(准确性、一致性、Token 使用量),然后迭代。
V1(简单):"Summarize this article" → 不一致的长度,遗漏关键点
V2(加约束):"Summarize in 3 bullet points" → 更好的结构,仍缺少细微差别
V3(加推理):"Identify the 3 main findings, then summarize each" → 一致、准确、捕获关键信息
4. 模板系统(Template Systems)
构建带有变量、条件部分和模块化组件的可复用提示结构。
template = """
Review this {language} code for {focus_area}.
Code:
{code_block}
Provide feedback on:
{checklist}
"""
prompt = template.format(
language="Python",
focus_area="security vulnerabilities",
code_block=user_code,
checklist="1. SQL injection\n2. XSS risks\n3. Authentication"
)
5. 系统提示设计(System Prompt Design)
设置跨对话持久的全局行为和约束。定义模型角色、专业水平、输出格式和安全准则。
System: You are a senior backend engineer specializing in API design.
Rules:
- Always consider scalability and performance
- Suggest RESTful patterns by default
- Flag security concerns immediately
- Provide code examples in Python
- Use early return pattern
Format responses as:
1. Analysis 2. Recommendation 3. Code example 4. Trade-offs
4.2 关键模式
渐进式披露(Progressive Disclosure)
从简单提示开始,仅在需要时增加复杂度:
指令层级
[系统上下文] → [任务指令] → [示例] → [输入数据] → [输出格式]
错误恢复
- 包含降级指令
- 请求置信度分数
- 在不确定时要求替代解释
- 指定如何指示缺失信息
4.3 Agent 提示最佳实践(基于 Anthropic 官方)
上下文窗口 = 公共资源
你的提示、命令、技能与以下内容共享 200K Token 的上下文窗口:系统提示、对话历史、其他命令/技能/钩子/元数据、实际请求。
默认假设:Claude 已经非常聪明。只添加 Claude 不具备的上下文,并对每条信息提出挑战:"Claude 真的需要这个解释吗?"
自由度匹配原则
| 自由度 | 使用场景 | 比喻 |
|---|---|---|
| 高自由度 | 多种方法有效、取决于上下文 | 开阔田野,无障碍 |
| 中等自由度 | 存在首选模式、允许一定变化 | 有路标的道路 |
| 低自由度 | 操作脆弱、一致性关键、须遵循特定序列 | 两侧悬崖的窄桥 |
精简示例 (~50 tokens)
## Extract PDF text
Use pdfplumber: with pdfplumber.open("file.pdf") as pdf: text = pdf.pages[0].extract_text()
4.4 说服力原则(Agent 通信)
研究基础:Meincke 等 (2025) 测试了 7 种说服原则,N=28,000 次 AI 对话。说服技巧将合规率从 33% 提升至 72% (p < .001)。
| 原则 | 含义 | 在提示中的应用 | 示例 |
|---|---|---|---|
| 权威 (Authority) |
对专业性的尊重 | 命令式语言:"YOU MUST"、"Never"、"Always" | Write code before test? Delete it. No exceptions. |
| 承诺 (Commitment) |
与先前行为保持一致 | 要求宣布:"Announce skill usage" | You MUST announce: "I'm using [Skill Name]" |
| 稀缺性 (Scarcity) |
时间限制的紧迫感 | 时间绑定:"Before proceeding"、"IMMEDIATELY" | IMMEDIATELY request code review before proceeding |
| 社会认同 (Social Proof) |
从众行为 | 通用模式:"Every time"、"X without Y = failure" | Checklists without tracking = steps get skipped. Every time. |
| 统一性 (Unity) |
共同身份认同 | 协作语言:"our codebase"、"we both want quality" | We're colleagues. I need your honest judgment. |
不建议使用的原则
互惠 (Reciprocity) - 几乎不需要,其他原则更有效。喜好 (Liking) - 绝不用于合规性,会产生谄媚行为,与诚实反馈文化冲突。
按提示类型组合原则
| 提示类型 | 使用 | 避免 |
|---|---|---|
| 纪律执行型 | 权威 + 承诺 + 社会认同 | 喜好, 互惠 |
| 指导/技术型 | 适度权威 + 统一性 | 重度权威 |
| 协作型 | 统一性 + 承诺 | 权威, 喜好 |
| 参考型 | 仅清晰度 | 所有说服手段 |
4.5 最佳实践 & 常见陷阱
最佳实践
- 具体化 - 模糊提示产生不一致结果
- 展示而非讲述 - 示例比描述更有效
- 广泛测试 - 在多样化输入上评估
- 快速迭代 - 小改动可能大影响
- 监控性能 - 在生产中跟踪指标
- 版本控制 - 像管理代码一样管理提示
- 记录意图 - 解释为什么如此组织
常见陷阱
- 过度工程 - 尝试简单方案前就用复杂提示
- 示例污染 - 使用与目标任务不匹配的示例
- 上下文溢出 - 示例过多超过 Token 限制
- 歧义指令 - 留有多种解释空间
- 忽略边缘情况 - 不在异常输入上测试
5 其他附属技能
深入理解上下文机制:注意力预算、渐进式披露、迷失在中间效应,以及实用优化模式。
| 组件 | 作用 | 关键洞察 |
|---|---|---|
| 系统提示 | 核心身份和约束 | 平衡具体性与灵活性 |
| 工具定义 | 可用操作 | 差描述迫使猜测;优化需加示例 |
| 检索文档 | 领域知识 | 即时加载,而非预加载 |
| 消息历史 | 对话状态 | 长任务可主导上下文 |
| 工具输出 | 操作结果 | 可占总上下文的 83.9% |
Agent 系统评估框架:LLM-as-Judge、多维评分表、偏差缓解。研究发现 Token 使用量解释了 80% 的性能差异。
| 评估维度 | 权重 | 衡量内容 |
|---|---|---|
| 指令遵循 | 0.30 | 任务遵守度 |
| 输出完整性 | 0.25 | 需求覆盖范围 |
| 工具效率 | 0.20 | 最优工具选择 |
| 推理质量 | 0.15 | 逻辑健全性 |
| 响应连贯性 | 0.10 | 结构与清晰度 |
全面的思维链(CoT)及相关技术指南,包含模板、决策矩阵和研究支撑。
| 技术 | 使用时机 | 准确率提升 |
|---|---|---|
| Zero-shot CoT | 快速推理,无示例 | +20-60% |
| Few-shot CoT | 有好示例 | +30-70% |
| Self-Consistency | 高风险决策 | +10-20% |
| Tree of Thoughts | 需探索的复杂问题 | +50-70% |
| ReAct | 需外部信息 | +15-35% |
| Reflexion | 迭代改进 | +10-20% |
6 可用命令
| 命令 | 说明 |
|---|---|
| /customaize-agent:create-agent | 创建 Claude Code Agent 的完整指南,包含结构、触发条件、系统提示 |
| /customaize-agent:create-command | 交互式助手创建新命令,包含正确结构和模式 |
| /customaize-agent:create-workflow-command | 创建通过子 Agent 编排多步骤执行的工作流命令 |
| /customaize-agent:create-skill | 使用 TDD 方法创建技能的指南 |
| /customaize-agent:create-hook | 智能项目分析后创建和配置 Git 钩子 |
| /customaize-agent:test-skill | 使用 RED-GREEN-REFACTOR 循环验证技能抗压性 |
| /customaize-agent:test-prompt | 使用子 Agent 进行 RED-GREEN-REFACTOR 循环测试提示 |
| /customaize-agent:apply-anthropic-skill-best-practices | 基于 Anthropic 官方最佳实践的技能优化 |
7 使用示例
快速开始
# 1. 安装插件
/plugin install customaize-agent@NeoLabHQ/context-engineering-kit
# 2. 创建一个新 Agent
/customaize-agent:create-agent code-reviewer "Review code for quality"
# 3. 创建一个新命令
/customaize-agent:create-command validate API documentation
# 4. 创建一个新技能
/customaize-agent:create-skill image-editor
# 5. 测试一个提示(部署前)
/customaize-agent:test-prompt
# 6. 对现有技能应用 Anthropic 最佳实践
/customaize-agent:apply-anthropic-skill-best-practices
Prompt Engineering 技能如何自动激活?
安装 customaize-agent 插件后,当你进行以下操作时,prompt-engineering 技能会自动被加载到 Claude 的上下文中:
- 编写新的 Claude Code 命令、钩子或技能
- 设计子 Agent 的系统提示
- 优化任何 LLM 交互的提示
- 使用
/customaize-agent:create-*系列命令 - 使用
/customaize-agent:test-*系列命令
技能本身不需要手动调用 — 它作为背景知识自动注入,指导 Claude 在构建 Agent 扩展时遵循最佳实践。
8 全部插件列表
| 插件 | 说明 | 安装命令 |
|---|---|---|
| Reflexion | 反馈和精炼循环,提升输出质量 8-21% | /plugin install reflexion@... |
| Code Review | 多专业 Agent 综合代码审查 | /plugin install code-review@... |
| Git | 提交和 PR 创建命令 | /plugin install git@... |
| TDD | 测试驱动开发命令和反模式检测 | /plugin install tdd@... |
| SADD | 子 Agent 驱动开发,质量门控 | /plugin install sadd@... |
| DDD | 领域驱动开发 + Clean Architecture + SOLID | /plugin install ddd@... |
| SDD | 规范驱动开发,完整工作流 | /plugin install sdd@... |
| FPF | 第一原理框架,ADI 推理循环 | /plugin install fpf@... |
| Kaizen | 日本持续改进方法论,根因分析 | /plugin install kaizen@... |
| Customaize Agent | 编写和优化命令/钩子/技能 + Prompt Engineering | /plugin install customaize-agent@... |
| Docs | 项目分析和文档编写 | /plugin install docs@... |
| Tech Stack | 语言/框架最佳实践设置 | /plugin install tech-stack@... |
| MCP | MCP 服务器集成设置 | /plugin install mcp@... |
所有安装命令后缀均为 @NeoLabHQ/context-engineering-kit