Appearance
第8天:Skills标准发布(2025年)
学习目标
- 理解Skills标准的诞生背景和核心思想
- 掌握Skills的文档驱动开发理念
- 了解Skills的架构设计和实现
- 理解Skills与MCP的关系
- 掌握Skills的应用场景和最佳实践
课程内容
1. Skills的诞生背景
1.1 AI能力描述的挑战
1.1.1 能力描述不统一
问题:
- 每个AI系统都有自己的能力描述方式
- 没有统一的标准
- 难以比较不同系统的能力
- 难以发现和复用能力
示例:
python
# 系统A的能力描述
{
"name": "text_generation",
"description": "Generate text",
"parameters": {
"prompt": "string",
"max_tokens": "integer"
}
}
# 系统B的能力描述
{
"capability": "generate",
"type": "text",
"inputs": {
"prompt": "text",
"length": "number"
}
}
# 描述方式不统一,难以比较和复用1.1.2 能力发现困难
问题:
- 没有统一的能力注册机制
- 难以发现可用的能力
- 难以理解能力的用途
- 难以评估能力的质量
1.1.3 能力集成复杂
问题:
- 每个能力都有不同的接口
- 集成成本高
- 维护困难
- 难以扩展
1.2 Skills的诞生
2025年:Anthropic发布Skills标准
核心思想:
- 文档驱动开发(Documentation-Driven Development)
- 标准化能力描述
- 简化能力发现和集成
- 促进能力生态发展
目标:
- 统一能力描述标准
- 简化能力发现
- 降低集成成本
- 促进能力复用
2. Skills标准详解
2.1 Skills的核心概念
2.1.1 定义
Skill(技能):一个标准化的AI能力描述,包含能力的目的、输入输出、使用方法等信息。
2.1.2 核心特性
文档驱动:
- 能力描述本身就是文档
- 文档即代码
- 自动生成文档
标准化:
- 统一的描述格式
- 统一的命名规范
- 统一的接口设计
可发现:
- 能力注册
- 能力搜索
- 能力推荐
可组合:
- 能力可以组合
- 能力可以嵌套
- 能力可以复用
2.2 Skills的架构
2.2.1 整体架构
┌─────────────────────────────────────────────────┐
│ Skill Registry │
│ (技能注册中心) │
└────────────────┬────────────────────────────┘
│
│ Discover
│
┌────────────────▼────────────────────────────┐
│ Skill Consumer │
│ (技能消费者) │
│ ┌──────────────────────────────────┐ │
│ │ Skill Discovery │ │
│ │ - Search │ │
│ │ - Filter │ │
│ │ - Recommend │ │
│ └──────────────────────────────────┘ │
│ ┌──────────────────────────────────┐ │
│ │ Skill Integration │ │
│ │ - Load │ │
│ │ - Configure │ │
│ │ - Execute │ │
│ └──────────────────────────────────┘ │
└──────────────────────────────────────────┘
│
│ Use
│
┌────────────────▼────────────────────────────┐
│ Skill Provider │
│ (技能提供者) │
│ ┌──────────────────────────────────┐ │
│ │ Skill Definition │ │
│ │ - Documentation │ │
│ │ - Schema │ │
│ │ - Examples │ │
│ └──────────────────────────────────┘ │
│ ┌──────────────────────────────────┐ │
│ │ Skill Implementation │ │
│ │ - Code │ │
│ │ - Tests │ │
│ │ - Deployment │ │
│ └──────────────────────────────────┘ │
└──────────────────────────────────────────┘2.2.2 Skill定义结构
基本信息:
json
{
"name": "text_summarization",
"version": "1.0.0",
"description": "Summarize text into a concise version",
"author": "anthropic",
"license": "MIT"
}能力描述:
json
{
"capability": {
"purpose": "Generate a concise summary of the input text",
"input": {
"type": "object",
"properties": {
"text": {
"type": "string",
"description": "The text to summarize"
},
"max_length": {
"type": "integer",
"description": "Maximum length of the summary",
"default": 100
}
},
"required": ["text"]
},
"output": {
"type": "object",
"properties": {
"summary": {
"type": "string",
"description": "The generated summary"
},
"original_length": {
"type": "integer",
"description": "Length of the original text"
},
"summary_length": {
"type": "integer",
"description": "Length of the summary"
}
}
}
}
}使用方法:
json
{
"usage": {
"examples": [
{
"input": {
"text": "Artificial intelligence (AI) is intelligence demonstrated by machines, as opposed to the natural intelligence displayed by humans or animals.",
"max_length": 50
},
"output": {
"summary": "AI is machine intelligence, distinct from natural intelligence.",
"original_length": 132,
"summary_length": 47
}
}
],
"best_practices": [
"Provide clear and well-structured input text",
"Adjust max_length based on desired summary length",
"Use for summarizing articles, reports, and other long-form content"
],
"limitations": [
"May miss important details in very long texts",
"May not preserve the original tone",
"May not handle technical jargon well"
]
}
}实现信息:
json
{
"implementation": {
"type": "llm",
"model": "claude-3-opus",
"parameters": {
"temperature": 0.7,
"max_tokens": 200
},
"dependencies": [
"anthropic-sdk>=1.0.0"
],
"performance": {
"latency": "500ms",
"throughput": "10 requests/second"
}
}
}2.3 Skills与MCP的关系
2.3.1 MCP是传输协议
MCP定义了AI Agent与外部系统之间的通信协议。
2.3.2 Skills是能力描述
Skills定义了AI能力的标准化描述。
2.3.3 两者结合
┌─────────────────────────────────────────────────┐
│ AI Agent │
└────────────────┬────────────────────────────┘
│
│ MCP Protocol (传输)
│
┌────────────────▼────────────────────────────┐
│ MCP Server │
│ ┌──────────────────────────────────┐ │
│ │ Tools (MCP工具) │ │
│ │ - text_summarization │ │
│ │ - code_generation │ │
│ │ - data_analysis │ │
│ └──────────────────────────────────┘ │
└────────────────┬────────────────────────────┘
│
│ Skills Standard (描述)
│
┌────────────────▼────────────────────────────┐
│ Skill Definitions │
│ ┌──────────────────────────────────┐ │
│ │ text_summarization.skill │ │
│ │ - Documentation │ │
│ │ - Schema │ │
│ │ - Examples │ │
│ └──────────────────────────────────┘ │
│ ┌──────────────────────────────────┐ │
│ │ code_generation.skill │ │
│ │ - Documentation │ │
│ │ - Schema │ │
│ │ - Examples │ │
│ └──────────────────────────────────┘ │
└──────────────────────────────────────────┘2.3.4 实际应用
MCP Server使用Skills:
python
from mcp.server import Server
from skills import SkillLoader
# 加载Skills
skill_loader = SkillLoader()
text_summarization_skill = skill_loader.load("text_summarization.skill")
# 创建MCP Server
server = Server(
name="skills-server",
version="1.0.0"
)
# 从Skill定义创建MCP工具
@server.list_tools()
async def list_tools() -> list[Tool]:
return [
Tool(
name=text_summarization_skill.name,
description=text_summarization_skill.description,
inputSchema=text_summarization_skill.input_schema
)
]
# 实现工具
@server.call_tool()
async def call_tool(name: str, arguments: dict) -> str:
if name == text_summarization_skill.name:
# 使用Skill实现
result = text_summarization_skill.execute(**arguments)
return result3. Skills开发
3.1 Skill定义
3.1.1 创建Skill文件
文件结构:
skills/
├── text_summarization/
│ ├── skill.yaml # Skill定义
│ ├── implementation.py # 实现
│ ├── tests/ # 测试
│ │ └── test_skill.py
│ └── examples/ # 示例
│ └── example1.jsonskill.yaml:
yaml
name: text_summarization
version: 1.0.0
description: Summarize text into a concise version
author: anthropic
license: MIT
capability:
purpose: Generate a concise summary of the input text
input:
type: object
properties:
text:
type: string
description: The text to summarize
max_length:
type: integer
description: Maximum length of the summary
default: 100
required:
- text
output:
type: object
properties:
summary:
type: string
description: The generated summary
original_length:
type: integer
description: Length of the original text
summary_length:
type: integer
description: Length of the summary
usage:
examples:
- input:
text: "Artificial intelligence (AI) is intelligence demonstrated by machines, as opposed to the natural intelligence displayed by humans or animals."
max_length: 50
output:
summary: "AI is machine intelligence, distinct from natural intelligence."
original_length: 132
summary_length: 47
best_practices:
- Provide clear and well-structured input text
- Adjust max_length based on desired summary length
- Use for summarizing articles, reports, and other long-form content
limitations:
- May miss important details in very long texts
- May not preserve the original tone
- May not handle technical jargon well
implementation:
type: llm
model: claude-3-opus
parameters:
temperature: 0.7
max_tokens: 200
dependencies:
- anthropic-sdk>=1.0.0
performance:
latency: 500ms
throughput: 10 requests/second3.1.2 实现Skill
implementation.py:
python
from anthropic import Anthropic
from typing import Dict, Any
class TextSummarizationSkill:
def __init__(self, api_key: str):
self.client = Anthropic(api_key=api_key)
self.model = "claude-3-opus-20240229"
def execute(self, text: str, max_length: int = 100) -> Dict[str, Any]:
"""执行文本摘要"""
# 构建Prompt
prompt = f"""Please summarize the following text in at most {max_length} characters:
{text}
Summary:"""
# 调用Claude API
message = self.client.messages.create(
model=self.model,
max_tokens=200,
messages=[
{
"role": "user",
"content": prompt
}
]
)
# 提取摘要
summary = message.content[0].text
# 返回结果
return {
"summary": summary,
"original_length": len(text),
"summary_length": len(summary)
}3.1.3 测试Skill
tests/test_skill.py:
python
import pytest
from text_summarization.implementation import TextSummarizationSkill
@pytest.fixture
def skill():
return TextSummarizationSkill(api_key="test-api-key")
def test_summarization(skill):
"""测试文本摘要"""
text = "Artificial intelligence (AI) is intelligence demonstrated by machines, as opposed to the natural intelligence displayed by humans or animals."
result = skill.execute(text, max_length=50)
assert "summary" in result
assert "original_length" in result
assert "summary_length" in result
assert result["original_length"] == len(text)
assert result["summary_length"] <= 50
def test_summarization_with_long_text(skill):
"""测试长文本摘要"""
text = "A" * 1000
result = skill.execute(text, max_length=100)
assert result["summary_length"] <= 1003.2 Skill注册
3.2.1 注册到Skill Registry
python
from skills import SkillRegistry
# 创建Registry
registry = SkillRegistry()
# 注册Skill
registry.register(
name="text_summarization",
version="1.0.0",
skill_file="skills/text_summarization/skill.yaml",
implementation="skills/text_summarization/implementation.py"
)
# 搜索Skill
skills = registry.search("summarization")
for skill in skills:
print(f"Found skill: {skill.name} - {skill.description}")3.2.2 发布到公共Registry
python
from skills import SkillPublisher
# 创建Publisher
publisher = SkillPublisher(
registry_url="https://skills.anthropic.com"
)
# 发布Skill
publisher.publish(
skill_file="skills/text_summarization/skill.yaml",
implementation="skills/text_summarization/implementation.py",
tests="skills/text_summarization/tests/"
)4. Skills应用
4.1 AI Agent集成
4.1.1 Agent使用Skills
python
from skills import SkillLoader
from mcp.server import Server
# 加载Skills
skill_loader = SkillLoader()
skills = skill_loader.load_all("skills/")
# 创建Agent
agent = Agent(
name="my-agent",
skills=skills
)
# 使用Skill
result = agent.use_skill(
skill_name="text_summarization",
arguments={
"text": "Long text here...",
"max_length": 100
}
)4.1.2 动态加载Skills
python
from skills import SkillLoader
# 动态加载Skill
skill_loader = SkillLoader()
# 发现新Skill
new_skill = skill_loader.discover("https://skills.anthropic.com/text_summarization")
# 加载Skill
skill_loader.load(new_skill)
# 使用Skill
result = skill_loader.execute("text_summarization", {
"text": "Long text here...",
"max_length": 100
})4.2 技能组合
4.2.1 顺序组合
python
from skills import SkillComposer
# 创建Composer
composer = SkillComposer()
# 定义工作流
workflow = composer.sequence([
("text_summarization", {"max_length": 100}),
("sentiment_analysis", {}),
("text_generation", {"prompt": "Based on the summary and sentiment, generate a response"})
])
# 执行工作流
result = workflow.execute({
"text": "Long text here..."
})4.2.2 并行组合
python
# 定义并行工作流
workflow = composer.parallel([
("text_summarization", {"max_length": 100}),
("keyword_extraction", {}),
("entity_recognition", {})
])
# 执行工作流
result = workflow.execute({
"text": "Long text here..."
})4.2.3 条件组合
python
# 定义条件工作流
workflow = composer.conditional(
condition="sentiment_analysis.sentiment == 'positive'",
if_true=("text_generation", {"prompt": "Generate a positive response"}),
if_false=("text_generation", {"prompt": "Generate a neutral response"})
)
# 执行工作流
result = workflow.execute({
"text": "Long text here..."
})4.3 技能推荐
4.3.1 基于需求的推荐
python
from skills import SkillRecommender
# 创建Recommender
recommender = SkillRecommender()
# 获取推荐
recommendations = recommender.recommend(
task="Summarize a long article",
context={
"input_type": "text",
"output_type": "text",
"length": "short"
}
)
for skill in recommendations:
print(f"Recommended skill: {skill.name}")
print(f" Description: {skill.description}")
print(f" Score: {skill.score}")4.3.2 基于历史的推荐
python
# 基于使用历史的推荐
recommendations = recommender.recommend_by_history(
user_id="user123",
recent_skills=["text_summarization", "sentiment_analysis"]
)
for skill in recommendations:
print(f"Recommended skill: {skill.name}")
print(f" Reason: {skill.reason}")5. Skills最佳实践
5.1 Skill设计
5.1.1 单一职责
每个Skill应该只做一件事。
好的设计:
yaml
name: text_summarization
description: Summarize text不好的设计:
yaml
name: text_summarization_and_sentiment_analysis
description: Summarize text and analyze sentiment5.1.2 清晰的命名
使用清晰、描述性的名称。
好的命名:
text_summarizationsentiment_analysisentity_recognition
不好的命名:
process_textanalyzedo_something
5.1.3 完整的文档
提供完整的文档,包括:
- Purpose(目的)
- Input(输入)
- Output(输出)
- Examples(示例)
- Best Practices(最佳实践)
- Limitations(限制)
5.2 Skill实现
5.2.1 错误处理
python
class TextSummarizationSkill:
def execute(self, text: str, max_length: int = 100) -> Dict[str, Any]:
try:
# 验证输入
if not text:
raise ValueError("Text cannot be empty")
if max_length <= 0:
raise ValueError("Max length must be positive")
# 执行摘要
summary = self._summarize(text, max_length)
# 返回结果
return {
"summary": summary,
"original_length": len(text),
"summary_length": len(summary)
}
except ValueError as e:
return {
"error": str(e),
"error_type": "validation_error"
}
except Exception as e:
return {
"error": str(e),
"error_type": "execution_error"
}5.2.2 性能优化
python
from functools import lru_cache
class TextSummarizationSkill:
@lru_cache(maxsize=100)
def execute(self, text: str, max_length: int = 100) -> Dict[str, Any]:
# 使用缓存提高性能
pass5.2.3 测试覆盖
python
import pytest
class TestTextSummarizationSkill:
def test_normal_case(self):
"""测试正常情况"""
pass
def test_empty_text(self):
"""测试空文本"""
pass
def test_invalid_max_length(self):
"""测试无效的max_length"""
pass
def test_long_text(self):
"""测试长文本"""
pass5.3 Skill发布
5.3.1 版本管理
使用语义化版本号。
版本号格式:MAJOR.MINOR.PATCH
MAJOR:不兼容的API变更MINOR:向后兼容的功能新增PATCH:向后兼容的问题修复
5.3.2 文档生成
自动生成文档。
python
from skills import DocumentationGenerator
# 生成文档
generator = DocumentationGenerator()
generator.generate(
skill_file="skills/text_summarization/skill.yaml",
output="docs/text_summarization.md"
)5.3.3 持续集成
设置CI/CD流程。
yaml
# .github/workflows/skill-ci.yml
name: Skill CI
on:
push:
paths:
- 'skills/text_summarization/**'
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Install dependencies
run: |
pip install -r requirements.txt
- name: Run tests
run: |
pytest skills/text_summarization/tests/实践任务
任务1:创建一个Skill
目标:创建一个文本分类Skill。
要求:
- 定义Skill
- 实现Skill
- 编写测试
- 编写文档
- 注册Skill
代码框架:
yaml
# skill.yaml
name: text_classification
version: 1.0.0
description: Classify text into predefined categories
author: your-name
license: MIT
capability:
purpose: Classify text into predefined categories
input:
type: object
properties:
text:
type: string
description: The text to classify
categories:
type: array
description: The predefined categories
default: ["positive", "negative", "neutral"]
required:
- text
output:
type: object
properties:
category:
type: string
description: The predicted category
confidence:
type: number
description: The confidence score任务2:组合多个Skills
目标:创建一个工作流,组合多个Skills。
要求:
- 选择多个相关Skills
- 设计工作流
- 实现工作流
- 测试工作流
- 优化性能
代码框架:
python
from skills import SkillComposer
# 创建Composer
composer = SkillComposer()
# 定义工作流
workflow = composer.sequence([
("text_classification", {}),
("sentiment_analysis", {}),
("text_generation", {})
])
# 执行工作流
result = workflow.execute({
"text": "This is a great product!"
})任务3:实现Skill推荐系统
目标:实现一个基于需求的Skill推荐系统。
要求:
- 定义推荐算法
- 实现推荐系统
- 测试推荐效果
- 优化推荐算法
- 评估推荐质量
代码框架:
python
from skills import SkillRecommender
# 创建Recommender
recommender = SkillRecommender()
# 获取推荐
recommendations = recommender.recommend(
task="Analyze customer reviews",
context={
"input_type": "text",
"output_type": "analysis"
}
)
# 显示推荐
for skill in recommendations:
print(f"Recommended: {skill.name}")
print(f" Score: {skill.score}")
print(f" Reason: {skill.reason}")课后作业
作业1:Skill开发
题目:开发一个特定领域的Skill。
要求:
- 选择一个领域(如代码生成、数据分析等)
- 设计Skill
- 实现Skill
- 编写测试
- 发布Skill
作业2:Skill组合
题目:创建一个复杂的Skill组合。
要求:
- 选择多个相关Skills
- 设计复杂工作流
- 实现工作流
- 测试工作流
- 优化性能
作业3:Skill生态调研
题目:调研Skills生态。
要求:
- 调研现有的Skills
- 分析Skills的功能和特点
- 比较不同Skills的优劣
- 撰写2000字调研报告
参考资料
必读文献
Anthropic (2025). "Skills Standard Specification".
- Skills标准规范
Anthropic (2025). "Skills Development Guide".
- Skills开发指南
Anthropic (2025). "Skills Best Practices".
- Skills最佳实践
推荐阅读
Documentation-Driven Development: https://www.documentationdriven.com/
- 文档驱动开发
API Design Patterns: https://api-patterns.com/
- API设计模式
在线资源
Skills GitHub: https://github.com/anthropics/skills
- Skills GitHub仓库
Skills Registry: https://skills.anthropic.com
- Skills注册中心
Skills Examples: https://github.com/anthropics/skills-examples
- Skills示例
扩展阅读
Skills前沿
Anthropic (2025). "Skills 2.0 Roadmap".
- Skills 2.0路线图
Community (2025). "Skills Use Cases".
- Skills用例
标准化
OpenAPI Specification: https://swagger.io/specification/
- OpenAPI规范
JSON Schema: https://json-schema.org/
- JSON Schema
下节预告
下一节我们将学习AI Agent爆发元年(2025),了解2025年AI Agent的爆发式发展,从"助手"到"操盘手"的质变,以及AI Agent在各行业的应用和未来趋势。

扫描二维码关注"架构师AI杜"公众号,获取更多技术内容和最新动态
