好的 Skills 应简洁、结构良好,并经过实际使用的测试。本指南提供实用的编写决策,帮助您编写 Claude 能够有效发现和使用的 Skills。
有关 Skills 工作原理的概念背景,请参阅 Skills 概述。
"Context window"(上下文窗口)是一种公共资源。您的 Skill 与 Claude 需要了解的所有其他内容共享上下文窗口,包括:
并非您 Skill 中的每个令牌都有即时成本。在启动时,只有所有 Skills 的元数据(name 和 description)会被预加载。Claude 仅在 Skill 变得相关时才读取 SKILL.md,并且仅在需要时才读取其他文件。然而,在 SKILL.md 中保持简洁仍然很重要:一旦 Claude 加载它,每个令牌都会与对话历史和其他上下文竞争。
默认假设: Claude 已经非常聪明
只添加 Claude 尚不具备的上下文。质疑每一条信息:
好的示例:简洁(约 50 个令牌):
## Extract PDF text
Use pdfplumber for text extraction:
```python
import pdfplumber
with pdfplumber.open("file.pdf") as pdf:
text = pdf.pages[0].extract_text()
```不好的示例:过于冗长(约 150 个令牌):
## Extract PDF text
PDF (Portable Document Format) files are a common file format that contains
text, images, and other content. To extract text from a PDF, you'll need to
use a library. There are many libraries available for PDF processing, but
pdfplumber is recommended because it's easy to use and handles most cases well.
First, you'll need to install it using pip. Then you can use the code below...简洁版本假设 Claude 已经了解 PDF 以及库的工作方式。
将具体程度与任务的脆弱性和可变性相匹配。
高自由度(基于文本的指令):
适用于以下情况:
示例:
## Code review process
1. Analyze the code structure and organization
2. Check for potential bugs or edge cases
3. Suggest improvements for readability and maintainability
4. Verify adherence to project conventions中等自由度(伪代码或带参数的脚本):
适用于以下情况:
示例:
## Generate report
Use this template and customize as needed:
```python
def generate_report(data, format="markdown", include_charts=True):
# Process data
# Generate output in specified format
# Optionally include visualizations
```低自由度(特定脚本,很少或没有参数):
适用于以下情况:
示例:
## Database migration
Run exactly this script:
```bash
python scripts/migrate.py --verify --backup
```
Do not modify the command or add additional flags.类比: 将 Claude 想象成一个探索路径的机器人:
Skills 作为模型的补充,因此其有效性取决于底层模型。使用您计划搭配使用的所有模型测试您的 Skill。
按模型划分的测试注意事项:
对 Opus 完美有效的内容可能需要为 Haiku 提供更多细节。如果您计划在多个模型中使用您的 Skill,请力求编写对所有模型都有效的指令。
YAML Frontmatter: SKILL.md 的 frontmatter 需要两个字段:
name:
description:
有关完整的 Skill 结构详细信息,请参阅 Skills 概述。
使用一致的命名模式,使 Skills 更容易引用和讨论。考虑对 Skill 名称使用动名词形式(动词 + -ing),因为这清楚地描述了 Skill 提供的活动或能力。
请记住,name 字段只能使用小写字母、数字和连字符。
好的命名示例(动名词形式):
processing-pdfsanalyzing-spreadsheetsmanaging-databasestesting-codewriting-documentation可接受的替代方案:
pdf-processing、spreadsheet-analysisprocess-pdfs、analyze-spreadsheets避免:
helper、utils、toolsdocuments、data、filesanthropic-helper、claude-tools一致的命名使以下工作更容易:
description 字段支持 Skill 发现,应同时包含 Skill 的功能以及何时使用它。
始终使用第三人称编写。描述会被注入到系统提示中,不一致的视角可能会导致发现问题。
要具体并包含关键术语。同时包含 Skill 的功能以及何时使用它的具体触发条件/上下文。
每个 Skill 只有一个 description 字段。描述对于 skill 选择至关重要:Claude 使用它从可能超过 100 个可用 Skills 中选择正确的 Skill。您的描述必须提供足够的细节,让 Claude 知道何时选择此 Skill,而 SKILL.md 的其余部分则提供实现细节。
有效示例:
PDF 处理 skill:
description: Extract text and tables from PDF files, fill forms, merge documents. Use when working with PDF files or when the user mentions PDFs, forms, or document extraction.Excel 分析 skill:
description: Analyze Excel spreadsheets, create pivot tables, generate charts. Use when analyzing Excel files, spreadsheets, tabular data, or .xlsx files.Git 提交助手 skill:
description: Generate descriptive commit messages by analyzing git diffs. Use when the user asks for help writing commit messages or reviewing staged changes.避免像这样的模糊描述:
description: Helps with documentsdescription: Processes datadescription: Does stuff with filesSKILL.md 作为一个概述,在需要时将 Claude 指向详细材料,就像入职指南中的目录一样。有关渐进式披露工作原理的解释,请参阅概述中的 Skills 工作原理。
实用指导:
一个基本的 Skill 从仅包含元数据和指令的 SKILL.md 文件开始:

随着您的 Skill 增长,您可以捆绑 Claude 仅在需要时加载的其他内容:

完整的 Skill 目录结构可能如下所示:
pdf/
├── SKILL.md # Main instructions (loaded when triggered)
├── FORMS.md # Form-filling guide (loaded as needed)
├── reference.md # API reference (loaded as needed)
├── examples.md # Usage examples (loaded as needed)
└── scripts/
├── analyze_form.py # Utility script (executed, not loaded)
├── fill_form.py # Form filling script
└── validate.py # Validation script---
name: pdf-processing
description: Extracts text and tables from PDF files, fills forms, and merges documents. Use when working with PDF files or when the user mentions PDFs, forms, or document extraction.
---
# PDF Processing
## Quick start
Extract text with pdfplumber:
```python
import pdfplumber
with pdfplumber.open("file.pdf") as pdf:
text = pdf.pages[0].extract_text()
```
## Advanced features
**Form filling**: See [FORMS.md](FORMS.md) for complete guide
**API reference**: See [REFERENCE.md](REFERENCE.md) for all methods
**Examples**: See [EXAMPLES.md](EXAMPLES.md) for common patternsClaude 仅在需要时加载 FORMS.md、REFERENCE.md 或 EXAMPLES.md。
对于具有多个领域的 Skills,按领域组织内容以避免加载不相关的上下文。当用户询问销售指标时,Claude 只需要读取与销售相关的模式,而不需要读取财务或营销数据。这可以保持较低的令牌使用量并使上下文保持聚焦。
bigquery-skill/
├── SKILL.md (overview and navigation)
└── reference/
├── finance.md (revenue, billing metrics)
├── sales.md (opportunities, pipeline)
├── product.md (API usage, features)
└── marketing.md (campaigns, attribution)# BigQuery Data Analysis
## Available datasets
**Finance**: Revenue, ARR, billing → See [reference/finance.md](reference/finance.md)
**Sales**: Opportunities, pipeline, accounts → See [reference/sales.md](reference/sales.md)
**Product**: API usage, features, adoption → See [reference/product.md](reference/product.md)
**Marketing**: Campaigns, attribution, email → See [reference/marketing.md](reference/marketing.md)
## Quick search
Find specific metrics using grep:
```bash
grep -i "revenue" reference/finance.md
grep -i "pipeline" reference/sales.md
grep -i "api usage" reference/product.md
```显示基本内容,链接到高级内容:
# DOCX Processing
## Creating documents
Use docx-js for new documents. See [DOCX-JS.md](DOCX-JS.md).
## Editing documents
For simple edits, modify the XML directly.
**For tracked changes**: See [REDLINING.md](REDLINING.md)
**For OOXML details**: See [OOXML.md](OOXML.md)Claude 仅在用户需要这些功能时才读取 REDLINING.md 或 OOXML.md。
当文件从其他被引用的文件中被引用时,Claude 可能只会部分读取文件。遇到嵌套引用时,Claude 可能会使用诸如 head -100 之类的命令来预览内容,而不是读取整个文件,从而导致信息不完整。
保持引用距 SKILL.md 只有一层深度。所有参考文件都应直接从 SKILL.md 链接,以确保 Claude 在需要时读取完整的文件。
不好的示例:太深:
# SKILL.md
See [advanced.md](advanced.md)...
# advanced.md
See [details.md](details.md)...
# details.md
Here's the actual information...好的示例:一层深度:
# SKILL.md
**Basic usage**: [instructions in SKILL.md]
**Advanced features**: See [advanced.md](advanced.md)
**API reference**: See [reference.md](reference.md)
**Examples**: See [examples.md](examples.md)对于超过 100 行的参考文件,请在顶部包含目录。这确保即使在部分读取预览时,Claude 也能看到可用信息的完整范围。
示例:
# API Reference
## Contents
- Authentication and setup
- Core methods (create, read, update, delete)
- Advanced features (batch operations, webhooks)
- Error handling patterns
- Code examples
## Authentication and setup
...
## Core methods
...然后,Claude 可以根据需要读取完整文件或跳转到特定部分。
有关这种基于文件系统的架构如何实现渐进式披露的详细信息,请参阅本指南后面的运行时环境部分。
将复杂操作分解为清晰的、顺序的步骤。对于特别复杂的工作流,提供一个清单,Claude 可以将其复制到响应中并在进展过程中逐项勾选。
示例 1:研究综合工作流(适用于不含代码的 Skills):
## Research synthesis workflow
Copy this checklist and track your progress:
```
Research Progress:
- [ ] Step 1: Read all source documents
- [ ] Step 2: Identify key themes
- [ ] Step 3: Cross-reference claims
- [ ] Step 4: Create structured summary
- [ ] Step 5: Verify citations
```
**Step 1: Read all source documents**
Review each document in the `sources/` directory. Note the main arguments and supporting evidence.
**Step 2: Identify key themes**
Look for patterns across sources. What themes appear repeatedly? Where do sources agree or disagree?
**Step 3: Cross-reference claims**
For each major claim, verify it appears in the source material. Note which source supports each point.
**Step 4: Create structured summary**
Organize findings by theme. Include:
- Main claim
- Supporting evidence from sources
- Conflicting viewpoints (if any)
**Step 5: Verify citations**
Check that every claim references the correct source document. If citations are incomplete, return to Step 3.此示例展示了工作流如何应用于不需要代码的分析任务。清单模式适用于任何复杂的多步骤流程。
示例 2:PDF 表单填写工作流(适用于含代码的 Skills):
## PDF form filling workflow
Copy this checklist and check off items as you complete them:
```
Task Progress:
- [ ] Step 1: Analyze the form (run analyze_form.py)
- [ ] Step 2: Create field mapping (edit fields.json)
- [ ] Step 3: Validate mapping (run validate_fields.py)
- [ ] Step 4: Fill the form (run fill_form.py)
- [ ] Step 5: Verify output (run verify_output.py)
```
**Step 1: Analyze the form**
Run: `python scripts/analyze_form.py input.pdf`
This extracts form fields and their locations, saving to `fields.json`.
**Step 2: Create field mapping**
Edit `fields.json` to add values for each field.
**Step 3: Validate mapping**
Run: `python scripts/validate_fields.py fields.json`
Fix any validation errors before continuing.
**Step 4: Fill the form**
Run: `python scripts/fill_form.py input.pdf fields.json output.pdf`
**Step 5: Verify output**
Run: `python scripts/verify_output.py output.pdf`
If verification fails, return to Step 2.清晰的步骤可以防止 Claude 跳过关键验证。清单帮助 Claude 和您跟踪多步骤工作流的进度。
常见模式: 运行验证器 → 修复错误 → 重复
这种模式可以大大提高输出质量。
示例 1:风格指南合规性(适用于不含代码的 Skills):
## Content review process
1. Draft your content following the guidelines in STYLE_GUIDE.md
2. Review against the checklist:
- Check terminology consistency
- Verify examples follow the standard format
- Confirm all required sections are present
3. If issues found:
- Note each issue with specific section reference
- Revise the content
- Review the checklist again
4. Only proceed when all requirements are met
5. Finalize and save the document这展示了使用参考文档而不是脚本的验证循环模式。"验证器"是 STYLE_GUIDE.md,Claude 通过阅读和比较来执行检查。
示例 2:文档编辑流程(适用于含代码的 Skills):
## Document editing process
1. Make your edits to `word/document.xml`
2. **Validate immediately**: `python ooxml/scripts/validate.py unpacked_dir/`
3. If validation fails:
- Review the error message carefully
- Fix the issues in the XML
- Run validation again
4. **Only proceed when validation passes**
5. Rebuild: `python ooxml/scripts/pack.py unpacked_dir/ output.docx`
6. Test the output document验证循环可以及早发现错误。
不要包含会过时的信息:
不好的示例:时效性(将会变得错误):
If you're doing this before August 2025, use the old API.
After August 2025, use the new API.好的示例(使用"旧模式"部分):
## Current method
Use the v2 API endpoint: `api.example.com/v2/messages`
## Old patterns
<details>
<summary>Legacy v1 API (deprecated 2025-08)</summary>
The v1 API used: `api.example.com/v1/messages`
This endpoint is no longer supported.
</details>旧模式部分提供历史背景,而不会使主要内容变得杂乱。
选择一个术语并在整个 Skill 中使用它:
好 - 一致:
不好 - 不一致:
一致性有助于 Claude 解析和遵循指令。
为输出格式提供模板。将严格程度与您的需求相匹配。
对于严格要求(例如 API 响应或数据格式):
## Report structure
ALWAYS use this exact template structure:
```markdown
# [Analysis Title]
## Executive summary
[One-paragraph overview of key findings]
## Key findings
- Finding 1 with supporting data
- Finding 2 with supporting data
- Finding 3 with supporting data
## Recommendations
1. Specific actionable recommendation
2. Specific actionable recommendation
```对于灵活指导(当适应性有用时):
## Report structure
Here is a sensible default format, but use your best judgment based on the analysis:
```markdown
# [Analysis Title]
## Executive summary
[Overview]
## Key findings
[Adapt sections based on what you discover]
## Recommendations
[Tailor to the specific context]
```
Adjust sections as needed for the specific analysis type.对于输出质量取决于查看示例的 Skills,就像在常规提示中一样提供输入/输出对:
## Commit message format
Generate commit messages following these examples:
**Example 1:**
Input: Added user authentication with JWT tokens
Output:
```
feat(auth): implement JWT-based authentication
Add login endpoint and token validation middleware
```
**Example 2:**
Input: Fixed bug where dates displayed incorrectly in reports
Output:
```
fix(reports): correct date formatting in timezone conversion
Use UTC timestamps consistently across report generation
```
**Example 3:**
Input: Updated dependencies and refactored error handling
Output:
```
chore: update dependencies and refactor error handling
- Upgrade lodash to 4.17.21
- Standardize error response format across endpoints
```
Follow this style: type(scope): brief description, then detailed explanation.示例比单独的描述更清楚地向 Claude 传达所需的风格和详细程度。
引导 Claude 通过决策点:
## Document modification workflow
1. Determine the modification type:
**Creating new content?** → Follow "Creation workflow" below
**Editing existing content?** → Follow "Editing workflow" below
2. Creation workflow:
- Use docx-js library
- Build document from scratch
- Export to .docx format
3. Editing workflow:
- Unpack existing document
- Modify XML directly
- Validate after each change
- Repack when complete如果工作流变得庞大或复杂,包含许多步骤,请考虑将它们推送到单独的文件中,并告诉 Claude 根据手头的任务读取适当的文件。
在编写大量文档之前创建评估。 这确保您的 Skill 解决的是真实问题,而不是记录想象中的问题。
评估驱动的开发:
这种方法确保您解决的是实际问题,而不是预测可能永远不会出现的需求。
评估结构:
{
"skills": ["pdf-processing"],
"query": "Extract all text from this PDF file and save it to output.txt",
"files": ["test-files/document.pdf"],
"expected_behavior": [
"Successfully reads the PDF file using an appropriate PDF processing library or command-line tool",
"Extracts text content from all pages in the document without missing any pages",
"Saves the extracted text to a file named output.txt in a clear, readable format"
]
}此示例演示了带有简单测试评分标准的数据驱动评估。目前没有内置的方式来运行这些评估。用户可以创建自己的评估系统。评估是衡量 Skill 有效性的真实来源。
最有效的 Skill 开发过程涉及 Claude 本身。与一个 Claude 实例("Claude A")合作创建一个供其他实例("Claude B")使用的 Skill。Claude A 帮助您设计和完善指令,而 Claude B 在实际任务中测试它们。这之所以有效,是因为 Claude 模型既了解如何编写有效的代理指令,也了解代理需要什么信息。
创建新 Skill:
在没有 Skill 的情况下完成任务: 使用常规提示与 Claude A 一起解决问题。在工作过程中,您会自然地提供上下文、解释偏好并分享程序性知识。注意您反复提供的信息。
识别可重用的模式: 完成任务后,确定您提供的哪些上下文对类似的未来任务有用。
示例: 如果您完成了一个 BigQuery 分析,您可能提供了表名、字段定义、过滤规则(例如"始终排除测试账户")和常见查询模式。
要求 Claude A 创建一个 Skill: "创建一个 Skill,捕获我们刚刚使用的这个 BigQuery 分析模式。包括表模式、命名约定以及关于过滤测试账户的规则。"
Claude 模型原生理解 Skill 格式和结构。您不需要特殊的系统提示或"编写 skills"的 skill 来让 Claude 帮助创建 Skills。只需要求 Claude 创建一个 Skill,它就会生成结构正确的 SKILL.md 内容,包含适当的 frontmatter 和正文内容。
审查简洁性: 检查 Claude A 是否添加了不必要的解释。询问:"删除关于胜率含义的解释——Claude 已经知道了。"
改进信息架构: 要求 Claude A 更有效地组织内容。例如:"将表模式组织到一个单独的参考文件中。我们以后可能会添加更多表。"
在类似任务上测试: 在相关用例上将 Skill 与 Claude B(加载了 Skill 的新实例)一起使用。观察 Claude B 是否找到正确的信息、正确应用规则并成功处理任务。
基于观察进行迭代: 如果 Claude B 遇到困难或遗漏了某些内容,请带着具体情况回到 Claude A:"当 Claude 使用这个 Skill 时,它忘记了按日期过滤 Q4。我们应该添加一个关于日期过滤模式的部分吗?"
迭代现有 Skills:
在改进 Skills 时,同样的分层模式继续适用。您在以下之间交替:
在实际工作流中使用 Skill: 给 Claude B(加载了 Skill)实际任务,而不是测试场景
观察 Claude B 的行为: 注意它在哪里遇到困难、成功或做出意外选择
示例观察: "当我要求 Claude B 提供区域销售报告时,它编写了查询,但忘记过滤掉测试账户,尽管 Skill 提到了这条规则。"
回到 Claude A 进行改进: 分享当前的 SKILL.md 并描述您观察到的情况。询问:"我注意到当我要求区域报告时,Claude B 忘记过滤测试账户。Skill 提到了过滤,但也许它不够突出?"
审查 Claude A 的建议: Claude A 可能会建议重新组织以使规则更突出,使用更强的语言,例如"MUST filter"而不是"always filter",或重构工作流部分。
应用并测试更改: 使用 Claude A 的改进更新 Skill,然后在类似请求上再次与 Claude B 测试
根据使用情况重复: 在遇到新场景时继续这个观察-改进-测试循环。每次迭代都基于真实的代理行为而不是假设来改进 Skill。
收集团队反馈:
为什么这种方法有效: Claude A 了解代理需求,您提供领域专业知识,Claude B 通过实际使用揭示差距,迭代改进基于观察到的行为而不是假设来改进 Skills。
在迭代 Skills 时,请注意 Claude 在实践中实际如何使用它们。注意以下情况:
基于这些观察而不是假设进行迭代。您 Skill 元数据中的 'name' 和 'description' 尤其关键。Claude 在确定是否针对当前任务触发 Skill 时会使用它们。确保它们清楚地描述 Skill 的功能以及何时应该使用它。
始终在文件路径中使用正斜杠,即使在 Windows 上也是如此:
scripts/helper.py、reference/guide.mdscripts\helper.py、reference\guide.mdUnix 风格的路径适用于所有平台,而 Windows 风格的路径会在 Unix 系统上导致错误。
除非必要,否则不要提供多种方法:
**Bad example: Too many choices** (confusing):
"You can use pypdf, or pdfplumber, or PyMuPDF, or pdf2image, or..."
**Good example: Provide a default** (with escape hatch):
"Use pdfplumber for text extraction:
```python
import pdfplumber
```
For scanned PDFs requiring OCR, use pdf2image with pytesseract instead."以下部分重点介绍包含可执行脚本的 Skills。如果您的 Skill 仅使用 markdown 指令,请跳至有效 Skills 清单。
在为 Skills 编写脚本时,要处理错误情况,而不是推给 Claude。
好的示例:显式处理错误:
def process_file(path):
"""Process a file, creating it if it doesn't exist."""
try:
with open(path) as f:
return f.read()
except FileNotFoundError:
# 创建带有默认内容的文件,而不是直接失败
print(f"File {path} not found, creating default")
with open(path, "w") as f:
f.write("")
return ""
except PermissionError:
# 提供替代方案,而不是直接失败
print(f"Cannot access {path}, using default")
return ""不好的示例:推给 Claude:
def process_file(path):
# 直接失败,让 Claude 自行处理
return open(path).read()配置参数也应该有理由并记录在案,以避免"巫毒常量"(Ousterhout 定律)。如果您不知道正确的值,Claude 将如何确定它?
好的示例:自我记录:
# HTTP 请求通常在 30 秒内完成
# 较长的超时时间可应对较慢的连接
REQUEST_TIMEOUT = 30
# 三次重试在可靠性与速度之间取得平衡
# 大多数间歇性故障在第二次重试时即可解决
MAX_RETRIES = 3不好的示例:魔法数字:
TIMEOUT = 47 # Why 47?
RETRIES = 5 # Why 5?即使 Claude 可以编写脚本,预制脚本也有优势:
实用脚本的好处:

上图显示了可执行脚本如何与指令文件一起工作。指令文件(forms.md)引用脚本,Claude 可以执行它而无需将其内容加载到上下文中。
重要区别: 在您的指令中明确说明 Claude 应该:
analyze_form.py 来提取字段"analyze_form.py 了解字段提取算法"对于大多数实用脚本,首选执行,因为它更可靠、更高效。有关脚本执行工作原理的详细信息,请参阅下面的运行时环境部分。
示例:
## Utility scripts
**analyze_form.py**: Extract all form fields from PDF
```bash
python scripts/analyze_form.py input.pdf > fields.json
```
Output format:
```json
{
"field_name": {"type": "text", "x": 100, "y": 200},
"signature": {"type": "sig", "x": 150, "y": 500}
}
```
**validate_boxes.py**: Check for overlapping bounding boxes
```bash
python scripts/validate_boxes.py fields.json
# Returns: "OK" or lists conflicts
```
**fill_form.py**: Apply field values to PDF
```bash
python scripts/fill_form.py input.pdf fields.json output.pdf
```当输入可以渲染为图像时,让 Claude 分析它们:
## Form layout analysis
1. Convert PDF to images:
```bash
python scripts/pdf_to_images.py form.pdf
```
2. Analyze each page image to identify form fields
3. Claude can see field locations and types visually在此示例中,您需要编写 pdf_to_images.py 脚本。
Claude 的视觉能力有助于分析布局和结构。
当 Claude 执行复杂的、开放式的任务时,它可能会犯错误。"计划-验证-执行"模式通过让 Claude 首先以结构化格式创建计划,然后在执行之前用脚本验证该计划,从而及早发现错误。
示例: 想象一下要求 Claude 根据电子表格更新 PDF 中的 50 个表单字段。如果没有验证,Claude 可能会引用不存在的字段、创建冲突的值、遗漏必填字段或错误地应用更新。
解决方案: 使用前面显示的工作流模式(PDF 表单填写),但添加一个中间 changes.json 文件,在应用更改之前对其进行验证。工作流变为:分析 → 创建计划文件 → 验证计划 → 执行 → 验证。
为什么这种模式有效:
何时使用: 批量操作、破坏性更改、复杂的验证规则、高风险操作。
实现提示: 使验证脚本详细并带有具体的错误消息,例如 "Field 'signature_date' not found. Available fields: customer_name, order_total, signature_date_signed",以帮助 Claude 修复问题。
Skills 在代码执行环境中运行,具有特定于平台的限制:
在您的 SKILL.md 中列出所需的包,并在代码执行工具文档中验证它们是否可用。
Skills 在具有文件系统访问、bash 命令和代码执行能力的代码执行环境中运行。有关此架构的概念解释,请参阅概述中的 Skills 架构。
这如何影响您的编写:
Claude 如何访问 Skills:
reference/guide.md),而不是反斜杠form_validation_rules.md,而不是 doc2.mdreference/finance.md、reference/sales.mddocs/file1.md、docs/file2.mdvalidate_form.py 而不是要求 Claude 生成验证代码analyze_form.py 来提取字段"(执行)analyze_form.py 了解提取算法"(作为参考阅读)示例:
bigquery-skill/
├── SKILL.md (overview, points to reference files)
└── reference/
├── finance.md (revenue metrics)
├── sales.md (pipeline data)
└── product.md (usage analytics)当用户询问收入时,Claude 读取 SKILL.md,看到对 reference/finance.md 的引用,并调用 bash 仅读取该文件。sales.md 和 product.md 文件保留在文件系统上,在需要之前消耗零上下文令牌。这种基于文件系统的模型正是实现渐进式披露的原因。Claude 可以导航并有选择地加载每个任务所需的确切内容。
有关技术架构的完整详细信息,请参阅 Skills 概述中的 Skills 工作原理。
如果您的 Skill 使用 MCP(Model Context Protocol)工具,请始终使用完全限定的工具名称以避免"找不到工具"错误。
格式: ServerName:tool_name
示例:
Use the BigQuery:bigquery_schema tool to retrieve table schemas.
Use the GitHub:create_issue tool to create issues.其中:
BigQuery 和 GitHub 是 MCP 服务器名称bigquery_schema 和 create_issue 是这些服务器中的工具名称如果没有服务器前缀,Claude 可能无法找到该工具,尤其是在有多个 MCP 服务器可用时。
不要假设包是可用的:
**Bad example: Assumes installation**:
"Use the pdf library to process the file."
**Good example: Explicit about dependencies**:
"Install required package: `pip install pypdf`
Then use it:
```python
from pypdf import PdfReader
reader = PdfReader("file.pdf")
```"SKILL.md 的 frontmatter 需要 name 和 description 字段,并具有特定的验证规则:
name:最多 64 个字符,仅限小写字母/数字/连字符,无 XML 标签,无保留词description:最多 1,024 个字符,非空,无 XML 标签有关完整的结构详细信息,请参阅 Skills 概述。
将 SKILL.md 正文保持在 500 行以内以获得最佳性能。如果您的内容超过此限制,请使用前面描述的渐进式披露模式将其拆分为单独的文件。有关架构详细信息,请参阅 Skills 概述。
在分享 Skill 之前,请验证:
创建您的第一个 Skill
在 Claude Code 中创建和管理 Skills
以编程方式上传和使用 Skills
Was this page helpful?