Communitygithub.com

SamuelChien/mega-skills-collection

此技能應在使用者要求「建立代理」、「新增代理」、「編寫子代理」、「代理 frontmatter」、「何時使用 description」、「代理範例」、「代理工具」、「代理顏色」、「自主代理」,或針對 Claude Code 外掛程式的代理結構、系統提示、觸發條件與代理開發最佳實務提供指引時使用。

mega-skills-collection 是什麼?

此技能提供 Claude Code 外掛程式中代理(Agent)開發的完整指南,涵蓋從結構定義、觸發條件設計到系統提示撰寫等所有面向。它能幫助開發者建立自主、具備多步驟處理能力的子進程,並確保代理在正確的情境下被觸發。此技能是「mega-skills-collection」的一部分,支援 Claude Code 平台,並詳細說明了 YAML frontmatter 中 name、description、model、color 及 tools 等必填與選填欄位的規範與最佳實務。此外,它也提供 AI 輔助生成與手動建立兩種代理建立方法,並包含驗證規則與測試流程,是開發高效、可靠 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) 是能獨立處理複雜多步驟任務的自主子進程。理解代理結構、觸發條件與系統提示設計,有助於打造強大的自主功能。

關鍵概念:

  • 代理是「為了」自主工作,指令則是「為了」使用者啟動的操作
  • 採用含有 YAML frontmatter 的 Markdown 檔案格式
  • 透過 description 欄位與範例觸發
  • 系統提示定義代理行為
  • 可自訂模型與顏色

代理檔案結構

完整格式

---
name: agent-identifier
description: 當 [觸發條件] 時使用此代理。範例:

<example>
Context: [情境描述]
user: "[使用者請求]"
assistant: "[助手應如何回應並使用此代理]"
<commentary>
[為何應觸發此代理]
</commentary>
</example>

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

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

您是 [代理角色描述]...

**您的核心職責:**
1. [職責 1]
2. [職責 2]

**分析流程:**
[逐步工作流程]

**輸出格式:**
[應回傳的內容]

Frontmatter 欄位

name (必填)

用於命名空間與呼叫的代理識別碼。

格式: 僅限小寫字母、數字與連字號 長度: 3-50 個字元 規則: 必須以英數字元開頭與結尾

良好範例:

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

不良範例:

  • helper (過於通用)
  • -agent- (以連字號開頭/結尾)
  • my_agent (不允許底線)
  • ag (太短,少於 3 個字元)

description (必填)

定義 Claude 何時應觸發此代理。這是最關鍵的欄位。

必須包含:

  1. 觸發條件 (「當...時使用此代理」)
  2. 展示使用方式的多個 <example> 區塊
  3. 每個範例中的 Context、user 要求與 assistant 回應
  4. 解釋為何觸發代理的 <commentary>

格式:

當 [條件] 時使用此代理。範例:

<example>
Context: [情境描述]
user: "[使用者說的話]"
assistant: "[Claude 應如何回應]"
<commentary>
[為何此代理是合適的]
</commentary>
</example>

[更多範例...]

最佳實務:

  • 包含 2-4 個具體範例
  • 展示主動與被動觸發
  • 涵蓋相同意圖的不同措辭
  • 在 commentary 中解釋理由
  • 明確說明何時「不」使用此代理

model (必填)

代理應使用的模型。

選項:

  • inherit - 使用與父層相同的模型 (建議)
  • sonnet - Claude Sonnet (平衡)
  • opus - Claude Opus (功能最強,成本最高)
  • haiku - Claude Haiku (快速,便宜)

建議: 除非代理需要特定模型功能,否則使用 inherit。

color (必填)

代理在使用者介面中的視覺識別色。

選項: blue, cyan, green, yellow, magenta, red

指南:

  • 同一外掛程式的不同代理應選擇不同的顏色
  • 對類似類型的代理使用一致的顏色
  • 藍色/青色:分析、審查
  • 綠色:成功導向任務
  • 黃色:謹慎、驗證
  • 紅色:關鍵、安全
  • 洋紅色:創意、產生

tools (選填)

限制代理使用的特定工具。

格式: 工具名稱陣列

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

預設值: 若省略,代理有權使用所有工具

最佳實務: 將工具限制在最小必要範圍 (最小權限原則)

常用工具組合:

  • 唯讀分析:["Read", "Grep", "Glob"]
  • 程式碼產生:["Read", "Write", "Grep"]
  • 測試:["Read", "Bash", "Grep"]
  • 完全存取:省略此欄位或使用 ["*"]

系統提示設計

Markdown 主體會成為代理的系統提示。請使用第二人稱,直接對代理說話。

結構

標準範本:

您是專精於 [領域] 的 [角色]。

**您的核心職責:**
1. [主要職責]
2. [次要職責]
3. [其他職責...]

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

**品質標準:**
- [標準 1]
- [標準 2]

**輸出格式:**
請依以下格式提供結果:
- [應包含的內容]
- [如何結構化]

**邊界案例:**
處理以下情況:
- [邊界案例 1]:[如何處理]
- [邊界案例 2]:[如何處理]

最佳實務

✅ 請務必:

  • 使用第二人稱書寫 (「您是...」、「您將...」)
  • 具體說明職責
  • 提供逐步流程
  • 定義輸出格式
  • 包含品質標準
  • 處理邊界案例
  • 保持在 10,000 字元以內

❌ 請勿:

  • 使用第一人稱書寫 (「我是...」、「我將...」)
  • 模糊或通用
  • 省略流程步驟
  • 未定義輸出格式
  • 跳過品質指引
  • 忽略錯誤案例

建立代理

方法 1:AI 輔助產生

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

根據此要求建立代理設定:「[您的描述]」

需求:
1. 萃取核心意圖與職責
2. 針對該領域設計專家角色
3. 建立全面的系統提示,包含:
   - 明確的行為邊界
   - 特定方法論
   - 邊界案例處理
   - 輸出格式
4. 建立識別碼 (小寫、連字號、3-50 個字元)
5. 撰寫包含觸發條件的 description
6. 加入 2-3 個顯示何時使用的 <example> 區塊

回傳 JSON,格式為:
{
  "identifier": "agent-name",
  "whenToUse": "當...時使用此代理。範例:<example>...</example>",
  "systemPrompt": "您是..."
}

然後將其轉換為含 frontmatter 的代理檔案格式。

完整範本請參閱 examples/agent-creation-prompt.md。

方法 2:手動建立

  1. 選擇代理識別碼 (3-50 個字元,小寫,連字號)
  2. 撰寫包含範例的 description
  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 字元 結構: 明確的職責、流程、輸出格式

代理組織

外掛程式代理目錄

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

agents/ 中的所有 .md 檔案都會被自動發現。

命名空間

代理會自動被命名空間化:

  • 單一外掛程式:agent-name
  • 包含子目錄:plugin:subdir:agent-name

測試代理

測試觸發

建立測試情境以驗證代理正確觸發:

  1. 撰寫包含特定觸發範例的代理
  2. 在測試中使用與範例相似的措辭
  3. 檢查 Claude 是否載入代理
  4. 驗證代理提供預期功能

測試系統提示

確保系統提示完整:

  1. 給予代理典型任務
  2. 檢查是否遵循流程步驟
  3. 驗證輸出格式是否正確
  4. 測試提示中提及的邊界案例
  5. 確認滿足品質標準

快速參考

最小代理

---
name: simple-agent
description: 當...時使用此代理。範例:<example>...</example>
model: inherit
color: blue
---

您是執行 [X 任務] 的代理。

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

輸出:[應提供的內容]

Frontmatter 欄位摘要

欄位必填格式範例
name是lowercase-hyphenscode-reviewer
description是文字 + 範例當...時使用 ...
model是inherit/sonnet/opus/haikuinherit
color是顏色名稱blue
tools否工具名稱陣列["Read", "Grep"]

最佳實務

請務必:

  • ✅ 在 description 中包含 2-4 個具體範例
  • ✅ 撰寫特定的觸發條件
  • ✅ 除非有特定需求,否則對 model 使用 inherit
  • ✅ 選擇合適的工具 (最小權限)
  • ✅ 撰寫清晰、結構化的系統提示
  • ✅ 徹底測試代理觸發

請勿:

  • ❌ 使用不包含範例的通用描述
  • ❌ 省略觸發條件
  • ❌ 給予所有代理相同顏色
  • ❌ 授權不必要的工具存取
  • ❌ 撰寫模糊的系統提示
  • ❌ 跳過測試

其他資源

參考檔案

如需詳細指引,請諮詢:

  • references/system-prompt-design.md - 完整的系統提示模式
  • references/triggering-examples.md - 範例格式與最佳實務
  • references/agent-creation-system-prompt.md - Claude Code 的確切提示

範例檔案

examples/ 中的實作範例:

  • agent-creation-prompt.md - AI 輔助代理產生範本
  • complete-agent-examples.md - 不同使用案例的完整代理範例

公用腳本

scripts/ 中的開發工具:

  • validate-agent.sh - 驗證代理檔案結構
  • test-agent-trigger.sh - 測試代理是否正確觸發

實作工作流程

若要為外掛程式建立代理:

  1. 定義代理目的與觸發條件
  2. 選擇建立方法 (AI 輔助或手動)
  3. 建立 agents/agent-name.md 檔案
  4. 撰寫包含所有必填欄位的 frontmatter
  5. 遵循最佳實務撰寫系統提示
  6. 在 description 中包含 2-4 個觸發範例
  7. 使用 scripts/validate-agent.sh 進行驗證
  8. 使用真實情境測試觸發
  9. 在外掛程式 README 中記錄代理

專注於清晰的觸發條件與全面的系統提示,以實現自主操作。

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".

相關技能