本文档详细说明 /plugin marketplace add 命令的实现机制,以及如何搭建自己的免费技能市场。
/plugin marketplace add <github-username>/<repository-name>
例如:
/plugin marketplace add anthropics/skills
/plugin marketplace add teaching-ai/skills
当您在 Claude Code 中执行 /plugin marketplace add 命令时,系统会执行以下步骤:
系统解析命令中的 GitHub 仓库路径:
anthropics/skills → 用户名: anthropics, 仓库名: skillshttps://api.github.com/repos/anthropics/skills系统从 GitHub 仓库获取配置文件:
.claude-plugin/marketplace.jsonhttps://raw.githubusercontent.com/anthropics/skills/main/.claude-plugin/marketplace.jsonhttps://api.github.com/repos/anthropics/skills/contents/.claude-plugin/marketplace.json系统解析 marketplace.json 文件,获取:
系统将 marketplace 信息存储到本地配置中,使其可用于后续的插件安装。
当用户安装插件时,系统会:
~/.claude/plugins/ 或类似位置){
"name": "marketplace-identifier", // Marketplace 的唯一标识符
"owner": { // 所有者信息(可选)
"name": "Owner Name",
"email": "owner@example.com"
},
"metadata": { // 元数据
"description": "Marketplace 描述",
"version": "1.0.0" // 版本号
},
"plugins": [ // 插件列表
{
"name": "plugin-identifier", // 插件的唯一标识符
"description": "插件描述",
"source": "./", // 源代码根路径(相对于仓库根目录)
"strict": false, // 是否严格模式(通常为 false)
"skills": [ // 技能路径列表(相对于 source)
"./skills/skill1",
"./skills/skill2"
]
}
]
}
"./"(仓库根目录)source 路径每个 skill 是一个目录,必须包含 SKILL.md 文件:
skill-name/
├── SKILL.md # 必需:技能定义文件
├── scripts/ # 可选:可执行脚本
│ └── script.py
├── references/ # 可选:参考文档
│ └── reference.md
└── assets/ # 可选:资源文件
└── template.html
每个 SKILL.md 文件必须包含:
YAML Frontmatter(必需):
---
name: skill-name # 技能的唯一标识符(小写,使用连字符)
description: 技能的简短描述,说明何时使用这个技能
license: 许可证信息(可选)
---
Markdown 内容(必需):
# 技能名称
## 概述
技能的详细说明...
## 核心功能
...
## 使用指南
...
SKILL.md(全大写)teaching-ai/skills)mkdir -p .claude-plugin
mkdir -p skills/your-skill-name
在 .claude-plugin/marketplace.json 中定义 marketplace 配置。
为每个技能创建目录和 SKILL.md 文件。
git add .
git commit -m "Initial marketplace setup"
git push origin main
/plugin marketplace add teaching-ai/skills
Claude Code 可能使用以下方式访问 GitHub 内容:
GitHub API:
GET /repos/{owner}/{repo}/contents/{path}Raw GitHub URLs:
https://raw.githubusercontent.com/{owner}/{repo}/{branch}/{path}GitHub CLI:
gh 命令获取内容安装的插件和 skills 通常存储在:
~/.claude/plugins/ 或 ~/.config/claude/plugins/%APPDATA%\claude\plugins\name 和 description(从 frontmatter)SKILL.md 内容metadata 中维护版本号description 字段应该准确描述何时使用该技能SKILL.md 简洁,避免不必要的冗长main 或 master 作为主分支无法找到 marketplace.json
.claude-plugin/marketplace.json技能无法加载
SKILL.md 文件是否存在marketplace.json 中正确配置插件安装失败
在 skill 目录下创建 scripts/ 目录,添加可执行脚本:
skills/your-skill/
├── SKILL.md
└── scripts/
└── process.py
在 SKILL.md 中引用脚本:
## 使用脚本
运行处理脚本:
bash python scripts/process.py [args]
在 skill 目录下创建 references/ 目录:
skills/your-skill/
├── SKILL.md
└── references/
└── api-reference.md
在 SKILL.md 中引用:
## API 参考
详细 API 文档请参考 [API Reference](references/api-reference.md)
在 skill 目录下创建 assets/ 目录:
skills/your-skill/
├── SKILL.md
└── assets/
└── template.html
/plugin marketplace add 命令的实现机制相对简单:
marketplace.json要搭建自己的技能市场,只需要:
.claude-plugin/marketplace.json 配置文件SKILL.md 文件/plugin marketplace add 命令整个过程完全基于 GitHub 的公开仓库,无需额外的服务器或 API。