乐于分享
好东西不私藏

claude code 插件

claude code 插件

        可以使用command、skills、agents、hooks 和 MCP servers等方式 扩展 Claude Code。如果不想仅仅自己使用,可以打包后进行共享。Claude Code 支持两种方式来添加自定义 skills、agents 和 hooks:
方法
Skill 名称
最适合
独立

.claude/ 目录)
/hello
个人工作流、项目特定的自定义、快速实验
插件

(包含 .claude-plugin/plugin.json 的目录)
/plugin-name:hello
与团队成员共享、分发到社区、版本化发布、跨项目重用
每个插件都位于其自己的目录中,包含清单和你的 skills、agents 或 hooks。现在创建一个:
mkdir my-first-plugin
创建插件清单:位于 .claude-plugin/plugin.json 的清单文件定义了你的插件的身份:其名称、描述和版本。Claude Code 使用此元数据在插件管理器中显示你的插件。
mkdir my-first-plugin/.claude-plugintouch my-first-plugin/.claude-plugin/plugin.json
{"name": "my-first-plugin","description": "A greeting plugin to learn the basics","version": "1.0.0","author": {"name": "Your Name"}}

添加 skill:Skills 位于 skills/ 目录中。每个 skill 是一个包含 SKILL.md 文件的文件夹。文件夹名称成为 skill 名称,以插件的命名空间为前缀(在名为 my-first-plugin 的插件中的 hello/ 创建 /my-first-plugin:hello

mkdir -p my-first-plugin/skills/hellotouch my-first-plugin/skills/hello/SKILL.md
---description: Greet the user with a friendly messagedisable-model-invocation: true---Greet the user warmly and ask how you can help them today.
使用 --plugin-dir 标志运行 Claude Code 以加载你的插件:

claude --plugin-dir ./my-first-plugin
Claude Code 启动后,尝试你的新 skill:
/my-first-plugin:hello
完整的插件包含下面的内容
目录
位置
目的
.claude-plugin/
插件根
包含 plugin.json 清单(如果组件使用默认位置,则可选)
commands/
插件根
作为 Markdown 文件的 Skills
agents/
插件根
自定义 agent 定义
skills/
插件根
带有 SKILL.md 文件的 Agent Skills
hooks/
插件根
hooks.json

 中的事件处理程序
.mcp.json
插件根
MCP server 配置
.lsp.json
插件根
用于代码智能的 LSP server 配置
settings.json
插件根
启用插件时应用的默认设置

如果你需要支持没有官方 LSP 插件的语言,你可以通过向你的插件添加 .lsp.json

{  "go": {    "command": "gopls",    "args": ["serve"],    "extensionToLanguage": {      ".go": "go"    }  }}

完成后就可以通过git提交到插件市场进行共享。如果想使用插件市场的插件,可以使用下面的命令进行添加

/plugin install plugin-name@claude-plugins-official

比如官方的插件市场

/plugin marketplace add anthropics/claude-code

然后就可用运行 /plugin 打开插件管理器。增删禁用插件。

也可以添加本地的目录

/plugin marketplace add ./my-marketplace
列出所有配置的市场:
/plugin marketplace list
刷新市场的插件列表:
/plugin marketplace update marketplace-name
删除市场:
/plugin marketplace remove marketplace-name
本站文章均为手工撰写未经允许谢绝转载:夜雨聆风 » claude code 插件

猜你喜欢

  • 暂无文章