<!DOCTYPE html><html lang="zh-CN"><head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Anthropic SKILL 深度研究报告 - 专家级AI能力扩展革命</title>
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- Google Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com"/>
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin=""/>
<link href="https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet"/>
<!-- Font Awesome -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"/>
<!-- Chart.js -->
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<!-- Mermaid -->
<script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
<style>
:root {
--primary: #1a1a1a;
--secondary: #f5f5f5;
--accent: #c7b299;
--text: #2d2d2d;
--muted: #6b7280;
--border: #e5e7eb;
}
body {
font-family: 'Inter', sans-serif;
color: var(--text);
background: linear-gradient(135deg, #fafafa 0%, #f5f5f5 100%);
overflow-x: hidden;
}
.font-serif {
font-family: 'Playfair Display', serif;
}
.hero-gradient {
background: linear-gradient(135deg,
rgba(26, 26, 26, 0.9) 0%,
rgba(45, 45, 45, 0.8) 50%,
rgba(199, 178, 153, 0.3) 100%);
}
.accent-line {
background: linear-gradient(90deg, var(--accent) 0%, transparent 100%);
height: 1px;
}
.toc-fixed {
position: fixed;
top: 2rem;
left: 2rem;
width: 280px;
max-height: calc(100vh - 4rem);
overflow-y: auto;
z-index: 50;
backdrop-filter: blur(10px);
background: rgba(255, 255, 255, 0.95);
border: 1px solid var(--border);
}
.main-content {
margin-left: 320px;
max-width: calc(100vw - 360px);
}
.citation-link {
color: var(--accent);
text-decoration: none;
font-weight: 500;
cursor: pointer;
}
.citation-link:hover {
text-decoration: underline;
}
.bento-grid {
display: grid;
grid-template-columns: 2fr 1fr;
grid-template-rows: auto auto;
gap: 1.5rem;
height: 60vh;
}
.bento-main {
grid-row: 1 / -1;
position: relative;
overflow: hidden;
}
.bento-side {
display: flex;
flex-direction: column;
gap: 1.5rem;
}
.hero-image {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
object-fit: cover;
opacity: 0.3;
}
.section-divider {
height: 1px;
background: linear-gradient(90deg, transparent 0%, var(--accent) 50%, transparent 100%);
margin: 4rem 0;
}
<span class="mention-invalid">@media</span> (max-width: 1024px) {
.toc-fixed {
position: fixed;
top: 0;
left: 0;
width: 280px;
height: 100vh;
z-index: 100;
transform: translateX(-100%);
transition: transform 0.3s ease;
}
.toc-fixed.active {
transform: translateX(0);
}
.main-content {
margin-left: 0;
max-width: 100%;
}
.bento-grid {
grid-template-columns: 1fr;
height: auto;
}
}
/* Responsive adjustments for small screens */
<span class="mention-invalid">@media</span> (max-width: 768px) {
.bento-main h1 {
font-size: 2.25rem;
line-height: 2.5rem;
}
.bento-main p.text-xl {
font-size: 1.125rem;
line-height: 1.75rem;
}
.bento-grid {
gap: 1rem;
}
.main-content {
padding-left: 1rem;
padding-right: 1rem;
}
}
.mermaid-container {
display: flex;
justify-content: center;
min-height: 300px;
max-height: 800px;
background: #ffffff;
border: 2px solid #e5e7eb;
border-radius: 12px;
padding: 30px;
margin: 30px 0;
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
position: relative;
overflow: hidden;
}
.mermaid-container .mermaid {
width: 100%;
max-width: 100%;
height: 100%;
cursor: grab;
transition: transform 0.3s ease;
transform-origin: center center;
display: flex;
justify-content: center;
align-items: center;
touch-action: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.mermaid-container .mermaid svg {
max-width: 100%;
height: 100%;
display: block;
margin: 0 auto;
}
.mermaid-container .mermaid:active {
cursor: grabbing;
}
.mermaid-container.zoomed .mermaid {
height: 100%;
width: 100%;
cursor: grab;
}
.mermaid-controls {
position: absolute;
top: 15px;
right: 15px;
display: flex;
gap: 10px;
z-index: 20;
background: rgba(255, 255, 255, 0.95);
padding: 8px;
border-radius: 8px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.mermaid-control-btn {
background: #ffffff;
border: 1px solid #d1d5db;
border-radius: 6px;
padding: 10px;
cursor: pointer;
transition: all 0.2s ease;
color: #374151;
font-size: 14px;
min-width: 36px;
height: 36px;
text-align: center;
display: flex;
align-items: center;
justify-content: center;
}
.mermaid-control-btn:hover {
background: #f8fafc;
border-color: #3b82f6;
color: #3b82f6;
transform: translateY(-1px);
}
.mermaid-control-btn:active {
transform: scale(0.95);
}
/* Ensure mermaid text has good contrast */
.mermaid .node rect,
.mermaid .node circle,
.mermaid .node ellipse,
.mermaid .node polygon {
stroke: var(--primary) !important;
stroke-width: 2px !important;
fill: #ffffff !important;
}
.mermaid .node .label {
color: var(--text) !important;
font-weight: 500 !important;
font-size: 14px !important;
}
.mermaid .edgePath .path {
stroke: var(--muted) !important;
stroke-width: 2px !important;
}
.mermaid .edgeLabel {
background-color: rgba(255, 255, 255, 0.9) !important;
color: var(--text) !important;
font-weight: 500 !important;
}
</style>
<base target="_blank">
</head>
<body>
<!-- Toggle button for small screens -->
<button id="toc-toggle" class="lg:hidden fixed top-4 left-4 z-50 bg-white/90 backdrop-blur-sm p-2 rounded-lg shadow-md">
<i class="fas fa-bars"></i>
</button>
<!-- Fixed Table of Contents -->
<nav id="toc" class="toc-fixed rounded-lg shadow-xl p-6 hidden lg:block">
<div class="flex justify-between items-center mb-4">
<h3 class="font-serif font-bold text-lg text-gray-800">目录导航</h3>
<button id="toc-close" class="lg:hidden text-gray-500 hover:text-gray-700">
<i class="fas fa-times"></i>
</button>
</div>
<ul class="space-y-2 text-sm">
<li>
<a href="#hero" class="block py-1 text-gray-600 hover:text-gray-900 transition-colors">概述</a>
</li>
<li>
<a href="#technical-details" class="block py-1 text-gray-600 hover:text-gray-900 transition-colors">1. 技术实现细节</a>
<ul class="ml-3 mt-1 space-y-1">
<li>
<a href="#architecture" class="block py-1 text-gray-500 hover:text-gray-700 transition-colors">1.1 核心架构设计</a>
</li>
<li>
<a href="#loading-architecture" class="block py-1 text-gray-500 hover:text-gray-700 transition-colors">1.2 三级加载架构</a>
</li>
<li>
<a href="#api-analysis" class="block py-1 text-gray-500 hover:text-gray-700 transition-colors">1.3 API接口分析</a>
</li>
</ul>
</li>
<li>
<a href="#applications" class="block py-1 text-gray-600 hover:text-gray-900 transition-colors">2. 应用场景与案例</a>
<ul class="ml-3 mt-1 space-y-1">
<li>
<a href="#enterprise-applications" class="block py-1 text-gray-500 hover:text-gray-700 transition-colors">2.1 企业级应用</a>
</li>
<li>
<a href="#case-studies" class="block py-1 text-gray-500 hover:text-gray-700 transition-colors">2.2 具体案例分析</a>
</li>
<li>
<a href="#ecosystem" class="block py-1 text-gray-500 hover:text-gray-700 transition-colors">2.3 生态系统</a>
</li>
</ul>
</li>
<li>
<a href="#comparison" class="block py-1 text-gray-600 hover:text-gray-900 transition-colors">3. 技术比较分析</a>
<ul class="ml-3 mt-1 space-y-1">
<li>
<a href="#vs-openai" class="block py-1 text-gray-500 hover:text-gray-700 transition-colors">3.1 与OpenAI对比</a>
</li>
<li>
<a href="#vs-other-tech" class="block py-1 text-gray-500 hover:text-gray-700 transition-colors">3.2 与其他技术对比</a>
</li>
<li>
<a href="#mcp-relationship" class="block py-1 text-gray-500 hover:text-gray-700 transition-colors">3.3 与MCP关系</a>
</li>
</ul>
</li>
<li>
<a href="#development" class="block py-1 text-gray-600 hover:text-gray-900 transition-colors">4. 开发指南与实践</a>
<ul class="ml-3 mt-1 space-y-1">
<li>
<a href="#getting-started" class="block py-1 text-gray-500 hover:text-gray-700 transition-colors">4.1 开发入门</a>
</li>
<li>
<a href="#custom-development" class="block py-1 text-gray-500 hover:text-gray-700 transition-colors">4.2 自定义开发</a>
</li>
<li>
<a href="#best-practices" class="block py-1 text-gray-500 hover:text-gray-700 transition-colors">4.3 最佳实践</a>
</li>
</ul>
</li>
</ul>
</nav>
<!-- Main Content -->
<main class="main-content px-8 py-12">
<!-- Side Elements -->
<div class="bento-side">
<div class="bg-white rounded-xl p-6 shadow-md border border-gray-200 flex-1">
<h3 class="font-serif font-bold text-lg mb-3 text-gray-800">核心技术突破</h3>
<div class="space-y-3">
<div class="flex items-start">
<div class="w-2 h-2 bg-amber-500 rounded-full mt-2 mr-3 flex-shrink-0"></div>
<div>
<div class="font-medium text-sm text-gray-800">渐进式信息披露</div>
<div class="text-xs text-gray-600">三级加载架构优化Token消耗</div>
</div>
</div>
<div class="flex items-start">
<div class="w-2 h-2 bg-amber-500 rounded-full mt-2 mr-3 flex-shrink-0"></div>
<div>
<div class="font-medium text-sm text-gray-800">文件系统模块化</div>
<div class="text-xs text-gray-600">基于文件夹的能力封装</div>
</div>
</div>
<div class="flex items-start">
<div class="w-2 h-2 bg-amber-500 rounded-full mt-2 mr-3 flex-shrink-0"></div>
<div>
<div class="font-medium text-sm text-gray-800">开放生态系统</div>
<div class="text-xs text-gray-600">企业级协作与知识管理</div>
</div>
</div>
</div>
</div>
<div class="bg-gradient-to-br from-amber-50 to-orange-50 rounded-xl p-6 border border-amber-200 flex-1">
<h3 class="font-serif font-bold text-lg mb-3 text-gray-800">关键优势</h3>
<div class="grid grid-cols-2 gap-3 text-sm">
<div class="text-center">
<div class="text-2xl font-bold text-amber-600">100</div>
<div class="text-gray-600">Tokens元数据</div>
</div>
<div class="text-center">
<div class="text-2xl font-bold text-amber-600">5000</div>
<div class="text-gray-600">Tokens指令上限</div>
</div>
</div>
</div>
</div>
</div>
<!-- Key Highlights -->
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
<div class="bg-white rounded-lg p-6 shadow-sm border border-gray-200">
<div class="w-12 h-12 bg-blue-100 rounded-lg flex items-center justify-center mb-4">
<i class="fas fa-microchip text-blue-600 text-xl"></i>
</div>
<h3 class="font-bold text-lg mb-2">技术架构</h3>
<p class="text-gray-600 text-sm">基于文件系统的模块化设计,将专业知识封装为可复用的技能包</p>
</div>
<div class="bg-white rounded-lg p-6 shadow-sm border border-gray-200">
<div class="w-12 h-12 bg-green-100 rounded-lg flex items-center justify-center mb-4">
<i class="fas fa-chart-line text-green-600 text-xl"></i>
</div>
<h3 class="font-bold text-lg mb-2">性能优化</h3>
<p class="text-gray-600 text-sm">渐进式信息披露机制显著降低Token消耗,提升运行效率</p>
</div>
<div class="bg-white rounded-lg p-6 shadow-sm border border-gray-200">
<div class="w-12 h-12 bg-purple-100 rounded-lg flex items-center justify-center mb-4">
<i class="fas fa-building text-purple-600 text-xl"></i>
</div>
<h3 class="font-bold text-lg mb-2">企业价值</h3>
<p class="text-gray-600 text-sm">实现内部流程自动化,封装隐性知识,提升组织效率</p>
</div>
</div>
</section>
<!-- Technical Details Section -->
<section id="technical-details" class="mb-16">
<div class="section-divider"></div>
<h2 class="font-serif text-4xl font-bold mb-8 text-gray-800">1. 技术实现细节</h2>
<div id="architecture" class="mb-12">
<h3 class="font-serif text-2xl font-semibold mb-6 text-gray-800">1.1 核心架构设计:基于文件系统的模块化能力</h3>
<div class="bg-white rounded-xl p-8 shadow-sm border border-gray-200 mb-6">
<p class="text-gray-700 leading-relaxed mb-4">
Anthropic的SKILL(Agent Skills)系统是一种创新的、基于文件系统的模块化能力框架,旨在将Claude从一个通用的对话式AI转变为一个具备特定领域专业知识的"专家智能体"<a href="#ref-231" class="citation-link">[231]</a>。该架构的核心理念在于将复杂的任务指令、可执行脚本和相关资源打包成一个独立的、可复用的单元,即"技能"(Skill)。
</p>
<blockquote class="border-l-4 border-amber-500 pl-6 py-4 bg-amber-50 rounded-r-lg mb-6">
<p class="text-gray-700 italic">
"SKILL的本质是一个文件夹,其中包含了所有必要的组件,使其能够被Claude动态加载和执行。这种基于文件系统的实现方式,使得SKILL的管理和分发变得非常直观,类似于在操作系统中管理应用程序。"
</p>
</blockquote>
<h4 class="font-bold text-lg mb-4 text-gray-800">1.1.1 核心理念:从"通用智能体"到"专业化技能库"</h4>
<p class="text-gray-700 leading-relaxed mb-4">
SKILL系统的核心目标是解决通用大语言模型在专业领域任务中表现不佳的问题。虽然Claude等模型具备强大的自然语言理解和生成能力,但在处理需要特定流程、规范或工具使用的任务时,往往会出现"幻觉"或操作失误<a href="#ref-247" class="citation-link">[247]</a>。
</p>
<div class="bg-gray-50 rounded-lg p-6 mb-6">
<h5 class="font-semibold mb-3 text-gray-800">架构组成要素</h5>
<div class="grid grid-cols-3 gap-4">
<div class="text-center">
<div class="w-16 h-16 bg-blue-100 rounded-full flex items-center justify-center mx-auto mb-3">
<i class="fas fa-file-alt text-blue-600 text-xl"></i>
</div>
<h6 class="font-medium text-sm text-gray-800">SKILL.md</h6>
<p class="text-xs text-gray-600">核心配置文件和指令集</p>
</div>
<div class="text-center">
<div class="w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-3">
<i class="fas fa-code text-green-600 text-xl"></i>
</div>
<h6 class="font-medium text-sm text-gray-800">脚本文件</h6>
<p class="text-xs text-gray-600">可执行的操作脚本</p>
</div>
<div class="text-center">
<div class="w-16 h-16 bg-purple-100 rounded-full flex items-center justify-center mx-auto mb-3">
<i class="fas fa-folder text-purple-600 text-xl"></i>
</div>
<h6 class="font-medium text-sm text-gray-800">资源文件</h6>
<p class="text-xs text-gray-600">模板和辅助资源</p>
</div>
</div>
</div>
<h4 class="font-bold text-lg mb-4 text-gray-800">1.1.2 渐进式信息披露(Progressive Disclosure)机制</h4>
<p class="text-gray-700 leading-relaxed">
为了在保证功能强大的同时,最大限度地减少Token消耗和上下文窗口的压力,SKILL系统采用了一种名为"渐进式信息披露"的架构设计<a href="#ref-250" class="citation-link">[250]</a>。这种机制的核心思想是,Claude不会一次性加载所有可用的SKILL的全部内容,而是根据任务需求,分阶段、按需加载所需的信息。
</p>
</div>
</div>
<div id="loading-architecture" class="mb-12">
<h3 class="font-serif text-2xl font-semibold mb-6 text-gray-800">1.2 三级加载架构详解</h3>
<div class="bg-gradient-to-r from-blue-50 to-indigo-50 rounded-xl p-8 border border-blue-200 mb-6">
<h4 class="font-bold text-lg mb-4 text-gray-800">三级加载流程</h4>
<div class="mermaid-container">
<div class="mermaid-controls">
<button class="mermaid-control-btn zoom-in" title="放大">
<i class="fas fa-search-plus"></i>
</button>
<button class="mermaid-control-btn zoom-out" title="缩小">
<i class="fas fa-search-minus"></i>
</button>
<button class="mermaid-control-btn reset-zoom" title="重置">
<i class="fas fa-expand-arrows-alt"></i>
</button>
<button class="mermaid-control-btn fullscreen" title="全屏查看">
<i class="fas fa-expand"></i>
</button>
</div>
<div class="mermaid">
graph TD
A["用户请求"] --> B["第一级:元数据加载
<br/>100 Tokens"]
B --> C{"技能匹配判断"}
C -->|匹配| D["第二级:指令加载
<br/>≤5000 Tokens"]
C -->|不匹配| E["继续扫描"]
D --> F{"需要资源?"}
F -->|是| G["第三级:资源加载
<br/>按需加载"]
F -->|否| H["执行任务"]
G --> H
E --> I["使用默认能力"]
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
<div class="bg-white rounded-lg p-4 shadow-sm">
<div class="flex items-center mb-3">
<div class="w-8 h-8 bg-blue-500 text-white rounded-full flex items-center justify-center text-sm font-bold mr-3">1</div>
<h5 class="font-semibold text-gray-800">元数据加载</h5>
</div>
<p class="text-sm text-gray-600 mb-2">始终加载,约100 Tokens</p>
<p class="text-xs text-gray-500">加载SKILL的名称和描述,快速了解可用技能</p>
</div>
<div class="bg-white rounded-lg p-4 shadow-sm">
<div class="flex items-center mb-3">
<div class="w-8 h-8 bg-green-500 text-white rounded-full flex items-center justify-center text-sm font-bold mr-3">2</div>
<h5 class="font-semibold text-gray-800">指令加载</h5>
</div>
<p class="text-sm text-gray-600 mb-2">触发时加载,≤5000 Tokens</p>
<p class="text-xs text-gray-500">加载完整指令,获得执行任务的详细指导</p>
</div>
<div class="bg-white rounded-lg p-4 shadow-sm">
<div class="flex items-center mb-3">
<div class="w-8 h-8 bg-purple-500 text-white rounded-full flex items-center justify-center text-sm font-bold mr-3">3</div>
<h5 class="font-semibold text-gray-800">资源加载</h5>
</div>
<p class="text-sm text-gray-600 mb-2">按需加载,灵活高效</p>
<p class="text-xs text-gray-500">加载脚本、模板等执行所需的资源</p>
</div>
</div>
</div>
<p class="text-gray-700 leading-relaxed">
SKILL的渐进式信息披露机制通过三级加载架构实现,确保了系统的高效性和可扩展性。这种架构使得Claude能够在处理复杂任务时,动态地获取所需的信息,避免了将所有SKILL的完整内容都加载到上下文窗口中,从而有效管理Token消耗和提升响应速度<a href="#ref-250" class="citation-link">[250]</a>。
</p>
</div>
<div id="api-analysis" class="mb-12">
<h3 class="font-serif text-2xl font-semibold mb-6 text-gray-800">1.3 API 接口分析</h3>
<div class="bg-white rounded-xl p-8 shadow-sm border border-gray-200 mb-6">
<h4 class="font-bold text-lg mb-4 text-gray-800">1.3.1 核心端点:`/v1/skills`</h4>
<p class="text-gray-700 leading-relaxed mb-4">
Anthropic为SKILL系统提供了一套专门的API接口,使得开发者可以通过编程的方式创建、管理和使用自定义的SKILL。这些API接口目前处于Beta阶段,但已经提供了核心的CRUD(创建、读取、更新、删除)功能<a href="#ref-241" class="citation-link">[241]</a>。
</p>
<div class="bg-gray-900 text-green-400 p-6 rounded-lg mb-6 font-mono text-sm overflow-x-auto">
<div class="mb-4">
<span class="text-blue-400">POST</span> /v1/skills <span class="text-gray-400"># 创建新SKILL</span>
</div>
<div class="mb-4">
<span class="text-yellow-400">GET</span> /v1/skills <span class="text-gray-400"># 列出所有SKILL</span>
</div>
<div>
<span class="text-yellow-400">GET</span> /v1/skills/{id} <span class="text-gray-400"># 获取特定SKILL</span>
</div>
</div>
<h4 class="font-bold text-lg mb-4 text-gray-800">1.3.2 Python SDK 调用示例</h4>
<div class="bg-gray-900 text-gray-300 p-6 rounded-lg mb-4 font-mono text-sm overflow-x-auto">
<pre><code>import anthropic
client = anthropic.Anthropic()
# 列出 Anthropic 管理的 Skills
skills = client.beta.skills.list(
source="anthropic",
betas=["skills-2025-10-02"]
)
for skill in skills.data:
print(f"{skill.id}: {skill.display_title}")
# 在 Messages API 中使用 Skill
response = client.messages.create(
model="claude-3-5-sonnet-20241022",
messages=[{"role": "user", "content": "创建一个关于 Q4 销售数据的 Excel 表格"}],
container={
"skills": [
{
"type": "anthropic",
"skill_id": "xlsx",
"version": "latest"
}
]
}
)</code></pre>
</div>
<p class="text-gray-700 leading-relaxed text-sm">
示例代码展示了如何使用Python SDK列出所有Anthropic管理的预构建SKILL,以及如何在Messages API调用中指定使用特定的SKILL<a href="#ref-276" class="citation-link">[276]</a>
<a href="#ref-279" class="citation-link">[279]</a>。
</p>
</div>
</div>
</section>
<!-- Applications Section -->
<section id="applications" class="mb-16">
<div class="section-divider"></div>
<h2 class="font-serif text-4xl font-bold mb-8 text-gray-800">2. 应用场景与企业案例</h2>
<div id="enterprise-applications" class="mb-12">
<h3 class="font-serif text-2xl font-semibold mb-6 text-gray-800">2.1 企业级应用场景概览</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-8 mb-8">
<div class="bg-gradient-to-br from-blue-50 to-indigo-50 rounded-xl p-6 border border-blue-200">
<div class="flex items-center mb-4">
<i class="fas fa-briefcase text-blue-600 text-2xl mr-3"></i>
<h4 class="font-bold text-lg text-gray-800">金融、法律与会计领域</h4>
</div>
<p class="text-gray-700 mb-4">
在专业服务领域,SKILL的应用价值尤为突出。这些行业通常涉及大量标准化、结构化的文档处理和分析任务<a href="#ref-293" class="citation-link">[293]</a>。
</p>
<ul class="space-y-2 text-sm text-gray-600">
<li class="flex items-start">
<i class="fas fa-check-circle text-green-500 mt-1 mr-2 flex-shrink-0"></i>
<span>财务报告自动生成,符合会计准则</span>
</li>
<li class="flex items-start">
<i class="fas fa-check-circle text-green-500 mt-1 mr-2 flex-shrink-0"></i>
<span>法律合同审查,识别潜在风险点</span>
</li>
<li class="flex items-start">
<i class="fas fa-check-circle text-green-500 mt-1 mr-2 flex-shrink-0"></i>
<span>合规报告自动生成,满足监管要求</span>
</li>
</ul>
</div>
<div class="bg-gradient-to-br from-green-50 to-emerald-50 rounded-xl p-6 border border-green-200">
<div class="flex items-center mb-4">
<i class="fas fa-cogs text-green-600 text-2xl mr-3"></i>
<h4 class="font-bold text-lg text-gray-800">内部流程自动化</h4>
</div>
<p class="text-gray-700 mb-4">
SKILL是企业实现内部流程自动化和知识管理的理想工具<a href="#ref-292" class="citation-link">[292]</a>
<a href="#ref-334" class="citation-link">[334]</a>。
</p>
<ul class="space-y-2 text-sm text-gray-600">
<li class="flex items-start">
<i class="fas fa-check-circle text-green-500 mt-1 mr-2 flex-shrink-0"></i>
<span>周报生成、项目状态更新自动化</span>
</li>
<li class="flex items-start">
<i class="fas fa-check-circle text-green-500 mt-1 mr-2 flex-shrink-0"></i>
<span>隐性知识显性化,封装专家经验</span>
</li>
<li class="flex items-start">
<i class="fas fa-check-circle text-green-500 mt-1 mr-2 flex-shrink-0"></i>
<span>新员工培训成本降低</span>
</li>
</ul>
</div>
</div>
<div class="bg-gradient-to-r from-purple-50 to-pink-50 rounded-xl p-6 border border-purple-200">
<div class="flex items-center mb-4">
<i class="fas fa-code text-purple-600 text-2xl mr-3"></i>
<h4 class="font-bold text-lg text-gray-800">开发者生产力提升</h4>
</div>
<p class="text-gray-700 mb-4">
对于技术团队而言,SKILL可以显著提升开发效率和代码质量<a href="#ref-295" class="citation-link">[295]</a>
<a href="#ref-330" class="citation-link">[330]</a>。
</p>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<ul class="space-y-2 text-sm text-gray-600">
<li class="flex items-start">
<i class="fas fa-code-branch text-blue-500 mt-1 mr-2 flex-shrink-0"></i>
<span>代码审查助手,自动检查安全标准</span>
</li>
<li class="flex items-start">
<i class="fas fa-file-code text-blue-500 mt-1 mr-2 flex-shrink-0"></i>
<span>API文档自动生成</span>
</li>
</ul>
<ul class="space-y-2 text-sm text-gray-600">
<li class="flex items-start">
<i class="fas fa-magic text-blue-500 mt-1 mr-2 flex-shrink-0"></i>
<span>实时代码建议与优化</span>
</li>
<li class="flex items-start">
<i class="fas fa-sync-alt text-blue-500 mt-1 mr-2 flex-shrink-0"></i>
<span>自动化代码重构</span>
</li>
</ul>
</div>
</div>
</div>
<div id="case-studies" class="mb-12">
<h3 class="font-serif text-2xl font-semibold mb-6 text-gray-800">2.2 具体应用案例分析</h3>
<div class="space-y-8">
<div class="bg-white rounded-xl p-8 shadow-sm border border-gray-200">
<div class="flex items-center mb-6">
<div class="w-12 h-12 bg-blue-100 rounded-lg flex items-center justify-center mr-4">
<i class="fas fa-file-powerpoint text-blue-600 text-xl"></i>
</div>
<div>
<h4 class="font-bold text-lg text-gray-800">案例一:自动化生成专业文档</h4>
<p class="text-sm text-gray-600">PPT、PDF等文档的自动化生成</p>
</div>
</div>
<p class="text-gray-700 leading-relaxed mb-4">
这是SKILL最典型和成熟的应用之一。Anthropic官方提供的
<code class="bg-gray-100 px-2 py-1 rounded text-sm">pptx</code>、
<code class="bg-gray-100 px-2 py-1 rounded text-sm">docx</code>和
<code class="bg-gray-100 px-2 py-1 rounded text-sm">pdf</code>等预构建技能,已经能够处理复杂的文档生成任务<a href="#ref-300" class="citation-link">[300]</a>。
</p>
<div class="bg-gray-50 rounded-lg p-4 mb-4">
<h5 class="font-semibold mb-2 text-gray-800">应用场景示例</h5>
<ul class="space-y-1 text-sm text-gray-600">
<li>• 市场团队季度营销报告自动生成</li>
<li>• 销售数据可视化与PPT生成</li>
<li>• 品牌规范的自动应用与格式统一</li>
</ul>
</div>
<p class="text-gray-700 text-sm">
当团队成员需要生成报告时,只需向Claude提供原始数据,并指示其使用相应的SKILL。Claude会自动加载技能,执行其中的Python脚本来处理数据、生成图表,并最终填充到模板中,生成专业、美观且符合品牌规范的报告<a href="#ref-309" class="citation-link">[309]</a>。
</p>
</div>
<div class="bg-white rounded-xl p-8 shadow-sm border border-gray-200">
<div class="flex items-center mb-6">
<div class="w-12 h-12 bg-green-100 rounded-lg flex items-center justify-center mr-4">
<i class="fas fa-pen-fancy text-green-600 text-xl"></i>
</div>
<div>
<h4 class="font-bold text-lg text-gray-800">案例二:基于模板的批量内容生成</h4>
<p class="text-sm text-gray-600">多平台营销文案的批量生成</p>
</div>
</div>
<p class="text-gray-700 leading-relaxed mb-4">
内容创作是许多企业的重要需求,例如为不同产品生成营销文案、为多个渠道撰写社交媒体帖子等。通过SKILL,可以创建一个"产品文案生成器"<a href="#ref-292" class="citation-link">[292]</a>。
</p>
<div class="bg-gradient-to-r from-green-50 to-emerald-50 rounded-lg p-4 mb-4">
<h5 class="font-semibold mb-2 text-gray-800">核心功能</h5>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<h6 class="font-medium text-sm text-gray-700 mb-1">写作风格定义</h6>
<p class="text-xs text-gray-600">目标受众、关键信息点、SEO关键词</p>
</div>
<div>
<h6 class="font-medium text-sm text-gray-700 mb-1">多平台模板</h6>
<p class="text-xs text-gray-600">微博、微信公众号、LinkedIn等平台适配</p>
</div>
</div>
</div>
<p class="text-gray-700 text-sm">
一个具体的例子是创建一个模仿特定公众号文风的技能,通过分析该公众号的历史文章,提取其写作风格、常用语气和结构,并将其封装在SKILL中,从而实现风格一致的内容批量产出。
</p>
</div>
<div class="bg-white rounded-xl p-8 shadow-sm border border-gray-200">
<div class="flex items-center mb-6">
<div class="w-12 h-12 bg-purple-100 rounded-lg flex items-center justify-center mr-4">
<i class="fas fa-chart-bar text-purple-600 text-xl"></i>
</div>
<div>
<h4 class="font-bold text-lg text-gray-800">案例三:企业级数据分析</h4>
<p class="text-sm text-gray-600">销售数据分析与洞察生成</p>
</div>
</div>
<p class="text-gray-700 leading-relaxed mb-4">
在企业内部,数据分析是驱动决策的关键。SKILL可以帮助非技术背景的业务人员也能进行复杂的数据分析<a href="#ref-315" class="citation-link">[315]</a>。
</p>
<div class="bg-purple-50 rounded-lg p-4 mb-4">
<h5 class="font-semibold mb-2 text-gray-800">分析流程自动化</h5>
<ul class="space-y-1 text-sm text-gray-600">
<li>• 关键绩效指标(KPIs)自动计算</li>
<li>• 销售趋势识别与预测</li>
<li>• 客户流失原因分析</li>
<li>• 可视化图表自动生成</li>
</ul>
</div>
<p class="text-gray-700 text-sm">
业务人员只需上传销售数据文件,并用自然语言描述他们的分析需求,Claude就会调用相应的SKILL,自动执行数据分析流程,并生成包含图表和洞察的Markdown或Excel报告。
</p>
</div>
</div>
</div>
<div id="ecosystem" class="mb-12">
<h3 class="font-serif text-2xl font-semibold mb-6 text-gray-800">2.3 SKILL 生态系统</h3>
<p class="text-gray-700 leading-relaxed mb-6">
Anthropic正在围绕SKILL构建一个开放的生态系统,这个生态系统由基础技能、第三方技能和企业内部技能共同构成,类似于移动应用生态中的操作系统、应用商店和开发者社区<a href="#ref-306" class="citation-link">[306]</a>。
</p>
<div class="mermaid-container mb-8">
<div class="mermaid-controls">
<button class="mermaid-control-btn zoom-in" title="放大">
<i class="fas fa-search-plus"></i>
</button>
<button class="mermaid-control-btn zoom-out" title="缩小">
<i class="fas fa-search-minus"></i>
</button>
<button class="mermaid-control-btn reset-zoom" title="重置">
<i class="fas fa-expand-arrows-alt"></i>
</button>
<button class="mermaid-control-btn fullscreen" title="全屏查看">
<i class="fas fa-expand"></i>
</button>
</div>
<div class="mermaid">
graph TB
A["SKILL 生态系统"] --> B["基础技能
<br/>Foundation Skills"]
A --> C["第三方技能
<br/>Third-party Skills"]
A --> D["企业内部技能
<br/>Enterprise Skills"]
B --> E["文档处理
<br/>pptx, docx, pdf"]
B --> F["数据分析
<br/>xlsx, csv"]
B --> G["品牌规范
<br/>guidelines"]
C --> H["Notion 集成"]
C --> I["Browserbase 集成"]
C --> J["其他第三方服务"]
D --> K["业务流程封装"]
D --> L["行业知识整合"]
D --> M["组织规范实施"]
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
<div class="bg-blue-50 rounded-xl p-6 border border-blue-200">
<div class="flex items-center mb-4">
<i class="fas fa-layer-group text-blue-600 text-xl mr-3"></i>
<h4 class="font-bold text-gray-800">基础技能</h4>
</div>
<p class="text-sm text-gray-600 mb-3">
Anthropic官方提供了一系列预构建的基础技能,作为生态系统的基石<a href="#ref-300" class="citation-link">[300]</a>
<a href="#ref-349" class="citation-link">[349]</a>。
</p>
<ul class="space-y-1 text-xs text-gray-500">
<li>• 文档处理:PPT、Word、Excel、PDF</li>
<li>• 品牌规范:确保内容一致性</li>
<li>• 创意与设计:算法艺术生成</li>
</ul>
</div>
<div class="bg-green-50 rounded-xl p-6 border border-green-200">
<div class="flex items-center mb-4">
<i class="fas fa-plug text-green-600 text-xl mr-3"></i>
<h4 class="font-bold text-gray-800">第三方技能</h4>
</div>
<p class="text-sm text-gray-600 mb-3">
第三方开发者和合作伙伴贡献的技能,集成特定软件和服务<a href="#ref-323" class="citation-link">[323]</a>。
</p>
<ul class="space-y-1 text-xs text-gray-500">
<li>• Notion Skills:增强协作能力</li>
<li>• 跨平台自动化工作流</li>
<li>• 第三方API集成</li>
</ul>
</div>
<div class="bg-purple-50 rounded-xl p-6 border border-purple-200">
<div class="flex items-center mb-4">
<i class="fas fa-building text-purple-600 text-xl mr-3"></i>
<h4 class="font-bold text-gray-800">企业内部技能</h4>
</div>
<p class="text-sm text-gray-600 mb-3">
企业自定义的SKILL,封装独特业务流程和行业知识。
</p>
<ul class="space-y-1 text-xs text-gray-500">
<li>• 专有分析框架</li>
<li>• 行业监管合规</li>
<li>• 核心竞争力沉淀</li>
</ul>
</div>
</div>
</div>
</section>
<!-- Comparison Section -->
<section id="comparison" class="mb-16">
<div class="section-divider"></div>
<h2 class="font-serif text-4xl font-bold mb-8 text-gray-800">3. 与其他技术的比较分析</h2>
<div id="vs-openai" class="mb-12">
<h3 class="font-serif text-2xl font-semibold mb-6 text-gray-800">3.1 与 OpenAI Assistants API 的对比</h3>
<p class="text-gray-700 leading-relaxed mb-6">
OpenAI的Assistants API和Anthropic的SKILL都旨在为AI模型提供更强大的工具和能力,但它们在实现方式和核心哲学上存在显著差异。
</p>
<div class="overflow-x-auto mb-6">
<table class="w-full bg-white rounded-xl shadow-sm border border-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-4 text-left font-semibold text-gray-800">特性</th>
<th class="px-6 py-4 text-left font-semibold text-gray-800">Anthropic Agent Skills</th>
<th class="px-6 py-4 text-left font-semibold text-gray-800">OpenAI Assistants API</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200">
<tr>
<td class="px-6 py-4 font-medium text-gray-800">模块化与可移植性</td>
<td class="px-6 py-4 text-green-600">
<i class="fas fa-check-circle mr-2"></i>
采用基于文件系统的模块化设计,SKILL是独立的、可移植的文件夹
</td>
<td class="px-6 py-4 text-yellow-600">
<i class="fas fa-exclamation-triangle mr-2"></i>
与OpenAI API紧密耦合,可移植性相对较差
</td>
</tr>
<tr class="bg-gray-50">
<td class="px-6 py-4 font-medium text-gray-800">上下文管理</td>
<td class="px-6 py-4 text-green-600">
<i class="fas fa-check-circle mr-2"></i>
<strong>渐进式披露</strong>:仅加载元数据,指令和工具按需加载
</td>
<td class="px-6 py-4 text-yellow-600">
<i class="fas fa-exclamation-triangle mr-2"></i>
<strong>持久化上下文</strong>:所有工具定义和相关上下文在每次调用时都会被加载
</td>
</tr>
<tr>
<td class="px-6 py-4 font-medium text-gray-800">代码执行</td>
<td class="px-6 py-4 text-green-600">
<i class="fas fa-check-circle mr-2"></i>
支持在沙盒环境中执行Python和Bash脚本
</td>
<td class="px-6 py-4 text-green-600">
<i class="fas fa-check-circle mr-2"></i>
提供Code Interpreter,但功能相对受限
</td>
</tr>
<tr class="bg-gray-50">
<td class="px-6 py-4 font-medium text-gray-800">状态管理</td>
<td class="px-6 py-4 text-red-600">
<i class="fas fa-times-circle mr-2"></i>
无跨会话状态持久化,每个会话都是独立的
</td>
<td class="px-6 py-4 text-green-600">
<i class="fas fa-check-circle mr-2"></i>
支持基于线程的对话状态持久化
</td>
</tr>
</tbody>
</table>
</div>
<div class="bg-blue-50 rounded-xl p-6 border border-blue-200">
<h4 class="font-bold text-lg mb-3 text-gray-800">核心差异分析</h4>
<div class="space-y-3 text-sm text-gray-700">
<div class="flex items-start">
<i class="fas fa-coins text-blue-600 mt-1 mr-3"></i>
<div>
<strong>Token效率</strong>:SKILL的渐进式加载机制在效率和成本方面具有巨大优势<a href="#ref-17" class="citation-link">[17]</a>
</div>
</div>
<div class="flex items-start">
<i class="fas fa-memory text-blue-600 mt-1 mr-3"></i>
<div>
<strong>状态持久化</strong>:OpenAI Assistants通过Thread机制提供长期记忆能力,而SKILL更适合独立任务
</div>
</div>
<div class="flex items-start">
<i class="fas fa-target text-blue-600 mt-1 mr-3"></i>
<div>
<strong>定位与哲学</strong>:SKILL侧重于"专家工具箱",强调模块化与效率;Assistants侧重于"对话伙伴",强调交互连贯性
</div>
</div>
</div>
</div>
</div>
<div id="vs-other-tech" class="mb-12">
<h3 class="font-serif text-2xl font-semibold mb-6 text-gray-800">3.2 与 Function Calling 和 Fine-tuning 的对比</h3>
<div class="overflow-x-auto mb-6">
<table class="w-full bg-white rounded-xl shadow-sm border border-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-4 text-left font-semibold text-gray-800">特性</th>
<th class="px-6 py-4 text-left font-semibold text-gray-800">Anthropic Agent Skills</th>
<th class="px-6 py-4 text-left font-semibold text-gray-800">Function Calling</th>
<th class="px-6 py-4 text-left font-semibold text-gray-800">Fine-tuning</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200">
<tr>
<td class="px-6 py-4 font-medium text-gray-800">知识注入方式</td>
<td class="px-6 py-4 text-sm">通过外部文件注入程序性知识和指令</td>
<td class="px-6 py-4 text-sm">通过API调用时传入的工具定义</td>
<td class="px-6 py-4 text-sm">通过在新数据集上重新训练模型</td>
</tr>
<tr class="bg-gray-50">
<td class="px-6 py-4 font-medium text-gray-800">模块化与灵活性</td>
<td class="px-6 py-4 text-green-600">
<i class="fas fa-check-circle text-sm mr-2"></i>
高度模块化,可组合多个SKILL
</td>
<td class="px-6 py-4 text-yellow-600">
<i class="fas fa-exclamation-triangle text-sm mr-2"></i>
工具独立,需要手动编排
</td>
<td class="px-6 py-4 text-red-600">
<i class="fas fa-times-circle text-sm mr-2"></i>
知识固化,无法灵活组合
</td>
</tr>
<tr>
<td class="px-6 py-4 font-medium text-gray-800">执行确定性</td>
<td class="px-6 py-4 text-green-600">
<i class="fas fa-check-circle text-sm mr-2"></i>
通过执行脚本实现确定性逻辑
</td>
<td class="px-6 py-4 text-red-600">
<i class="fas fa-times-circle text-sm mr-2"></i>
仅定义调用,执行逻辑由外部保证
</td>
<td class="px-6 py-4 text-red-600">
<i class="fas fa-times-circle text-sm mr-2"></i>
输出基于概率,可靠性较低
</td>
</tr>
</tbody>
</table>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div class="bg-yellow-50 rounded-xl p-6 border border-yellow-200">
<h4 class="font-bold text-lg mb-3 text-gray-800">
<i class="fas fa-function mr-2 text-yellow-600"></i>
vs. Function Calling
</h4>
<p class="text-sm text-gray-700">
Function Calling的核心是"工具调用",教会模型如何"使用工具",但工具功能在外部实现。而SKILL的核心是"工作流封装",不仅教会模型"做什么",还通过脚本教会模型"怎么做"<a href="#ref-17" class="citation-link">[17]</a>。
</p>
</div>
<div class="bg-red-50 rounded-xl p-6 border border-red-200">
<h4 class="font-bold text-lg mb-3 text-gray-800">
<i class="fas fa-brain mr-2 text-red-600"></i>
vs. Fine-tuning
</h4>
<p class="text-sm text-gray-700">
Fine-tuning将知识"内化"到模型中,适合注入事实性知识。SKILL将知识"外化"为独立模块,保持灵活性和可组合性。你可以为不同任务组合不同SKILL,而无需重新训练模型。
</p>
</div>
</div>
</div>
<div id="mcp-relationship" class="mb-12">
<h3 class="font-serif text-2xl font-semibold mb-6 text-gray-800">3.3 SKILL 与 MCP(Model Context Protocol)的关系</h3>
<p class="text-gray-700 leading-relaxed mb-6">
Anthropic的Model Context Protocol (MCP)是一个开放协议,旨在标准化LLM与外部数据源和工具的交互方式。SKILL和MCP并非相互替代,而是相辅相成的关系。
</p>
<div class="mermaid-container mb-8">
<div class="mermaid-controls">
<button class="mermaid-control-btn zoom-in" title="放大">
<i class="fas fa-search-plus"></i>
</button>
<button class="mermaid-control-btn zoom-out" title="缩小">
<i class="fas fa-search-minus"></i>
</button>
<button class="mermaid-control-btn reset-zoom" title="重置">
<i class="fas fa-expand-arrows-alt"></i>
</button>
<button class="mermaid-control-btn fullscreen" title="全屏查看">
<i class="fas fa-expand"></i>
</button>
</div>
<div class="mermaid">
graph LR
subgraph "连接层"
A["MCP
<br/>Model Context Protocol"]
end
subgraph "能力层"
B["SKILL
<br/>Agent Skills"]
end
subgraph "外部系统"
C["数据库
<br/>PostgreSQL"]
D["API服务
<br/>REST API"]
E["文件系统
<br/>File System"]
end
A -->|"标准化连接"| C
A -->|"标准化连接"| D
A -->|"标准化连接"| E
B -->|"使用MCP连接"| A
B -->|"封装业务逻辑"| F["复杂工作流
<br/>业务流程"]
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-8">
<div class="bg-blue-50 rounded-xl p-6 border border-blue-200">
<h4 class="font-bold text-lg mb-4 text-gray-800">
<i class="fas fa-plug mr-2 text-blue-600"></i>
MCP 的角色:连接层
</h4>
<ul class="space-y-2 text-sm text-gray-700">
<li class="flex items-start">
<i class="fas fa-arrow-right text-blue-500 mt-1 mr-2 flex-shrink-0"></i>
<span>定义标准通信协议</span>
</li>
<li class="flex items-start">
<i class="fas fa-arrow-right text-blue-500 mt-1 mr-2 flex-shrink-0"></i>
<span>连接数据库、API、文件系统</span>
</li>
<li class="flex items-start">
<i class="fas fa-arrow-right text-blue-500 mt-1 mr-2 flex-shrink-0"></i>
<span>解决"如何连接"的问题</span>
</li>
</ul>
</div>
<div class="bg-green-50 rounded-xl p-6 border border-green-200">
<h4 class="font-bold text-lg mb-4 text-gray-800">
<i class="fas fa-cogs mr-2 text-green-600"></i>
SKILL 的角色:能力层
</h4>
<ul class="space-y-2 text-sm text-gray-700">
<li class="flex items-start">
<i class="fas fa-arrow-right text-green-500 mt-1 mr-2 flex-shrink-0"></i>
<span>封装具体业务逻辑和专业知识</span>
</li>
<li class="flex items-start">
<i class="fas fa-arrow-right text-green-500 mt-1 mr-2 flex-shrink-0"></i>
<span>执行复杂的多步骤任务</span>
</li>
<li class="flex items-start">
<i class="fas fa-arrow-right text-green-500 mt-1 mr-2 flex-shrink-0"></i>
<span>解决"连接后做什么"的问题</span>
</li>
</ul>
</div>
</div>
<div class="bg-gray-50 rounded-xl p-6 mt-6">
<h4 class="font-bold text-lg mb-3 text-gray-800">混合架构:构建复杂企业级工作流</h4>
<p class="text-gray-700 text-sm mb-3">
在实际的企业级应用中,SKILL和MCP通常会结合使用,形成一个强大的混合架构。开发者可以利用MCP将Claude连接到企业内部的各种系统,然后创建一系列SKILL来编排这些连接,实现复杂的自动化工作流。
</p>
<div class="bg-white rounded-lg p-4">
<h5 class="font-medium text-gray-800 mb-2">示例:订单处理工作流</h5>
<ol class="text-xs text-gray-600 space-y-1 list-decimal list-inside">
<li>接收订单SKILL被触发</li>
<li>通过MCP连接到订单管理系统获取详情</li>
<li>调用客户信用检查SKILL</li>
<li>根据结果自动批准或标记人工审核</li>
<li>发送确认邮件SKILL通过MCP连接邮件服务</li>
</ol>
</div>
</div>
</div>
</section>
<!-- Development Section -->
<section id="development" class="mb-16">
<div class="section-divider"></div>
<h2 class="font-serif text-4xl font-bold mb-8 text-gray-800">4. 开发指南与最佳实践</h2>
<div id="getting-started" class="mb-12">
<h3 class="font-serif text-2xl font-semibold mb-6 text-gray-800">4.1 开发入门与资源</h3>
<div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-8">
<div class="bg-blue-50 rounded-xl p-6 border border-blue-200">
<div class="w-12 h-12 bg-blue-100 rounded-lg flex items-center justify-center mb-4">
<i class="fas fa-book text-blue-600 text-xl"></i>
</div>
<h4 class="font-bold text-gray-800 mb-2">官方文档</h4>
<p class="text-sm text-gray-600 mb-3">
Anthropic官方提供的资源是最佳起点,详细阐述了SKILL的架构、规范和最佳实践<a href="#ref-3" class="citation-link">[3]</a>
<a href="#ref-201" class="citation-link">[201]</a>。
</p>
<ul class="space-y-1 text-xs text-gray-500">
<li>• 架构规范详解</li>
<li>• API接口文档</li>
<li>• 示例代码库</li>
</ul>
</div>
<div class="bg-green-50 rounded-xl p-6 border border-green-200">
<div class="w-12 h-12 bg-green-100 rounded-lg flex items-center justify-center mb-4">
<i class="fas fa-users text-green-600 text-xl"></i>
</div>
<h4 class="font-bold text-gray-800 mb-2">开发者社区</h4>
<p class="text-sm text-gray-600 mb-3">
全球开发者社区快速成长,提供中文开发指南和案例分享。
</p>
<ul class="space-y-1 text-xs text-gray-500">
<li>• 技术博客与论坛</li>
<li>• 中文开发指南</li>
<li>• 社区讨论支持</li>
</ul>
</div>
<div class="bg-purple-50 rounded-xl p-6 border border-purple-200">
<div class="w-12 h-12 bg-purple-100 rounded-lg flex items-center justify-center mb-4">
<i class="fas fa-code text-purple-600 text-xl"></i>
</div>
<h4 class="font-bold text-gray-800 mb-2">预构建技能</h4>
<p class="text-sm text-gray-600 mb-3">
建议先学习和使用官方预构建技能,理解设计理念。
</p>
<ul class="space-y-1 text-xs text-gray-500">
<li>• pptx技能:演示文稿生成</li>
<li>• pdf技能:文档处理</li>
<li>• xlsx技能:数据分析</li>
</ul>
</div>
</div>
<blockquote class="border-l-4 border-amber-500 pl-6 py-4 bg-amber-50 rounded-r-lg mb-6">
<p class="text-gray-700 italic">
"建议开发者遵循'从使用到理解,再到创造'的学习路径。首先通过实际调用预构建技能来感受SKILL的强大功能,然后仔细阅读其SKILL.md文件理解指令编写方式,最后再开始创建自定义SKILL。"
</p>
</blockquote>
</div>
<div id="custom-development" class="mb-12">
<h3 class="font-serif text-2xl font-semibold mb-6 text-gray-800">4.2 自定义 SKILL 开发流程</h3>
<div class="space-y-8">
<div class="bg-white rounded-xl p-8 shadow-sm border border-gray-200">
<div class="flex items-center mb-6">
<div class="w-12 h-12 bg-blue-100 rounded-lg flex items-center justify-center mr-4">
<span class="text-blue-600 font-bold">1</span>
</div>
<h4 class="font-bold text-lg text-gray-800">创建 SKILL.md 文件</h4>
</div>
<p class="text-gray-700 leading-relaxed mb-4">
这是SKILL开发的第一步,也是最关键的一步。SKILL.md文件是SKILL的"大脑",其质量直接决定了Claude能否正确理解和执行任务。
</p>
<div class="bg-gray-50 rounded-lg p-6 mb-4">
<h5 class="font-semibold mb-3 text-gray-800">关键要素</h5>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<h6 class="font-medium text-sm text-gray-700 mb-2">元数据定义</h6>
<ul class="text-xs text-gray-600 space-y-1">
<li>• 准确的name(唯一标识符)</li>
<li>• 简洁的description(功能描述)</li>
<li>• 清晰的版本信息</li>
</ul>
</div>
<div>
<h6 class="font-medium text-sm text-gray-700 mb-2">指令编写</h6>
<ul class="text-xs text-gray-600 space-y-1">
<li>• 结构化的执行步骤</li>
<li>• 具体的输入输出示例</li>
<li>• 明确的边界和约束</li>
</ul>
</div>
</div>
</div>
<div class="bg-gray-900 text-gray-300 p-4 rounded-lg font-mono text-sm overflow-x-auto">
<pre><code>---
name: excel-report-generator
description: 自动生成Excel格式的销售数据分析报告
version: 1.0.0
---
# Excel报告生成器
## 用途
本技能用于根据销售数据自动生成Excel格式的分析报告。
## 执行步骤
1. 接收CSV格式的销售数据文件
2. 进行数据清洗和预处理
3. 计算关键指标(总销售额、增长率等)
4. 生成数据透视表
5. 创建可视化图表
6. 保存为.xlsx格式
## 示例
输入:sales_data_2025.csv
输出:包含数据分析和图表的Excel报告</code></pre>
</div>
</div>
<div class="bg-white rounded-xl p-8 shadow-sm border border-gray-200">
<div class="flex items-center mb-6">
<div class="w-12 h-12 bg-green-100 rounded-lg flex items-center justify-center mr-4">
<span class="text-green-600 font-bold">2</span>
</div>
<h4 class="font-bold text-lg text-gray-800">编写脚本与组织资源</h4>
</div>
<p class="text-gray-700 leading-relaxed mb-4">
如果SKILL需要执行复杂逻辑或与外部系统交互,编写脚本和组织资源是必不可少的环节。
</p>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div class="bg-green-50 rounded-lg p-4">
<h5 class="font-semibold mb-3 text-gray-800">
<i class="fas fa-code mr-2 text-green-600"></i>
脚本编写
</h5>
<ul class="space-y-2 text-sm text-gray-700">
<li class="flex items-start">
<i class="fas fa-arrow-right text-green-500 mt-1 mr-2 flex-shrink-0"></i>
<span>优先使用Python或Bash等脚本语言</span>
</li>
<li class="flex items-start">
<i class="fas fa-arrow-right text-green-500 mt-1 mr-2 flex-shrink-0"></i>
<span>将确定性任务逻辑固化下来</span>
</li>
<li class="flex items-start">
<i class="fas fa-arrow-right text-green-500 mt-1 mr-2 flex-shrink-0"></i>
<span>确保代码可读性和可维护性</span>
</li>
</ul>
</div>
<div class="bg-purple-50 rounded-lg p-4">
<h5 class="font-semibold mb-3 text-gray-800">
<i class="fas fa-folder-open mr-2 text-purple-600"></i>
资源组织
</h5>
<ul class="space-y-2 text-sm text-gray-700">
<li class="flex items-start">
<i class="fas fa-arrow-right text-purple-500 mt-1 mr-2 flex-shrink-0"></i>
<span>模板文件存放在resources/目录</span>
</li>
<li class="flex items-start">
<i class="fas fa-arrow-right text-purple-500 mt-1 mr-2 flex-shrink-0"></i>
<span>确保文件命名清晰,路径正确</span>
</li>
<li class="flex items-start">
<i class="fas fa-arrow-right text-purple-500 mt-1 mr-2 flex-shrink-0"></i>
<span>模块化设计,提高代码复用性</span>
</li>
</ul>
</div>
</div>
<div class="mt-4 bg-gray-900 text-gray-300 p-4 rounded-lg font-mono text-sm overflow-x-auto">
<pre><code>scripts/
├── data_processor.py # 数据处理逻辑
├── chart_generator.py # 图表生成逻辑
└── report_builder.py # 报告构建逻辑
resources/
├── templates/
│ ├── report_template.xlsx
│ └── chart_template.pptx
└── styles/
└── brand_guidelines.json</code></pre>
</div>
</div>
<div class="bg-white rounded-xl p-8 shadow-sm border border-gray-200">
<div class="flex items-center mb-6">
<div class="w-12 h-12 bg-purple-100 rounded-lg flex items-center justify-center mr-4">
<span class="text-purple-600 font-bold">3</span>
</div>
<h4 class="font-bold text-lg text-gray-800">通过 API 上传与管理</h4>
</div>
<p class="text-gray-700 leading-relaxed mb-4">
完成SKILL文件编写后,可以通过API将其上传到Claude平台,并进行版本管理和测试。
</p>
<div class="bg-gray-900 text-gray-300 p-6 rounded-lg mb-4 font-mono text-sm overflow-x-auto">
<pre><code># 1. 打包SKILL文件夹
zip -r excel-report-generator.skill skill-folder/
# 2. 使用Python SDK上传
from anthropic import Anthropic
client = Anthropic()
# 上传新的SKILL
with open("excel-report-generator.skill", "rb") as f:
skill = client.beta.skills.create(
file=f,
name="excel-report-generator",
description="自动生成Excel销售报告"
)
print(f"SKILL创建成功: {skill.id}")
# 3. 在对话中使用SKILL
response = client.messages.create(
model="claude-3-5-sonnet-20241022",
messages=[{
"role": "user",
"content": "请分析这个CSV文件并生成销售报告"
}],
container={
"skills": [{
"type": "custom",
"skill_id": skill.id,
"version": "1"
}]
}
)</code></pre>
</div>
<div class="bg-amber-50 rounded-lg p-4">
<h5 class="font-semibold mb-2 text-gray-800">
<i class="fas fa-lightbulb mr-2 text-amber-600"></i>
最佳实践
</h5>
<ul class="space-y-1 text-sm text-gray-700">
<li>• 使用Git等版本控制系统管理SKILL源代码</li>
<li>• 明确声明依赖关系(requirements.txt)</li>
<li>• 建立自动化部署流程,集成到CI/CD管道</li>
<li>• 记录变更日志,便于版本追踪</li>
</ul>
</div>
</div>
</div>
</div>
<div id="best-practices" class="mb-12">
<h3 class="font-serif text-2xl font-semibold mb-6 text-gray-800">4.3 企业级部署最佳实践</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-8 mb-8">
<div class="bg-blue-50 rounded-xl p-6 border border-blue-200">
<h4 class="font-bold text-lg mb-4 text-gray-800">
<i class="fas fa-bullseye mr-2 text-blue-600"></i>
评估先行
</h4>
<p class="text-gray-700 mb-3">
在投入开发之前,企业应首先明确业务目标和核心指标。
</p>
<ul class="space-y-1 text-sm text-gray-600">
<li>• 明确提升效率、降低成本等具体目标</li>
<li>• 定义可量化的KPIs(如报告生成时间缩短90%)</li>
<li>• 确保项目方向的正确性</li>
</ul>
</div>
<div class="bg-green-50 rounded-xl p-6 border border-green-200">
<h4 class="font-bold text-lg mb-4 text-gray-800">
<i class="fas fa-balance-scale mr-2 text-green-600"></i>
权衡智能度、成本与延迟
</h4>
<p class="text-gray-700 mb-3">
需要在AI智能度、运行成本和响应延迟之间做出权衡。
</p>
<ul class="space-y-1 text-sm text-gray-600">
<li>• 根据任务复杂度选择合适模型</li>
<li>• 充分利用渐进式信息披露机制</li>
<li>• 优化成本和性能表现</li>
</ul>
</div>
</div>
<div class="bg-white rounded-xl p-8 shadow-sm border border-gray-200 mb-8">
<h4 class="font-bold text-lg mb-6 text-gray-800">
<i class="fas fa-shield-alt mr-2 text-purple-600"></i>
安全与治理
</h4>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div>
<h5 class="font-semibold mb-3 text-gray-800">权限控制</h5>
<ul class="space-y-2 text-sm text-gray-700">
<li class="flex items-start">
<i class="fas fa-user-shield text-purple-500 mt-1 mr-2 flex-shrink-0"></i>
<span>确保只有授权用户可创建、修改和调用SKILL</span>
</li>
<li class="flex items-start">
<i class="fas fa-lock text-purple-500 mt-1 mr-2 flex-shrink-0"></i>
<span>对敏感信息进行严格加密和访问控制</span>
</li>
<li class="flex items-start">
<i class="fas fa-key text-purple-500 mt-1 mr-2 flex-shrink-0"></i>
<span>建立完善的身份认证机制</span>
</li>
</ul>
</div>
<div>
<h5 class="font-semibold mb-3 text-gray-800">审计追踪</h5>
<ul class="space-y-2 text-sm text-gray-700">
<li class="flex items-start">
<i class="fas fa-history text-purple-500 mt-1 mr-2 flex-shrink-0"></i>
<span>记录所有SKILL的创建、修改和执行情况</span>
</li>
<li class="flex items-start">
<i class="fas fa-search text-purple-500 mt-1 mr-2 flex-shrink-0"></i>
<span>便于问题追溯和排查</span>
</li>
<li class="flex items-start">
<i class="fas fa-chart-line text-purple-500 mt-1 mr-2 flex-shrink-0"></i>
<span>分析使用模式和性能表现</span>
</li>
</ul>
</div>
</div>
</div>
<div class="bg-gradient-to-r from-gray-50 to-slate-50 rounded-xl p-8 border border-gray-200">
<h4 class="font-bold text-lg mb-6 text-gray-800">
<i class="fas fa-code-branch mr-2 text-gray-600"></i>
版本控制与依赖管理
</h4>
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
<div class="bg-white rounded-lg p-4 shadow-sm">
<div class="flex items-center mb-3">
<i class="fas fa-code-branch text-blue-600 text-lg mr-2"></i>
<h5 class="font-semibold text-gray-800">版本控制</h5>
</div>
<ul class="space-y-1 text-xs text-gray-600">
<li>• 使用Git管理源代码</li>
<li>• 记录所有变更历史</li>
<li>• 支持版本回滚</li>
</ul>
</div>
<div class="bg-white rounded-lg p-4 shadow-sm">
<div class="flex items-center mb-3">
<i class="fas fa-box text-green-600 text-lg mr-2"></i>
<h5 class="font-semibold text-gray-800">依赖管理</h5>
</div>
<ul class="space-y-1 text-xs text-gray-600">
<li>• requirements.txt声明依赖</li>
<li>• 虚拟环境隔离</li>
<li>• 避免版本冲突</li>
</ul>
</div>
<div class="bg-white rounded-lg p-4 shadow-sm">
<div class="flex items-center mb-3">
<i class="fas fa-rocket text-purple-600 text-lg mr-2"></i>
<h5 class="font-semibold text-gray-800">自动化部署</h5>
</div>
<ul class="space-y-1 text-xs text-gray-600">
<li>• CI/CD管道集成</li>
<li>• 自动化测试</li>
<li>• 快速可靠交付</li>
</ul>
</div>
</div>
</div>
</div>
</section>
<!-- References Section -->
<section class="mb-16">
<div class="section-divider"></div>
<h2 class="font-serif text-4xl font-bold mb-8 text-gray-800">参考文献</h2>
<div class="bg-white rounded-xl p-8 shadow-sm border border-gray-200">
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 text-sm">
<div id="ref-3" class="p-3 bg-gray-50 rounded">
<strong>[3]</strong> Anthropic Skills GitHub仓库:
<a href="https://github.com/anthropics/skills" class="citation-link" target="_blank" rel="noopener">
https://github.com/anthropics/skills
</a>
</div>
<div id="ref-17" class="p-3 bg-gray-50 rounded">
<strong>[17]</strong> Claude's Modular Mind - ikangai.com:
<a href="https://www.ikangai.com/claudes-modular-mind-how-anthropics-agent-skills-redefine-context-in-ai-systems/" class="citation-link" target="_blank" rel="noopener">
Claude's Modular Mind Analysis
</a>
</div>
<div id="ref-201" class="p-3 bg-gray-50 rounded">
<strong>[201]</strong> 开源中国 - Anthropic Agent Skills:
<a href="https://www.oschina.net/news/391639?to=comment&rpl=353297836" class="citation-link" target="_blank" rel="noopener">
https://www.oschina.net/news/391639
</a>
</div>
<div id="ref-228" class="p-3 bg-gray-50 rounded">
<strong>[228]</strong> GitHub Skills Repository:
<a href="https://github.com/anthropics/skills" class="citation-link" target="_blank" rel="noopener">
https://github.com/anthropics/skills
</a>
</div>
<div id="ref-231" class="p-3 bg-gray-50 rounded">
<strong>[231]</strong> Claude Agent Skills 中文文档:
<a href="https://claudecn.com/docs/agent-skills/" class="citation-link" target="_blank" rel="noopener">
https://claudecn.com/docs/agent-skills/
</a>
</div>
<div id="ref-239" class="p-3 bg-gray-50 rounded">
<strong>[239]</strong> 阿里云开发者社区:
<a href="https://developer.aliyun.com/article/1694081" class="citation-link" target="_blank" rel="noopener">
https://developer.aliyun.com/article/1694081
</a>
</div>
<div id="ref-240" class="p-3 bg-gray-50 rounded">
<strong>[240]</strong> Claude Skills 初学者指南:
<a href="https://help.apiyi.com/claude-skills-beginners-guide-2025.html" class="citation-link" target="_blank" rel="noopener">
https://help.apiyi.com/claude-skills-beginners-guide-2025.html
</a>
</div>
<div id="ref-241" class="p-3 bg-gray-50 rounded">
<strong>[241]</strong> Claude API 概览:
<a href="https://platform.claude.com/docs/en/api/overview" class="citation-link" target="_blank" rel="noopener">
https://platform.claude.com/docs/en/api/overview
</a>
</div>
<div id="ref-247" class="p-3 bg-gray-50 rounded">
<strong>[247]</strong> Anthropic开源SKILL标准解答:
<a href="https://jimo.studio/blog/anthropic-open-source-skills-claude-agent-development-standard-answer/" class="citation-link" target="_blank" rel="noopener">
Jimo Studio Analysis
</a>
</div>
<div id="ref-250" class="p-3 bg-gray-50 rounded">
<strong>[250]</strong> Awesome Claude Skills:
<a href="https://github.com/travisvn/awesome-claude-skills" class="citation-link" target="_blank" rel="noopener">
https://github.com/travisvn/awesome-claude-skills
</a>
</div>
<div id="ref-263" class="p-3 bg-gray-50 rounded">
<strong>[263]</strong> LiteLLM SKILL文档:
<a href="https://docs.litellm.ai/docs/skills" class="citation-link" target="_blank" rel="noopener">
https://docs.litellm.ai/docs/skills
</a>
</div>
<div id="ref-273" class="p-3 bg-gray-50 rounded">
<strong>[273]</strong> Awesome Claude Skills GitHub:
<a href="https://github.com/travisvn/awesome-claude-skills" class="citation-link" target="_blank" rel="noopener">
https://github.com/travisvn/awesome-claude-skills
</a>
</div>
<div id="ref-276" class="p-3 bg-gray-50 rounded">
<strong>[276]</strong> Claude Agent Skills 快速入门:
<a href="https://claudecn.com/docs/agent-skills/quickstart/" class="citation-link" target="_blank" rel="noopener">
https://claudecn.com/docs/agent-skills/quickstart/
</a>
</div>
<div id="ref-277" class="p-3 bg-gray-50 rounded">
<strong>[277]</strong> Claude Agents and Tools:
<a href="https://platform.claude.com/docs/en/agents-and-tools/agent-skills/overview" class="citation-link" target="_blank" rel="noopener">
https://platform.claude.com/docs/en/agents-and-tools/agent-skills/overview
</a>
</div>
<div id="ref-279" class="p-3 bg-gray-50 rounded">
<strong>[279]</strong> Claude SKILL 指南:
<a href="https://platform.claude.com/docs/zh-CN/build-with-claude/skills-guide" class="citation-link" target="_blank" rel="noopener">
https://platform.claude.com/docs/zh-CN/build-with-claude/skills-guide
</a>
</div>
<div id="ref-292" class="p-3 bg-gray-50 rounded">
<strong>[292]</strong> 火山引擎开发者文档:
<a href="https://developer.volcengine.com/articles/7571775947595055114" class="citation-link" target="_blank" rel="noopener">
https://developer.volcengine.com/articles/7571775947595055114
</a>
</div>
<div id="ref-293" class="p-3 bg-gray-50 rounded">
<strong>[293]</strong> APFramework Anthropic Claude Skills:
<a href="https://apframework.com/blog/essay/2025-12-20-Anthropic-Claude-Skills" class="citation-link" target="_blank" rel="noopener">
https://apframework.com/blog/essay/2025-12-20-Anthropic-Claude-Skills
</a>
</div>
<div id="ref-295" class="p-3 bg-gray-50 rounded">
<strong>[295]</strong> Tony Bai - Anthropic Agent Skills:
<a href="https://tonybai.com/2025/12/19/anthropic-agent-skills-open-standard-launch/" class="citation-link" target="_blank" rel="noopener">
https://tonybai.com/2025/12/19/anthropic-agent-skills-open-standard-launch/
</a>
</div>
<div id="ref-297" class="p-3 bg-gray-50 rounded">
<strong>[297]</strong> Claude Agent Skills 完整指南:
<a href="https://claudecn.com/blog/claude-agent-skills-complete-guide/" class="citation-link" target="_blank" rel="noopener">
https://claudecn.com/blog/claude-agent-skills-complete-guide/
</a>
</div>
<div id="ref-300" class="p-3 bg-gray-50 rounded">
<strong>[300]</strong> Claude Skills 快速入门:
<a href="https://claudecn.com/docs/agent-skills/quickstart/" class="citation-link" target="_blank" rel="noopener">
https://claudecn.com/docs/agent-skills/quickstart/
</a>
</div>
<div id="ref-301" class="p-3 bg-gray-50 rounded">
<strong>[301]</strong> VibeTools Claude Skills 指南:
<a href="https://vibetools.net/zh/posts/claude-skills-guide" class="citation-link" target="_blank" rel="noopener">
https://vibetools.net/zh/posts/claude-skills-guide
</a>
</div>
<div id="ref-306" class="p-3 bg-gray-50 rounded">
<strong>[306]</strong> 腾讯新闻 - Anthropic SKILL生态系统:
<a href="https://view.inews.qq.com/a/20251018A01JB900" class="citation-link" target="_blank" rel="noopener">
https://view.inews.qq.com/a/20251018A01JB900
</a>
</div>
<div id="ref-309" class="p-3 bg-gray-50 rounded">
<strong>[309]</strong> 博客园 - Claude SKILL应用案例:
<a href="https://www.cnblogs.com/xiaohuatongxueai/p/19163431" class="citation-link" target="_blank" rel="noopener">
https://www.cnblogs.com/xiaohuatongxueai/p/19163431
</a>
</div>
<div id="ref-315" class="p-3 bg-gray-50 rounded">
<strong>[315]</strong> CSDN - Anthropic SKILL企业应用:
<a href="https://blog.csdn.net/NetGoldenSpider/article/details/155824124" class="citation-link" target="_blank" rel="noopener">
https://blog.csdn.net/NetGoldenSpider/article/details/155824124
</a>
</div>
<div id="ref-323" class="p-3 bg-gray-50 rounded">
<strong>[323]</strong> Anthropic Skills GitHub:
<a href="https://github.com/anthropics/skills" class="citation-link" target="_blank" rel="noopener">
https://github.com/anthropics/skills
</a>
</div>
<div id="ref-330" class="p-3 bg-gray-50 rounded">
<strong>[330]</strong> 七牛云 - Claude Code配置说明:
<a href="https://developer.qiniu.com/aitokenapi/13085/claude-code-configuration-instructions" class="citation-link" target="_blank" rel="noopener">
https://developer.qiniu.com/aitokenapi/13085/claude-code-configuration-instructions
</a>
</div>
<div id="ref-334" class="p-3 bg-gray-50 rounded">
<strong>[334]</strong> Tony Bai - Anthropic Agent Skills开放标准:
<a href="https://tonybai.com/2025/12/19/anthropic-agent-skills-open-standard-launch/" class="citation-link" target="_blank" rel="noopener">
https://tonybai.com/2025/12/19/anthropic-agent-skills-open-standard-launch/
</a>
</div>
<div id="ref-349" class="p-3 bg-gray-50 rounded">
<strong>[349]</strong> Claude Skills 初学者指南:
<a href="https://help.apiyi.com/claude-skills-beginners-guide-2025-en.html" class="citation-link" target="_blank" rel="noopener">
https://help.apiyi.com/claude-skills-beginners-guide-2025-en.html
</a>
</div>
</div>
</div>
</section>
</main>
<script>
// Toggle TOC on small screens
const toc = document.getElementById('toc');
const tocToggle = document.getElementById('toc-toggle');
const tocClose = document.getElementById('toc-close');
tocToggle.addEventListener('click', () => {
toc.classList.toggle('active');
});
tocClose.addEventListener('click', () => {
toc.classList.remove('active');
});
// Initialize Mermaid
mermaid.initialize({
startOnLoad: true,
theme: 'default',
themeVariables: {
primaryColor: '#ffffff',
primaryTextColor: '#2d2d2d',
primaryBorderColor: '#1a1a1a',
lineColor: '#6b7280',
secondaryColor: '#f5f5f5',
tertiaryColor: '#fafafa',
background: '#ffffff',
mainBkg: '#ffffff',
secondaryBkg: '#f9fafb',
tertiaryBkg: '#f3f4f6',
nodeBkg: '#ffffff',
nodeBorder: '#1a1a1a',
clusterBkg: '#f9fafb',
clusterBorder: '#d1d5db',
defaultLinkColor: '#6b7280',
titleColor: '#1a1a1a',
edgeLabelBackground: 'rgba(255, 255, 255, 0.9)',
nodeTextColor: '#2d2d2d'
},
fontSize: 14,
fontFamily: 'Inter, sans-serif'
});
// Initialize Mermaid Controls for zoom and pan
function initializeMermaidControls() {
const containers = document.querySelectorAll('.mermaid-container');
containers.forEach(container => {
const mermaidElement = container.querySelector('.mermaid');
let scale = 1;
let isDragging = false;
let startX, startY, translateX = 0, translateY = 0;
// 触摸相关状态
let isTouch = false;
let touchStartTime = 0;
let initialDistance = 0;
let initialScale = 1;
let isPinching = false;
// Zoom controls
const zoomInBtn = container.querySelector('.zoom-in');
const zoomOutBtn = container.querySelector('.zoom-out');
const resetBtn = container.querySelector('.reset-zoom');
const fullscreenBtn = container.querySelector('.fullscreen');
function updateTransform() {
mermaidElement.style.transform = `translate(${translateX}px, ${translateY}px) scale(${scale})`;
if (scale > 1) {
container.classList.add('zoomed');
} else {
container.classList.remove('zoomed');
}
mermaidElement.style.cursor = isDragging ? 'grabbing' : 'grab';
}
if (zoomInBtn) {
zoomInBtn.addEventListener('click', () => {
scale = Math.min(scale * 1.25, 4);
updateTransform();
});
}
if (zoomOutBtn) {
zoomOutBtn.addEventListener('click', () => {
scale = Math.max(scale / 1.25, 0.3);
if (scale <= 1) {
translateX = 0;
translateY = 0;
}
updateTransform();
});
}
if (resetBtn) {
resetBtn.addEventListener('click', () => {
scale = 1;
translateX = 0;
translateY = 0;
updateTransform();
});
}
if (fullscreenBtn) {
fullscreenBtn.addEventListener('click', () => {
if (container.requestFullscreen) {
container.requestFullscreen();
} else if (container.webkitRequestFullscreen) {
container.webkitRequestFullscreen();
} else if (container.msRequestFullscreen) {
container.msRequestFullscreen();
}
});
}
// Mouse Events
mermaidElement.addEventListener('mousedown', (e) => {
if (isTouch) return; // 如果是触摸设备,忽略鼠标事件
isDragging = true;
startX = e.clientX - translateX;
startY = e.clientY - translateY;
mermaidElement.style.cursor = 'grabbing';
updateTransform();
e.preventDefault();
});
document.addEventListener('mousemove', (e) => {
if (isDragging && !isTouch) {
translateX = e.clientX - startX;
translateY = e.clientY - startY;
updateTransform();
}
});
document.addEventListener('mouseup', () => {
if (isDragging && !isTouch) {
isDragging = false;
mermaidElement.style.cursor = 'grab';
updateTransform();
}
});
document.addEventListener('mouseleave', () => {
if (isDragging && !isTouch) {
isDragging = false;
mermaidElement.style.cursor = 'grab';
updateTransform();
}
});
// 获取两点之间的距离
function getTouchDistance(touch1, touch2) {
return Math.hypot(
touch2.clientX - touch1.clientX,
touch2.clientY - touch1.clientY
);
}
// Touch Events - 触摸事件处理
mermaidElement.addEventListener('touchstart', (e) => {
isTouch = true;
touchStartTime = Date.now();
if (e.touches.length === 1) {
// 单指拖动
isPinching = false;
isDragging = true;
const touch = e.touches[0];
startX = touch.clientX - translateX;
startY = touch.clientY - translateY;
} else if (e.touches.length === 2) {
// 双指缩放
isPinching = true;
isDragging = false;
const touch1 = e.touches[0];
const touch2 = e.touches[1];
initialDistance = getTouchDistance(touch1, touch2);
initialScale = scale;
}
e.preventDefault();
}, { passive: false });
mermaidElement.addEventListener('touchmove', (e) => {
if (e.touches.length === 1 && isDragging && !isPinching) {
// 单指拖动
const touch = e.touches[0];
translateX = touch.clientX - startX;
translateY = touch.clientY - startY;
updateTransform();
} else if (e.touches.length === 2 && isPinching) {
// 双指缩放
const touch1 = e.touches[0];
const touch2 = e.touches[1];
const currentDistance = getTouchDistance(touch1, touch2);
if (initialDistance > 0) {
const newScale = Math.min(Math.max(
initialScale * (currentDistance / initialDistance),
0.3
), 4);
scale = newScale;
updateTransform();
}
}
e.preventDefault();
}, { passive: false });
mermaidElement.addEventListener('touchend', (e) => {
// 重置状态
if (e.touches.length === 0) {
isDragging = false;
isPinching = false;
initialDistance = 0;
// 延迟重置isTouch,避免鼠标事件立即触发
setTimeout(() => {
isTouch = false;
}, 100);
} else if (e.touches.length === 1 && isPinching) {
// 从双指变为单指,切换为拖动模式
isPinching = false;
isDragging = true;
const touch = e.touches[0];
startX = touch.clientX - translateX;
startY = touch.clientY - translateY;
}
updateTransform();
});
mermaidElement.addEventListener('touchcancel', (e) => {
isDragging = false;
isPinching = false;
initialDistance = 0;
setTimeout(() => {
isTouch = false;
}, 100);
updateTransform();
});
// Enhanced wheel zoom with better center point handling
container.addEventListener('wheel', (e) => {
e.preventDefault();
const rect = container.getBoundingClientRect();
const centerX = rect.width / 2;
const centerY = rect.height / 2;
const delta = e.deltaY > 0 ? 0.9 : 1.1;
const newScale = Math.min(Math.max(scale * delta, 0.3), 4);
// Adjust translation to zoom towards center
if (newScale !== scale) {
const scaleDiff = newScale / scale;
translateX = translateX * scaleDiff;
translateY = translateY * scaleDiff;
scale = newScale;
if (scale <= 1) {
translateX = 0;
translateY = 0;
}
updateTransform();
}
});
// Initialize display
updateTransform();
});
}
initializeMermaidControls();
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
// Highlight current section in TOC
function highlightCurrentSection() {
const sections = document.querySelectorAll('section[id], div[id]');
const tocLinks = document.querySelectorAll('.toc-fixed a');
let current = '';
sections.forEach(section => {
const sectionTop = section.offsetTop - 100;
if (pageYOffset >= sectionTop) {
current = section.getAttribute('id');
}
});
tocLinks.forEach(link => {
link.classList.remove('font-semibold', 'text-blue-600');
if (link.getAttribute('href') === `#${current}`) {
link.classList.add('font-semibold', 'text-blue-600');
}
});
}
window.addEventListener('scroll', highlightCurrentSection);
// Close TOC when clicking on a link (for small screens)
document.querySelectorAll('.toc-fixed a').forEach(link => {
link.addEventListener('click', () => {
if (window.innerWidth <= 1024) {
toc.classList.remove('active');
}
});
});
</script>
</body></html>
登录后可参与表态
讨论回复
0 条回复还没有人回复,快来发表你的看法吧!