Loading...
Loading...
Compare original and translation side by side
.claude/file:///~/.claude/plugins/.claude/plugins/.claude/file:///~/.claude/plugins/.claude/plugins/my-plugin/.claude-plugin/plugin.json{
"name": "my-plugin"
}/plugin install file:///absolute/path/to/my-plugin/plugin reloadmy-plugin/.claude-plugin/plugin.json{
"name": "my-plugin"
}/plugin install file:///absolute/path/to/my-plugin/plugin reloadmy-plugin/
�� .claude-plugin/
�� plugin.json # Required: plugin manifest
�� commands/ # Optional: slash commands
�� my-command.md
�� agents/ # Optional: specialized subagents
�� my-agent.md
�� skills/ # Optional: reusable techniques
�� my-skill/
�� SKILL.md
�� hooks/ # Optional: event handlers
�� hooks.json
�� .mcp.json # Optional: MCP server configs
�� README.md # Recommended: documentation.claude-plugin/plugin.jsonmy-plugin/
�� .claude-plugin/
�� plugin.json # 必填:插件清单
�� commands/ # 可选:斜杠命令
�� my-command.md
�� agents/ # 可选:专用子代理
�� my-agent.md
�� skills/ # 可选:可复用技术
�� my-skill/
�� SKILL.md
�� hooks/ # 可选:事件处理器
�� hooks.json
�� .mcp.json # 可选:MCP服务器配置
�� README.md # 推荐:文档plugin.json.claude-plugin/| Component | Location | File Format | When to Use |
|---|---|---|---|
| Commands | | Markdown + YAML frontmatter | Custom slash commands for repetitive tasks |
| Agents | | Markdown + YAML frontmatter | Specialized subagents for complex workflows |
| Skills | | Markdown + YAML frontmatter | Reusable techniques and patterns |
| Hooks | | JSON | Event handlers (format code, validate, etc.) |
| MCP Servers | | JSON | External tool integrations |
| 组件 | 位置 | 文件格式 | 使用场景 |
|---|---|---|---|
| Commands | | Markdown + YAML前置元数据 | 用于重复任务的自定义斜杠命令 |
| Agents | | Markdown + YAML前置元数据 | 用于复杂工作流的专用子代理 |
| Skills | | Markdown + YAML前置元数据 | 可复用技术和模式 |
| Hooks | | JSON | 事件处理器(格式化代码、验证等) |
| MCP服务器 | | JSON | 外部工具集成 |
{
"name": "my-plugin"
}{
"name": "my-plugin", // Required: kebab-case identifier
"version": "1.0.0", // Recommended: semantic versioning
"description": "What this plugin does", // Recommended: brief description
"author": { // Optional but recommended
"name": "Your Name",
"email": "you@example.com",
"url": "https://github.com/yourname"
},
"homepage": "https://github.com/yourname/my-plugin",
"repository": "https://github.com/yourname/my-plugin",
"license": "MIT",
"keywords": ["productivity", "automation"],
"commands": [ // Optional: explicit command paths
"./commands/cmd1.md",
"./commands/cmd2.md"
],
"agents": [ // Optional: explicit agent paths
"./agents/agent1.md"
],
"hooks": [ // Optional: inline hooks
{
"event": "PostToolUse",
"matcher": "Edit|Write",
"command": "npx prettier --write \"$CLAUDE_FILE_PATHS\""
}
],
"mcpServers": { // Optional: inline MCP configs
"my-server": {
"command": "${CLAUDE_PLUGIN_ROOT}/servers/my-server",
"args": ["--port", "8080"],
"env": {
"API_KEY": "${API_KEY}"
}
}
}
}name${CLAUDE_PLUGIN_ROOT}commands/agents/skills/*/SKILL.md{
"name": "my-plugin"
}{
"name": "my-plugin", // 必填:短横线命名标识符
"version": "1.0.0", // 推荐:语义化版本
"description": "What this plugin does", // 推荐:简短描述
"author": { // 可选但推荐
"name": "Your Name",
"email": "you@example.com",
"url": "https://github.com/yourname"
},
"homepage": "https://github.com/yourname/my-plugin",
"repository": "https://github.com/yourname/my-plugin",
"license": "MIT",
"keywords": ["productivity", "automation"],
"commands": [ // 可选:显式命令路径
"./commands/cmd1.md",
"./commands/cmd2.md"
],
"agents": [ // 可选:显式代理路径
"./agents/agent1.md"
],
"hooks": [ // 可选:内联钩子
{
"event": "PostToolUse",
"matcher": "Edit|Write",
"command": "npx prettier --write \"$CLAUDE_FILE_PATHS\""
}
],
"mcpServers": { // 可选:内联MCP配置
"my-server": {
"command": "${CLAUDE_PLUGIN_ROOT}/servers/my-server",
"args": ["--port", "8080"],
"env": {
"API_KEY": "${API_KEY}"
}
}
}
}name${CLAUDE_PLUGIN_ROOT}commands/agents/skills/*/SKILL.mdcommands/my-command.md/my-commandcommands/feature/sub-command.md/plugin-name:feature:sub-command---
description: Brief description of what this command does
allowed-tools: Read, Grep, Glob, Bash
model: sonnet
argument-hint: "[file-path]"
---commands/my-command.md/my-commandcommands/feature/sub-command.md/plugin-name:feature:sub-command---
description: Brief description of what this command does
allowed-tools: Read, Grep, Glob, Bash
model: sonnet
argument-hint: "[file-path]"
---
**Frontmatter fields:**
- `description` - Brief description shown in `/help`
- `allowed-tools` - Comma-separated list: `Read, Grep, Glob, Bash, Edit, Write, TodoWrite, Task`
- `model` - Optional: `haiku`, `sonnet`, or `opus` (defaults to user's setting)
- `argument-hint` - Optional: shown in help text
- `disable-model-invocation` - Optional: `true` to prevent auto-run
**Complete example** (`commands/review-pr.md`):
```markdown
---
description: Review pull request for security and best practices
allowed-tools: Read, Grep, Glob, Bash
model: opus
argument-hint: "[pr-number]"
---
**前置元数据字段:**
- `description` - 简短描述,显示在`/help`中
- `allowed-tools` - 逗号分隔列表:`Read, Grep, Glob, Bash, Edit, Write, TodoWrite, Task`
- `model` - 可选:`haiku`, `sonnet`, 或`opus`(默认使用用户设置)
- `argument-hint` - 可选:显示在帮助文本中
- `disable-model-invocation` - 可选:设为`true`可阻止自动运行
**完整示例** (`commands/review-pr.md`):
```markdown
---
description: Review pull request for security and best practices
allowed-tools: Read, Grep, Glob, Bash
model: opus
argument-hint: "[pr-number]"
---undefinedundefinedagents/code-reviewer.md---
name: agent-name
description: When and why to use this agent (critical for auto-delegation)
tools: Read, Edit, Write, Grep, Glob, Bash
model: opus
---agents/code-reviewer.md---
name: agent-name
description: When and why to use this agent (critical for auto-delegation)
tools: Read, Edit, Write, Grep, Glob, Bash
model: opus
---
**Frontmatter fields:**
- `name` - Required: kebab-case identifier
- `description` - Required: Max 1024 chars, used for auto-delegation
- `tools` - Comma-separated list of allowed tools
- `model` - Optional: `haiku`, `sonnet`, or `opus`
**Complete example** (`agents/security-auditor.md`):
```markdown
---
name: security-auditor
description: Use when reviewing code for security vulnerabilities, analyzing authentication flows, or checking for common security anti-patterns like SQL injection, XSS, or insecure dependencies
tools: Read, Grep, Glob, Bash
model: opus
---
**前置元数据字段:**
- `name` - 必填:短横线命名标识符
- `description` - 必填:最多1024字符,用于自动委托
- `tools` - 逗号分隔的允许工具列表
- `model` - 可选:`haiku`, `sonnet`, 或`opus`
**完整示例** (`agents/security-auditor.md`):
```markdown
---
name: security-auditor
description: Use when reviewing code for security vulnerabilities, analyzing authentication flows, or checking for common security anti-patterns like SQL injection, XSS, or insecure dependencies
tools: Read, Grep, Glob, Bash
model: opus
---file:lineundefinedfile:lineundefinedwriting-skillsskills/my-skill/SKILL.md---
name: my-skill-name
description: Use when [specific triggers] - [what it does]
---writing-skillsskills/my-skill/SKILL.md---
name: my-skill-name
description: Use when [specific triggers] - [what it does]
---
**Key principles:**
- `name` uses only letters, numbers, hyphens (no special chars)
- `description` starts with "Use when..." in third person
- Keep token-efficient (<500 words if frequently loaded)
- One excellent example beats many mediocre ones
- Use `writing-skills` skill for complete guidance
**关键原则:**
- `name`仅使用字母、数字、短横线(无特殊字符)
- `description`以"Use when..."开头,使用第三人称
- 保持token高效(如果频繁加载,控制在500词以内)
- 一个优秀的示例胜过多个平庸的示例
- 使用`writing-skills`技能获取完整指导hooks/hooks.jsonplugin.json{
"hooks": [
{
"event": "PreToolUse",
"matcher": "Bash",
"command": "echo 'About to run: $CLAUDE_TOOL_NAME'"
},
{
"event": "PostToolUse",
"matcher": "Edit|Write",
"command": "npx prettier --write \"$CLAUDE_FILE_PATHS\""
},
{
"event": "SessionStart",
"matcher": "*",
"command": "${CLAUDE_PLUGIN_ROOT}/scripts/setup.sh"
}
]
}PreToolUsePostToolUseUserPromptSubmitStopSessionStartSessionEndNotificationSubagentStopPreCompact"Bash""Edit|Write""*"$CLAUDE_EVENT_TYPE$CLAUDE_TOOL_NAME$CLAUDE_TOOL_INPUT$CLAUDE_FILE_PATHShooks/hooks.jsonplugin.json{
"hooks": [
{
"event": "PreToolUse",
"matcher": "Bash",
"command": "echo 'About to run: $CLAUDE_TOOL_NAME'"
},
{
"event": "PostToolUse",
"matcher": "Edit|Write",
"command": "npx prettier --write \"$CLAUDE_FILE_PATHS\""
},
{
"event": "SessionStart",
"matcher": "*",
"command": "${CLAUDE_PLUGIN_ROOT}/scripts/setup.sh"
}
]
}PreToolUsePostToolUseUserPromptSubmitStopSessionStartSessionEndNotificationSubagentStopPreCompact"Bash""Edit|Write""*"$CLAUDE_EVENT_TYPE$CLAUDE_TOOL_NAME$CLAUDE_TOOL_INPUT$CLAUDE_FILE_PATHS.mcp.jsonplugin.json{
"mcpServers": {
"database-tools": {
"command": "${CLAUDE_PLUGIN_ROOT}/servers/db-server",
"args": ["--config", "${CLAUDE_PLUGIN_ROOT}/config.json"],
"env": {
"DB_URL": "${DB_URL}",
"API_KEY": "${API_KEY:-default-key}"
}
},
"web-scraper": {
"command": "npx",
"args": ["web-mcp-server", "--port", "3000"]
}
}
}commandargsenv${VAR}${VAR:-default}${CLAUDE_PLUGIN_ROOT}.mcp.jsonplugin.json{
"mcpServers": {
"database-tools": {
"command": "${CLAUDE_PLUGIN_ROOT}/servers/db-server",
"args": ["--config", "${CLAUDE_PLUGIN_ROOT}/config.json"],
"env": {
"DB_URL": "${DB_URL}",
"API_KEY": "${API_KEY:-default-key}"
}
},
"web-scraper": {
"command": "npx",
"args": ["web-mcp-server", "--port", "3000"]
}
}
}commandargsenv${VAR}${VAR:-default}${CLAUDE_PLUGIN_ROOT}dev-marketplace/.claude-plugin/marketplace.json{
"$schema": "https://anthropic.com/claude-code/marketplace.schema.json",
"name": "my-dev-marketplace",
"version": "1.0.0",
"owner": {
"name": "Your Name",
"email": "you@example.com"
},
"metadata": {
"description": "Local development marketplace for my plugins",
"pluginRoot": "./plugins"
},
"plugins": [
{
"name": "my-plugin-one",
"version": "1.0.0",
"description": "What this plugin does",
"source": "./plugins/my-plugin-one",
"category": "development",
"author": {
"name": "Your Name",
"email": "you@example.com"
}
},
{
"name": "my-plugin-two",
"version": "0.1.0",
"description": "Experimental plugin",
"source": "./plugins/my-plugin-two",
"category": "productivity",
"strict": false
}
]
}dev-marketplace/
�� .claude-plugin/
�� marketplace.json
�� plugins/
�� my-plugin-one/
�� .claude-plugin/
�� plugin.json
�� commands/
�� my-plugin-two/
�� .claude-plugin/
�� plugin.json
�� agents//plugin marketplace add file:///absolute/path/to/dev-marketplace
/plugin browse
/plugin install my-plugin-one@my-dev-marketplacenamesourceversiondescriptioncategoryauthorstricttruefalse// Local relative path
"source": "./plugins/my-plugin"
// GitHub repository
"source": {
"source": "github",
"repo": "owner/repo"
}
// Git URL
"source": {
"source": "url",
"url": "https://gitlab.com/team/plugin.git"
}dev-marketplace/.claude-plugin/marketplace.json{
"$schema": "https://anthropic.com/claude-code/marketplace.schema.json",
"name": "my-dev-marketplace",
"version": "1.0.0",
"owner": {
"name": "Your Name",
"email": "you@example.com"
},
"metadata": {
"description": "Local development marketplace for my plugins",
"pluginRoot": "./plugins"
},
"plugins": [
{
"name": "my-plugin-one",
"version": "1.0.0",
"description": "What this plugin does",
"source": "./plugins/my-plugin-one",
"category": "development",
"author": {
"name": "Your Name",
"email": "you@example.com"
}
},
{
"name": "my-plugin-two",
"version": "0.1.0",
"description": "Experimental plugin",
"source": "./plugins/my-plugin-two",
"category": "productivity",
"strict": false
}
]
}dev-marketplace/
�� .claude-plugin/
�� marketplace.json
�� plugins/
�� my-plugin-one/
�� .claude-plugin/
�� plugin.json
�� commands/
�� my-plugin-two/
�� .claude-plugin/
�� plugin.json
�� agents//plugin marketplace add file:///absolute/path/to/dev-marketplace
/plugin browse
/plugin install my-plugin-one@my-dev-marketplacenamesourceversiondescriptioncategoryauthorstricttruefalse// 本地相对路径
"source": "./plugins/my-plugin"
// GitHub仓库
"source": {
"source": "github",
"repo": "owner/repo"
}
// Git URL
"source": {
"source": "url",
"url": "https://gitlab.com/team/plugin.git"
}my-awesome-pluginreview-codesecurity-auditortest-driven-developmentcommands/my-command.md/my-commandcommands/project/build.md/plugin-name:project:buildagents/code-reviewer.mdcode-reviewerskills/my-skill/SKILL.mdmy-skillmy-awesome-pluginreview-codesecurity-auditortest-driven-developmentcommands/my-command.md/my-commandcommands/project/build.md/plugin-name:project:buildagents/code-reviewer.mdcode-reviewerskills/my-skill/SKILL.mdmy-skillmkdir -p my-plugin/.claude-plugin
echo '{"name":"my-plugin"}' > my-plugin/.claude-plugin/plugin.json/plugin install file:///absolute/path/to/my-plugin/my-command arg1 arg2
# Use Task tool with your agent
# Use Skill tool with your skill/plugin reload/plugin marketplace add file:///absolute/path/to/dev-marketplace/plugin browse
/plugin install my-plugin@my-dev-marketplacemkdir -p my-plugin/.claude-plugin
echo '{"name":"my-plugin"}' > my-plugin/.claude-plugin/plugin.json/plugin install file:///absolute/path/to/my-plugin/my-command arg1 arg2
# 使用Task工具调用你的代理
# 使用Skill工具调用你的技能/plugin reload/plugin marketplace add file:///absolute/path/to/dev-marketplace/plugin browse
/plugin install my-plugin@my-dev-marketplace| Issue | Symptom | Fix |
|---|---|---|
Missing | Plugin not recognized | Create |
| Invalid plugin.json | Parse error on load | Validate JSON syntax, ensure |
| Wrong tool name | Tool not available in command/agent | Check spelling: |
| Description too long | Warning or truncation | Keep under 1024 characters total |
| Not using third person | Description sounds wrong | Use "Use when..." not "I will..." |
| Absolute paths in plugin.json | Breaks on other machines | Use relative paths or |
Forgetting | Changes not visible | Run |
| Command not found | Slash command doesn't work | Check filename matches expected command, reload plugin |
| Agent not auto-delegated | Agent never gets used | Improve |
| 问题 | 症状 | 修复方案 |
|---|---|---|
缺少 | 插件不被识别 | 在根目录创建 |
| 无效的plugin.json | 加载时解析错误 | 验证JSON语法,确保 |
| 错误的工具名称 | 命令/代理中工具不可用 | 检查拼写: |
| 描述过长 | 警告或截断 | 总长度保持在1024字符以内 |
| 未使用第三人称 | 描述语气错误 | 使用"Use when..."而非"I will..." |
| plugin.json中使用绝对路径 | 在其他机器上无法运行 | 使用相对路径或 |
忘记运行 | 修改不生效 | 编辑后运行 |
| 命令未找到 | 斜杠命令无法工作 | 检查文件名是否与预期命令匹配,重新加载插件 |
| 代理未自动委托 | 代理从未被使用 | 优化 |
/plugin marketplace add user-or-org/marketplace-repo
/plugin install plugin-name@marketplace-name/plugin marketplace add user-or-org/marketplace-repo
/plugin install plugin-name@marketplace-name