name: claude-code-templates description: “Claude Code扩展的样板模板。触发条件:创建智能体、新技能、命令模板、钩子脚本、扩展脚手架。” compatibility: “Claude Code CLI” allowed-tools: “Read Write” depends-on: [] related-skills: [claude-code-hooks, claude-code-debug]
Claude Code 模板
构建Claude Code扩展的入门模板。
模板选择
| 构建内容 | 模板 | 关键特性 |
|---|---|---|
| 专家角色 | agent-template.md |
专注领域、质量检查清单、参考资料 |
| 工具能力 | skill-template.md |
命令、示例、触发器 |
| 用户工作流 | command-template.md |
执行流程、选项 |
| 自动化 | hook-script.sh |
输入解析、退出代码 |
快速开始
创建智能体
# 复制模板
cp ~/.claude/skills/claude-code-templates/assets/agent-template.md \
~/.claude/agents/my-expert.md
# 编辑:名称、描述、专注领域、参考资料
创建技能
# 创建技能目录
mkdir -p ~/.claude/skills/my-skill
# 复制模板
cp ~/.claude/skills/claude-code-templates/assets/skill-template.md \
~/.claude/skills/my-skill/SKILL.md
# 编辑:名称、描述、命令、示例
创建命令
# 复制模板
cp ~/.claude/skills/claude-code-templates/assets/command-template.md \
~/.claude/commands/my-command.md
# 编辑:名称、描述、执行流程
创建钩子脚本
# 复制模板
cp ~/.claude/skills/claude-code-templates/assets/hook-script.sh \
.claude/hooks/my-hook.sh
# 设为可执行
chmod +x .claude/hooks/my-hook.sh
模板位置
模板位于 ./assets/ 目录:
| 文件 | 用途 |
|---|---|
agent-template.md |
专家智能体样板 |
skill-template.md |
带YAML前置元数据的技能 |
command-template.md |
斜杠命令脚手架 |
hook-script.sh |
安全的钩子脚本模板 |
命名规范
| 类型 | 模式 | 示例 |
|---|---|---|
| 智能体 | {技术}-expert.md |
react-expert.md |
| 技能 | {工具或模式}/SKILL.md |
git-workflow/SKILL.md |
| 命令 | {动作}.md |
review.md |
| 钩子 | {事件}-{动作}.sh |
pre-write-validate.sh |
验证
# 验证YAML前置元数据
head -20 my-extension.md
# 检查名称是否匹配文件名
grep "^name:" my-extension.md
# 运行项目测试
just test
官方文档
- https://code.claude.com/docs/en/skills - 技能参考
- https://code.claude.com/docs/en/sub-agents - 自定义子智能体
- https://code.claude.com/docs/en/hooks - 钩子参考
- https://agentskills.io/specification - 智能体技能开放标准
资源文件
./assets/agent-template.md- 专家智能体脚手架./assets/skill-template.md- 带参考资料模式的技能./assets/command-template.md- 斜杠命令脚手架./assets/hook-script.sh- 安全的bash钩子模板
另请参阅: claude-code-debug 用于故障排除扩展