关于 advanced-features-2025
这份 Claude 插件技能资料面向插件作者和团队维护者,说明 Agent Skills、钩子、MCP 服务及仓库级配置的组织方式。内容提供事件匹配、配置示例和团队分发流程。
主要功能
- 01按需加载分层技能内容
- 02通过钩子自动化工具事件
- 03配置插件使用 MCP 服务
- 04设置仓库级团队插件
- 05管理插件路径与工具输入变量
适用场景
- 01在文件修改后运行测试或 lint
- 02执行 Bash 前验证命令
- 03为团队仓库配置并分发插件
- 04按任务加载补充参考资料
MCP 相关
.mcp.json 中可配置 MCP 服务,包括启动命令、参数和环境变量。资料给出连接外部服务的配置示例。
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ josiahsiegel/ claude-plugin-marketplace --skill advanced-features-2025安装后在 Claude Code 中输入/advanced-features-2025确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
examples/hook-scripts.mdreferences/hooks-advanced.mdmcp-patterns.mdteam-distribution.md详细介绍
高级插件功能(2025)
快速参考
| 功能 | 位置 | 用途 |
|---|---|---|
| Agent Skills | skills/*/SKILL.md | 动态加载知识 |
| Hooks | hooks/hooks.json | 事件自动化 |
| MCP 服务 | .mcp.json | 外部集成 |
| 团队配置 | .claude/settings.json | 仓库插件 |
| Hook 事件 | 触发时机 | 使用场景 |
|---|---|---|
| PreToolUse | 工具调用前 | 验证 |
| PostToolUse | 工具调用后 | 测试、lint |
| SessionStart | 会话开始时 | 日志记录、设置 |
| SessionEnd | 会话结束时 | 清理 |
| UserPromptSubmit | 提交提示词时 | 预处理 |
| PreCompact | 压缩前 | 保存状态 |
| Notification | 显示通知时 | 自定义提醒 |
| Stop | 用户停止时 | 清理 |
| SubagentStop | 子 Agent 结束时 | 日志记录 |
| 变量 | 用途 |
|---|---|
${CLAUDE_PLUGIN_ROOT} | 插件安装路径 |
${TOOL_INPUT_*} | 工具输入参数 |
Agent Skills
概念
Skills 会根据任务上下文动态加载,从而实现:
- 无限容量:将知识拆分到多个文件中
- 上下文效率:只加载所需内容
- 渐进式披露:分三层加载
三层加载
- Frontmatter:启动时加载(触发条件)
- SKILL.md 正文:激活时加载
- references/:需要详细信息时加载
结构
skills/
└── skill-name/
├── SKILL.md # Core content
├── references/ # Detailed docs
│ └── deep-dive.md
├── examples/ # Working code
│ └── example.md
└── scripts/ # Utilities
└── tool.sh
SKILL.md 格式
---
name: skill-name
description: |
When to activate this skill. Include:
(1) Use case 1
(2) Use case 2
Provides: what it offers
---
# Skill Title
## Quick Reference
[Tables, key points]
## Core Content
[Essential information - keep lean]
## Additional Resources
See `references/` for detailed guidance.
Hooks
配置
在 plugin.json 中内联配置:
{
"hooks": {
"PostToolUse": [{
"matcher": "Write|Edit",
"hooks": [{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/scripts/lint.sh"
}]
}]
}
}
单独使用 hooks.json:
{
"PostToolUse": [{
"matcher": "Write",
"hooks": [{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/scripts/format.sh",
"timeout": 5000
}]
}]
}
匹配器
Write- 写入文件Edit- 编辑文件Bash- Shell 命令Write|Edit- 多个工具.*- 任意工具(谨慎使用)
常见模式
更改后自动测试:
{
"PostToolUse": [{
"matcher": "Write|Edit",
"hooks": [{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/scripts/run-tests.sh"
}]
}]
}
Bash 调用前进行验证:
{
"PreToolUse": [{
"matcher": "Bash",
"hooks": [{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/scripts/validate-cmd.sh"
}]
}]
}
MCP 服务集成
配置
{
"mcpServers": {
"server-name": {
"command": "node",
"args": ["${CLAUDE_PLUGIN_ROOT}/mcp/server.js"],
"env": {
"API_KEY": "${API_KEY}"
}
}
}
}
外部服务
{
"mcpServers": {
"stripe": {
"command": "npx",
"args": ["-y", "@stripe/mcp-server"],
"env": {
"STRIPE_API_KEY": "${STRIPE_API_KEY}"
}
}
}
}
仓库配置
团队分发
在仓库根目录创建 .claude/settings.json:
{
"extraKnownMarketplaces": [
"company/internal-plugins"
],
"plugins": {
"enabled": [
"deployment-helper@company",
"code-standards@company"
]
}
}
工作流
- 维护者创建
.claude/settings.json - 团队成员克隆仓库
- 出现提示时信任该文件夹
- 自动安装插件
最佳实践
渐进式披露
- 将 SKILL.md 控制在 500 行以内
- 将详细内容移至
references/ - 使用
examples/存放可运行代码 - 使用相对路径引用文件
Hooks
- 使用具体的匹配器(避免
.*) - 设置合理的超时时间
- 使用
${CLAUDE_PLUGIN_ROOT}指定路径 - 独立测试脚本
MCP
- 说明所需的环境变量
- 提供设置说明
- 使用环境变量存储密钥
- 分发前测试连接
其他资源
如需了解详细模式,请参阅:
references/hooks-advanced.md- 完整的 Hook 模式references/mcp-patterns.md- MCP 集成示例references/team-distribution.md- 仓库配置examples/hook-scripts.md- 可运行的 Hook 脚本
评论
支持 Markdown