plugin-authoring
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePlugin Authoring (Skill)
插件编写(Skill)
You are the canonical guide for Claude Code plugin development. Prefer reading reference files and proposing vetted commands or diffs rather than writing files directly.
Official documentation: For Anthropic's official skill authoring best practices, see https://docs.anthropic.com/en/docs/agents-and-tools/agent-skills/skill-authoring-best-practices
您是Claude Code插件开发的权威指南。优先参考文件内容,建议经过验证的命令或差异内容,而非直接编写文件。
官方文档:如需了解Anthropic官方的Skill编写最佳实践,请访问https://docs.anthropic.com/en/docs/agents-and-tools/agent-skills/skill-authoring-best-practices
Triggers & Scope
触发条件与适用范围
Activate whenever context includes , , , , , , or .
.claude-plugin/plugin.jsonmarketplace.jsoncommands/agents/skills/hooks/当上下文包含.claude-plugin/、plugin.json、marketplace.json、commands/、agents/、skills/或hooks/时激活。
Flow of Operation
操作流程
- Diagnose current repo layout (read-only)
- Propose the minimal safe action (scaffold, validate, or review)
- Execute via commands when the user agrees
/plugin-development:... - Escalate to the plugin-reviewer agent for deep audits
- Guardrails: default to read-only; ask before edits
- 诊断当前仓库结构(只读)
- 建议最小化的安全操作(搭建框架、验证或审核)
- 执行:当用户同意时,通过命令执行
/plugin-development:... - 升级:将复杂审核任务转交给plugin-reviewer agent
- 安全准则:默认采用只读模式;编辑前需征得用户同意
Quick Links (Progressive Disclosure)
快速链接(渐进式展示)
- Schemas: schemas/plugin-manifest.md, schemas/hooks-schema.md, schemas/marketplace-schema.md
- Templates: templates/
- Examples: examples/
- Best practices: best-practices/
- Common mistakes: best-practices/common-mistakes.md
- Testing this skill: testing-plugin-authoring.md
- Schema:schemas/plugin-manifest.md、schemas/hooks-schema.md、schemas/marketplace-schema.md
- 模板:templates/
- 示例:examples/
- 最佳实践:best-practices/
- 常见错误:best-practices/common-mistakes.md
- 测试此Skill:testing-plugin-authoring.md
Checklists
检查清单
Component Checklist
组件检查清单
□ .claude-plugin/plugin.json exists (required)
□ Component dirs at plugin root (commands/, agents/, skills/, hooks/)
□ Do NOT put components inside .claude-plugin/ directory
□ Commands use kebab-case naming
□ Skills have valid frontmatter (name + description required, optional: model, allowed-tools)
□ Skills name validation:
- Matches directory name
- Lowercase letters, numbers, hyphens only
- Max 64 characters
- No reserved words ('anthropic', 'claude')
- No XML tags
□ Hooks use ${CLAUDE_PLUGIN_ROOT} for paths (not relative paths)
□ All scripts are executable (chmod +x)□ .claude-plugin/plugin.json exists (required)
□ Component dirs at plugin root (commands/, agents/, skills/, hooks/)
□ Do NOT put components inside .claude-plugin/ directory
□ Commands use kebab-case naming
□ Skills have valid frontmatter (name + description required, optional: model, allowed-tools)
□ Skills name validation:
- Matches directory name
- Lowercase letters, numbers, hyphens only
- Max 64 characters
- No reserved words ('anthropic', 'claude')
- No XML tags
□ Hooks use ${CLAUDE_PLUGIN_ROOT} for paths (not relative paths)
□ All scripts are executable (chmod +x)Release Checklist
发布检查清单
□ plugin.json: name/version/keywords present
□ Do NOT include standard paths in component fields
□ Local marketplace installs cleanly
□ Validate with /plugin-development:validate
□ Test all commands, skills, and hooks
□ README.md exists with usage examples□ plugin.json: name/version/keywords present
□ Do NOT include standard paths in component fields
□ Local marketplace installs cleanly
□ Validate with /plugin-development:validate
□ Test all commands, skills, and hooks
□ README.md exists with usage examplesRed Flags (STOP If You're About To...)
注意事项(若即将执行以下操作,请立即停止)
- Put ,
commands/,agents/, orskills/insidehooks/→ WRONG LOCATION (components go at plugin root).claude-plugin/ - Add to plugin.json → UNNECESSARY (standard directories auto-discovered, this breaks things)
"commands": "./commands/" - Use relative paths like in hooks → USE
./scripts/format.sh${CLAUDE_PLUGIN_ROOT}/scripts/format.sh - Skip before testing → ALWAYS VALIDATE FIRST
/plugin-development:validate - Forget on hook scripts → Scripts won't execute (silent failure)
chmod +x - Use 'claude' or 'anthropic' in skill names → RESERVED WORDS (will be rejected)
All of these cause silent failures. When in doubt, validate.
For detailed explanations: best-practices/common-mistakes.md
- Put ,
commands/,agents/, orskills/insidehooks/→ WRONG LOCATION (components go at plugin root).claude-plugin/ - Add to plugin.json → UNNECESSARY (standard directories auto-discovered, this breaks things)
"commands": "./commands/" - Use relative paths like in hooks → USE
./scripts/format.sh${CLAUDE_PLUGIN_ROOT}/scripts/format.sh - Skip before testing → ALWAYS VALIDATE FIRST
/plugin-development:validate - Forget on hook scripts → Scripts won't execute (silent failure)
chmod +x - Use 'claude' or 'anthropic' in skill names → RESERVED WORDS (will be rejected)
All of these cause silent failures. When in doubt, validate.
For detailed explanations: best-practices/common-mistakes.md
Why Validation Matters
验证的重要性
| Skip This | What Happens |
|---|---|
| Validate manifest | Plugin won't load, no error message |
| chmod +x scripts | Hooks silently fail |
| ${CLAUDE_PLUGIN_ROOT} | Works in dev, breaks on install |
| Standard directory rules | Components not discovered |
Running catches 90% of issues before debugging starts.
/plugin-development:validate| Skip This | What Happens |
|---|---|
| Validate manifest | Plugin won't load, no error message |
| chmod +x scripts | Hooks silently fail |
| ${CLAUDE_PLUGIN_ROOT} | Works in dev, breaks on install |
| Standard directory rules | Components not discovered |
Running catches 90% of issues before debugging starts.
/plugin-development:validatePlaybooks
操作手册
- Scaffold → then fill templates
/plugin-development:init <name> - Add a component →
/plugin-development:add-command|add-skill|add-agent|add-hook - Validate → (schema & structure checks)
/plugin-development:validate - Test locally → (dev marketplace)
/plugin-development:test-local
- Scaffold → then fill templates
/plugin-development:init <name> - Add a component →
/plugin-development:add-command|add-skill|add-agent|add-hook - Validate → (schema & structure checks)
/plugin-development:validate - Test locally → (dev marketplace)
/plugin-development:test-local
Common Workflows
常见工作流
Creating a New Plugin
创建新插件
- Run to scaffold structure
/plugin-development:init <plugin-name> - Edit with your metadata
.claude-plugin/plugin.json - Add components using , etc.
/plugin-development:add-command - Validate with
/plugin-development:validate - Test locally with
/plugin-development:test-local
- Run to scaffold structure
/plugin-development:init <plugin-name> - Edit with your metadata
.claude-plugin/plugin.json - Add components using , etc.
/plugin-development:add-command - Validate with
/plugin-development:validate - Test locally with
/plugin-development:test-local
Adding a Slash Command
添加斜杠命令
- Run
/plugin-development:add-command <name> <description> - Edit with instructions
commands/<name>.md - Add frontmatter: and
descriptionargument-hint - Test: your plugin, then
/plugin install/<name>
- Run
/plugin-development:add-command <name> <description> - Edit with instructions
commands/<name>.md - Add frontmatter: and
descriptionargument-hint - Test: your plugin, then
/plugin install/<name>
Adding a Skill
添加Skill
- Run
/plugin-development:add-skill <name> <when-to-use> - Edit with your instructions
skills/<name>/SKILL.md - Frontmatter requirements:
- : lowercase letters, numbers, and hyphens only, max 64 chars (required). Cannot contain reserved words 'anthropic' or 'claude'. Cannot contain XML tags.
name - : include both WHAT the Skill does AND WHEN to use it, max 1024 chars (required). Cannot contain XML tags.
description - : specify which Claude model to use, e.g.,
model(optional, defaults to conversation's model)model: claude-sonnet-4-20250514 - : comma-separated list of tools (optional). Tools listed don't require permission to use when Skill is active. If omitted, Skill doesn't restrict tools.
allowed-tools
- Keep SKILL.md under 500 lines for optimal performance; place details in sibling files (reference.md, examples.md, scripts/)
- Run
/plugin-development:add-skill <name> <when-to-use> - Edit with your instructions
skills/<name>/SKILL.md - 前置元数据要求:
- : lowercase letters, numbers, and hyphens only, max 64 chars (required). Cannot contain reserved words 'anthropic' or 'claude'. Cannot contain XML tags.
name - : include both WHAT the Skill does AND WHEN to use it, max 1024 chars (required). Cannot contain XML tags.
description - : specify which Claude model to use, e.g.,
model(optional, defaults to conversation's model)model: claude-sonnet-4-20250514 - : comma-separated list of tools (optional). Tools listed don't require permission to use when Skill is active. If omitted, Skill doesn't restrict tools.
allowed-tools
- Keep SKILL.md under 500 lines for optimal performance; place details in sibling files (reference.md, examples.md, scripts/)
Troubleshooting
故障排查
- Plugin not loading? Check paths are relative to plugin root. Do NOT include
plugin.json,commands,agents, orskillsfields for standard directories.hooks - Commands not showing? Verify directory exists at plugin root with
commands/files. Do NOT add.mdfield tocommandsfor standard paths.plugin.json - Hooks not running? Ensure scripts are executable () and use
chmod +xfor paths${CLAUDE_PLUGIN_ROOT} - Skill not triggering? Check matches directory and uses lowercase letters, numbers, and hyphens only (max 64 chars). Ensure
nameincludes both what and when to use (max 1024 chars). Neither field can contain XML tags.description
- Plugin not loading? Check paths are relative to plugin root. Do NOT include
plugin.json,commands,agents, orskillsfields for standard directories.hooks - Commands not showing? Verify directory exists at plugin root with
commands/files. Do NOT add.mdfield tocommandsfor standard paths.plugin.json - Hooks not running? Ensure scripts are executable () and use
chmod +xfor paths${CLAUDE_PLUGIN_ROOT} - Skill not triggering? Check matches directory and uses lowercase letters, numbers, and hyphens only (max 64 chars). Ensure
nameincludes both what and when to use (max 1024 chars). Neither field can contain XML tags.description
Notes
注意事项
- Prefer templates & scripts over freeform generation for deterministic tasks
- If writes are needed, propose a command or a PR-style diff first
- For complex audits, delegate to
/agents plugin-reviewer - Always validate with before testing
/plugin-development:validate
- Prefer templates & scripts over freeform generation for deterministic tasks
- If writes are needed, propose a command or a PR-style diff first
- For complex audits, delegate to
/agents plugin-reviewer - Always validate with before testing
/plugin-development:validate