談談 `Claude Skills`
最近 Claude 在 ??github??? 上有一個比較火的項目:??https://github.com/anthropics/skills???,項目是圍繞新概念 ??Skills??,我覺得實際上是:通過工程化結構來實現智能體,用一種工程范式來完成子功能,就像C++代碼中提出一種更好的設計模式來解決通用問題。
?1. 什么是 ???Skills???
??Skills??? 是一組由說明文檔、腳本與資源組成的 “技能包”,Claude 會在需要時動態加載,用于提升在特定任務上的一致性與表現,借助 ??Skills??,Claude 能以可復用的方式完成某類任務,例如:按公司品牌規范創作文檔、按組織特定流程分析數據,或自動化個人工作流。

???Skills?? 如何工作?
??Skills??? 通過 “逐步迭代” 的方式工作:當你發起任務時,Claude 會審視可用 ??Skills??,自動挑選相關的技能并只加載完成任務所需的指令與資源,這樣既能提升速度與效果,也能避免將無關內容塞滿上下文窗口,從而保持對話與計算的高效與穩定。
核心機制:
- 你提出任務請求
- Claude 在可用?
?Skills?? 中進行匹配與選擇 - 自動加載相關技能的指令/腳本/資源
- 按技能流程執行任務,提高一致性與完成質量
優勢:
- 提升專項任務表現:為文檔創作、數據分析與領域任務提供專門能力,補強通用模型的知識與流程執行力
- 組織知識沉淀:將組織流程、最佳實踐與制度化知識打包,使團隊成員與 Claude 保持一致的執行標準
- 易于定制:使用 Markdown 編寫說明即可創建基礎?
?Skills??,如需更高級功能,可為自定義技能附加可執行腳本 - 易于組合:對于復雜的任務,可以通過多個?
?Skills?? 組合迭代處理
SKILL.md 模版文件:
---
name: my-skill-name
description: A clear description of what this skill does and when to use it
---
# My Skill Name
[Add your instructions here that Claude will follow when this skill is active]
## Examples
- Example usage 1
- Example usage 2
## Guidelines
- Guideline 1
- Guideline 22. 與 Claude 其他功能對比
Skills vs. Projects:
- Projects:為特定項目對話提供 “持續加載” 的靜態背景知識
- Skills:提供 “按需激活” 的專門流程與操作指南,并可在任意對話中動態生效
Skills vs. MCP(Model Context Protocol):
- MCP:將 Claude 連接到外部服務與數據源
- ?
?Skills??:提供 “如何完成任務” 的流程性知識與操作步驟 - 二者可協同:MCP 負責接入工具與數據,?
?Skills?? 負責教會 Claude 如何有效使用這些工具
Skills vs. Prompt
- Prompt:對所有對話生效,強調通用偏好與風格
- ?
?Skills??:面向特定任務,僅在相關時加載,更適合專業工作流與場景化流程
?3. ???Skills?? 目錄結構?
??Skills?? 目錄結構如下:
my-skill/
├── SKILL.md (required)
├── reference.md (optional documentation)
├── examples.md (optional examples)
├── scripts/
│ └── helper.py (optional utility)
└── templates/
└── template.txt (optional template)3.1 基礎結構
- ?
?Skills??? 目錄與??SKILL.md?? 文件 - 每個?
?Skills??? 至少包含一個目錄和其中的??SKILL.md?? 文件 - ?
?SKILL.md??? 頂部必須以??YAML frontmatter??? 開始,至少包含??name??? 與??description?? 兩個必填元數據字段 - 其余內容采用 “迭代執行” 原則:先讀元數據,必要時再加載正文、參考文件與腳本,避免上下文過載
3.2 元數據
- name【必填】:人類可讀的 Skill 名稱(≤ 64 字符),示例:Brand Guidelines
- description【必填】:Skill 的用途與觸發條件(≤ 200 字符;Claude 依此判斷何時調用),示例:Apply Acme Corp brand guidelines to presentations and documents, including official colors, fonts, and logo usage.
- version【可選】:版本號(便于演進與回滾),示例:1.0.0
- dependencies【可選】:所需軟件包,示例:python>=3.8, pandas>=1.5.0
?3.3 ???SKILL.md?? 的正文?
- 當僅憑元數據不足以執行任務時,Claude 會加載正文
- 正文可包含:執行步驟、規范細則、示例、何時/何不適用、引用的資源文件等
??SKILL.md??樣例:
---
name: Brand Guidelines
description: Apply Acme Corp brand guidelines to all presentations and documents, including official colors, fonts, and logo usage.
version: 1.0.0
dependencies: []
---
# Overview
This Skill provides Acme Corp's official brand guidelines for creating consistent, professional materials. When creating presentations, documents, or marketing materials, apply these standards to ensure all outputs match Acme's visual identity. Claude should reference these guidelines whenever creating external-facing materials or documents that represent Acme Corp.
## Brand Colors
- Primary: #FF6B35 (Coral)
- Secondary: #004E89 (Navy Blue)
- Accent: #F7B801 (Gold)
- Neutral: #2E2E2E (Charcoal)
## Typography
- Headers: Montserrat Bold
- Body text: Open Sans Regular
- Size guidelines:
- H1: 32pt
- H2: 24pt
- Body: 11pt
## Logo Usage
- Use the full-color logo on light backgrounds; use the white logo on dark backgrounds.
- Maintain minimum spacing of 0.5 inches around the logo.
## When to Apply
Apply these guidelines when creating:
- PowerPoint presentations
- Word documents for external sharing
- Marketing materials
- Client-facing reports
## Examples
- Input: “Create a 10-slide pitch deck for Acme Corp’s new product.”
- Output: A PPT with the above colors, fonts, logo rules, and spacing applied consistently.
## Resources
See the resources folder for logo files and font downloads.?3.4 ???Skill?? 涉及的資源?
??SKILL.md?? 需要引入的資源文件
- 當信息較多、且部分內容僅在特定情境需要時,可將補充材料拆分為獨立文件(如 REFERENCE.md、CHECKLIST.md、TEMPLATES/)
- 在?
?SKILL.md?? 中引用這些文件,Claude 將按需加載,減少無關內容占用
可執行腳本
- 進階?
?Skill?? 可附帶可執行代碼文件,供 Claude 調用以完成復雜任務(例如文檔批量處理、數據清洗、可視化等) - 常用語言與生態:
- Python(pandas、numpy、matplotlib 等)
- JavaScript / Node.js等
- 包管理約束:
- Claude 與 Claude Code 在加載?
?Skill?? 時可從標準倉庫安裝依賴(Python PyPI、JavaScript npm) - 使用 API Skills 時,運行時無法臨時安裝新包,所有依賴必須預裝在容器中
4. 在 Claude 上如何使用

上傳前:
- 通讀?
?SKILL.md??,確保指令清晰、步驟完備 - 確認 description 能準確描述 “何時使用”
- 校驗被引用文件路徑與命名無誤
- 以若干示例提示詞本地自測,觀察 Claude 是否會觸發該 Skill
上傳到 Claude 后:
- 在 Settings > Capabilities 中啟用該 Skill
- 使用多種應觸發它的提示詞進行驗證
- 確認 Claude 在響應中已加載 Skill(例如輸出中體現技能名稱或遵循技能流程)
- 若未按預期觸發,迭代完善 description 與正文的觸發條件與范圍
?5. 最佳實踐:什么樣的 ???Skills?? 才是好 “Skill”?
- 指令清晰、可被 Claude 穩定執行
- 面向一個明確、可重復的任務
- 聚焦單一工作流:面向不同流程分別創建技能,小而專注的 Skills 更易組合復用
- 描述要具體:明確“適用對象、時機、邊界與例外”,便于 Claude 正確判定調用
- 從簡入手:先用 Markdown 指令跑通骨架,再逐步引入腳本與復雜邏輯
- 加示例:在 Skill.md 放入典型輸入/輸出,幫助對齊 “何為成功”
- 版本化:持續維護 version 字段,便于回溯與排錯
- 漸進測試:每次重要變更后快速驗證,避免一次性 “大改大上”
- 組合性:盡管 Skills 不能顯式互相引用,但 Claude 可自動同時使用多個技能,發揮 “組裝效應”
?6. ???Claude Skills?? 官方示例?
Claude 官方提供 ??https://github.com/anthropics/skills??? 20+個樣例,本文就拆解其中一個比較常用的,自動執行 ??Web 應用程序測試?? ,目錄結構如下:
webapp-testing/
├── SKILL.md
├── scripts/
│ └── with_server.py
└── examples/
└── console_logging.py
└── element_discovery.py
└── static_html_automation.py6.1 功能描述
根據 description 介紹當前功能,用于使用 Playwright 交互和測試本地 Web 應用程序的工具包,支持驗證前端功能、調試 UI 行為、捕獲瀏覽器截圖以及查看瀏覽器日志。
---
name: webapp-testing
description: Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.
license: Complete terms in LICENSE.txt
---6.2 正文-工作流程
這部分是正文重點的部分,介紹當前決策樹的工作流,不過我覺得用時序圖,EARS等也可以,只要能介紹清楚每個步驟需要做什么。
## Decision Tree: Choosing Your Approach
User task → Is it static HTML?
├─ Yes → Read HTML file directly to identify selectors
│ ├─ Success → Write Playwright script using selectors
│ └─ Fails/Incomplete → Treat as dynamic (below)
│
└─ No (dynamic webapp) → Is the server already running?
├─ No → Run: python scripts/with_server.py --help
│ Then use the helper + write simplified Playwright script
│
└─ Yes → Reconnaissance-then-action:
1. Navigate and waitfor networkidle
2. Take screenshot or inspect DOM
3. Identify selectors from rendered state
4. Execute actions with discovered selectors6.3 正文-使用腳本示例
這部分主要是介紹腳本怎么使用,腳本執行前需要做什么,腳本執行后需要做什么等,如下:
## Example: Using with_server.py
To start a server, run `--help` first, then use the helper:
...6.4 正文-其他
其他部分就是包括一些流程需要的細節,注意事項,涉及的一些文件是做什么的等介紹,如下:
## Reconnaissance-Then-Action Pattern
...
## Common Pitfall
...
## Best Practices
...
## Reference Files
...7. 總結
Claude ??Skills??? 是提供了一種工程范式,以前大家通過各種 ??MCP???,??Agent??? 等將功能組合起來,中間層通過 ??Prompt??? 粘合,一方面不容易維護和繼承,另一方面沒有規范會導致不穩定,但是 ??Skills??? 通過工程范式約束很大程度上解決 ??AI??? 項目的工程化問題;同時每一個 ??Skills??? 文件夾就是小的 ??Agent???,這些 ??Skills??? 又可以組合為一個復雜的 ??Agent??,就像我們寫代碼一樣,先有基礎庫,然后通過基礎庫再組合復雜工程邏輯,這個大概是就是從混沌到規范化的歷程。
參考
(1)https://github.com/anthropics/skills(2)https://docs.claude.com/zh-CN/docs/claude-code/skills
本文轉載自??周末程序猿??,作者:周末程序猿

















