ADK Skill Patterns 🧩
Source: Google Cloud Tech — 5 Agent Skill Design Patterns
Adapted for: OpenClaw Agent System
Purpose: Build reliable, composable agent skills using proven architectural patterns
Overview
The specification explains how to package a skill, but offers zero guidance on how to structure the logic inside it. These 5 patterns solve that problem.
| Pattern | Question It Answers | Use When |
|---|
| Tool Wrapper | "How do I make my agent an expert on a specific library?" | Agent needs deep, contextual knowledge about a technology |
| Generator |
"How do I enforce consistent output structure?" | Output format must be predictable every time |
|
Reviewer | "How do I separate what to check from how to check it?" | Code review, quality gates, compliance checking |
|
Inversion | "How do I stop the agent from guessing and gather requirements first?" | Complex tasks requiring full context before execution |
|
Pipeline | "How do I enforce a strict multi-step workflow?" | Multi-phase tasks with checkpoints and approvals |
Pattern 1: Tool Wrapper
Purpose: Give your agent on-demand context for a specific library/framework.
Mechanism:
- - Listens for library keywords in prompts
- Dynamically loads documentation from INLINECODE0
- Applies conventions as absolute truth only when needed
Example Use Cases:
- - FastAPI conventions
- Internal coding standards
- Framework-specific best practices
- API design guidelines
Template: See templates/tool-wrapper-SKILL.md
Pattern 2: Generator
Purpose: Enforce consistent output via fill-in-the-blank orchestration.
Mechanism:
- -
assets/ holds output template - INLINECODE3 holds style guide
- Instructions act as project manager
- Asks for missing variables before generating
Example Use Cases:
- - API documentation generation
- Standardized commit messages
- Project scaffolding
- Technical reports
Template: See templates/generator-SKILL.md
Pattern 3: Reviewer
Purpose: Separate review criteria from review execution.
Mechanism:
- - Stores modular rubric in INLINECODE5
- Methodically scores submissions
- Groups findings by severity
- Swap checklist = completely different audit
Example Use Cases:
- - PR review automation
- Security vulnerability scanning
- Code quality audits
- Compliance checking
Template: See templates/reviewer-SKILL.md
Pattern 4: Inversion
Purpose: Stop agents from guessing — make them interview first.
Mechanism:
- - Agent acts as interviewer, not executor
- Structured questions in phases
- Hard gates prevent premature synthesis
- User drives through answers, not prompts
Example Use Cases:
- - Project planning/requirements gathering
- System design interviews
- Complex task specification
- Knowledge extraction
Template: See templates/inversion-SKILL.md
Pattern 5: Pipeline
Purpose: Enforce strict sequential workflow with hard checkpoints.
Mechanism:
- - Instructions = workflow definition
- Diamond gate conditions (user approval required)
- Cannot bypass steps or present unvalidated results
- Progressive disclosure keeps context clean
Example Use Cases:
- - Documentation generation workflows
- Multi-step code generation
- Complex build/deploy pipelines
- Research synthesis workflows
Template: See templates/pipeline-SKILL.md
Decision Tree
CODEBLOCK0
Pattern Composition
These patterns are not mutually exclusive — they compose:
| Combination | Effect |
|---|
| Pipeline + Reviewer | Multi-step workflow with quality gate at the end |
| Generator + Inversion |
Gather variables via interview, then fill template |
| Pipeline + Tool Wrapper | Each step loads specific expertise as needed |
| Reviewer + Generator | Review output before generating final document |
Principle: Your agent only spends context tokens on the exact patterns it needs at runtime.
Quick Reference: Pattern Selection
| Scenario | Pattern | Why |
|---|
| "Teach my agent FastAPI conventions" | Tool Wrapper | Context loads only when FastAPI mentioned |
| "Generate consistent API docs" |
Generator | Template + style guide = predictable output |
| "Automate PR reviews" | Reviewer | Swap checklist for different audit types |
| "Plan a new project" | Inversion | Gathers full requirements before designing |
| "Generate docs from code" | Pipeline | Parse → Generate → Review → Assemble |
Directory Structure
CODEBLOCK1
Anti-Patterns to Avoid
❌ Cramming everything into system prompt — Use Tool Wrapper instead
❌ Different output every run — Use Generator for consistency
❌ Hardcoded review criteria — Use Reviewer for modularity
❌ Agent assumes context — Use Inversion to gather requirements
❌ Skipped steps in workflows — Use Pipeline for enforcement
Implementation Notes for OpenClaw
- 1. File Loading: Use
read tool to load references/assets dynamically - Pattern Detection: Check user's intent to determine which pattern to apply
- Composition: Chain skills via
sessions_spawn for complex workflows - Gates: Explicit user confirmation before proceeding (especially Pipeline/Inversion)
Using This Skill
To Apply a Pattern
Ask me: "Use the [pattern-name] pattern to [task]"
Examples:
- - "Use the Tool Wrapper pattern to create a FastAPI expert skill"
- "Use the Generator pattern to standardize my report outputs"
- "Use the Reviewer pattern to build a code quality checker"
- "Use the Inversion pattern to plan my new project"
- "Use the Pipeline pattern to create a documentation workflow"
To Get Pattern Advice
Ask: "Which pattern should I use for [scenario]?"
To Compose Patterns
Ask: "How do I combine [pattern-1] and [pattern-2]?"
Source Article: https://x.com/GoogleCloudTech/status/2033953579824758855
Last Updated: March 29, 2026
ADK 技能模式 🧩
来源: Google Cloud Tech — 5 种 Agent 技能设计模式
适配: OpenClaw Agent 系统
目的: 使用经过验证的架构模式构建可靠、可组合的 Agent 技能
概述
该规范解释了如何打包一个技能,但未提供任何关于如何构建其内部逻辑的指导。这 5 种模式解决了这个问题。
| 模式 | 解决的问题 | 使用场景 |
|---|
| 工具包装器 | 如何让我的 Agent 成为某个特定库的专家? | Agent 需要关于某项技术的深度、上下文知识 |
| 生成器 |
如何强制输出结构的一致性? | 输出格式每次都必须可预测 |
|
审查器 | 如何将检查内容与检查方式分离? | 代码审查、质量门禁、合规性检查 |
|
反转 | 如何阻止 Agent 猜测,先收集需求? | 执行前需要完整上下文的复杂任务 |
|
流水线 | 如何强制执行严格的多步骤工作流? | 带有检查点和审批的多阶段任务 |
模式 1:工具包装器
目的: 为你的 Agent 提供针对特定库/框架的按需上下文。
机制:
- - 监听提示中的库关键词
- 动态加载 references/ 中的文档
- 仅在需要时将约定作为绝对真理应用
示例用例:
- - FastAPI 约定
- 内部编码标准
- 框架特定最佳实践
- API 设计指南
模板: 参见 templates/tool-wrapper-SKILL.md
模式 2:生成器
目的: 通过填空式编排强制输出一致性。
机制:
- - assets/ 存放输出模板
- references/ 存放风格指南
- 指令充当项目经理
- 在生成前询问缺失的变量
示例用例:
- - API 文档生成
- 标准化提交信息
- 项目脚手架
- 技术报告
模板: 参见 templates/generator-SKILL.md
模式 3:审查器
目的: 将审查标准与审查执行分离。
机制:
- - 将模块化评分标准存储在 references/review-checklist.md 中
- 有条理地对提交内容进行评分
- 按严重程度对发现结果进行分组
- 更换检查清单 = 完全不同的审计
示例用例:
- - PR 审查自动化
- 安全漏洞扫描
- 代码质量审计
- 合规性检查
模板: 参见 templates/reviewer-SKILL.md
模式 4:反转
目的: 阻止 Agent 猜测——让它先进行访谈。
机制:
- - Agent 充当访谈者,而非执行者
- 分阶段提出结构化问题
- 硬性门禁防止过早综合
- 用户通过回答驱动,而非提示
示例用例:
- - 项目规划/需求收集
- 系统设计访谈
- 复杂任务规范
- 知识提取
模板: 参见 templates/inversion-SKILL.md
模式 5:流水线
目的: 通过硬性检查点强制执行严格的顺序工作流。
机制:
- - 指令 = 工作流定义
- 菱形门条件(需要用户批准)
- 不能跳过步骤或呈现未经验证的结果
- 渐进式披露保持上下文清晰
示例用例:
- - 文档生成工作流
- 多步骤代码生成
- 复杂构建/部署流水线
- 研究综合工作流
模板: 参见 templates/pipeline-SKILL.md
决策树
开始:你的技能需要做什么?
│
├─→ 提供关于特定库/框架的深度知识?
│ └─→ 使用:工具包装器
│
├─→ 产生一致的、基于模板的输出?
│ └─→ 使用:生成器
│
├─→ 根据标准检查/审计某些内容?
│ └─→ 使用:审查器
│
├─→ 在行动前收集需求?
│ └─→ 使用:反转
│
├─→ 执行严格的多步骤工作流?
│ └─→ 使用:流水线
│
└─→ 以上多种情况?
└─→ 模式可组合(见下文)
模式组合
这些模式并非互斥——它们可以组合:
| 组合 | 效果 |
|---|
| 流水线 + 审查器 | 多步骤工作流,末尾带有质量门禁 |
| 生成器 + 反转 |
通过访谈收集变量,然后填充模板 |
| 流水线 + 工具包装器 | 每个步骤按需加载特定专业知识 |
| 审查器 + 生成器 | 在生成最终文档前审查输出 |
原则: 你的 Agent 仅在运行时为其需要的精确模式花费上下文令牌。
快速参考:模式选择
| 场景 | 模式 | 原因 |
|---|
| 教我的 Agent FastAPI 约定 | 工具包装器 | 仅在提到 FastAPI 时加载上下文 |
| 生成一致的 API 文档 |
生成器 | 模板 + 风格指南 = 可预测输出 |
| 自动化 PR 审查 | 审查器 | 为不同审计类型更换检查清单 |
| 规划一个新项目 | 反转 | 在设计前收集完整需求 |
| 从代码生成文档 | 流水线 | 解析 → 生成 → 审查 → 组装 |
目录结构
skills/
└── your-skill/
├── SKILL.md # 指令(实现模式)
├── references/ # 知识、检查清单、风格指南
│ ├── conventions.md
│ ├── review-checklist.md
│ └── style-guide.md
└── assets/ # 模板、示例
├── report-template.md
└── plan-template.md
应避免的反模式
❌ 将所有内容塞入系统提示 — 改用工具包装器
❌ 每次运行输出不同 — 使用生成器确保一致性
❌ 硬编码审查标准 — 使用审查器实现模块化
❌ Agent 假设上下文 — 使用反转收集需求
❌ 工作流中跳过步骤 — 使用流水线强制执行
OpenClaw 实现说明
- 1. 文件加载: 使用 read 工具动态加载引用/资产
- 模式检测: 检查用户意图以确定应用哪种模式
- 组合: 通过 sessions_spawn 链式技能以实现复杂工作流
- 门禁: 在继续前获取用户明确确认(特别是流水线/反转)
使用此技能
应用模式
问我:使用 [模式名称] 模式来 [任务]
示例:
- - 使用工具包装器模式创建一个 FastAPI 专家技能
- 使用生成器模式标准化我的报告输出
- 使用审查器模式构建一个代码质量检查器
- 使用反转模式规划我的新项目
- 使用流水线模式创建一个文档工作流
获取模式建议
问:我应该为 [场景] 使用哪种模式?
组合模式
问:如何组合 [模式1] 和 [模式2]?
来源文章: https://x.com/GoogleCloudTech/status/2033953579824758855
最后更新: 2026年3月29日