skill-authoring
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAI Agent Skills Best Practices
AI Agent技能最佳实践
Design and development guide for AI agent skills, including Claude Code skills and MCP tools. Contains 46 rules across 8 categories, prioritized by impact to guide skill creation, review, and optimization.
Claude Code技能及MCP工具的AI Agent技能设计与开发指南。包含8个类别共46条规则,按影响优先级排序,用于指导技能的创建、评审与优化。
When to Apply
适用场景
- Creating new Claude Code skills or MCP tools
- Writing or reviewing SKILL.md metadata and descriptions
- Optimizing skill trigger reliability
- Structuring content for progressive disclosure
- Testing skill activation and behavior
- Designing tool interfaces for agent workflows
- 创建新的Claude Code技能或MCP工具
- 编写或评审SKILL.md元数据与描述
- 优化技能触发的可靠性
- 为渐进式披露构建内容结构
- 测试技能的激活与行为
- 为Agent工作流设计工具界面
Core Principles
核心原则
1. Descriptions drive activation. Claude selects skills based on description matching against user intent. Include specific capabilities, trigger keywords, and negative cases. A skill with a vague description activates inconsistently or never.
2. Front-load critical instructions. Claude may truncate long content. Place non-negotiable rules in the first 100 lines. Bury important constraints at the end and they get ignored.
3. Progressive disclosure saves tokens. Load detailed content only when needed. A 2000-line skill wastes context on every activation. Structure as: SKILL.md (overview) → references/ (details) → scripts/ (execution).
4. Test activation, not just execution. A skill that works perfectly but never triggers provides zero value. Test with real user phrases, synonyms, and edge cases before deployment.
5. One skill per domain. Overlapping skills create activation conflicts. Split by clear boundaries (language, framework, workflow stage) with distinct trigger keywords.
1. 描述驱动激活。Claude会根据描述与用户意图的匹配度选择技能。需包含具体能力、触发关键词及排除场景。描述模糊的技能激活效果不稳定或无法激活。
2. 前置关键指令。Claude可能会截断长内容。将不可协商的规则放在前100行。若重要约束放在末尾,会被忽略。
3. 渐进式披露节省令牌。仅在需要时加载详细内容。一个2000行的技能会在每次激活时浪费上下文。建议结构为:SKILL.md(概述)→ references/(详情)→ scripts/(执行代码)。
4. 测试激活而非仅执行。一个执行完美但从未触发的技能毫无价值。部署前需用真实用户语句、同义词及边缘案例进行测试。
5. 单一领域对应单一技能。重叠技能会导致激活冲突。需按清晰边界(语言、框架、工作流阶段)拆分,使用独特触发关键词。
Rule Categories
规则类别
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Skill Metadata Design | CRITICAL | |
| 2 | Description Engineering | CRITICAL | |
| 3 | Content Structure | HIGH | |
| 4 | Trigger Optimization | HIGH | |
| 5 | Progressive Disclosure | MEDIUM-HIGH | |
| 6 | MCP Tool Design | MEDIUM | |
| 7 | Testing and Validation | MEDIUM | |
| 8 | Maintenance and Distribution | LOW-MEDIUM | |
| 优先级 | 类别 | 影响程度 | 前缀 |
|---|---|---|---|
| 1 | 技能元数据设计 | 关键 | |
| 2 | 描述工程 | 关键 | |
| 3 | 内容结构 | 高 | |
| 4 | 触发优化 | 高 | |
| 5 | 渐进式披露 | 中高 | |
| 6 | MCP工具设计 | 中 | |
| 7 | 测试与验证 | 中 | |
| 8 | 维护与分发 | 中低 | |
Quick Reference
快速参考
1. Skill Metadata Design (CRITICAL)
1. 技能元数据设计(关键)
- - Use lowercase hyphenated skill names
meta-name-format - - Never start or end names with hyphens
meta-name-hyphen-boundaries - - Avoid consecutive hyphens in names
meta-name-no-consecutive-hyphens - - Ensure skill names are globally unique
meta-name-uniqueness - - Include all required frontmatter fields
meta-required-frontmatter - - Use only allowed frontmatter fields
meta-allowed-frontmatter-fields - - Use valid YAML frontmatter syntax
meta-frontmatter-yaml-syntax - - Keep skill names under 64 characters
meta-name-length - - Match skill name to directory name
meta-directory-match
- - 使用小写连字符分隔的技能名称
meta-name-format - - 技能名称首尾不能使用连字符
meta-name-hyphen-boundaries - - 避免技能名称中出现连续连字符
meta-name-no-consecutive-hyphens - - 确保技能名称全局唯一
meta-name-uniqueness - - 包含所有必填的前置元数据字段
meta-required-frontmatter - - 仅使用允许的前置元数据字段
meta-allowed-frontmatter-fields - - 使用有效的YAML前置元数据语法
meta-frontmatter-yaml-syntax - - 技能名称长度保持在64字符以内
meta-name-length - - 技能名称需与目录名称匹配
meta-directory-match
2. Description Engineering (CRITICAL)
2. 描述工程(关键)
- - Name specific capabilities in description
desc-specific-capabilities - - Include user trigger keywords in description
desc-trigger-keywords - - Write descriptions in third person
desc-third-person-voice - - Optimize description length for discovery
desc-length-optimization - - Avoid vague terms in descriptions
desc-avoid-vague-terms - - Differentiate similar skills with distinct triggers
desc-differentiate-similar-skills - - Include negative cases for precision
desc-include-negative-cases
- - 在描述中明确列出具体能力
desc-specific-capabilities - - 在描述中包含用户触发关键词
desc-trigger-keywords - - 使用第三人称撰写描述
desc-third-person-voice - - 优化描述长度以提升可发现性
desc-length-optimization - - 描述中避免使用模糊术语
desc-avoid-vague-terms - - 通过独特触发词区分相似技能
desc-differentiate-similar-skills - - 包含排除场景以提高精准度
desc-include-negative-cases
3. Content Structure (HIGH)
3. 内容结构(高)
- - Use consistent header hierarchy
struct-header-hierarchy - - Put critical instructions early in content
struct-instructions-first - - Write instructions in imperative mood
struct-imperative-instructions - - Specify language in code blocks
struct-code-blocks-with-language - - Keep SKILL.md under 500 lines
struct-line-limit - - One skill per domain
struct-single-responsibility
- - 使用一致的标题层级
struct-header-hierarchy - - 将关键指令放在内容前部
struct-instructions-first - - 使用祈使语气撰写指令
struct-imperative-instructions - - 在代码块中指定语言
struct-code-blocks-with-language - - SKILL.md文件行数保持在500行以内
struct-line-limit - - 单一技能对应单一领域
struct-single-responsibility
4. Trigger Optimization (HIGH)
4. 触发优化(高)
- - Include slash command aliases in description
trigger-slash-command-aliases - - Include file type patterns in description
trigger-file-type-patterns - - Reference workflow stages in description
trigger-workflow-stages - - Include error patterns in debugging skills
trigger-error-patterns - - Cover synonyms and alternate phrasings
trigger-synonym-coverage
- - 在描述中包含斜杠命令别名
trigger-slash-command-aliases - - 在描述中包含文件类型模式
trigger-file-type-patterns - - 在描述中提及工作流阶段
trigger-workflow-stages - - 在调试技能中包含错误模式
trigger-error-patterns - - 覆盖同义词及替代表述
trigger-synonym-coverage
5. Progressive Disclosure (MEDIUM-HIGH)
5. 渐进式披露(中高)
- - Implement three-level progressive disclosure
prog-three-level-disclosure - - Limit reference links to one level deep
prog-one-level-deep-links - - Execute scripts instead of reading code
prog-scripts-execute-not-read - - Lazy load examples and reference material
prog-lazy-load-examples - - Separate mutually exclusive contexts
prog-mutual-exclusion
- - 实现三级渐进式披露
prog-three-level-disclosure - - 限制参考链接深度为一级
prog-one-level-deep-links - - 执行脚本而非读取代码
prog-scripts-execute-not-read - - 延迟加载示例及参考资料
prog-lazy-load-examples - - 分离互斥上下文
prog-mutual-exclusion
6. MCP Tool Design (MEDIUM)
6. MCP工具设计(中)
- - Use clear action-object tool names
mcp-tool-naming - - Document all tool parameters
mcp-parameter-descriptions - - Return actionable error messages
mcp-error-messages - - Design single-purpose tools
mcp-tool-scope - - Use allowed-tools for safety constraints
mcp-allowed-tools - - Design idempotent tool operations
mcp-idempotent-operations
- - 使用清晰的“动作-对象”式工具名称
mcp-tool-naming - - 记录所有工具参数
mcp-parameter-descriptions - - 返回可执行的错误信息
mcp-error-messages - - 设计单一用途的工具
mcp-tool-scope - - 使用allowed-tools设置安全约束
mcp-allowed-tools - - 设计幂等操作的工具
mcp-idempotent-operations
7. Testing and Validation (MEDIUM)
7. 测试与验证(中)
- - Test skill activation with real user phrases
test-trigger-phrases - - Test skills with edge case inputs
test-edge-cases - - Test that skills do NOT trigger on unrelated requests
test-negative-scenarios - - Test instructions with fresh context
test-instruction-clarity
- - 使用真实用户语句测试技能激活
test-trigger-phrases - - 使用边缘案例输入测试技能
test-edge-cases - - 测试技能在无关请求下不触发
test-negative-scenarios - - 在全新上下文下测试指令清晰度
test-instruction-clarity
8. Maintenance and Distribution (LOW-MEDIUM)
8. 维护与分发(中低)
- - Use semantic versioning for skill releases
maint-semantic-versioning - - Maintain a changelog for skill updates
maint-changelog - - Package skills as plugins for distribution
maint-plugin-packaging - - Audit skills before installing from external sources
maint-audit-security
- - 为技能版本使用语义化版本控制
maint-semantic-versioning - - 维护技能更新的变更日志
maint-changelog - - 将技能打包为插件进行分发
maint-plugin-packaging - - 安装外部来源的技能前进行安全审计
maint-audit-security
Creating Rules
创建规则
Copy assets/templates/_template.md and follow the frontmatter schema:
yaml
---
title: Rule Title Here
impact: CRITICAL|HIGH|MEDIUM-HIGH|MEDIUM|LOW-MEDIUM|LOW
impactDescription: Quantified impact (e.g., "2-10x improvement")
tags: prefix, technique, related-concepts
---Reference files use the pattern:
references/{prefix}-{slug}.md复制assets/templates/_template.md并遵循前置元数据 schema:
yaml
---
title: Rule Title Here
impact: CRITICAL|HIGH|MEDIUM-HIGH|MEDIUM|LOW-MEDIUM|LOW
impactDescription: Quantified impact (e.g., "2-10x improvement")
tags: prefix, technique, related-concepts
---参考文件使用以下命名模式:
references/{prefix}-{slug}.md