Was this page helpful?
このチュートリアルでは、Agent Skillsを使用してPowerPointプレゼンテーションを作成する方法を説明します。Skillsを有効にする方法、簡単なリクエストを行う方法、生成されたファイルにアクセスする方法を学びます。
事前構築されたAgent Skillsは、ドキュメントの作成、データの分析、ファイルの処理などのタスクに特化した専門知識でClaudeの機能を拡張します。Anthropicは、APIで以下の事前構築されたAgent Skillsを提供しています。
カスタムSkillsを作成したいですか? ドメイン固有の専門知識を持つ独自のSkillsを構築する例については、Agent Skills Cookbookを参照してください。
まず、どのSkillsが利用可能かを確認します。Skills APIを使用して、Anthropicが管理するすべてのSkillsを一覧表示します。
次のSkillsが表示されます:pptx、xlsx、docx、pdf。
このAPIは各Skillのメタデータ(名前と説明)を返します。Claudeは起動時にこのメタデータを読み込み、どのSkillsが利用可能かを把握します。これは「progressive disclosure」(段階的開示)の第1レベルであり、Claudeは完全な指示をまだ読み込まずにSkillsを発見します。
次に、PowerPoint Skillを使用して再生可能エネルギーに関するプレゼンテーションを作成します。Messages APIのcontainerパラメータを使用してSkillsを指定します。
各部分の役割を説明します。
container.skills: Claudeが使用できるSkillsを指定しますtype: "anthropic": これがAnthropic管理のSkillであることを示しますskill_id: "pptx": PowerPoint Skillの識別子version: "latest": 最新の公開バージョンに設定されたSkillバージョンtools: コード実行を有効にします(Skillsに必須)code-execution-2025-08-25とskills-2025-10-02ここでの例では、code_execution_20250825ツールバージョンと、それに対応するcode-execution-2025-08-25ベータヘッダーを使用しています。Skillsは、より新しいコード実行ツールのリビジョン(code_execution_20260120以降)でも動作します。どのコード実行ツールバージョンでもSkillsの要件を満たします。どのバージョンを使用する場合でも、ツールのtypeとベータヘッダーをコード実行ツールのページと一致させ、常にskills-2025-10-02を含めてください。
このリクエストを行うと、Claudeは自動的にタスクを関連するSkillにマッチングします。プレゼンテーションを依頼したため、ClaudeはPowerPoint Skillが関連していると判断し、その完全な指示を読み込みます。これが段階的開示の第2レベルです。その後、ClaudeはSkillのコードを実行してプレゼンテーションを作成します。
プレゼンテーションはコード実行コンテナ内で作成され、ファイルとして保存されました。レスポンスにはファイルIDを含むファイル参照が含まれています。ファイルIDを抽出し、Files APIを使用してダウンロードします。
生成されたファイルの操作に関する詳細については、コード実行ツールのドキュメントを参照してください。
Skillsを使用して最初のドキュメントを作成したので、次のバリエーションを試してみてください。
事前構築されたAgent Skillsを使用したので、次のことができます。
# Anthropic管理のスキルを一覧表示
ant beta:skills list --source anthropic# PowerPoint Skillを使用してメッセージを作成
response = client.beta.messages.create(
model="claude-opus-4-8",
max_tokens=16000,
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(f"stop_reason={response.stop_reason}, blocks={len(response.content)}")# コード実行ツールの結果からファイルIDを抽出。Skillは
# Pythonまたはbashのコード実行ツールのいずれかで処理を実行する可能性があるため、
# 両方の結果タイプを確認します。
file_id = None
for block in response.content:
if block.type == "code_execution_tool_result":
if block.content.type == "code_execution_result":
for output in block.content.content:
file_id = output.file_id
elif block.type == "bash_code_execution_tool_result":
if block.content.type == "bash_code_execution_result":
for output in block.content.content:
file_id = output.file_id
if file_id:
# ファイルをダウンロードして保存
output_path = Path(tempfile.gettempdir()) / "renewable_energy.pptx"
file_content = client.beta.files.download(file_id=file_id)
file_content.write_to_file(output_path)
print(f"Presentation saved to {output_path}")response = client.beta.messages.create(
model="claude-opus-4-8",
max_tokens=16000,
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-8",
max_tokens=16000,
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-8",
max_tokens=16000,
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"}],
)Claude CodeでのSkillsについて学ぶ