方式 | 技能名称 | 适用场景 |
独立配置( .codebuddy/ 目录) | /hello | 个人工作流、项目特定定制、快速实验 |
插件(含 .codebuddy-plugin/plugin.json 的目录) | /plugin-name:hello | 团队共享、社区分发、版本化发布、跨项目复用 |
/hello 或 /deploy/my-plugin:hello(命名空间防止插件间冲突).codebuddy/ 中使用独立配置快速迭代,准备共享时再转换为插件。--plugin-dir 参数在本地测试。/plugin 命令,请将 CodeBuddy Code 更新到最新版本。mkdir my-first-plugin
.codebuddy-plugin/plugin.json,定义插件的身份信息:名称、描述和版本。CodeBuddy Code 使用这些元数据在插件管理器中展示您的插件。在插件目录内创建 .codebuddy-plugin 目录:mkdir my-first-plugin/.codebuddy-plugin
my-first-plugin/.codebuddy-plugin/plugin.json,内容如下:{"name": "my-first-plugin","description": "A greeting plugin to learn the basics","version": "1.0.0","author": {"name": "Your Name"}}
字段 | 用途 |
name | 唯一标识符和技能命名空间。技能以此为前缀(如 /my-first-plugin:hello) |
description | 在插件管理器中浏览或安装插件时显示 |
version | |
author | 可选。用于归属标注 |
skills/ 目录中。每个技能是一个包含 SKILL.md 文件的文件夹。文件夹名称成为技能名称,并以插件命名空间为前缀(在名为 my-first-plugin 的插件中,hello/ 创建 /my-first-plugin:hello)。在插件目录中创建技能目录:mkdir -p my-first-plugin/skills/hello
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 参数运行 CodeBuddy Code 以加载您的插件:codebuddy --plugin-dir ./my-first-plugin
/my-first-plugin:hello
/help 可以看到您的技能列在插件命名空间下。/my-first-plugin:hello),以防止多个插件中同名技能产生冲突。要更改命名空间前缀,请更新 plugin.json 中的 name 字段。$ARGUMENTS 占位符捕获用户在技能名称后提供的任何文本。更新您的 SKILL.md 文件:---description: Greet the user with a personalized message---# Hello SkillGreet the user named "$ARGUMENTS" warmly and ask how you can help them today. Make the greeting personal and encouraging.
/reload-plugins 以获取更改,然后用您的名字尝试技能:/my-first-plugin:hello Alex
.codebuddy-plugin/plugin.json):描述插件的元数据skills/):包含您的自定义技能$ARGUMENTS):捕获用户输入实现动态行为commands/、agents/、skills/ 或 hooks/ 放在 .codebuddy-plugin/ 目录内。只有 plugin.json 放在 .codebuddy-plugin/ 内。所有其他目录必须在插件根目录层级。目录 | 位置 | 用途 |
.codebuddy-plugin/ | 插件根目录 | 包含 plugin.json 清单 |
commands/ | 插件根目录 | Markdown 格式的斜杠命令 |
agents/ | 插件根目录 | 自定义代理定义 |
skills/ | 插件根目录 | 包含 SKILL.md 文件的代理技能 |
hooks/ | 插件根目录 | hooks.json 事件处理器 |
.mcp.json | 插件根目录 | MCP 服务器配置 |
.lsp.json | 插件根目录 | LSP 服务器配置(代码智能) |
bin/ | 插件根目录 | 插件启用时添加到 Bash 工具 PATH 的可执行文件 |
settings.json | 插件根目录 |
my-plugin/├── .codebuddy-plugin/ # 元数据目录(必需)│ └── plugin.json # 插件清单文件├── commands/ # 命令目录(可选)│ └── example.md├── agents/ # 代理目录(可选)│ └── example.md├── skills/ # 技能目录(可选)│ └── code-review/│ └── SKILL.md├── hooks/ # Hooks 目录(可选)│ └── hooks.json├── bin/ # 可执行文件目录(可选)│ └── my-tool├── .mcp.json # MCP 配置文件(可选)├── .lsp.json # LSP 配置文件(可选)└── settings.json # 默认设置文件(可选)
skills/ 目录,其中包含带有 SKILL.md 文件的技能文件夹:my-plugin/├── .codebuddy-plugin/│ └── plugin.json└── skills/└── code-review/└── SKILL.md
SKILL.md 需要包含 name 和 description 字段的 frontmatter,后跟指令:---name: code-reviewdescription: Reviews code for best practices and potential issues. Use when reviewing code, checking PRs, or analyzing code quality.---When reviewing code, check for:1. Code organization and structure2. Error handling3. Security concerns4. Test coverage
commands/example.md---description: "示例命令描述"argument-hint: "[参数]"---这是一个示例命令。当用户输入 /my-plugin:example 时会执行此命令。参数:$ARGUMENTS
jq 提取字段。hooks/hooks.json{"hooks": {"PostToolUse": [{"matcher": "Write|Edit","hooks": [{"type": "command","command": "jq -r '.tool_input.file_path' | xargs npm run lint:fix"}]}]}}
hooks/hooks.json 中的 hooks 在插件启用时自动与用户和项目级 hooks 合并(不会覆盖),并且不受 allowUntrustedFrontmatterHooks 闸门约束(该闸门只针对 Agent / Skill frontmatter 中声明的 hooks)。command,hook 也支持 type: prompt(小模型语义判定)、type: agent(subagent 验证)、type: http(POST/PUT/PATCH 到指定 URL)三种执行方式,详见 Hooks 文档。如果您的插件还需要随 Skill 一起携带 frontmatter hooks,请参考 Skills 文档 - 在 Skill 中配置 Hooks(注意此路径受安全闸门约束)。详细说明请参考 Hooks 文档。.lsp.json 文件:{"go": {"command": "gopls","args": ["serve"],"extensionToLanguage": {".go": "go"}}}
{"python": {"command": "pylsp","args": [],"extensionToLanguage": {".py": "python"}},"rust": {"command": "rust-analyzer","args": [],"extensionToLanguage": {".rs": "rust"}}}
go install golang.org/x/tools/gopls@latestpip install python-lsp-serverrustup component add rust-analyzersettings.json 文件,在插件启用时应用默认配置。目前仅支持 agent 键。设置 agent 会将插件的一个自定义代理激活为主线程,应用其系统提示词、工具限制和模型。这让插件在启用时可以改变 CodeBuddy Code 的默认行为。{"agent": "security-reviewer"}
agents/ 目录中定义的 security-reviewer 代理。settings.json 中的设置优先于 plugin.json 中声明的 settings。未知键会被静默忽略。--plugin-dir 参数在开发过程中测试插件。这会直接加载您的插件,无需安装。codebuddy --plugin-dir ./my-plugin
--plugin-dir 插件与已安装的市场插件同名时,本地副本在该会话中优先使用。这让您可以测试已安装插件的改动而无需卸载它。通过托管设置强制启用的市场插件是唯一的例外,不能被覆盖。/reload-plugins 无需重启即可获取更新。这会重新加载插件、技能、代理、钩子、插件 MCP 服务器和插件 LSP 服务器。测试您的插件组件:/plugin-name:skill-name 尝试技能/agents 中检查代理是否出现codebuddy --plugin-dir ./plugin-one --plugin-dir ./plugin-two
.codebuddy-plugin/ 内--debug 参数启动 CodeBuddy 查看详细日志.codebuddy-plugin/plugin.json:{"name": "my-plugin","version": "1.0.0","description": "插件描述","author": {"name": "作者名称","email": "author@example.com"},"homepage": "https://github.com/username/my-plugin","repository": "https://github.com/username/my-plugin","keywords": ["example"],"category": "开发工具","commands": [],"agents": [],"skills": [],"hooks": "./hooks/hooks.json"}
README.md,说明安装和使用方式plugin.json 中使用语义化版本.codebuddy/ 目录中有技能或钩子,可以将它们转换为插件以便于共享和分发。mkdir -p my-plugin/.codebuddy-plugin
my-plugin/.codebuddy-plugin/plugin.json:{"name": "my-plugin","description": "Migrated from standalone configuration","version": "1.0.0"}
# 复制命令cp -r .codebuddy/commands my-plugin/# 复制代理(如有)cp -r .codebuddy/agents my-plugin/# 复制技能(如有)cp -r .codebuddy/skills my-plugin/
mkdir my-plugin/hooks
my-plugin/hooks/hooks.json,将 hooks 配置放入其中。从 .codebuddy/settings.json 或 settings.local.json 中复制 hooks 对象,格式是一样的。命令通过标准输入接收 hook 输入的 JSON 数据,可以使用 jq 提取字段:{"hooks": {"PostToolUse": [{"matcher": "Write|Edit","hooks": [{"type": "command","command": "jq -r '.tool_input.file_path' | xargs npm run lint:fix"}]}]}}
codebuddy --plugin-dir ./my-plugin
/agents 中检查代理、验证钩子正确触发。独立配置( .codebuddy/) | 插件 |
仅在一个项目中可用 | 可通过市场共享 |
文件在 .codebuddy/commands/ | 文件在 plugin-name/commands/ |
Hooks 在 settings.json 中 | Hooks 在 hooks/hooks.json 中 |
需要手动复制来共享 | 使用 /plugin install 安装 |
.codebuddy/ 中的原始文件以避免重复。加载时插件版本会优先使用。plugin.json 中提供详细的描述和作者信息--plugin-dir 在本地测试插件后再发布/plugin 进入 "Installed" 标签页查看plugin.json 格式是否正确/reload-plugins 重新加载插件--debug 模式查看加载日志commands/ 中,而不是 .codebuddy-plugin/ 内/reload-plugins 刷新# 验证插件格式codebuddy plugin validate /path/to/plugin# 使用 --plugin-dir 本地测试codebuddy --plugin-dir ./my-plugin# 测试插件的技能/my-plugin:skill-name
文档反馈