返回列表
🧠 阿头学 · 💬 讨论题

Agent Skill 设计的五种模式——从格式标准化到行为结构化

Agent 开发的真正瓶颈已从"格式规范"转向"行为设计",通过 Tool Wrapper、Generator、Reviewer、Inversion、Pipeline 五种模式的组合,可以显著提升 Agent 的可靠性和一致性,但这套方法论的通用性和实际效果仍需验证。
打开原文 ↗

2026-03-18 原文链接 ↗
阅读简报
双语对照
完整翻译
原文
讨论归档

核心观点

  • 格式标准化已成过去式,内容设计成为新瓶颈 30+ Agent 工具已在 SKILL.md 布局上达成一致,真正的差异化在于如何组织 Agent 的行为逻辑——不是怎么写 Prompt,而是怎么设计工作流。
  • 五种模式本质上是对 LLM 默认冲动的结构化抑制 Tool Wrapper 通过按需加载控制知识注入,Generator 通过模板强制输出一致性,Reviewer 将标准外置便于迭代,Inversion 强制先问后做打破"急于生成"的本性,Pipeline 用关卡禁止跳步。这些都在做同一件事:让 Agent 按流程老实,而不是靠更强模型。
  • 关键创新是"逻辑与资产分离"——把规则从 Prompt 中拆出来 将开发规范、审查清单、输出模板外置到 `references/` 和 `assets/` 目录,使其可独立维护、复用和迭代。这样 Reviewer 模式只需替换清单就能从代码审查变成安全审计,大幅降低维护成本。
  • Inversion 模式直击 Agent 最大痛点——基于错误假设的无效返工 通过设置不可协商的"关卡",强制 Agent 在完成所有结构化问题前拒绝执行,从根源上解决"Garbage in, garbage out"。这是对抗 AI 幻觉和瞎猜的最直接方式。
  • 模式可组合但存在隐藏成本 文章声称按需加载能保持上下文干净,但多模式嵌套(如 Pipeline 内嵌 Reviewer 和 Inversion)会导致对话历史膨胀,实际 Token 消耗和注意力丢失问题仍未解决。

跟我们的关联

  • 对 Neta 意味着什么 这套模式论证了"Agent 可靠性不靠模型升级,靠流程设计",这对 AI 产品经理很关键——意味着投资应该从"买更贵的 API"转向"设计更好的工作流"。下一步可以用这五种模式评审自家 Agent 产品,找出哪些环节缺少结构化约束。
  • 对 ATou 意味着什么 如果你在用 Claude Code、Cursor 等 Agent 工具,理解这五种模式能帮你写出更稳定的 Prompt。特别是 Inversion(先问后做)和 Pipeline(分步确认)两种,直接可以复制进你的日常工作流,减少 AI 的瞎猜和返工。
  • 对 Uota 意味着什么 这篇文章本质是 Google ADK 的布道文,推广其 SKILL.md 规范。如果你的团队已经在用 ADK 或考虑采用,这五种模式是官方推荐的最佳实践;如果你用其他 Agent 框架,这些思想仍然可迁移,但需要自己做适配。
  • 下一步怎么用 先对照自己当前的 Agent 设计,判断属于哪种模式或缺少哪种模式;然后尝试把最常用的规则和清单外置到独立文件,体验"逻辑与资产分离"的维护优势;最后在关键任务上试用 Inversion 或 Pipeline,观察是否真的能减少 Agent 的错误和返工。

讨论引子

  • 文章声称这五种模式是从行业实践"归纳"出来的,但没有给出样本范围、筛选标准或反例。你认为这个归纳是否充分?是否还有其他常见的 Agent 行为模式被遗漏了?
  • Inversion 和 Pipeline 模式会增加轮次、延迟和 Token 成本,有时可能让 Agent 机械执行、错失高效捷径。在什么场景下这些模式的收益大于成本?什么场景下反而会拖累效率?
  • 文章假设 LLM 会像传统代码一样严格执行 YAML 里的自然语言指令(如"Do NOT start building until..."),但实际上当前大模型在多轮对话中极易出现"越狱"或忽略否定指令。这个假设的风险有多大?

谈到 𝚂𝙺𝙸𝙻𝙻.𝚖𝚍,开发者往往会盯着格式不放——把 YAML 写对、把目录结构搭好、严格遵循规范。但如今已有 30 多个 agent 工具(比如 Claude Code、Gemini CLI 和 Cursor)在同一套布局上完成标准化,“格式问题”几乎已经过时了。

现在的挑战在于内容设计。规范解释了如何打包一个 skill,却完全没有告诉你该如何组织其中的逻辑。举例来说,一个封装 FastAPI 约定的 skill,其运作方式与一个四步文档流水线截然不同,尽管它们对外呈现的 𝚂𝙺𝙸𝙻𝙻.𝚖𝚍 文件看起来一模一样。

通过研究整个生态里 skill 的构建方式——从 Anthropic 的仓库到 Vercel,再到 Google 的内部指南——我们发现有五种反复出现的设计模式,能够帮助开发者构建 agent。

作者:@Saboo_Shubham_ 与 @lavinigam

本文将结合可运行的 ADK 代码逐一讲解:

  • Tool Wrapper:让你的 agent 瞬间精通任何库

  • Generator:用可复用模板生成结构化文档

  • Reviewer:按严重程度用清单给代码打分

  • Inversion:agent 先“访谈”你,再开始行动

  • Pipeline:用检查点强制执行严格的多步工作流

https://google.github.io/adk-docs/

Pattern 1: The Tool Wrapper

Tool Wrapper 会为你的 agent 提供某个特定库的按需上下文。你不必把 API 约定硬塞进 system prompt,而是将它们打包进一个 skill。你的 agent 只会在确实要处理该技术时才加载这段上下文。

# skills/project-planner/SKILL.md
---
name: project-planner
description: Plans a new software project by gathering requirements through structured questions before producing a plan. Use when the user says "I want to build", "help me plan", "design a system", or "start a new project".
metadata:
  pattern: inversion
  interaction: multi-turn
---

You are conducting a structured requirements interview. DO NOT start building or designing until all phases are complete.

## Phase 1 — Problem Discovery (ask one question at a time, wait for each answer)

Ask these questions in order. Do not skip any.

- Q1: "What problem does this project solve for its users?"
- Q2: "Who are the primary users? What is their technical level?"
- Q3: "What is the expected scale? (users per day, data volume, request rate)"

## Phase 2 — Technical Constraints (only after Phase 1 is fully answered)

- Q4: "What deployment environment will you use?"
- Q5: "Do you have any technology stack requirements or preferences?"
- Q6: "What are the non-negotiable requirements? (latency, uptime, compliance, budget)"

## Phase 3 — Synthesis (only after all questions are answered)

1. Load 'assets/plan-template.md' for the output format
2. Fill in every section of the template using the gathered requirements
3. Present the completed plan to the user
4. Ask: "Does this plan accurately capture your requirements? What would you change?"
5. Iterate on feedback until the user confirms

这是最容易实现的一种模式。𝚂𝙺𝙸𝙻𝙻.𝚖𝚍 文件会在用户提示中监听特定库的关键词,动态从 𝚛𝚎𝚏𝚎𝚛𝚎𝚗𝚌𝚎𝚜/ 目录加载你的内部文档,并将这些规则当作绝对真理来执行。这正是把团队内部编码规范或特定框架最佳实践,直接分发进开发者工作流的机制。

下面是一个 Tool Wrapper 的例子,它教会 agent 如何编写 FastAPI 代码。注意这些指令如何明确要求:只有在开始审查或编写代码时,才加载 𝚌𝚘𝚗𝚟𝚎𝚗𝚝𝚒𝚘𝚗𝚜.𝚖𝚍 文件:

# skills/report-generator/SKILL.md
---
name: report-generator
description: Generates structured technical reports in Markdown. Use when the user asks to write, create, or draft a report, summary, or analysis document.
metadata:
  pattern: generator
  output-format: markdown
---

You are a technical report generator. Follow these steps exactly:

Step 1: Load 'references/style-guide.md' for tone and formatting rules.

Step 2: Load 'assets/report-template.md' for the required output structure.

Step 3: Ask the user for any missing information needed to fill the template:
- Topic or subject
- Key findings or data points
- Target audience (technical, executive, general)

Step 4: Fill the template following the style guide rules. Every section in the template must be present in the output.

Step 5: Return the completed report as a single Markdown document.

Pattern 2: The Generator

如果说 Tool Wrapper 负责“应用知识”,那么 Generator 负责“强制一致的输出”。如果你苦于 agent 每次运行都生成不同的文档结构,Generator 会通过编排一个“填空式”的流程来解决这一点。

它利用两个可选目录:𝚊𝚜𝚜𝚎𝚝𝚜/ 存放输出模板,𝚛𝚎𝚏𝚎𝚛𝚎𝚗𝚌𝚎𝚜/ 存放风格指南。指令就像项目经理:告诉 agent 加载模板、阅读风格指南、向用户补齐缺失变量,并把内容填入文档。这对于生成可预测的 API 文档、统一 commit message、或为项目架构搭脚手架都非常实用。

在这个技术报告生成器示例中,skill 文件并不包含真实的版式或语法规则。它只是协调这些资产的检索,并强制 agent 按步骤执行:

Pattern 3: The Reviewer

Reviewer 模式把“检查什么”和“怎么检查”分离开来。你不需要写一段冗长的 system prompt 去罗列所有代码异味,而是把一份模块化的评审量表存放在 𝚛𝚎𝚏𝚎𝚛𝚎𝚗𝚌𝚎𝚜/𝚛𝚎𝚟𝚒𝚎𝚠-𝚌𝚑𝚎𝚌𝚔𝚕𝚒𝚜𝚝.𝚖𝚍 文件里。

当用户提交代码时,agent 会加载这份清单,按部就班地为提交内容打分,并按严重程度分组输出发现。如果你把 Python 风格检查清单替换成 OWASP 安全清单,你就能在完全相同的 skill 基础设施上,得到一份截然不同、同样专业的审计报告。这是自动化 PR 评审、或在人工介入之前捕捉漏洞的高效方式。

下面这个代码审查 skill 演示了这种分离:指令保持不变,但 agent 会动态加载外部清单中的具体评审标准,并被强制输出结构化、按严重程度分层的结果:

# skills/doc-pipeline/SKILL.md
---
name: doc-pipeline
description: Generates API documentation from Python source code through a multi-step pipeline. Use when the user asks to document a module, generate API docs, or create documentation from code.
metadata:
  pattern: pipeline
  steps: "4"
---

You are running a documentation generation pipeline. Execute each step in order. Do NOT skip steps or proceed if a step fails.

## Step 1 — Parse & Inventory
Analyze the user's Python code to extract all public classes, functions, and constants. Present the inventory as a checklist. Ask: "Is this the complete public API you want documented?"

## Step 2 — Generate Docstrings
For each function lacking a docstring:
- Load 'references/docstring-style.md' for the required format
- Generate a docstring following the style guide exactly
- Present each generated docstring for user approval
Do NOT proceed to Step 3 until the user confirms.

## Step 3 — Assemble Documentation
Load 'assets/api-doc-template.md' for the output structure. Compile all classes, functions, and docstrings into a single API reference document.

## Step 4 — Quality Check
Review against 'references/quality-checklist.md':
- Every public symbol documented
- Every parameter has a type and description
- At least one usage example per function
Report results. Fix issues before presenting the final document.

Pattern 4: Inversion

agent 天生倾向于立刻猜测并开始生成。Inversion 模式反转了这种动态:不再由用户驱动提示、agent 执行;而是由 agent 扮演访谈者的角色。

# skills/code-reviewer/SKILL.md
---
name: code-reviewer
description: Reviews Python code for quality, style, and common bugs. Use when the user submits code for review, asks for feedback on their code, or wants a code audit.
metadata:
  pattern: reviewer
  severity-levels: error,warning,info
---

You are a Python code reviewer. Follow this review protocol exactly:

Step 1: Load 'references/review-checklist.md' for the complete review criteria.

Step 2: Read the user's code carefully. Understand its purpose before critiquing.

Step 3: Apply each rule from the checklist to the code. For every violation found:
- Note the line number (or approximate location)
- Classify severity: error (must fix), warning (should fix), info (consider)
- Explain WHY it's a problem, not just WHAT is wrong
- Suggest a specific fix with corrected code

Step 4: Produce a structured review with these sections:
- **Summary**: What the code does, overall quality assessment
- **Findings**: Grouped by severity (errors first, then warnings, then info)
- **Score**: Rate 1-10 with brief justification
- **Top 3 Recommendations**: The most impactful improvements

Inversion 依赖明确、不可协商的“关卡”指令(例如“在所有阶段完成之前,不要开始构建”),来强制 agent 先收集上下文。它会按顺序提出结构化问题,并等待你的回答后才进入下一阶段。在对你的需求与部署约束形成完整理解之前,agent 会拒绝综合出最终产物。

想看它如何工作,请看这个项目规划 skill。这里的关键,是严格分阶段,以及那条明确的“守门”提示:在收集到所有用户答案之前,阻止 agent 综合出最终计划:

Pattern 5: The Pipeline

面对复杂任务,你承受不起跳步或忽视指令的代价。Pipeline 模式用严格的顺序工作流与硬检查点来强制执行。

指令本身就是工作流定义。通过实现明确的关卡条件(例如:从生成 docstring 进入最终组装之前必须获得用户批准),Pipeline 能确保 agent 无法绕过复杂任务,直接给出未经验证的最终结果。

这种模式会用到所有可选目录:只在需要的具体步骤里引入对应的参考文件与模板,从而让上下文窗口保持干净。

在这个文档流水线示例里,注意那些明确的关卡条件:在用户确认上一步生成的 docstring 之前,agent 被明确禁止进入组装阶段:

# skills/api-expert/SKILL.md
---
name: api-expert
description: FastAPI development best practices and conventions. Use when building, reviewing, or debugging FastAPI applications, REST APIs, or Pydantic models.
metadata:
  pattern: tool-wrapper
  domain: fastapi
---

You are an expert in FastAPI development. Apply these conventions to the user's code or question.

## Core Conventions

Load 'references/conventions.md' for the complete list of FastAPI best practices.

## When Reviewing Code
1. Load the conventions reference
2. Check the user's code against each convention
3. For each violation, cite the specific rule and suggest the fix

## When Writing Code
1. Load the conventions reference
2. Follow every convention exactly
3. Add type annotations to all function signatures
4. Use Annotated style for dependency injection

Choosing the right agent skill pattern

每种模式都在回答一个不同的问题。用这棵决策树为你的 use-case 找到合适的那一种:

And finally, patterns compose

这些模式并非互斥,它们可以组合。

一个 Pipeline skill 可以在最后加入 Reviewer 步骤来复核自身工作;一个 Generator 可以在最开始借助 Inversion 先收集填模板所需的变量。得益于 ADK 的 𝚂𝚔𝚒𝚕𝚕𝚃𝚘𝚘𝚕𝚜𝚎𝚝 与渐进式披露,你的 agent 只会在运行时为它确实需要的模式消耗上下文 token。

别再试图把复杂而脆弱的指令塞进一条 system prompt。把工作流拆开,应用正确的结构模式,构建可靠的 agent。

Get started today

Agent Skills 规范是开源的,并在 ADK 中获得原生支持。你已经知道如何打包格式;现在,你也知道如何设计内容了。用 Google Agent Development Kit 去构建更聪明的 agent 吧。

When it comes to 𝚂𝙺𝙸𝙻𝙻.𝚖𝚍, developers tend to fixate on the format—getting the YAML right, structuring directories, and following the spec. But with more than 30 agent tools (like Claude Code, Gemini CLI, and Cursor) standardizing on the same layout, the formatting problem is practically obsolete.

谈到 𝚂𝙺𝙸𝙻𝙻.𝚖𝚍,开发者往往会盯着格式不放——把 YAML 写对、把目录结构搭好、严格遵循规范。但如今已有 30 多个 agent 工具(比如 Claude Code、Gemini CLI 和 Cursor)在同一套布局上完成标准化,“格式问题”几乎已经过时了。

The challenge now is content design. The specification explains how to package a skill, but offers zero guidance on how to structure the logic inside it. For example, a skill that wraps FastAPI conventions operates completely differently from a four-step documentation pipeline, even though their 𝚂𝙺𝙸𝙻𝙻.𝚖𝚍 files look identical on the outside.

现在的挑战在于内容设计。规范解释了如何打包一个 skill,却完全没有告诉你该如何组织其中的逻辑。举例来说,一个封装 FastAPI 约定的 skill,其运作方式与一个四步文档流水线截然不同,尽管它们对外呈现的 𝚂𝙺𝙸𝙻𝙻.𝚖𝚍 文件看起来一模一样。

By studying how skills are built across the ecosystem—from Anthropic’s repositories to Vercel and Google's internal guidelines— there are five recurring design patterns that can help developers build agents.

通过研究整个生态里 skill 的构建方式——从 Anthropic 的仓库到 Vercel,再到 Google 的内部指南——我们发现有五种反复出现的设计模式,能够帮助开发者构建 agent。

By @Saboo_Shubham_ and @lavinigam

作者:@Saboo_Shubham_ 与 @lavinigam

This article covers each one with working ADK code:

本文将结合可运行的 ADK 代码逐一讲解:

  • Tool Wrapper: Make your agent an instant expert on any library
  • Tool Wrapper:让你的 agent 瞬间精通任何库
  • Generator: Produce structured documents from a reusable template
  • Generator:用可复用模板生成结构化文档
  • Reviewer: Score code against a checklist by severity
  • Reviewer:按严重程度用清单给代码打分
  • Inversion: The agent interviews you before acting
  • Inversion:agent 先“访谈”你,再开始行动
  • Pipeline: Enforce a strict multi-step workflow with checkpoints
  • Pipeline:用检查点强制执行严格的多步工作流

Pattern 1: The Tool Wrapper

Pattern 1: The Tool Wrapper

A Tool Wrapper gives your agent on-demand context for a specific library. Instead of hardcoding API conventions into your system prompt, you package them into a skill. Your agent only loads this context when it actually works with that technology.

Tool Wrapper 会为你的 agent 提供某个特定库的按需上下文。你不必把 API 约定硬塞进 system prompt,而是将它们打包进一个 skill。你的 agent 只会在确实要处理该技术时才加载这段上下文。

# skills/project-planner/SKILL.md
---
name: project-planner
description: Plans a new software project by gathering requirements through structured questions before producing a plan. Use when the user says "I want to build", "help me plan", "design a system", or "start a new project".
metadata:
  pattern: inversion
  interaction: multi-turn
---

You are conducting a structured requirements interview. DO NOT start building or designing until all phases are complete.

## Phase 1 — Problem Discovery (ask one question at a time, wait for each answer)

Ask these questions in order. Do not skip any.

- Q1: "What problem does this project solve for its users?"
- Q2: "Who are the primary users? What is their technical level?"
- Q3: "What is the expected scale? (users per day, data volume, request rate)"

## Phase 2 — Technical Constraints (only after Phase 1 is fully answered)

- Q4: "What deployment environment will you use?"
- Q5: "Do you have any technology stack requirements or preferences?"
- Q6: "What are the non-negotiable requirements? (latency, uptime, compliance, budget)"

## Phase 3 — Synthesis (only after all questions are answered)

1. Load 'assets/plan-template.md' for the output format
2. Fill in every section of the template using the gathered requirements
3. Present the completed plan to the user
4. Ask: "Does this plan accurately capture your requirements? What would you change?"
5. Iterate on feedback until the user confirms

# skills/project-planner/SKILL.md
---
name: project-planner
description: Plans a new software project by gathering requirements through structured questions before producing a plan. Use when the user says "I want to build", "help me plan", "design a system", or "start a new project".
metadata:
  pattern: inversion
  interaction: multi-turn
---

You are conducting a structured requirements interview. DO NOT start building or designing until all phases are complete.

## Phase 1 — Problem Discovery (ask one question at a time, wait for each answer)

Ask these questions in order. Do not skip any.

- Q1: "What problem does this project solve for its users?"
- Q2: "Who are the primary users? What is their technical level?"
- Q3: "What is the expected scale? (users per day, data volume, request rate)"

## Phase 2 — Technical Constraints (only after Phase 1 is fully answered)

- Q4: "What deployment environment will you use?"
- Q5: "Do you have any technology stack requirements or preferences?"
- Q6: "What are the non-negotiable requirements? (latency, uptime, compliance, budget)"

## Phase 3 — Synthesis (only after all questions are answered)

1. Load 'assets/plan-template.md' for the output format
2. Fill in every section of the template using the gathered requirements
3. Present the completed plan to the user
4. Ask: "Does this plan accurately capture your requirements? What would you change?"
5. Iterate on feedback until the user confirms

It is the simplest pattern to implement. The 𝚂𝙺𝙸𝙻𝙻.𝚖𝚍 file listens for specific library keywords in the user's prompt, dynamically loads your internal documentation from the 𝚛𝚎𝚏𝚎𝚛𝚎𝚗𝚌𝚎𝚜/ directory, and applies those rules as absolute truth. This is the exact mechanism you use to distribute your team's internal coding guidelines or specific framework best practices directly into your developers' workflows.

这是最容易实现的一种模式。𝚂𝙺𝙸𝙻𝙻.𝚖𝚍 文件会在用户提示中监听特定库的关键词,动态从 𝚛𝚎𝚏𝚎𝚛𝚎𝚗𝚌𝚎𝚜/ 目录加载你的内部文档,并将这些规则当作绝对真理来执行。这正是把团队内部编码规范或特定框架最佳实践,直接分发进开发者工作流的机制。

Here is an example of a Tool Wrapper that teaches an agent how to write FastAPI code. Notice how the instructions explicitly tell the agent to load the 𝚌𝚘𝚗𝚟𝚎𝚗𝚝𝚒𝚘𝚗𝚜.𝚖𝚍 file only when it starts reviewing or writing code:

下面是一个 Tool Wrapper 的例子,它教会 agent 如何编写 FastAPI 代码。注意这些指令如何明确要求:只有在开始审查或编写代码时,才加载 𝚌𝚘𝚗𝚟𝚎𝚗𝚝𝚒𝚘𝚗𝚜.𝚖𝚍 文件:

# skills/report-generator/SKILL.md
---
name: report-generator
description: Generates structured technical reports in Markdown. Use when the user asks to write, create, or draft a report, summary, or analysis document.
metadata:
  pattern: generator
  output-format: markdown
---

You are a technical report generator. Follow these steps exactly:

Step 1: Load 'references/style-guide.md' for tone and formatting rules.

Step 2: Load 'assets/report-template.md' for the required output structure.

Step 3: Ask the user for any missing information needed to fill the template:
- Topic or subject
- Key findings or data points
- Target audience (technical, executive, general)

Step 4: Fill the template following the style guide rules. Every section in the template must be present in the output.

Step 5: Return the completed report as a single Markdown document.

# skills/report-generator/SKILL.md
---
name: report-generator
description: Generates structured technical reports in Markdown. Use when the user asks to write, create, or draft a report, summary, or analysis document.
metadata:
  pattern: generator
  output-format: markdown
---

You are a technical report generator. Follow these steps exactly:

Step 1: Load 'references/style-guide.md' for tone and formatting rules.

Step 2: Load 'assets/report-template.md' for the required output structure.

Step 3: Ask the user for any missing information needed to fill the template:
- Topic or subject
- Key findings or data points
- Target audience (technical, executive, general)

Step 4: Fill the template following the style guide rules. Every section in the template must be present in the output.

Step 5: Return the completed report as a single Markdown document.

Pattern 2: The Generator

Pattern 2: The Generator

While the Tool Wrapper applies knowledge, the Generator enforces consistent output. If you struggle with an agent generating different document structures on every run, the Generator solves this by orchestrating a fill-in-the-blank process.

如果说 Tool Wrapper 负责“应用知识”,那么 Generator 负责“强制一致的输出”。如果你苦于 agent 每次运行都生成不同的文档结构,Generator 会通过编排一个“填空式”的流程来解决这一点。

It leverages two optional directories: 𝚊𝚜𝚜𝚎𝚝𝚜/ holds your output template, and 𝚛𝚎𝚏𝚎𝚛𝚎𝚗𝚌𝚎𝚜/ holds your style guide. The instructions act as a project manager. They tell the agent to load the template, read the style guide, ask the user for missing variables, and populate the document. This is practical for generating predictable API documentation, standardizing commit messages, or scaffolding project architectures.

它利用两个可选目录:𝚊𝚜𝚜𝚎𝚝𝚜/ 存放输出模板,𝚛𝚎𝚏𝚎𝚛𝚎𝚗𝚌𝚎𝚜/ 存放风格指南。指令就像项目经理:告诉 agent 加载模板、阅读风格指南、向用户补齐缺失变量,并把内容填入文档。这对于生成可预测的 API 文档、统一 commit message、或为项目架构搭脚手架都非常实用。

In this technical report generator example, the skill file does not contain the actual layout or the grammar rules. It simply coordinates the retrieval of those assets and forces the agent to execute them step by step:

在这个技术报告生成器示例中,skill 文件并不包含真实的版式或语法规则。它只是协调这些资产的检索,并强制 agent 按步骤执行:

Pattern 3: The Reviewer

Pattern 3: The Reviewer

The Reviewer pattern separates what to check from how to check it. Rather than writing a long system prompt detailing every code smell, you store a modular rubric inside a 𝚛𝚎𝚏𝚎𝚛𝚎𝚗𝚌𝚎𝚜/𝚛𝚎𝚟𝚒𝚎𝚠-𝚌𝚑𝚎𝚌𝚔𝚕𝚒𝚜𝚝.𝚖𝚍 file.

Reviewer 模式把“检查什么”和“怎么检查”分离开来。你不需要写一段冗长的 system prompt 去罗列所有代码异味,而是把一份模块化的评审量表存放在 𝚛𝚎𝚏𝚎𝚛𝚎𝚗𝚌𝚎𝚜/𝚛𝚎𝚟𝚒𝚎𝚠-𝚌𝚑𝚎𝚌𝚔𝚕𝚒𝚜𝚝.𝚖𝚍 文件里。

When a user submits code, the agent loads this checklist and methodically scores the submission, grouping its findings by severity. If you swap out a Python style checklist for an OWASP security checklist, you get a completely different, specialized audit using the exact same skill infrastructure. It is a highly effective way to automate PR reviews or catch vulnerabilities before a human looks at the code.

当用户提交代码时,agent 会加载这份清单,按部就班地为提交内容打分,并按严重程度分组输出发现。如果你把 Python 风格检查清单替换成 OWASP 安全清单,你就能在完全相同的 skill 基础设施上,得到一份截然不同、同样专业的审计报告。这是自动化 PR 评审、或在人工介入之前捕捉漏洞的高效方式。

The following code reviewer skill demonstrates this separation. The instructions remain static, but the agent dynamically loads the specific review criteria from an external checklist and forces a structured, severity-based output:

下面这个代码审查 skill 演示了这种分离:指令保持不变,但 agent 会动态加载外部清单中的具体评审标准,并被强制输出结构化、按严重程度分层的结果:

# skills/doc-pipeline/SKILL.md
---
name: doc-pipeline
description: Generates API documentation from Python source code through a multi-step pipeline. Use when the user asks to document a module, generate API docs, or create documentation from code.
metadata:
  pattern: pipeline
  steps: "4"
---

You are running a documentation generation pipeline. Execute each step in order. Do NOT skip steps or proceed if a step fails.

## Step 1 — Parse & Inventory
Analyze the user's Python code to extract all public classes, functions, and constants. Present the inventory as a checklist. Ask: "Is this the complete public API you want documented?"

## Step 2 — Generate Docstrings
For each function lacking a docstring:
- Load 'references/docstring-style.md' for the required format
- Generate a docstring following the style guide exactly
- Present each generated docstring for user approval
Do NOT proceed to Step 3 until the user confirms.

## Step 3 — Assemble Documentation
Load 'assets/api-doc-template.md' for the output structure. Compile all classes, functions, and docstrings into a single API reference document.

## Step 4 — Quality Check
Review against 'references/quality-checklist.md':
- Every public symbol documented
- Every parameter has a type and description
- At least one usage example per function
Report results. Fix issues before presenting the final document.

# skills/doc-pipeline/SKILL.md
---
name: doc-pipeline
description: Generates API documentation from Python source code through a multi-step pipeline. Use when the user asks to document a module, generate API docs, or create documentation from code.
metadata:
  pattern: pipeline
  steps: "4"
---

You are running a documentation generation pipeline. Execute each step in order. Do NOT skip steps or proceed if a step fails.

## Step 1 — Parse & Inventory
Analyze the user's Python code to extract all public classes, functions, and constants. Present the inventory as a checklist. Ask: "Is this the complete public API you want documented?"

## Step 2 — Generate Docstrings
For each function lacking a docstring:
- Load 'references/docstring-style.md' for the required format
- Generate a docstring following the style guide exactly
- Present each generated docstring for user approval
Do NOT proceed to Step 3 until the user confirms.

## Step 3 — Assemble Documentation
Load 'assets/api-doc-template.md' for the output structure. Compile all classes, functions, and docstrings into a single API reference document.

## Step 4 — Quality Check
Review against 'references/quality-checklist.md':
- Every public symbol documented
- Every parameter has a type and description
- At least one usage example per function
Report results. Fix issues before presenting the final document.

Pattern 4: Inversion

Pattern 4: Inversion

Agents inherently want to guess and generate immediately. The Inversion pattern flips this dynamic. Instead of the user driving the prompt and the agent executing, the agent acts as an interviewer.

agent 天生倾向于立刻猜测并开始生成。Inversion 模式反转了这种动态:不再由用户驱动提示、agent 执行;而是由 agent 扮演访谈者的角色。

# skills/code-reviewer/SKILL.md
---
name: code-reviewer
description: Reviews Python code for quality, style, and common bugs. Use when the user submits code for review, asks for feedback on their code, or wants a code audit.
metadata:
  pattern: reviewer
  severity-levels: error,warning,info
---

You are a Python code reviewer. Follow this review protocol exactly:

Step 1: Load 'references/review-checklist.md' for the complete review criteria.

Step 2: Read the user's code carefully. Understand its purpose before critiquing.

Step 3: Apply each rule from the checklist to the code. For every violation found:
- Note the line number (or approximate location)
- Classify severity: error (must fix), warning (should fix), info (consider)
- Explain WHY it's a problem, not just WHAT is wrong
- Suggest a specific fix with corrected code

Step 4: Produce a structured review with these sections:
- **Summary**: What the code does, overall quality assessment
- **Findings**: Grouped by severity (errors first, then warnings, then info)
- **Score**: Rate 1-10 with brief justification
- **Top 3 Recommendations**: The most impactful improvements

# skills/code-reviewer/SKILL.md
---
name: code-reviewer
description: Reviews Python code for quality, style, and common bugs. Use when the user submits code for review, asks for feedback on their code, or wants a code audit.
metadata:
  pattern: reviewer
  severity-levels: error,warning,info
---

You are a Python code reviewer. Follow this review protocol exactly:

Step 1: Load 'references/review-checklist.md' for the complete review criteria.

Step 2: Read the user's code carefully. Understand its purpose before critiquing.

Step 3: Apply each rule from the checklist to the code. For every violation found:
- Note the line number (or approximate location)
- Classify severity: error (must fix), warning (should fix), info (consider)
- Explain WHY it's a problem, not just WHAT is wrong
- Suggest a specific fix with corrected code

Step 4: Produce a structured review with these sections:
- **Summary**: What the code does, overall quality assessment
- **Findings**: Grouped by severity (errors first, then warnings, then info)
- **Score**: Rate 1-10 with brief justification
- **Top 3 Recommendations**: The most impactful improvements

Inversion relies on explicit, non-negotiable gating instructions (like "DO NOT start building until all phases are complete") to force the agent to gather context first. It asks structured questions sequentially and waits for your answers before moving to the next phase. The agent refuses to synthesize a final output until it has a complete picture of your requirements and deployment constraints.

Inversion 依赖明确、不可协商的“关卡”指令(例如“在所有阶段完成之前,不要开始构建”),来强制 agent 先收集上下文。它会按顺序提出结构化问题,并等待你的回答后才进入下一阶段。在对你的需求与部署约束形成完整理解之前,agent 会拒绝综合出最终产物。

To see this in action, look at this project planner skill. The crucial element here is the strict phasing and the explicit gatekeeping prompt that stops the agent from synthesizing the final plan until all user answers are collected:

想看它如何工作,请看这个项目规划 skill。这里的关键,是严格分阶段,以及那条明确的“守门”提示:在收集到所有用户答案之前,阻止 agent 综合出最终计划:

Pattern 5: The Pipeline

Pattern 5: The Pipeline

For complex tasks, you cannot afford skipped steps or ignored instructions. The Pipeline pattern enforces a strict, sequential workflow with hard checkpoints.

面对复杂任务,你承受不起跳步或忽视指令的代价。Pipeline 模式用严格的顺序工作流与硬检查点来强制执行。

The instructions themselves serve as the workflow definition. By implementing explicit diamond gate conditions (such as requiring user approval before moving from docstring generation to final assembly), the Pipeline ensures an agent cannot bypass a complex task and present an unvalidated final result.

指令本身就是工作流定义。通过实现明确的关卡条件(例如:从生成 docstring 进入最终组装之前必须获得用户批准),Pipeline 能确保 agent 无法绕过复杂任务,直接给出未经验证的最终结果。

This pattern utilizes all optional directories, pulling in different reference files and templates only at the specific step where they are needed, keeping the context window clean.

这种模式会用到所有可选目录:只在需要的具体步骤里引入对应的参考文件与模板,从而让上下文窗口保持干净。

In this documentation pipeline example, notice the explicit gate conditions. The agent is explicitly forbidden from moving to the assembly phase until the user confirms the generated docstrings in the previous step:

在这个文档流水线示例里,注意那些明确的关卡条件:在用户确认上一步生成的 docstring 之前,agent 被明确禁止进入组装阶段:

# skills/api-expert/SKILL.md
---
name: api-expert
description: FastAPI development best practices and conventions. Use when building, reviewing, or debugging FastAPI applications, REST APIs, or Pydantic models.
metadata:
  pattern: tool-wrapper
  domain: fastapi
---

You are an expert in FastAPI development. Apply these conventions to the user's code or question.

## Core Conventions

Load 'references/conventions.md' for the complete list of FastAPI best practices.

## When Reviewing Code
1. Load the conventions reference
2. Check the user's code against each convention
3. For each violation, cite the specific rule and suggest the fix

## When Writing Code
1. Load the conventions reference
2. Follow every convention exactly
3. Add type annotations to all function signatures
4. Use Annotated style for dependency injection

# skills/api-expert/SKILL.md
---
name: api-expert
description: FastAPI development best practices and conventions. Use when building, reviewing, or debugging FastAPI applications, REST APIs, or Pydantic models.
metadata:
  pattern: tool-wrapper
  domain: fastapi
---

You are an expert in FastAPI development. Apply these conventions to the user's code or question.

## Core Conventions

Load 'references/conventions.md' for the complete list of FastAPI best practices.

## When Reviewing Code
1. Load the conventions reference
2. Check the user's code against each convention
3. For each violation, cite the specific rule and suggest the fix

## When Writing Code
1. Load the conventions reference
2. Follow every convention exactly
3. Add type annotations to all function signatures
4. Use Annotated style for dependency injection

Choosing the right agent skill pattern

Choosing the right agent skill pattern

Each pattern answers a different question. Use this decision tree to find the right one for your use-case:

每种模式都在回答一个不同的问题。用这棵决策树为你的 use-case 找到合适的那一种:

And finally, patterns compose

And finally, patterns compose

These patterns are not mutually exclusive. They compose.

这些模式并非互斥,它们可以组合。

A Pipeline skill can include a Reviewer step at the end to double-check its own work. A Generator can rely on Inversion at the very beginning to gather the necessary variables before filling out its template. Thanks to ADK's 𝚂𝚔𝚒𝚕𝚕𝚃𝚘𝚘𝚕𝚜𝚎𝚝 and progressive disclosure, your agent only spends context tokens on the exact patterns it needs at runtime.

一个 Pipeline skill 可以在最后加入 Reviewer 步骤来复核自身工作;一个 Generator 可以在最开始借助 Inversion 先收集填模板所需的变量。得益于 ADK 的 𝚂𝚔𝚒𝚕𝚕𝚃𝚘𝚘𝚕𝚜𝚎𝚝 与渐进式披露,你的 agent 只会在运行时为它确实需要的模式消耗上下文 token。

Stop trying to cram complex and fragile instructions into a single system prompt. Break your workflows down, apply the right structural pattern, and build reliable agents.

别再试图把复杂而脆弱的指令塞进一条 system prompt。把工作流拆开,应用正确的结构模式,构建可靠的 agent。

Get started today

Get started today

The Agent Skills specification is open-source and natively supported across ADK. You already know how to package the format. Now you know how to design the content. Go build smarter agents with Google Agent Development Kit.

Agent Skills 规范是开源的,并在 ADK 中获得原生支持。你已经知道如何打包格式;现在,你也知道如何设计内容了。用 Google Agent Development Kit 去构建更聪明的 agent 吧。

When it comes to 𝚂𝙺𝙸𝙻𝙻.𝚖𝚍, developers tend to fixate on the format—getting the YAML right, structuring directories, and following the spec. But with more than 30 agent tools (like Claude Code, Gemini CLI, and Cursor) standardizing on the same layout, the formatting problem is practically obsolete.

The challenge now is content design. The specification explains how to package a skill, but offers zero guidance on how to structure the logic inside it. For example, a skill that wraps FastAPI conventions operates completely differently from a four-step documentation pipeline, even though their 𝚂𝙺𝙸𝙻𝙻.𝚖𝚍 files look identical on the outside.

By studying how skills are built across the ecosystem—from Anthropic’s repositories to Vercel and Google's internal guidelines— there are five recurring design patterns that can help developers build agents.

By @Saboo_Shubham_ and @lavinigam

This article covers each one with working ADK code:

  • Tool Wrapper: Make your agent an instant expert on any library

  • Generator: Produce structured documents from a reusable template

  • Reviewer: Score code against a checklist by severity

  • Inversion: The agent interviews you before acting

  • Pipeline: Enforce a strict multi-step workflow with checkpoints

https://google.github.io/adk-docs/

Pattern 1: The Tool Wrapper

A Tool Wrapper gives your agent on-demand context for a specific library. Instead of hardcoding API conventions into your system prompt, you package them into a skill. Your agent only loads this context when it actually works with that technology.

# skills/project-planner/SKILL.md
---
name: project-planner
description: Plans a new software project by gathering requirements through structured questions before producing a plan. Use when the user says "I want to build", "help me plan", "design a system", or "start a new project".
metadata:
  pattern: inversion
  interaction: multi-turn
---

You are conducting a structured requirements interview. DO NOT start building or designing until all phases are complete.

## Phase 1 — Problem Discovery (ask one question at a time, wait for each answer)

Ask these questions in order. Do not skip any.

- Q1: "What problem does this project solve for its users?"
- Q2: "Who are the primary users? What is their technical level?"
- Q3: "What is the expected scale? (users per day, data volume, request rate)"

## Phase 2 — Technical Constraints (only after Phase 1 is fully answered)

- Q4: "What deployment environment will you use?"
- Q5: "Do you have any technology stack requirements or preferences?"
- Q6: "What are the non-negotiable requirements? (latency, uptime, compliance, budget)"

## Phase 3 — Synthesis (only after all questions are answered)

1. Load 'assets/plan-template.md' for the output format
2. Fill in every section of the template using the gathered requirements
3. Present the completed plan to the user
4. Ask: "Does this plan accurately capture your requirements? What would you change?"
5. Iterate on feedback until the user confirms

It is the simplest pattern to implement. The 𝚂𝙺𝙸𝙻𝙻.𝚖𝚍 file listens for specific library keywords in the user's prompt, dynamically loads your internal documentation from the 𝚛𝚎𝚏𝚎𝚛𝚎𝚗𝚌𝚎𝚜/ directory, and applies those rules as absolute truth. This is the exact mechanism you use to distribute your team's internal coding guidelines or specific framework best practices directly into your developers' workflows.

Here is an example of a Tool Wrapper that teaches an agent how to write FastAPI code. Notice how the instructions explicitly tell the agent to load the 𝚌𝚘𝚗𝚟𝚎𝚗𝚝𝚒𝚘𝚗𝚜.𝚖𝚍 file only when it starts reviewing or writing code:

# skills/report-generator/SKILL.md
---
name: report-generator
description: Generates structured technical reports in Markdown. Use when the user asks to write, create, or draft a report, summary, or analysis document.
metadata:
  pattern: generator
  output-format: markdown
---

You are a technical report generator. Follow these steps exactly:

Step 1: Load 'references/style-guide.md' for tone and formatting rules.

Step 2: Load 'assets/report-template.md' for the required output structure.

Step 3: Ask the user for any missing information needed to fill the template:
- Topic or subject
- Key findings or data points
- Target audience (technical, executive, general)

Step 4: Fill the template following the style guide rules. Every section in the template must be present in the output.

Step 5: Return the completed report as a single Markdown document.

Pattern 2: The Generator

While the Tool Wrapper applies knowledge, the Generator enforces consistent output. If you struggle with an agent generating different document structures on every run, the Generator solves this by orchestrating a fill-in-the-blank process.

It leverages two optional directories: 𝚊𝚜𝚜𝚎𝚝𝚜/ holds your output template, and 𝚛𝚎𝚏𝚎𝚛𝚎𝚗𝚌𝚎𝚜/ holds your style guide. The instructions act as a project manager. They tell the agent to load the template, read the style guide, ask the user for missing variables, and populate the document. This is practical for generating predictable API documentation, standardizing commit messages, or scaffolding project architectures.

In this technical report generator example, the skill file does not contain the actual layout or the grammar rules. It simply coordinates the retrieval of those assets and forces the agent to execute them step by step:

Pattern 3: The Reviewer

The Reviewer pattern separates what to check from how to check it. Rather than writing a long system prompt detailing every code smell, you store a modular rubric inside a 𝚛𝚎𝚏𝚎𝚛𝚎𝚗𝚌𝚎𝚜/𝚛𝚎𝚟𝚒𝚎𝚠-𝚌𝚑𝚎𝚌𝚔𝚕𝚒𝚜𝚝.𝚖𝚍 file.

When a user submits code, the agent loads this checklist and methodically scores the submission, grouping its findings by severity. If you swap out a Python style checklist for an OWASP security checklist, you get a completely different, specialized audit using the exact same skill infrastructure. It is a highly effective way to automate PR reviews or catch vulnerabilities before a human looks at the code.

The following code reviewer skill demonstrates this separation. The instructions remain static, but the agent dynamically loads the specific review criteria from an external checklist and forces a structured, severity-based output:

# skills/doc-pipeline/SKILL.md
---
name: doc-pipeline
description: Generates API documentation from Python source code through a multi-step pipeline. Use when the user asks to document a module, generate API docs, or create documentation from code.
metadata:
  pattern: pipeline
  steps: "4"
---

You are running a documentation generation pipeline. Execute each step in order. Do NOT skip steps or proceed if a step fails.

## Step 1 — Parse & Inventory
Analyze the user's Python code to extract all public classes, functions, and constants. Present the inventory as a checklist. Ask: "Is this the complete public API you want documented?"

## Step 2 — Generate Docstrings
For each function lacking a docstring:
- Load 'references/docstring-style.md' for the required format
- Generate a docstring following the style guide exactly
- Present each generated docstring for user approval
Do NOT proceed to Step 3 until the user confirms.

## Step 3 — Assemble Documentation
Load 'assets/api-doc-template.md' for the output structure. Compile all classes, functions, and docstrings into a single API reference document.

## Step 4 — Quality Check
Review against 'references/quality-checklist.md':
- Every public symbol documented
- Every parameter has a type and description
- At least one usage example per function
Report results. Fix issues before presenting the final document.

Pattern 4: Inversion

Agents inherently want to guess and generate immediately. The Inversion pattern flips this dynamic. Instead of the user driving the prompt and the agent executing, the agent acts as an interviewer.

# skills/code-reviewer/SKILL.md
---
name: code-reviewer
description: Reviews Python code for quality, style, and common bugs. Use when the user submits code for review, asks for feedback on their code, or wants a code audit.
metadata:
  pattern: reviewer
  severity-levels: error,warning,info
---

You are a Python code reviewer. Follow this review protocol exactly:

Step 1: Load 'references/review-checklist.md' for the complete review criteria.

Step 2: Read the user's code carefully. Understand its purpose before critiquing.

Step 3: Apply each rule from the checklist to the code. For every violation found:
- Note the line number (or approximate location)
- Classify severity: error (must fix), warning (should fix), info (consider)
- Explain WHY it's a problem, not just WHAT is wrong
- Suggest a specific fix with corrected code

Step 4: Produce a structured review with these sections:
- **Summary**: What the code does, overall quality assessment
- **Findings**: Grouped by severity (errors first, then warnings, then info)
- **Score**: Rate 1-10 with brief justification
- **Top 3 Recommendations**: The most impactful improvements

Inversion relies on explicit, non-negotiable gating instructions (like "DO NOT start building until all phases are complete") to force the agent to gather context first. It asks structured questions sequentially and waits for your answers before moving to the next phase. The agent refuses to synthesize a final output until it has a complete picture of your requirements and deployment constraints.

To see this in action, look at this project planner skill. The crucial element here is the strict phasing and the explicit gatekeeping prompt that stops the agent from synthesizing the final plan until all user answers are collected:

Pattern 5: The Pipeline

For complex tasks, you cannot afford skipped steps or ignored instructions. The Pipeline pattern enforces a strict, sequential workflow with hard checkpoints.

The instructions themselves serve as the workflow definition. By implementing explicit diamond gate conditions (such as requiring user approval before moving from docstring generation to final assembly), the Pipeline ensures an agent cannot bypass a complex task and present an unvalidated final result.

This pattern utilizes all optional directories, pulling in different reference files and templates only at the specific step where they are needed, keeping the context window clean.

In this documentation pipeline example, notice the explicit gate conditions. The agent is explicitly forbidden from moving to the assembly phase until the user confirms the generated docstrings in the previous step:

# skills/api-expert/SKILL.md
---
name: api-expert
description: FastAPI development best practices and conventions. Use when building, reviewing, or debugging FastAPI applications, REST APIs, or Pydantic models.
metadata:
  pattern: tool-wrapper
  domain: fastapi
---

You are an expert in FastAPI development. Apply these conventions to the user's code or question.

## Core Conventions

Load 'references/conventions.md' for the complete list of FastAPI best practices.

## When Reviewing Code
1. Load the conventions reference
2. Check the user's code against each convention
3. For each violation, cite the specific rule and suggest the fix

## When Writing Code
1. Load the conventions reference
2. Follow every convention exactly
3. Add type annotations to all function signatures
4. Use Annotated style for dependency injection

Choosing the right agent skill pattern

Each pattern answers a different question. Use this decision tree to find the right one for your use-case:

And finally, patterns compose

These patterns are not mutually exclusive. They compose.

A Pipeline skill can include a Reviewer step at the end to double-check its own work. A Generator can rely on Inversion at the very beginning to gather the necessary variables before filling out its template. Thanks to ADK's 𝚂𝚔𝚒𝚕𝚕𝚃𝚘𝚘𝚕𝚜𝚎𝚝 and progressive disclosure, your agent only spends context tokens on the exact patterns it needs at runtime.

Stop trying to cram complex and fragile instructions into a single system prompt. Break your workflows down, apply the right structural pattern, and build reliable agents.

Get started today

The Agent Skills specification is open-source and natively supported across ADK. You already know how to package the format. Now you know how to design the content. Go build smarter agents with Google Agent Development Kit.

📋 讨论归档

讨论进行中…