本教學課程展示如何使用 Agent Skills 建立 PowerPoint 簡報。您將學習如何啟用 Skills、進行簡單請求,以及存取產生的檔案。
預先建立的 Agent Skills 使用專門的專業知識擴展 Claude 的功能,用於建立文件、分析資料和處理檔案等任務。Anthropic 在 API 中提供以下預先建立的 Agent Skills:
想要建立自訂 Skills? 請參閱 Agent Skills Cookbook 以取得使用領域特定專業知識建立您自己的 Skills 的範例。
首先,檢查有哪些 Skills 可用。使用 Skills API 列出所有 Anthropic 管理的 Skills:
ant beta:skills list --source anthropic您會看到以下 Skills:pptx、xlsx、docx 和 pdf。
此 API 傳回每個 Skill 的中繼資料:其名稱和描述。Claude 在啟動時載入此中繼資料,以了解有哪些 Skills 可用。這是漸進式揭露的第一個層級,其中 Claude 發現 Skills 而不會立即載入其完整指示。
現在使用 PowerPoint Skill 建立關於再生能源的簡報。使用 Messages API 中的 container 參數指定 Skills:
import anthropic
client = anthropic.Anthropic()
# Create a message with the PowerPoint Skill
response = client.beta.messages.create(
model="claude-opus-4-7",
max_tokens=4096,
betas=["code-execution-2025-08-25", "skills-2025-10-02"],
container={
"skills": [{"type": "anthropic", "skill_id": "pptx", "version": "latest"}]
},
messages=[
{
"role": "user",
"content": "Create a presentation about renewable energy with 5 slides",
}
],
tools=[{"type": "code_execution_20250825", "name": "code_execution"}],
)
print(response.content)讓我們分解每個部分的作用:
container.skills: 指定 Claude 可以使用哪些 Skillstype: "anthropic": 表示這是 Anthropic 管理的 Skillskill_id: "pptx": PowerPoint Skill 識別碼version: "latest": Skill 版本設定為最近發佈的版本tools: 啟用程式碼執行(Skills 所需)code-execution-2025-08-25 和 skills-2025-10-02當您進行此請求時,Claude 會自動將您的任務與相關的 Skill 進行配對。由於您要求簡報,Claude 判斷 PowerPoint Skill 是相關的,並載入其完整指示:漸進式揭露的第二個層級。然後 Claude 執行 Skill 的程式碼以建立您的簡報。
簡報已在程式碼執行容器中建立並儲存為檔案。回應包含具有檔案 ID 的檔案參考。提取檔案 ID 並使用 Files API 下載它:
from typing import Any
response: Any = None
# Extract file ID from response
file_id = None
for block in response.content:
if block.type == "tool_use" and block.name == "code_execution":
# File ID is in the tool result
for result_block in block.content:
if hasattr(result_block, "file_id"):
file_id = result_block.file_id
break
if file_id:
# Download the file
file_content = client.beta.files.download(
file_id=file_id, betas=["files-api-2025-04-14"]
)
# Save to disk
with open("renewable_energy.pptx", "wb") as f:
file_content.write_to_file(f.name)
print(f"Presentation saved to renewable_energy.pptx")如需有關使用產生的檔案的完整詳細資訊,請參閱程式碼執行工具文件。
現在您已使用 Skills 建立了第一個文件,請嘗試這些變化:
response = client.beta.messages.create(
model="claude-opus-4-7",
max_tokens=4096,
betas=["code-execution-2025-08-25", "skills-2025-10-02"],
container={
"skills": [{"type": "anthropic", "skill_id": "xlsx", "version": "latest"}]
},
messages=[
{
"role": "user",
"content": "Create a quarterly sales tracking spreadsheet with sample data",
}
],
tools=[{"type": "code_execution_20250825", "name": "code_execution"}],
)response = client.beta.messages.create(
model="claude-opus-4-7",
max_tokens=4096,
betas=["code-execution-2025-08-25", "skills-2025-10-02"],
container={
"skills": [{"type": "anthropic", "skill_id": "docx", "version": "latest"}]
},
messages=[
{
"role": "user",
"content": "Write a 2-page report on the benefits of renewable energy",
}
],
tools=[{"type": "code_execution_20250825", "name": "code_execution"}],
)response = client.beta.messages.create(
model="claude-opus-4-7",
max_tokens=4096,
betas=["code-execution-2025-08-25", "skills-2025-10-02"],
container={
"skills": [{"type": "anthropic", "skill_id": "pdf", "version": "latest"}]
},
messages=[{"role": "user", "content": "Generate a PDF invoice template"}],
tools=[{"type": "code_execution_20250825", "name": "code_execution"}],
)現在您已使用預先建立的 Agent Skills,您可以:
在 Claude API 中使用 Skills
上傳您自己的 Skills 以進行專門任務
學習撰寫有效 Skills 的最佳實踐
了解 Claude Code 中的 Skills
探索範例 Skills 和實作模式
Was this page helpful?