create-cowork-plugin

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Create Cowork Plugin

创建Cowork插件

Build a new plugin from scratch through guided conversation. Walk the user through discovery, planning, design, implementation, and packaging — delivering a ready-to-install
.plugin
file at the end.
通过引导式对话从零开始构建新插件。引导用户完成探索、规划、设计、实现和打包的全流程,最终交付一个可直接安装的
.plugin
文件。

Overview

概述

A plugin is a self-contained directory that extends Claude's capabilities with commands, skills, agents, hooks, and MCP server integrations. This skill encodes the full plugin architecture and a five-phase workflow for creating one conversationally.
The process:
  1. Discovery — understand what the user wants to build
  2. Component Planning — determine which component types are needed
  3. Design & Clarifying Questions — specify each component in detail
  4. Implementation — create all plugin files
  5. Review & Package — deliver the
    .plugin
    file
Nontechnical output: Keep all user-facing conversation in plain language. Do not expose implementation details like file paths, directory structures, or schema fields unless the user asks. Frame everything in terms of what the plugin will do.
插件是一个独立的目录,通过命令、技能、Agent、钩子和MCP服务器集成来扩展Claude的功能。本技能包含完整的插件架构,以及一个通过对话创建插件的五阶段工作流。
流程如下:
  1. 探索阶段 — 理解用户想要构建的内容
  2. 组件规划阶段 — 确定所需的组件类型
  3. 设计与答疑阶段 — 详细定义每个组件
  4. 实现阶段 — 创建所有插件文件
  5. 审核与打包阶段 — 交付
    .plugin
    文件
非技术输出要求:所有面向用户的对话需使用通俗易懂的语言。除非用户主动询问,否则不要暴露文件路径、目录结构或 Schema 字段等实现细节。所有内容都要围绕插件能实现的功能来表述。

Plugin Architecture

插件架构

Directory Structure

目录结构

Every plugin follows this layout:
plugin-name/
├── .claude-plugin/
│   └── plugin.json           # Required: plugin manifest
├── commands/                 # Slash commands (.md files)
├── agents/                   # Subagent definitions (.md files)
├── skills/                   # Skills (subdirectories with SKILL.md)
│   └── skill-name/
│       ├── SKILL.md
│       └── references/
├── .mcp.json                 # MCP server definitions
└── README.md                 # Plugin documentation
Rules:
  • .claude-plugin/plugin.json
    is always required
  • Component directories (
    commands/
    ,
    agents/
    ,
    skills/
    ) go at the plugin root, not inside
    .claude-plugin/
  • Only create directories for components the plugin actually uses
  • Use kebab-case for all directory and file names
每个插件都遵循以下布局:
plugin-name/
├── .claude-plugin/
│   └── plugin.json           # 必填:插件清单
├── commands/                 # 斜杠命令(.md文件)
├── agents/                   # 子Agent定义(.md文件)
├── skills/                   # 技能(包含SKILL.md的子目录)
│   └── skill-name/
│       ├── SKILL.md
│       └── references/
├── .mcp.json                 # MCP服务器定义
└── README.md                 # 插件文档
规则:
  • .claude-plugin/plugin.json
    始终为必填项
  • 组件目录(
    commands/
    agents/
    skills/
    )需放在插件根目录,而非
    .claude-plugin/
    内部
  • 仅为插件实际使用的组件创建目录
  • 所有目录和文件名使用短横线分隔命名法(kebab-case)

plugin.json Manifest

plugin.json 清单

Located at
.claude-plugin/plugin.json
. Minimal required field is
name
.
json
{
  "name": "plugin-name",
  "version": "0.1.0",
  "description": "Brief explanation of plugin purpose",
  "author": {
    "name": "Author Name"
  }
}
Name rules: kebab-case, lowercase with hyphens, no spaces or special characters. Version: semver format (MAJOR.MINOR.PATCH). Start at
0.1.0
.
Optional fields:
homepage
,
repository
,
license
,
keywords
.
Custom component paths can be specified (supplements, does not replace, auto-discovery):
json
{
  "commands": "./custom-commands",
  "agents": ["./agents", "./specialized-agents"],
  "hooks": "./config/hooks.json",
  "mcpServers": "./.mcp.json"
}
位于
.claude-plugin/plugin.json
。必填字段为
name
json
{
  "name": "plugin-name",
  "version": "0.1.0",
  "description": "插件用途的简要说明",
  "author": {
    "name": "作者姓名"
  }
}
命名规则: 使用kebab-case,小写字母加短横线,无空格或特殊字符。 版本: 采用语义化版本格式(MAJOR.MINOR.PATCH)。初始版本从
0.1.0
开始。
可选字段:
homepage
repository
license
keywords
可指定自定义组件路径(作为自动发现的补充,而非替代):
json
{
  "commands": "./custom-commands",
  "agents": ["./agents", "./specialized-agents"],
  "hooks": "./config/hooks.json",
  "mcpServers": "./.mcp.json"
}

Component Schemas

组件Schema

Detailed schemas for each component type are in
references/component-schemas.md
. Summary:
ComponentLocationFormat
Commands
commands/*.md
Markdown + YAML frontmatter
Skills
skills/*/SKILL.md
Markdown + YAML frontmatter
MCP Servers
.mcp.json
JSON
Agents (uncommonly used in Cowork)
agents/*.md
Markdown + YAML frontmatter
Hooks (rarely used in Cowork)
hooks/hooks.json
JSON
This schema is shared with Claude Code's plugin system, but you're creating a plugin for Claude Cowork, a desktop app for doing knowledge work. Cowork users will usually find commands and skills the most useful.
各组件类型的详细Schema位于
references/component-schemas.md
。摘要如下:
组件位置格式
命令
commands/*.md
Markdown + YAML前置元数据
技能
skills/*/SKILL.md
Markdown + YAML前置元数据
MCP服务器
.mcp.json
JSON
Agent(在Cowork中不常用)
agents/*.md
Markdown + YAML前置元数据
钩子(在Cowork中极少使用)
hooks/hooks.json
JSON
此Schema与Claude Code的插件系统共用,但你现在是为Claude Cowork(一款用于知识工作的桌面应用)创建插件。Cowork用户通常会发现命令和技能是最实用的组件。

Customizable plugins with
~~
placeholders

支持
~~
占位符的可自定义插件

Do not use or ask about this pattern by default. Only introduce
~~
placeholders if the user explicitly says they want people outside their organization to use the plugin. You can mention this is an option if it seems like the user wants to distribute the plugin externally, but do not proactively ask about this with AskUserQuestion.
When a plugin is intended to be shared with others outside their company, it might have parts that need to be adapted to individual users. You might need to reference external tools by category rather than specific product (e.g., "project tracker" instead of "Jira"). When sharing is needed, use generic language and mark these as requiring customization with two tilde characters such as
create an issue in ~~project tracker
. If used any tool categories, write a
CONNECTORS.md
file at the plugin root to explain:
markdown
undefined
默认情况下请勿使用或询问此模式。 仅当用户明确表示希望组织外部人员使用该插件时,才引入
~~
占位符。 如果看起来用户想要将插件分发给外部人员,你可以提及这是一个选项,但不要主动用AskUserQuestion询问。
当插件打算与公司外部人员共享时,可能存在需要根据不同用户进行适配的部分。你可能需要按类别引用外部工具,而非具体产品(例如,用“项目跟踪工具”代替“Jira”)。当需要共享时,使用通用语言,并使用两个波浪线
~~
标记这些需要自定义的部分,例如
在~~项目跟踪工具中创建一个问题
。 如果使用了任何工具类别,请在插件根目录编写
CONNECTORS.md
文件进行说明:
markdown
undefined

Connectors

连接器

How tool references work

工具引用的工作方式

Plugin files use
~~category
as a placeholder for whatever tool the user connects in that category. Plugins are tool-agnostic — they describe workflows in terms of categories rather than specific products.
插件文件使用
~~category
作为占位符,代表用户在该类别中连接的任意工具。插件与工具无关——它们按类别而非具体产品描述工作流。

Connectors for this plugin

此插件的连接器

| Category | Placeholder | Options | |----------|-------------|-----------------|---------------| | Chat |
~~chat
| Slack, Microsoft Teams, Discord | | Project tracker |
~~project tracker
| Linear, Asana, Jira |
undefined
| 类别 | 占位符 | 可选工具 | |----------|-------------|-----------------|---------------| | 聊天工具 |
~~chat
| Slack, Microsoft Teams, Discord | | 项目跟踪工具 |
~~project tracker
| Linear, Asana, Jira |
undefined

${CLAUDE_PLUGIN_ROOT} Variable

${CLAUDE_PLUGIN_ROOT} 变量

Use
${CLAUDE_PLUGIN_ROOT}
for all intra-plugin path references in hooks and MCP configs. Never hardcode absolute paths.
在钩子和MCP配置中,所有插件内部路径引用请使用
${CLAUDE_PLUGIN_ROOT}
。切勿硬编码绝对路径。

Guided Workflow

引导式工作流

When you ask the user something, use AskUserQuestion. Don't assume "industry standard" defaults are correct. Note: AskUserQuestion always includes a Skip button and a free-text input box for custom answers, so do not include
None
or
Other
as options.
当你向用户提问时,请使用AskUserQuestion。不要假设“行业标准”默认值是正确的。注意:AskUserQuestion始终包含一个跳过按钮和一个用于自定义答案的自由文本输入框,因此请勿将
None
Other
作为选项。

Phase 1: Discovery

阶段1:探索

Goal: Understand what the user wants to build and why.
Ask (only what is unclear — skip questions if the user's initial request already answers them):
  • What should this plugin do? What problem does it solve?
  • Who will use it and in what context?
  • Does it integrate with any external tools or services?
  • Is there a similar plugin or workflow to reference?
Summarize understanding and confirm before proceeding.
Output: Clear statement of plugin purpose and scope.
目标:理解用户想要构建的内容及其原因。
询问(仅询问不清楚的内容——如果用户的初始请求已回答,则跳过相关问题):
  • 此插件应实现什么功能?它解决什么问题?
  • 谁会使用它?使用场景是什么?
  • 它是否需要与任何外部工具或服务集成?
  • 是否有可参考的类似插件或工作流?
总结你的理解并确认后再继续。
输出:明确的插件用途和范围说明。

Phase 2: Component Planning

阶段2:组件规划

Goal: Determine which component types the plugin needs.
Based on the discovery answers, determine:
  • Skills — Does it need specialized knowledge that Claude should load on-demand? (domain expertise, reference schemas, workflow guides)
  • Commands — Are there user-initiated actions? (deploy, configure, analyze, review)
  • MCP Servers — Does it need external service integration? (databases, APIs, SaaS tools)
  • Agents (uncommon) — Are there autonomous multi-step tasks? (validation, generation, analysis)
  • Hooks (rare) — Should something happen automatically on certain events? (enforce policies, load context, validate operations)
Present a component plan table, including component types you decided not to create:
| Component | Count | Purpose |
|-----------|-------|---------|
| Skills    | 1     | Domain knowledge for X |
| Commands  | 2     | /do-thing, /check-thing |
| Agents    | 0     | Not needed |
| Hooks     | 1     | Validate writes |
| MCP       | 1     | Connect to service Y |
Get user confirmation or adjustments before proceeding.
Output: Confirmed list of components to create.
目标:确定插件需要的组件类型。
根据探索阶段的答案,确定:
  • 技能 — 是否需要Claude按需加载的专业知识?(领域专业知识、参考Schema、工作流指南)
  • 命令 — 是否存在用户触发的操作?(部署、配置、分析、审核)
  • MCP服务器 — 是否需要与外部服务集成?(数据库、API、SaaS工具)
  • Agent(不常用) — 是否存在自主执行的多步骤任务?(验证、生成、分析)
  • 钩子(极少使用) — 是否需要在特定事件发生时自动执行某些操作?(强制执行策略、加载上下文、验证操作)
呈现组件规划表格,包括你决定不创建的组件类型:
| 组件 | 数量 | 用途 |
|-----------|-------|---------|
| 技能    | 1     | X领域的专业知识 |
| 命令  | 2     | /执行操作, /检查状态 |
| Agent    | 0     | 不需要 |
| 钩子     | 1     | 验证写入操作 |
| MCP       | 1     | 连接到服务Y |
获取用户确认或调整后再继续。
输出:已确认的待创建组件列表。

Phase 3: Design & Clarifying Questions

阶段3:设计与答疑

Goal: Specify each component in detail. Resolve all ambiguities before implementation.
For each component type in the plan, ask targeted design questions. Present questions grouped by component type. Wait for answers before proceeding.
Skills:
  • What user queries should trigger this skill?
  • What knowledge domains does it cover?
  • Should it include reference files for detailed content?
Commands:
  • What arguments does each command accept?
  • What tools does each command need? (Read, Write, Bash, Grep, etc.)
  • Is each command interactive or automated?
Agents:
  • Should each agent trigger proactively or only when requested?
  • What tools does it need?
  • What should the output format be?
Hooks:
  • Which events? (PreToolUse, PostToolUse, Stop, SessionStart, etc.)
  • What behavior — validate, block, modify, add context?
  • Prompt-based (LLM-driven) or command-based (deterministic script)?
MCP Servers:
  • What server type? (stdio for local, SSE for hosted with OAuth, HTTP for REST APIs)
  • What authentication method?
  • What tools should be exposed?
If the user says "whatever you think is best," provide specific recommendations and get explicit confirmation.
Output: Detailed specification for every component.
目标:详细定义每个组件。在实现前解决所有歧义。
针对规划中的每个组件类型,提出针对性的设计问题。按组件类型分组呈现问题。等待用户回答后再继续。
技能:
  • 哪些用户查询应触发此技能?
  • 它涵盖哪些知识领域?
  • 是否需要包含用于详细内容的参考文件?
命令:
  • 每个命令接受哪些参数?
  • 每个命令需要使用哪些工具?(Read、Write、Bash、Grep等)
  • 每个命令是交互式的还是自动化的?
Agent:
  • 每个Agent应主动触发还是仅在被请求时触发?
  • 它需要使用哪些工具?
  • 输出格式应是什么样的?
钩子:
  • 针对哪些事件?(PreToolUse、PostToolUse、Stop、SessionStart等)
  • 执行什么行为——验证、阻止、修改、添加上下文?
  • 基于提示词(由大语言模型驱动)还是基于命令(确定性脚本)?
MCP服务器:
  • 服务器类型是什么?(stdio用于本地服务,SSE用于带OAuth的托管服务,HTTP用于REST API)
  • 使用什么认证方式?
  • 应暴露哪些工具?
如果用户说“你觉得怎么好就怎么来”,请提供具体建议并获取明确确认。
输出:每个组件的详细规格说明。

Phase 4: Implementation

阶段4:实现

Goal: Create all plugin files following best practices.
Order of operations:
  1. Create the plugin directory structure
  2. Create
    plugin.json
    manifest
  3. Create each component (see
    references/component-schemas.md
    for exact formats)
  4. Create
    README.md
    documenting the plugin
Implementation guidelines:
  • Commands are instructions FOR Claude, not messages to the user. Write them as directives about what to do.
  • Skills use progressive disclosure: lean SKILL.md body (under 3,000 words), detailed content in
    references/
    . Frontmatter description must be third-person with specific trigger phrases.
  • Agents need a description with
    <example>
    blocks showing triggering conditions, plus a system prompt in the markdown body.
  • Hooks config goes in
    hooks/hooks.json
    . Use
    ${CLAUDE_PLUGIN_ROOT}
    for script paths. Prefer prompt-based hooks for complex logic.
  • MCP configs go in
    .mcp.json
    at plugin root. Use
    ${CLAUDE_PLUGIN_ROOT}
    for local server paths. Document required env vars in README.
目标:遵循最佳实践创建所有插件文件。
操作顺序:
  1. 创建插件目录结构
  2. 创建
    plugin.json
    清单
  3. 创建每个组件(具体格式请参考
    references/component-schemas.md
  4. 创建
    README.md
    文档说明插件
实现指南:
  • 命令 是给Claude的指令,而非给用户的消息。请以指令的形式编写,说明要执行的操作。
  • 技能 使用渐进式披露:SKILL.md主体内容精简(少于3000字),详细内容放在
    references/
    目录中。前置元数据的描述必须使用第三人称,并包含具体的触发短语。
  • Agent 需要包含带有
    <example>
    块的描述,展示触发条件,同时在Markdown主体中包含系统提示词。
  • 钩子 配置放在
    hooks/hooks.json
    中。脚本路径请使用
    ${CLAUDE_PLUGIN_ROOT}
    。对于复杂逻辑,优先选择基于提示词的钩子。
  • MCP配置 放在插件根目录的
    .mcp.json
    中。本地服务器路径请使用
    ${CLAUDE_PLUGIN_ROOT}
    。在README中记录所需的环境变量。

Phase 5: Review & Package

阶段5:审核与打包

Goal: Deliver the finished plugin.
  1. Summarize what was created — list each component and its purpose
  2. Ask if the user wants any adjustments
  3. Run
    claude plugin validate <path-to-plugin-json>
    ; fix any errors and warnings
  4. Package as a
    .plugin
    file:
bash
cd /path/to/plugin-dir && zip -r /tmp/plugin-name.plugin . -x "*.DS_Store" && cp /tmp/plugin-name.plugin /path/to/outputs/plugin-name.plugin
Important: Always create the zip in
/tmp/
first, then copy to the outputs folder. Writing directly to the outputs folder may fail due to permissions.
Naming: Use the plugin name from
plugin.json
for the
.plugin
file (e.g., if name is
code-reviewer
, output
code-reviewer.plugin
).
The
.plugin
file will appear in the chat as a rich preview where the user can browse the files and accept the plugin by pressing a button.
目标:交付完成的插件。
  1. 总结已创建的内容——列出每个组件及其用途
  2. 询问用户是否需要任何调整
  3. 运行
    claude plugin validate <path-to-plugin-json>
    ;修复所有错误和警告
  4. 打包为
    .plugin
    文件:
bash
cd /path/to/plugin-dir && zip -r /tmp/plugin-name.plugin . -x "*.DS_Store" && cp /tmp/plugin-name.plugin /path/to/outputs/plugin-name.plugin
重要提示:始终先在
/tmp/
目录创建压缩包,再复制到outputs文件夹。直接写入outputs文件夹可能因权限问题失败。
命名:使用
plugin.json
中的插件名称作为
.plugin
文件名(例如,如果名称为
code-reviewer
,则输出
code-reviewer.plugin
)。
.plugin
文件将在聊天中以富预览形式展示,用户可以浏览文件并通过点击按钮安装插件。

Best Practices

最佳实践

  • Start small: Begin with the minimum viable set of components. A plugin with one well-crafted skill is more useful than one with five half-baked components.
  • Progressive disclosure for skills: Core knowledge in SKILL.md, detailed reference material in
    references/
    , working examples in
    examples/
    .
  • Clear trigger phrases: Skill descriptions should include specific phrases users would say. Agent descriptions should include
    <example>
    blocks.
  • Commands are for Claude: Write command content as instructions for Claude to follow, not documentation for the user to read.
  • Imperative writing style: Use verb-first instructions in skills ("Parse the config file," not "You should parse the config file").
  • Portability: Always use
    ${CLAUDE_PLUGIN_ROOT}
    for intra-plugin paths, never hardcoded paths.
  • Security: Use environment variables for credentials, HTTPS for remote servers, least-privilege tool access.
  • 从小处着手:从最小可行组件集开始。一个精心打造的单技能插件比五个半成品组件的插件更有用。
  • 技能的渐进式披露:核心知识放在SKILL.md中,详细参考材料放在
    references/
    ,工作示例放在
    examples/
  • 明确的触发短语:技能描述应包含用户会使用的具体触发短语。Agent描述应包含
    <example>
    块。
  • 命令是给Claude的指令:命令内容应编写为Claude需遵循的指令,而非给用户阅读的文档。
  • 命令式写作风格:技能中使用动词开头的指令(如“解析配置文件”,而非“你应该解析配置文件”)。
  • 可移植性:插件内部路径引用始终使用
    ${CLAUDE_PLUGIN_ROOT}
    ,切勿硬编码路径。
  • 安全性:使用环境变量存储凭据,远程服务器使用HTTPS,遵循最小权限原则分配工具访问权限。

Additional Resources

额外资源

  • references/component-schemas.md
    — Detailed format specifications for every component type (commands, skills, agents, hooks, MCP, CONNECTORS.md)
  • references/example-plugins.md
    — Three complete example plugin structures at different complexity levels
  • references/component-schemas.md
    — 所有组件类型(命令、技能、Agent、钩子、MCP、CONNECTORS.md)的详细格式规范
  • references/example-plugins.md
    — 三个完整的示例插件结构,涵盖不同复杂度级别