6.5 Skills 技能
什么是 Skills?
Skills(技能)是 Claude Code 的渐进式能力扩展机制。每个 Skill 都是一个封装好的工作流,包含详细的步骤指引、代码示例和最佳实践。Skills 的特点是"按需加载"——只有在相关任务被触发时才会激活。
Skills 与 Agents/Commands 的区别
| 特性 | Agents | Commands | Skills |
|---|---|---|---|
| 定位 | 专家角色 | 快捷操作 | 详细工作流 |
| 激活方式 | 手动或自动 | 斜杠命令 | 上下文触发 |
| 内容深度 | 角色设定 | 任务步骤 | 完整教程 |
| 适用场景 | 领域专业 | 单一任务 | 复杂流程 |
Skills 目录结构
skill-name/
├── SKILL.md # 技能定义文件
├── reference.md # 详细参考文档(可选)
├── examples/ # 示例文件(可选)
│ ├── example1.py
│ └── example2.js
└── templates/ # 模板文件(可选)
└── template.htmlSKILL.md 文件结构
markdown
---
name: skill-name
description: 技能的详细描述
license: Apache 2.0 或 Proprietary
---
# 技能标题
## Overview(概述)
技能的用途和场景说明
## Quick Start(快速开始)
最基本的使用示例
## 详细指南
具体的步骤和代码示例
## 参考
更多资源链接安装 Skills
bash
# 安装单个 Skill
npx claude-code-templates@latest --skill document-processing/pdf --yes
# 安装多个 Skills
npx claude-code-templates@latest \
--skill document-processing/pdf \
--skill creative-design/theme-factory \
--skill development/skill-creator \
--yes安装后的目录结构:
.claude/
└── skills/
├── pdf/
│ ├── SKILL.md
│ ├── reference.md
│ └── forms.md
└── theme-factory/
├── SKILL.md
└── themes/Skills 分类
1. 文档处理 (document-processing)
| Skill | 描述 | 许可证 |
|---|---|---|
pdf | PDF 创建、编辑、分割合并 | Proprietary |
xlsx | Excel 电子表格处理 | Proprietary |
docx | Word 文档处理 | Proprietary |
pptx | PowerPoint 演示文稿 | Proprietary |
2. 创意设计 (creative-design)
| Skill | 描述 | 许可证 |
|---|---|---|
theme-factory | 主题样式应用 | Apache 2.0 |
algorithmic-art | 生成式艺术 (p5.js) | Apache 2.0 |
canvas-design | 视觉设计 (PNG/PDF) | Apache 2.0 |
slack-gif-creator | 创建 Slack 动图 | Apache 2.0 |
3. 开发工具 (development)
| Skill | 描述 | 许可证 |
|---|---|---|
skill-creator | 创建自定义 Skill | Apache 2.0 |
mcp-builder | 创建 MCP 服务器 | Apache 2.0 |
git-commit-helper | Git 提交助手 | Apache 2.0 |
changelog-generator | 变更日志生成 | Apache 2.0 |
4. 企业通讯 (enterprise-communication)
| Skill | 描述 | 许可证 |
|---|---|---|
internal-comms | 内部通讯写作 | Apache 2.0 |
brand-guidelines | 品牌指南应用 | Apache 2.0 |
5. 生产力 (productivity)
| Skill | 描述 | 许可证 |
|---|---|---|
webapp-testing | Web 应用测试 | Apache 2.0 |
artifacts-builder | HTML 工件构建 | Apache 2.0 |
经典 Skills 示例
Theme Factory
markdown
---
name: theme-factory
description: Toolkit for styling artifacts with themes.
Apply to slides, docs, reports, HTML pages, etc.
license: Apache 2.0
---
# Theme Factory Skill
This skill provides professional font and color themes.
## Purpose
Apply consistent, professional styling including:
- Cohesive color palette with hex codes
- Complementary font pairings
- Distinct visual identity
## Usage Instructions
1. **Show the theme showcase**: Display theme-showcase.pdf
2. **Ask for choice**: Ask which theme to apply
3. **Wait for selection**: Get explicit confirmation
4. **Apply the theme**: Apply colors and fonts
## Themes Available
1. **Ocean Depths** - Professional maritime theme
2. **Sunset Boulevard** - Warm sunset colors
3. **Forest Canopy** - Natural earth tones
4. **Modern Minimalist** - Clean grayscale
5. **Golden Hour** - Rich autumnal palette
6. **Arctic Frost** - Cool winter theme
7. **Desert Rose** - Soft dusty tones
8. **Tech Innovation** - Bold tech aesthetic
9. **Botanical Garden** - Fresh garden colors
10. **Midnight Galaxy** - Dramatic cosmic tones
## Application Process
1. Read the theme file from themes/ directory
2. Apply colors and fonts consistently
3. Ensure proper contrast and readability
4. Maintain visual identity across all slidesPDF Processing
markdown
---
name: pdf
description: Comprehensive PDF manipulation toolkit
license: Proprietary
---
# PDF Processing Guide
## Overview
PDF processing operations using Python and CLI tools.
## Quick Start
```python
from pypdf import PdfReader, PdfWriter
# Read a PDF
reader = PdfReader("document.pdf")
print(f"Pages: {len(reader.pages)}")
# Extract text
text = ""
for page in reader.pages:
text += page.extract_text()Python Libraries
pypdf - Basic Operations
Merge PDFs
python
from pypdf import PdfWriter, PdfReader
writer = PdfWriter()
for pdf_file in ["doc1.pdf", "doc2.pdf"]:
reader = PdfReader(pdf_file)
for page in reader.pages:
writer.add_page(page)
with open("merged.pdf", "wb") as output:
writer.write(output)pdfplumber - Text and Table Extraction
python
import pdfplumber
with pdfplumber.open("document.pdf") as pdf:
for page in pdf.pages:
text = page.extract_text()
tables = page.extract_tables()reportlab - Create PDFs
python
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
c = canvas.Canvas("hello.pdf", pagesize=letter)
c.drawString(100, 750, "Hello World!")
c.save()Quick Reference
| Task | Best Tool |
|---|---|
| Merge PDFs | pypdf |
| Extract text | pdfplumber |
| Extract tables | pdfplumber |
| Create PDFs | reportlab |
| OCR scanned PDFs | pytesseract |
### Skill Creator
```markdown
---
name: skill-creator
description: Guide for creating effective skills
license: Apache 2.0
---
# Skill Creator Guide
## What is a Skill?
A skill is a set of instructions that teaches Claude
how to perform specific tasks.
## Structuremy-skill/ ├── SKILL.md # Required ├── reference.md # Optional detailed docs ├── examples/ # Optional examples └── templates/ # Optional templates
## SKILL.md Template
```markdown
---
name: your-skill-name
description: What this skill does
license: Apache 2.0
---
# Skill Title
## Overview
What this skill enables
## Quick Start
Basic usage example
## Detailed Guide
Step-by-step instructions
## Best Practices
Tips and recommendationsBest Practices
- Start with a clear overview
- Provide runnable examples
- Include troubleshooting tips
- Keep content focused
- Use progressive disclosure
## 创建自定义 Skill
### 步骤 1:创建目录结构
```bash
mkdir -p .claude/skills/my-skill步骤 2:创建 SKILL.md
markdown
---
name: my-custom-skill
description: 我的自定义技能描述
license: MIT
---
# 我的自定义技能
## 概述
这个技能用于 [描述用途]。
## 快速开始
```python
# 最基本的示例代码
print("Hello from my skill!")详细指南
第一步:准备工作
描述准备步骤...
第二步:执行操作
描述执行步骤...
第三步:验证结果
描述验证步骤...
常见问题
Q: 问题1?
A: 答案1
Q: 问题2?
A: 答案2
### 步骤 3:添加参考文档(可选)
创建 `.claude/skills/my-skill/reference.md`:
```markdown
# 详细参考文档
## API 参考
...
## 高级用法
...
## 故障排除
...完整示例:文档处理工作流
bash
#!/bin/bash
# 文档处理 Skills 配置
# 1. 安装文档处理 Skills
npx claude-code-templates@latest \
--skill document-processing/pdf \
--skill document-processing/xlsx \
--skill document-processing/docx \
--yes
# 2. 安装设计 Skills
npx claude-code-templates@latest \
--skill creative-design/theme-factory \
--skill creative-design/canvas-design \
--yes
# 3. 安装开发 Skills
npx claude-code-templates@latest \
--skill development/skill-creator \
--skill development/changelog-generator \
--yes
echo "文档处理工作流配置完成!"
echo ""
echo "已配置技能:"
echo " - PDF 处理(创建、编辑、合并、分割)"
echo " - Excel 处理(读取、写入、分析)"
echo " - Word 处理(创建、编辑)"
echo " - 主题工厂(样式应用)"
echo " - 画布设计(视觉设计)"
echo " - Skill 创建(自定义技能)"
echo " - 变更日志(自动生成)"Skills 使用场景
场景 1:PDF 报告生成
我需要将这些数据生成 PDF 报告,包含表格和图表。Claude Code 会自动加载 PDF Skill,使用 reportlab 生成专业报告。
场景 2:主题应用
给这个演示文稿应用 Tech Innovation 主题。Claude Code 会加载 Theme Factory Skill,应用预设的颜色和字体方案。
场景 3:Excel 数据分析
分析这个 Excel 文件中的销售数据。Claude Code 会加载 xlsx Skill,使用 pandas 进行数据分析。
许可证说明
开源 Skills (Apache 2.0)
可自由使用、修改和分发:
- algorithmic-art
- theme-factory
- canvas-design
- skill-creator
- mcp-builder
专有 Skills
仅供参考学习:
- xlsx
- docx
- pptx
这些文档处理 Skills 由 Anthropic 提供作为参考示例,不适合未经许可的商业使用。
最佳实践
- 渐进式披露:从简单开始,按需深入
- 提供示例:每个功能都包含可运行的代码
- 错误处理:包含常见问题和解决方案
- 保持聚焦:每个 Skill 专注一个领域
- 版本控制:在团队间共享和管理 Skills
下一步
- 6.6 Analytics 工具 - 开发分析
- 6.7 工具协作 - 与 Cursor 等工具协作