Communitygithub.com

SamuelChien/mega-skills-collection

当用户要求“创建agent”、“添加agent”、“编写子agent”、“agent frontmatter”、“何时使用描述”、“agent示例”、“agent工具”、“agent颜色”、“自主agent”或需要指导agent结构、系统提示、触发条件或Claude Code插件的agent开发最佳实践时,应使用此技能。

mega-skills-collection 是什么?

此技能提供了一份详尽的指南,专为开发Claude Code插件的agent而设计。它系统性地讲解了Agent的文件结构(包括YAML frontmatter)、触发条件(description字段与示例)、系统提示词设计原则,以及模型、颜色和工具集的配置方法。该技能重点强调了Agent(自主子进程)与命令(用户发起)之间的根本区别,并给出了从标识符命名规范到系统提示词长度限制的精确验证规则。此外,它还支持通过AI辅助生成或手动创建两种途径来构建Agent,并附带了测试与验证脚本,帮助开发者快速生成可靠、可维护的自主Agent。对于任何希望为Claude Code插件开发高效、自治子系统的工程师而言,这份技能都是不可或缺的参考。

兼容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/SamuelChien/mega-skills-collection/tree/HEAD/agent-development

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

Claude Code插件的Agent开发指南

概述

Agent是能够独立处理复杂多步骤任务的自主子进程。理解Agent的结构、触发条件和系统提示词设计,可以创建强大的自主能力。

关键概念:

  • Agent是为了自主工作,而命令是为了用户发起的操作
  • 带YAML frontmatter的Markdown文件格式
  • 通过带有示例的description字段触发
  • 系统提示词定义Agent行为
  • 模型和颜色自定义

Agent文件结构

完整格式

---
name: agent-identifier
description: 当[触发条件]时使用该Agent。示例:

<example>
Context: [场景描述]
user: "[用户请求]"
assistant: "[助手应如何响应并使用该Agent]"
<commentary>
[为什么应该触发该Agent]
</commentary>
</example>

<example>
[更多示例...]
</example>

model: inherit
color: blue
tools: ["Read", "Write", "Grep"]
---

你是[Agent角色描述]...

**你的核心职责:**
1. [职责1]
2. [职责2]

**分析流程:**
[步骤化工作流程]

**输出格式:**
[返回内容]

Frontmatter字段

name(必填)

用于命名空间和调用的Agent标识符。

**格式:**仅限小写字母、数字、连字符 **长度:**3-50个字符 **模式:**必须以字母数字开头和结尾

好示例:

  • code-reviewer
  • test-generator
  • api-docs-writer
  • security-analyzer

坏示例:

  • helper(过于通用)
  • -agent-(以连字符开头/结尾)
  • my_agent(不允许下划线)
  • ag(太短,<3个字符)

description(必填)

定义Claude何时应触发该Agent。这是最关键字段。

必须包含:

  1. 触发条件("当...时使用该Agent")
  2. 多个展示用法的<example>块
  3. 每个示例中的Context、user请求和assistant响应
  4. 解释触发原因的<commentary>

格式:

当[条件]时使用该Agent。示例:

<example>
Context: [场景描述]
user: "[用户所说]"
assistant: "[Claude应如何响应]"
<commentary>
[该Agent为何适用]
</commentary>
</example>

[更多示例...]

最佳实践:

  • 包含2-4个具体示例
  • 展示主动和被动触发
  • 覆盖同一意图的不同表述
  • 在commentary中解释推理
  • 明确说明何时不使用该Agent

model(必填)

Agent应使用的模型。

选项:

  • inherit - 使用与父级相同的模型(推荐)
  • sonnet - Claude Sonnet(均衡)
  • opus - Claude Opus(最强,成本高)
  • haiku - Claude Haiku(快速,便宜)

**建议:**除非Agent需要特定模型能力,否则使用inherit。

color(必填)

Agent在UI中的视觉标识符。

选项:blue, cyan, green, yellow, magenta, red

指南:

  • 同一插件中的不同Agent选择不同的颜色
  • 相似类型的Agent使用一致的颜色
  • Blue/cyan:分析、审查
  • Green:面向成功的任务
  • Yellow:谨慎、验证
  • Red:关键、安全
  • Magenta:创意、生成

tools(可选)

将Agent限制为特定工具。

**格式:**工具名称数组

tools: ["Read", "Write", "Grep", "Bash"]

**默认:**如省略,Agent可访问所有工具

**最佳实践:**将工具限制为所需的最小集合(最小权限原则)

常见工具组合:

  • 只读分析:["Read", "Grep", "Glob"]
  • 代码生成:["Read", "Write", "Grep"]
  • 测试:["Read", "Bash", "Grep"]
  • 完全访问:省略字段或使用["*"]

系统提示词设计

Markdown正文成为Agent的系统提示词。以第二人称写作,直接对Agent讲话。

结构

标准模板:

你是专注于[领域]的[角色]。

**你的核心职责:**
1. [主要职责]
2. [次要职责]
3. [更多职责...]

**分析流程:**
1. [步骤一]
2. [步骤二]
3. [步骤三]
[...]

**质量标准:**
- [标准1]
- [标准2]

**输出格式:**
以以下格式提供结果:
- [包含内容]
- [如何组织]

**边缘情况:**
处理以下情况:
- [边缘情况1]:[如何处理]
- [边缘情况2]:[如何处理]

最佳实践

✅ 应做:

  • 以第二人称写作("你是...", "你将...")
  • 具体说明职责
  • 提供步骤化的流程
  • 定义输出格式
  • 包含质量标准
  • 处理边缘情况
  • 保持少于10,000字符

❌ 不应做:

  • 以第一人称写作("我是...", "我将...")
  • 模糊或泛泛而谈
  • 省略流程步骤
  • 未定义输出格式
  • 跳过质量指导
  • 忽略错误情况

创建Agent

方法1:AI辅助生成

使用此提示模式(摘自Claude Code):

根据以下请求创建一个Agent配置:"[你的描述]"

要求:
1. 提取核心意图和职责
2. 为该领域设计专家角色
3. 创建全面的系统提示词,包含:
   - 清晰的行为边界
   - 具体方法
   - 边缘情况处理
   - 输出格式
4. 创建标识符(小写、连字符、3-50字符)
5. 编写带有触发条件的描述
6. 包含2-3个展示何时使用的<example>块

返回JSON,格式如下:
{
  "identifier": "agent-name",
  "whenToUse": "当...时使用该Agent。示例:<example>...</example>",
  "systemPrompt": "你是..."
}

然后转换为带有frontmatter的Agent文件格式。

完整模板请参阅 examples/agent-creation-prompt.md。

方法2:手动创建

  1. 选择Agent标识符(3-50字符,小写,连字符)
  2. 编写带示例的描述
  3. 选择模型(通常为inherit)
  4. 选择视觉识别的颜色
  5. 定义工具(如需限制访问)
  6. 按上述结构编写系统提示词
  7. 保存为 agents/agent-name.md

验证规则

标识符验证

✅ 有效:code-reviewer, test-gen, api-analyzer-v2
❌ 无效:ag(太短), -start(以连字符开头), my_agent(下划线)

规则:

  • 3-50个字符
  • 仅限小写字母、数字、连字符
  • 必须以字母数字开头和结尾
  • 无下划线、空格或特殊字符

Description验证

**长度:**10-5,000字符 **必须包含:**触发条件和示例 **最佳:**200-1,000字符,2-4个示例

系统提示词验证

**长度:**20-10,000字符 **最佳:**500-3,000字符 **结构:**清晰的职责、流程、输出格式

Agent组织

插件Agents目录

plugin-name/
└── agents/
    ├── analyzer.md
    ├── reviewer.md
    └── generator.md

agents/目录下的所有.md文件将被自动发现。

命名空间

Agent自动分配命名空间:

  • 单插件:agent-name
  • 带子目录:plugin:subdir:agent-name

测试Agent

测试触发

创建测试场景以验证Agent是否正确触发:

  1. 编写带有特定触发示例的Agent
  2. 在测试中使用与示例相似的措辞
  3. 检查Claude是否加载了Agent
  4. 验证Agent提供了预期功能

测试系统提示词

确保系统提示词完整:

  1. 给Agent典型任务
  2. 检查它是否遵循流程步骤
  3. 验证输出格式是否正确
  4. 测试提示词中提到的边缘情况
  5. 确认达到质量标准

快速参考

最小Agent

---
name: simple-agent
description: 当...时使用该Agent。示例:<example>...</example>
model: inherit
color: blue
---

你是执行[某事]的Agent。

流程:
1. [步骤1]
2. [步骤2]

输出:[提供内容]

Frontmatter字段摘要

字段必填格式示例
name是小写-连字符code-reviewer
description是文本+示例何时使用... ...
model是inherit/sonnet/opus/haikuinherit
color是颜色名称blue
tools否工具名称数组["Read", "Grep"]

最佳实践

应做:

  • ✅ 在描述中包含2-4个具体示例
  • ✅ 编写具体的触发条件
  • ✅ 除非有特殊需求,否则使用inherit作为模型
  • ✅ 选择合适的工具(最小权限)
  • ✅ 编写清晰、结构化的系统提示词
  • ✅ 彻底测试Agent触发

不应做:

  • ❌ 使用没有示例的通用描述
  • ❌ 省略触发条件
  • ❌ 所有Agent使用相同颜色
  • ❌ 授予不必要的工具访问权限
  • ❌ 编写模糊的系统提示词
  • ❌ 跳过测试

附加资源

参考文件

有关详细指导,请参考:

  • references/system-prompt-design.md - 完整的系统提示词模式
  • references/triggering-examples.md - 示例格式和最佳实践
  • references/agent-creation-system-prompt.md - 来自Claude Code的确切提示

示例文件

examples/目录下的工作示例:

  • agent-creation-prompt.md - AI辅助Agent生成模板
  • complete-agent-examples.md - 不同用例的完整Agent示例

实用脚本

scripts/目录下的开发工具:

  • validate-agent.sh - 验证Agent文件结构
  • test-agent-trigger.sh - 测试Agent是否正确触发

实施工作流程

为插件创建Agent的步骤:

  1. 定义Agent目的和触发条件
  2. 选择创建方法(AI辅助或手动)
  3. 创建 agents/agent-name.md 文件
  4. 编写包含所有必填字段的frontmatter
  5. 遵循最佳实践编写系统提示词
  6. 在描述中包含2-4个触发示例
  7. 使用 scripts/validate-agent.sh 验证
  8. 使用真实场景测试触发
  9. 在插件README中记录Agent

专注于清晰的触发条件和全面的系统提示词,以实现自主操作。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

SamuelChien/mega-skills-collection

Security audit, hardening, threat modeling (STRIDE/PASTA), Red/Blue Team, OWASP checks, code review, incident response, and infrastructure security for any project.

SamuelChien/mega-skills-collection

Arquitecto de Soluciones Principal y Consultor Tecnológico de Andru.ia. Diagnostica y traza la hoja de ruta óptima para proyectos de IA en español.

SamuelChien/mega-skills-collection

Ingeniero de Sistemas de Andru.ia. Diseña, redacta y despliega nuevas habilidades (skills) dentro del repositorio siguiendo el Estándar de Diamante.

SamuelChien/mega-skills-collection

Estratega de Inteligencia de Dominio de Andru.ia. Analiza el nicho específico de un proyecto para inyectar conocimientos, regulaciones y estándares únicos del sector. Actívalo tras definir el nicho.

SamuelChien/mega-skills-collection

2D game development principles. Sprites, tilemaps, physics, camera.

SamuelChien/mega-skills-collection

3D game development principles. Rendering, shaders, physics, cameras.

SamuelChien/mega-skills-collection

Expert in building 3D experiences for the web - Three.js, React Three Fiber, Spline, WebGL, and interactive 3D scenes. Covers product configurators, 3D portfolios, immersive websites, and bringing depth to web experiences.

SamuelChien/mega-skills-collection

Accessibility audit skill for scanning, fixing, and verifying WCAG 2.2 Level A and AA compliance across React, Next.js, Vue, Angular, Svelte, and plain HTML codebases. Use when auditing accessibility, fixing a11y violations, checking color contrast, generating compliance reports, or integrating accessibility checks into CI/CD pipelines.

SamuelChien/mega-skills-collection

Ab Test Analyzer - Auto-activating skill for Data Analytics. Triggers on: ab test analyzer, ab test analyzer Part of the Data Analytics skill category.

SamuelChien/mega-skills-collection

A B Test Config Creator - Auto-activating skill for ML Deployment. Triggers on: a b test config creator, a b test config creator Part of the ML Deployment skill category.

SamuelChien/mega-skills-collection

When the user wants to plan, design, or implement an A/B test or experiment. Also use when the user mentions "A/B test," "split test," "experiment," "test this change," "variant copy," "multivariate test," "hypothesis," "conversion experiment," "statistical significance," or "test this." For tracking implementation, see analytics-tracking.

SamuelChien/mega-skills-collection

Acceptance Criteria Creator - Auto-activating skill for Enterprise Workflows. Triggers on: acceptance criteria creator, acceptance criteria creator Part of the Enterprise Workflows skill category.

SamuelChien/mega-skills-collection

Use when a coding task should be driven end-to-end from issue intake through implementation, review, deployment, and acceptance verification with minimal human re-intervention.

SamuelChien/mega-skills-collection

Accessibility Audit Runner - Auto-activating skill for Frontend Development. Triggers on: accessibility audit runner, accessibility audit runner Part of the Frontend Development skill category.

SamuelChien/mega-skills-collection

You are an accessibility expert specializing in WCAG compliance, inclusive design, and assistive technology compatibility. Conduct audits, identify barriers, and provide remediation guidance.

SamuelChien/mega-skills-collection

Web accessibility patterns for WCAG 2.2 compliance including ARIA, keyboard navigation, screen readers, and testing

SamuelChien/mega-skills-collection

Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed, or change policy for the Discord channel.

SamuelChien/mega-skills-collection

Create unified specification packages across Business, Development, and Design teams. Staged elaboration (L0 Vision → L1 Requirements → L2 Team Detail → L3 Acceptance Criteria) to build shared understanding. Does not write code.

SamuelChien/mega-skills-collection

Research a company or person and get actionable sales intel. Works standalone with web search, supercharged when you connect enrichment tools or your CRM. Trigger with "research [company]", "look up [person]", "intel on [prospect]", "who is [name] at [company]", or "tell me about [company]".

SamuelChien/mega-skills-collection

Validate messaging consistency across website, GitHub repos, and local documentation generating read-only discrepancy reports. Use when checking content alignment or finding mixed messaging. Trigger with phrases like "check consistency", "validate documentation", or "audit messaging".

相关技能