如何制作一个Skill?

前言

如果你使用过AI编程工具,你可能知道Skill是一个强大的功能 —— 它可以让AI学习你的工作流程,在特定场景下自动执行复杂的任务序列。

本文将以我基于开源的youtube内容提取SKill二次开发的 [youtube-pro](https://github.com/HAxiaoyu/youtube-pro) 项目为例,创建这个Skill的最初想法是我想实现一个提取视频内容并制作成PPT的工作流,这个技能实现了视频内容提取的步骤。下面我将详细讲解如何创建一个功能完整的Skill。

什么是Skill?

Skill是Agent中的一种扩展机制,允许用户定义自定义的工作流程。当用户输入特定短语或执行特定任务时,Agent会自动加载对应的Skill,按照预定义的指令执行操作。

Skill能做什么?

  • 📝 文档处理:自动生成Word、PDF、PPT文档

  • 📊 数据分析:Excel处理、图表生成、数据可视化

  • 🎬 多媒体处理:YouTube视频转录、字幕提取、视频摘要

  • 💬 沟通协作:内部通讯、FAQ回答、新闻稿撰写

  • 🎨 设计创作:Canvas设计、主题生成、算法艺术

  • 🔧 开发工具:MCP服务器构建、Web应用测试

Skill项目结构

一个标准的 Skill 项目结构如下:

skill-name/

├── SKILL.md              # 核心文件:Skill 定义和指令

├── _meta.json            # 元数据:版本、触发词、依赖等

├── README.md             # 用户文档(可选)

├── scripts/              # 可执行脚本(可选)

│   ├── fetch_transcript.py

│   ├── detect_languages.py

│   └── summarize.py

├── references/           # 参考文档(可选)

│   └── language_codes.md

├── templates/            # 输出模板(可选)

│   └── markdown_template.md

└── assets/               # 资源文件(可选)

    └── icons/

核心文件说明

文件

必填

说明

SKILL.md

Skill 的核心定义,包含触发条件和执行指令

_meta.json

元数据,包含版本、触发词、依赖等信息

README.md

用户文档,说明如何使用 Skill

scripts/

可执行脚本,用于自动化重复任务

references/

参考文档,按需加载到上下文

templates/

输出模板,定义生成内容的格式

assets/

资源文件,如图标、字体等

完善一个SKill

原有的YouTube-watcher Skill已经能实现视频内容提取,我又结合AI和各种天马行空的想法,补齐了下面这些能力

1. Multi-Language Support多语言支持

  • Auto-detect available subtitle languages

  • Specify preferred language with --lang

  • Support for auto-generated and manual subtitles

  • Auto-translate to target language (optional)

2. Output Formats多种输出格式

  • text - Clean plain text (default)

  • timestamped - With clickable timestamps [HH:MM:SS]

  • json - Structured data for programmatic use

  • srt - Standard subtitle format

  • markdown - Formatted document with sections

3. Language Detection语言检测

# Returns available languages with codes
python scripts/detect_languages.py "URL"

4. AI Summarization智能总结

# Generates section-by-section summary
python scripts/summarize.py "URL" --sections 5 --lang zh-Hans

5. Keyword Search关键词搜索

# Returns matches with timestamps
python scripts/search_keywords.py "URL" --keywords "machine learning" "AI"

6. Batch Processing批处理

python scripts/batch_process.py --playlist "PLAYLIST_URL" --output-dir ./output/
python scripts/batch_process.py --urls-file urls.txt --output-dir ./output/

脚本总览

Script

Purpose

fetch_transcript.py

Core transcript fetching with format options

detect_languages.py

List available subtitle languages

format_output.py

Convert between output formats

summarize.py

AI-powered section summarization

search_keywords.py

Search keywords in transcript

batch_process.py

Process multiple videos/playlists

Language Codes

  • en - English

  • zh-Hans - 简体中文 (Simplified Chinese)

  • zh-Hant - 繁體中文 (Traditional Chinese)

  • ja - 日本語 (Japanese)

  • ko - 한국어 (Korean)

  • es - Español (Spanish)

  • fr - Français (French)

  • de - Deutsch (German)

  • pt - Português (Portuguese)

  • ru - Русский (Russian)

Quick Start

# Fetch transcript
python scripts/fetch_transcript.py "https://youtube.com/watch?v=VIDEO_ID"

# Specify language
python scripts/fetch_transcript.py "URL" --lang zh-Hans

# With timestamps
python scripts/fetch_transcript.py "URL" --format timestamped

总结

创建 Skill 的核心步骤:

  1. 定义意图:明确 Skill 要解决的问题

  2. 设计结构:规划项目结构和文件组织

  3. 编写 SKILL.md:核心指令和触发条件

  4. 创建脚本:自动化重复任务

  5. 编写文档:用户指南和参考文档

  6. 测试优化:运行测试用例,迭代改进

一个好的 Skill 应该:

  • ✅ 触发准确:在正确的场景下被调用

  • ✅ 指令清晰:Claude 能准确理解要做什么

  • ✅ 输出稳定:多次运行结果一致

  • ✅ 文档完善:用户知道如何使用