Skip to content

6.5 Skills 技能

什么是 Skills?

Skills(技能)是 Claude Code 的渐进式能力扩展机制。每个 Skill 都是一个封装好的工作流,包含详细的步骤指引、代码示例和最佳实践。Skills 的特点是"按需加载"——只有在相关任务被触发时才会激活。

Skills 与 Agents/Commands 的区别

特性AgentsCommandsSkills
定位专家角色快捷操作详细工作流
激活方式手动或自动斜杠命令上下文触发
内容深度角色设定任务步骤完整教程
适用场景领域专业单一任务复杂流程

Skills 目录结构

skill-name/
├── SKILL.md           # 技能定义文件
├── reference.md       # 详细参考文档(可选)
├── examples/          # 示例文件(可选)
│   ├── example1.py
│   └── example2.js
└── templates/         # 模板文件(可选)
    └── template.html

SKILL.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描述许可证
pdfPDF 创建、编辑、分割合并Proprietary
xlsxExcel 电子表格处理Proprietary
docxWord 文档处理Proprietary
pptxPowerPoint 演示文稿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创建自定义 SkillApache 2.0
mcp-builder创建 MCP 服务器Apache 2.0
git-commit-helperGit 提交助手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-testingWeb 应用测试Apache 2.0
artifacts-builderHTML 工件构建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 slides

PDF 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

TaskBest Tool
Merge PDFspypdf
Extract textpdfplumber
Extract tablespdfplumber
Create PDFsreportlab
OCR scanned PDFspytesseract

### 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.

## Structure

my-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 recommendations

Best Practices

  1. Start with a clear overview
  2. Provide runnable examples
  3. Include troubleshooting tips
  4. Keep content focused
  5. 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

仅供参考学习:

  • pdf
  • xlsx
  • docx
  • pptx

这些文档处理 Skills 由 Anthropic 提供作为参考示例,不适合未经许可的商业使用。

最佳实践

  1. 渐进式披露:从简单开始,按需深入
  2. 提供示例:每个功能都包含可运行的代码
  3. 错误处理:包含常见问题和解决方案
  4. 保持聚焦:每个 Skill 专注一个领域
  5. 版本控制:在团队间共享和管理 Skills

下一步

基于 MIT 许可证发布。内容版权归作者所有。