mcpField
A
advanced-features-2025

advanced-features-2025

github.com/josiahsiegelAgent 工作流59156 次安装19 周前更新
代码仓库

关于 advanced-features-2025

这份 Claude 插件技能资料面向插件作者和团队维护者,说明 Agent Skills、钩子、MCP 服务及仓库级配置的组织方式。内容提供事件匹配、配置示例和团队分发流程。

主要功能

  1. 01按需加载分层技能内容
  2. 02通过钩子自动化工具事件
  3. 03配置插件使用 MCP 服务
  4. 04设置仓库级团队插件
  5. 05管理插件路径与工具输入变量

适用场景

  1. 01在文件修改后运行测试或 lint
  2. 02执行 Bash 前验证命令
  3. 03为团队仓库配置并分发插件
  4. 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.md
references/
hooks-advanced.md
mcp-patterns.md
team-distribution.md

详细介绍

高级插件功能(2025)

快速参考

功能位置用途
Agent Skillsskills/*/SKILL.md动态加载知识
Hookshooks/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 会根据任务上下文动态加载,从而实现:

  • 无限容量:将知识拆分到多个文件中
  • 上下文效率:只加载所需内容
  • 渐进式披露:分三层加载
三层加载
  1. Frontmatter:启动时加载(触发条件)
  2. SKILL.md 正文:激活时加载
  3. 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"
    ]
  }
}
工作流
  1. 维护者创建 .claude/settings.json
  2. 团队成员克隆仓库
  3. 出现提示时信任该文件夹
  4. 自动安装插件

最佳实践

渐进式披露
  • 将 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