claude code 插件
|
|
|
|
|---|---|---|
独立
.claude/ 目录) |
/hello |
|
插件
.claude-plugin/plugin.json 的目录) |
/plugin-name:hello |
|
mkdir my-first-plugin
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
/my-first-plugin:hello
完整的插件包含下面的内容
|
|
|
|
|---|---|---|
.claude-plugin/ |
|
plugin.json 清单(如果组件使用默认位置,则可选) |
commands/ |
|
|
agents/ |
|
|
skills/ |
|
SKILL.md 文件的 Agent Skills |
hooks/ |
|
hooks.json
|
.mcp.json |
|
|
.lsp.json |
|
|
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


夜雨聆风