← Academy 日本語で学ぶ(一覧へ戻る)

claude platform 101

Anthropic Academy コースの日本語ナレッジ(学習用)/ 全 15 項目

Claude Platform 101(Anthropic Academy)日本語ナレッジ

Claude Developer Platform(API / Console)でゼロから開発する入門コース。ブラウザのチャットではなく、コードから構造化リクエストを送って Claude をプロダクトに組み込む方法を、primitives → infrastructure → controls の 3 レイヤーで学ぶ。全 14 レッスン(本文 13 + クイズ 1)を日本語全訳+英語原文の 2 層で収録。

出典: Anthropic Academy「Claude Platform 101」/ ナレッジ化日 2026-07-04 用途: 中嶋直喜さんの学習用。API・Console・モデル名・パラメータ・コード例は原文(英語)のまま正確に保持。

レッスン一覧

# ファイル タイトル(原題) 要点
01 01_claude-developer-platformとは.md Claude Developer Platform とは?(What is the Claude Developer Platform?) REST API / SDK / CLI / Console の全体像。3 レイヤー:primitives・infrastructure・controls。「build with primitives, scale on infrastructure, run with control」
02 02_はじめてのAPI呼び出し.md はじめての API 呼び出し(Your first API call) messages.create(model / max_tokens / messages)。キーは .env.local。response.content はブロック配列でループ処理
03 03_適切なモデルを選ぶ.md 適切なモデルを選ぶ(Choosing the right model) Fable / Opus / Sonnet / Haiku のティア。20〜30 例で eval を組み、Haiku から上げて「世に出せる最安モデル」で止める。response.usage が請求根拠
04 04_エージェントループの仕組み.md エージェントループの仕組み(The agent loop explained) tool_use → 実行 → tool_result → 繰り返し → end_turn。最小例(get_weather)で while ループの全体像
05 05_ツール使用とは.md ツール使用とは?(What is tool use?) tool = name / description / input_schema の JSON。実行はあなたのコード。description の質が tool 選択の質。複数ツールと switch 分岐
06 06_思考とは.md 思考とは?(What is thinking?) extended thinking / adaptive。Opus 4.7 は thinking:{"type":"adaptive"}effortoutput_config 内(low〜max)。難問・トレードオフ用
07 07_組み込みツール.md 組み込みツール(Built-in tools) server tools(web_search / code_execution / web_fetch)は Anthropic 実行・ループ不要。client tools(memory / bash)は SDK 同梱
08 08_スキル.md スキル(Skills) SKILL.md で手順をパッケージ化。tools=何ができるか / Skills=どうやってほしいか。段階読み込み。container.skills で付与(beta)
09 09_MCP.md MCP 統合のメンテを提供者側に移す。tools=自社データ / skills=自社プロセス / MCP=他社サービス。mcp_serversmcp_toolset。ツール単位で enable/disable
10 10_コンテキスト管理.md コンテキスト管理(Context management) 4 パターン:just-in-time(設計)/ server-side compaction / prompt caching / memory tool。managed agents はキャッシュ&圧縮がデフォルト ON
11 11_マネージドエージェントとは.md マネージドエージェントとは?(What are managed agents?) エージェントループを Anthropic がホスト。3 例(Kanban / 定期リサーチ+memory / マルチエージェントのインシデント対応)。rubric grader・並行セッション
12 12_はじめてのマネージドエージェントを作る.md はじめてのマネージドエージェントを作る(Building your first managed agent) 4 プリミティブ:Agent / Environment / Session / Events。while ではなく「イベントを送って読む」。ストリームは kickoff より先に開く
13 13_claude-codeで作る.md Claude Code で作る(Building with Claude Code) スタブ → Claude Code に委譲 → diff レビュー。組み込み Claude API skill(/claude-api、TS SDK 検知で自動)。良いプロンプト=ファイル / パターン / 最終状態を名指し
14 14_claude-platform-101クイズ.md Claude Platform 101 クイズ(Quiz) クイズ(受験は別途)

モデル名・API シンボル早見(原文ママ)

コース内で登場したモデル ID・API 要素(バージョン付き識別子はコース制作時点のもの。実装時は最新を確認):

  • モデル: claude-haiku-4-5 / claude-sonnet-4-5 / claude-sonnet-4-6 / claude-opus-4-7 / claude-opus-4-8(+新ティア Claude Fable / Claude Mythos)
  • コア: client.messages.createmodel / max_tokens / system / messages / tools)、response.content(block.type = text / tool_use / thinking)、response.stop_reasonend_turn / tool_use)、response.usage
  • tool runner: client.beta.messages.toolRunner({ model, max_tokens, messages, tools:[fn,...] })await runner.untilDone()(TypeScript / Python / Ruby。実関数から型・docs を読んでスキーマ自動生成し、tool use / tool result ループを内包)
  • thinking: thinking={"type":"adaptive"}output_config={"effort": ...}(low / medium / high / xhigh / max)
  • server tools: web_search_20260209 / code_execution_20260120(block: server_tool_use / bash_code_execution_tool_result
  • skills: client.beta.skills.createcontainer.skillsbetas=["skills-2025-10-02","code-execution-2025-08-25"]
  • MCP: mcp_servers(type/url/name/authorization_token)+ tools:[{type:"mcp_toolset",...}]betas=["mcp-client-2025-11-20"](default_config.enabled で絞り込み)
  • context: context_management={"edits":[{"type":"compact"}]}、prompt caching、memory tool
  • managed agents: client.beta.agents.create / environments.create / sessions.create / sessions.events.stream / sessions.events.send。toolset = agent_toolset_20260401。events = user.message / agent.message / agent.tool_use / session.status_idle

ClaudeCode/API 開発に活きる点

  1. モデルはティア昇順で eval → 最安で確定:本番実装前に実ワークロード 20〜30 例で Haiku→Sonnet→Opus と回し「世に出せる最安モデル」で止める。1 エンドポイント内でタスク別ルーティング(分類=Haiku / 生成=Sonnet / 難物=Opus)。自作システムのモデル選定・コスト最適化に直結。
  2. tool の description が tool 選択の質を決める:曖昧な description が「エージェントが正しいツールを掴めない」第 1 位原因。自作 MCP / agent / subagent 定義でも description を具体的に書く原則は共通。
  3. MCP は「他社統合のメンテを外す」設計思想:tools=自社データ / skills=自社プロセス / MCP=他社サービス、という切り分けは、このワークスペースの多数の MCP(supabase / figma / shopify / notion 等)の使い分け判断と同じ軸。default_config.enabled=false → 必要ツールだけ enable は、書き込み権限の事故防止に有効(mcp-on-demand 運用と整合)。
  4. コンテキスト管理 4 パターンは Claude Code 運用にも写像:just-in-time(必要時に読む)/ compaction / prompt caching / memory tool は、本ワークスペースの session-hygiene・strategic-compact・memory 運用と同型。「全部詰め込まず適切なものを詰める」原則を API 側でも徹底。
  5. thinking の effort 使い分け:活字は low で十分・トレードオフや難物に high 以上、というコース指針は、DA 動画ナレッジ化で得た「活字=low最適 / 手描き=xhigh」の実測知見と一致。effortoutput_config 内という API 上の位置は要注意(thinking ブロック直下ではない)。
  6. ツールランナーで tool use ループを内包client.beta.messages.toolRunner に実関数を直接渡すと、JSON スキーマの手書きも while ループも stop_reason 分岐もツール結果の手動 push も不要になる(TS / Python / Ruby)。「自分でループを回す」か「ランナーに委譲する」かの選択で、自作 API 統合コードは大幅に減る。Claude Code は TS SDK を検知すると Claude API skill(/claude-api)を自動起動し、この形(tool 定義→runner→結果)を書いてくれる(Lesson 05・13)。手でループを持ちたい難所だけ手動に落とす、が指針。
↑ 目次へ戻る

Claude Platform 101 | Lesson 01「Claude Developer Platform とは?(What is the Claude Developer Platform?)」

出典: Anthropic Academy / 2026-07-04

日本語ナレッジ(本文の自然な全訳)

Claude Developer Platform は、Claude をプログラムから使って開発するための Anthropic のインフラです。ブラウザで Claude とチャットする代わりに、あなたのコードから構造化されたリクエストを送り、構造化されたレスポンスを受け取ります。しかもその際、あらゆる詳細をコントロールできます。どのモデルを使うか、トークンをどれだけ消費するか、Claude にどのツールを使わせるか、どんなシステム指示に従わせるか、といった具合です。

具体的には、このプラットフォームはいくつかの要素で構成されています。

  • どの言語からでも呼び出せる REST API
  • 各プログラミング言語向けの SDK
  • コマンドラインインターフェース(CLI)
  • API キーの管理、使用状況のモニタリング、マネージドエージェントのデプロイ、プロンプトのテストができるコンソール

プラットフォームの 3 つのレイヤー

プラットフォームを理解する便利な捉え方は、3 つのレイヤーが積み重なっているとイメージすることです。

  • Primitives(プリミティブ) — Claude 向けにチューニングされた API の構成要素。これは Messages API、tool use、files、web search、code execution、MCP servers、skills です。実際にあなたのコードから呼び出す部品にあたります。
  • Infrastructure(インフラ) — プロトタイプの先へエージェント的システムを構築・スケールさせるために必要なもの。マネージドエージェント、リトライ、キュー、オブザーバビリティなど、1 回の Claude 呼び出しが 1,000 回になっても動き続けさせる「配管」です。
  • Controls(コントロール) — これらのシステムを本番で運用するためのツール。ダッシュボードや evals(評価)などです。稼働後にチームが回すダイヤルにあたります。

合言葉はこうです。primitives で作り、infrastructure でスケールし、control で運用する。

この構造は Claude Console 自体にも反映されています。コンソールこそが infrastructure と control のレイヤーが存在する場所で、build(構築)、agent の管理、analytics(分析)のセクションが用意されています。

実例:ヘルプデスクの返信ドラフトを作る

たとえば、基本的なヘルプデスクアプリを運用していて、「チケットの内容に基づいて、チームのトーンとガイドラインに沿った返信ドラフトを作成する」機能を追加してほしいと依頼されたとします。そしてこれを UI 上のボタンに繋ぎたい。

これはまさに Messages API の格好の用途です。流れはこうなります。

  • クライアントを定義する
  • チャットが参照しているチケットを取得する
  • messages.create を呼び出す
  • レスポンスをボタンに返して描画する
client = anthropic.Anthropic()

response = client.messages.create(
    model="claude-haiku-4-5",  # Haiku: シンプルなドラフト作成に適した選択
    max_tokens=1024,
    system=TONE_AND_GUIDELINES,
    messages=[
        {"role": "user", "content": ticket_content}
    ],
)

draft = response.content

各パラメータには、それぞれ明確な役割があります。

  • model — どのモデルがリクエストを処理するか。ここでは返信ドラフト作成はシンプルなタスクなので Haiku を使っています。
  • max_tokens — Claude のレスポンスの最大長に上限を設けます。
  • system — システムプロンプト。ここで Claude が演じる役割を定義します。関連するトーンとガイドラインはここに入れます。
  • messages — オブジェクトの配列。user ロールはこれがユーザー入力であることを Claude に伝え、そこにチケット内容が入ります。

あとはレスポンスを取り出し、ボタンに返して描画するだけ。完了です。

「Claude に質問する」から「Claude が自分のプロダクトの一部になる」へ

この例で起きたことに注目してください。あなたはチャットボットをゼロから作っているわけではありません。すでに存在するプロダクトに Claude を組み込んでいて、その接続手段が API なのです。

これが核心のアイデアです。Claude Platform は、Claude のモデル・ツール・インフラへの API レベルのアクセスです。これによって「Claude に質問する」から「Claude が自分のプロダクトの一部になる」へと進めます。

そしてプロダクトがエージェントを必要とするようになったとき、プラットフォームは単にモデルを渡すだけではありません。マネージドエージェントを使えば、そのエージェントをあなたの代わりに実行してくれます。

まとめ

  • Claude Developer Platform は、Claude をプログラムから使って開発するための Anthropic のインフラ。REST API、SDK、CLI、そしてキー・使用状況・マネージドエージェント・プロンプトテストを扱うコンソールで構成される。
  • 3 つのレイヤーで捉える。primitives(Messages API、tool use、files、web search、code execution、MCP servers、skills)、infrastructure(マネージドエージェント、リトライ、キュー、オブザーバビリティ)、controls(ダッシュボード、evals)。
  • 合言葉:primitives で作り、infrastructure でスケールし、control で運用する。
  • 1 回の messages.create 呼び出しで、モデル・レスポンス長・システムプロンプト・ユーザー入力をフルコントロールできる。ヘルプデスクの返信ドラフトのような既存機能に Claude を組み込むには十分。
  • このプラットフォームは、Claude に質問するところから、Claude をプロダクトの一部にするところまで導く。マネージドエージェントを使えば、あなたのエージェントを代わりに実行してくれる。

英語原文

The Claude Developer Platform is Anthropic's infrastructure for building with Claude programmatically. Instead of chatting with Claude in a browser, you send structured requests from your code and get structured responses back — with control over every detail: which model to use, how many tokens to spend, what tools Claude can use, and what system instructions it follows.

Concretely, the platform is made up of a few pieces:

  • A REST API you can call from any language
  • SDKs for different programming languages
  • Command line interfaces
  • A console where you manage API keys, monitor usage, deploy managed agents, and test prompts

The three layers of the platform

A useful way to picture the platform is as three layers stacked on top of each other.

  • Primitives — the API building blocks tuned to Claude. This is the Messages API, tool use, files, web search, code execution, MCP servers, and skills. These are the pieces you actually call from your code.
  • Infrastructure — what you need to build and scale agentic systems past a prototype. Managed agents, retries, queues, observability — the plumbing that keeps things running when one Claude call becomes a thousand.
  • Controls — the tools for running those systems in production, like dashboards and evals. These are the dials your team uses once it's live.

The shorthand: build with primitives, scale on infrastructure, run with control.

You can see this structure reflected in the Claude Console itself — it's where the infrastructure and control layers live, with sections for building, managing agents, and analytics.

A real example: drafting help desk replies

Say you manage a basic help desk app, and you've been asked to add a feature: draft a reply based on the contents of a ticket, following your team's tone and guidelines. You want to wire this up to a button in the UI.

This is a perfect use case for the Messages API. The flow looks like this:

  • Define a client
  • Retrieve the ticket the chat refers to
  • Call messages.create
  • Return the response to the button to render
client = anthropic.Anthropic()

response = client.messages.create(
    model="claude-haiku-4-5",  # Haiku: a good fit for a simple drafting task
    max_tokens=1024,
    system=TONE_AND_GUIDELINES,
    messages=[
        {"role": "user", "content": ticket_content}
    ],
)

draft = response.content

Each parameter does a specific job:

  • model — which model handles the request. Here that's Haiku, since drafting a reply is a simple task.
  • max_tokens — caps how long Claude's response can be.
  • system — the system prompt, where you define the role Claude plays. The relevant tone and guidelines go here.
  • messages — an array of objects. The user role tells Claude this is user input; the ticket content goes there.

Then you retrieve the response and return it to the button to render. Done.

From "ask Claude a question" to "Claude is part of my product"

Notice what happened in that example: you're not building a chatbot from scratch. You're adding Claude into a product that already exists, and the API is how you wire it in.

That's the core idea. The Claude Platform is your API-level access to Claude's models, tools, and infrastructure. It's how you go from ask Claude a question to Claude is part of my product.

And when your product needs agents, the platform doesn't just hand you the model. With managed agents, it runs them for you.

Recap

  • The Claude Developer Platform is Anthropic's infrastructure for building with Claude programmatically: a REST API, SDKs, CLIs, and a console for keys, usage, managed agents, and prompt testing.
  • Think of it as three layers: primitives (Messages API, tool use, files, web search, code execution, MCP servers, skills), infrastructure (managed agents, retries, queues, observability), and controls (dashboards, evals).
  • The shorthand: build with primitives, scale on infrastructure, run with control.
  • A single messages.create call gives you full control over the model, response length, system prompt, and user input — enough to wire Claude into an existing feature like drafting help desk replies.
  • The platform takes you from asking Claude questions to making Claude part of your product — and with managed agents, it can run your agents for you.
↑ 目次へ戻る

Claude Platform 101 | Lesson 02「はじめての API 呼び出し(Your first API call)」

出典: Anthropic Academy / 2026-07-04

日本語ナレッジ(本文の自然な全訳)

Claude に「hi」と挨拶するのは心温まるかもしれませんが、実用にはなりません。このレッスンでは、20 行足らずのコードで、Claude に本物のインプットを送り、構造化された洞察を返してもらいます。

セットアップ

まず、platform.claude.com で API キーを取得します。事前にクレジットを購入しておく必要があります。

取得した API キーは .env.local ファイルに保存し、バージョン管理から外しておきます。ソースファイルにキーをハードコードするのが、GitHub にキーが流出する典型的な原因です。環境ファイルに置いておきましょう。

次に SDK をインストールします。

npm install @anthropic-ai/sdk

リクエストの構造

すべての API 呼び出しは messages.create 関数を通ります。指定するのは 3 つです。

  • model(モデル) — どの Claude モデルがリクエストを処理するか
  • max tokens(最大トークン数) — レスポンスの最大長の上限
  • messages(メッセージのリスト)user または assistant ロールを持つオブジェクトの配列。他の場面で Claude と会話するのと同じような構造

もっとも基本的な形はこうです。

import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic();

const msg = await client.messages.create({
    model: "claude-opus-4-7",
    max_tokens: 1024,
    messages: [{
        role: "user",
        content: "Hello, Claude",
    }],
});

実例:バグのあるコードをレビューする

「hello」よりも少し面白いものを Claude に渡してみましょう。バグのあるコードを指し示して、レビューを依頼します。全体はこれだけ。1 ファイル、約 20 行です。

import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic();

const buggyCode = `
function add(a, b) {
    return a - b;
}
`;

const response = await client.messages.create({
    model: "claude-opus-4-8",
    max_tokens: 1024,
    system: "You are a terse senior code reviewer. Give feedback in one paragraph.",
    messages: [
        { role: "user", content: `Review this code:\n${buggyCode}` },
    ],
});

for (const block of response.content) {
    if (block.type === "text") {
        console.log(block.text);
    }
}

ここで注目すべき点が 2 つあります。

  • システムプロンプトはペルソナを形作る場所です。 私は「簡潔なシニアレビュアー」が欲しくて、おしゃべりなレビュアーは要らないので、そう書くだけです。
  • レスポンスの message.content は文字列ではなくブロックの配列です。 基本的なテキスト返信なら通常は type: text のブロックが 1 つだけですが、Claude はテキスト・ツール呼び出し・思考など複数のブロックを返すことがあるので、常にループして type をチェックします。

これを実行すると、Claude は add が実は引き算をしていることに気づき、それを 1 段落で教えてくれます。以上です。これが API 呼び出しの全体像です。

スクリプトからプロダクトへ

実際のプロダクトでは、この同じ messages.create の形が、たとえば「要約エンドポイント」の裏側のエンジンになります。データベースからミーティングの文字起こしを取り出し、「洞察とリスクを抽出せよ」と指示するシステムプロンプトとともに Claude に渡し、結果を行に保存し直して UI に返す。同じ呼び出しを、ルートハンドラーで包んだだけです。

まとめ

  • はじめての API 呼び出しは、model・トークン上限・messages を持つ messages.create 関数。
  • API キーは .env.local ファイルに保存してバージョン管理から外す。
  • システムプロンプトを加えて Claude の振る舞いを形作る。
  • レスポンスの content はブロックの配列。ループして各ブロックの type をチェックする。
  • ここからすべてがこのパターンの上に積み上がっていく。

英語原文

Saying hi to Claude might warm your heart, but it's not really useful. In this lesson we'll send Claude something real and get structured insight back — in just under 20 lines of code.

Get set up

First, grab an API key from platform.claude.com. You'll need to purchase some credits beforehand.

Take the API key and store it in a .env.local file so it stays out of your version control. Hardcoding keys in source files is how they end up leaked on GitHub — keep them in environment files instead. Next, install the SDK:

npm install @anthropic-ai/sdk

The anatomy of a request

Every API call goes through the messages.create function. You specify three things:

  • A model — which Claude model handles the request
  • A max tokens limit — a cap on how long the response can be
  • A list of messages — objects with either user or assistant roles, structured similarly to how you'd have a conversation with Claude elsewhere

Here's what that looks like in its most basic form:

import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic();

const msg = await client.messages.create({
    model: "claude-opus-4-7",
    max_tokens: 1024,
    messages: [{
        role: "user",
        content: "Hello, Claude",
    }],
});

A real example: reviewing buggy code

Let's give Claude something a little more interesting than "hello." We'll point it at some buggy code and ask for a review. Here's the whole thing — one file, about 20 lines of code:

import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic();

const buggyCode = `
function add(a, b) {
    return a - b;
}
`;

const response = await client.messages.create({
    model: "claude-opus-4-8",
    max_tokens: 1024,
    system: "You are a terse senior code reviewer. Give feedback in one paragraph.",
    messages: [
        { role: "user", content: `Review this code:\n${buggyCode}` },
    ],
});

for (const block of response.content) {
    if (block.type === "text") {
        console.log(block.text);
    }
}

Two things to notice here:

  • The system prompt is where you shape the persona. I want a terse senior reviewer, not a chatty one — so I just say that.
  • The message.content in the response is an array of blocks, not a string. For a basic text reply there's usually just one block of type text, but Claude can return multiple blocks — text, tool calls, thinking — so we always loop and check the type.

Run it, and Claude spots that add is subtracting and tells you in one paragraph. That's it. That's the whole API call.

From script to product

In a real product, this same messages.create shape is the engine behind something like a summarize endpoint. Pull a meeting transcript out of the database, hand it to Claude with a system prompt that says "extract insights and risks," save the result back on the row, and return it to the UI. It's the same call — just wrapped in a route handler.

Recap

  • Your first API call is a messages.create function with a model, a token limit, and messages.
  • Store your API key in a .env.local file to keep it out of version control.
  • Add a system prompt to shape Claude's behavior.
  • The response content is an array of blocks — loop and check each block's type.
  • From here, everything builds on this pattern.
↑ 目次へ戻る

Claude Platform 101 | Lesson 03「適切なモデルを選ぶ(Choosing the right model)」

出典: Anthropic Academy / 2026-07-04

日本語ナレッジ(本文の自然な全訳)

Claude を使ったアプリをリリースしようとしています。どのモデルを選びますか? いちばん賢いモデルをデフォルトにすると、API の請求額に驚くことになります。いちばん安いモデルを選ぶと、出力が実用に耐えないかもしれません。各モデルにはそれぞれのトレードオフがあり、適切に選ぶことが品質とコストの両方を左右します。

モデルのティア

Anthropic は現在 4 つのモデルティアを提供しており、API 呼び出しの model パラメータでその中から選びます。

なお、このコース制作時点では Claude Fable は一般提供されておらず、上の動画には反映されていません。Claude Fable と Claude Mythos の詳細はこちらで学べます。

  • Claude Fable は、これまでで最も高性能なモデルです。Opus のさらに上に位置する新ティアで、最も難しい課題向けに作られています。Opus よりも大幅に高コストなので、その追加能力に見合う価値のある仕事に限って使ってください。
  • Claude Opus は 3 つのコアモデルファミリーの中で最も高性能ですが、最も遅く、最も高コストでもあります。深い推論、複雑な分析、多段階のコーディング、繊細な文章作成に使います。
  • Claude Haiku は最も高速で最も低コスト。最大の知能よりも速度とコスト効率に最適化されています。分類・抽出・ルーティングのような、大量かつ低複雑度の処理に使います。
  • Claude Sonnet はちょうどスイートスポットに位置します。知能・速度・コストのバランスが取れており、たいていの本番作業でうまく機能します。

まずシンプルな評価(eval)から始める

本番コードを書く前に、シンプルな評価をセットアップしましょう。各モデルに通す入力例のセットを用意し、あなたのユースケースにとって「良い出力」とは何かに照らしてスコアリングします。凝ったものは要りません。実際のワークロードから 20〜30 の代表例があれば始めるには十分です。

そこからティアを段階的に上げていきます。

  • まず Haiku に例を通す。品質が持ちこたえるなら、それで完了 — 大幅にコストを節約できます。
  • 持ちこたえないなら、Sonnet にステップアップ。
  • タスクが本当に必要とするときだけ Opus に手を伸ばす。

ティアを横並びで比較する

ティアの違いは語るだけでなく、実際に見てみましょう。同じプロンプトを 3 つのモデルすべてに送り、レイテンシとトークン数を観察します。

models = ["claude-haiku-4-5", "claude-sonnet-4-6", "claude-opus-4-7"]

for model in models:
    response = client.messages.create(
        model=model,
        max_tokens=300,
        messages=[{"role": "user", "content": prompt}],
    )
    print(model, response.usage)

ここで起きていることは 2 つです。

  • ループがリクエストごとに model フィールドを差し替えています。同じプロンプト、同じ max_tokens、変わるのはモデルだけ。
  • response.usage は入力・出力のトークン数を API から直接返してくれます。これがあなたの請求額の計算根拠になります。

実行すると、3 つのモデルと 3 組の数値が見えます。Opus は最も時間がかかり、最も洗練された文章を返します。でも 2 文の定義には、その洗練は無駄です。Sonnet は文章を少し引き締めます。そして Haiku は、しばしば 1 秒未満で、非常に有能な 2 文の答えを返してきます。この種のシナリオには正直言って完璧です。

つまりこういうことです。適切なモデルとは、その出力を実際にあなたが世に出せる、いちばん安いモデル。 定義を書くだけなら Haiku で十分。規制対応の文書をドラフトするなら、同じ比較を回して、おそらく Opus に行き着くでしょう。eval の形は毎回まったく同じです。

仕事の種類ごとに異なるモデルへルーティングする

実際のアプリでは、同じエンドポイントの中で仕事の種類ごとに異なるモデルへルーティングします。ドキュメント処理ルートを持つ運用ダッシュボードを例に。

  • 入ってくるファイルはすべて Haiku で分類する。
  • クライアント向けアップデートは Sonnet でドラフトする。
  • RFP(提案依頼)への回答だけ Opus に手を伸ばす。

1 つのキュー、3 つのモデル、タスクごとに選ぶ。

まとめ

  • Anthropic は 3 つのモデルティアを提供する。難問には Opus、日常業務には Sonnet、大量処理には Haiku。
  • 本番コードを書く前に、シンプルな評価(実ワークロードから 20〜30 の代表例)をセットアップする。
  • eval を Haiku から上へ回し、その出力を実際に世に出せる、いちばん安いモデルで止める。
  • response.usage は入力・出力トークンを報告し、これが請求の根拠になる。
  • 本番では、1 つのモデルを万能に使うのではなく、同じエンドポイント内でタスクごとに異なるモデルへルーティングする。

英語原文

You're shipping an app with Claude. Which model do you pick? If you default to the smartest one, your API bill will surprise you. Pick the cheapest one, and the output might not hold up. Each model has different trade-offs, and picking the right one affects both quality and cost.

The model tiers

Anthropic currently offers four model tiers, and you choose between them with the model parameter in your API call. Note that at the time of this course, Claude Fable was not generally available, and are not reflected in the video above. Learn more about Claude Fable and Claude Mythos here.

  • Claude Fable is our most capable model yet — a new tier that sits above Opus, built for your toughest challenges. It comes at a significantly higher cost than Opus, so reserve it for work where that extra capability is worth paying for.
  • Claude Opus is the most capable of the three core model families, but also the slowest and highest cost of the three. Use it for deep reasoning, complex analysis, multi-step coding, and nuanced writing.
  • Claude Haiku is the fastest and lowest cost, optimized for speed and cost efficiency rather than maximum intelligence. Use it for high-volume, low-complexity work like classification, extraction, and routing.
  • Claude Sonnet sits in the sweet spot: a balanced combination of intelligence, speed, and cost that works well for most production work.

Start with a simple evaluation

Before you write production code, set up a simple evaluation: a set of example inputs that you run through each model and score against what good output means for your use case. You don't need anything fancy — 20 or 30 representative examples from your actual workload is enough to start. Then work your way up the tiers:

  • Run your examples through Haiku first. If the quality holds, you're done — and you just saved a lot of money.
  • If it doesn't, step up to Sonnet.
  • Only reach for Opus when the task needs it.

Comparing the tiers side by side

Let's see the difference between the tiers, not just talk about it. We'll send the same prompt through all three models and watch the latency and token counts:

models = ["claude-haiku-4-5", "claude-sonnet-4-6", "claude-opus-4-7"]

for model in models:
    response = client.messages.create(
        model=model,
        max_tokens=300,
        messages=[{"role": "user", "content": prompt}],
    )
    print(model, response.usage)

Two things are going on here:

  • The loop swaps the model field on each request. Same prompt, same max tokens — only the model changes.
  • response.usage gives you the input and output tokens straight back from the API, which is what your bill is calculated on.

Run it and you'll see three models and three sets of numbers. Opus takes the longest and reads the most polished — but for a two-sentence definition, that polish is wasted. Sonnet tightens the writing up a little. And Haiku comes back, often in under a second, with a very competent two-sentence answer. It's honestly perfect for this kind of scenario. And that's the whole point: the right model is the cheapest one whose output you'd actually ship. For a definition, Haiku is plenty. For drafting a regulatory response, you'd run the same comparison and probably end up on Opus. The eval is the same shape every single time.

Routing different work to different models

In a real app, you'd route different kinds of work to different models inside the same endpoint. Take an operations dashboard with a document processing route:

  • Every incoming file gets classified with Haiku.
  • Client updates get drafted with Sonnet.
  • Only RFP responses reach for Opus.

One queue, three models, picked per task.

Recap

  • Anthropic offers three model tiers: Opus for hard problems, Sonnet for daily work, and Haiku for volume.
  • Set up a simple evaluation — 20 or 30 representative examples from your real workload — before writing production code.
  • Run the eval from Haiku upward and stop at the cheapest model whose output you'd actually ship.
  • response.usage reports input and output tokens, which is what your bill is based on.
  • In production, route different tasks to different models inside the same endpoint instead of picking one model for everything.
↑ 目次へ戻る

Claude Platform 101 | Lesson 04「エージェントループの仕組み(The agent loop explained)」

出典: Anthropic Academy / 2026-07-04

日本語ナレッジ(本文の自然な全訳)

あなたは API 呼び出しをしてきましたが、単発の呼び出しは 1 つのレスポンスを返すだけです。ワークフローを自動化したいなら、Claude が行動し、その結果を見て、次に何をするか判断し、それを続ける必要があります。このパターンこそ、人々が「エージェント的ワークフロー(agentic workflows)」と言うときに意味しているものです。

エージェントとは実際には何か

エージェントとは、Claude の自律版です。人間を間に挟まずに、メッセージングループの両側を回します。エージェントはタスクを受け取り、ツールを選び、Claude がタスク完了と判断するまでループでコードを実行します。

エージェントループを実装する最も簡単な形はこうです。

  • ツールを使える状態で Claude にメッセージを送る。
  • Claude は「最終回答」か、「あなたが定義したツールを使いたいというリクエスト」のどちらかで応答する。
  • あなたのコードがそのツールを実行する。
  • その結果を Claude に送り返す。
  • stop reason が end_turn になるまで繰り返す。

会話だと考えてください。ターンが交互に来る会話です。ユーザーが口火を切り、エージェントがツールを呼び、ツールが結果を返し、エージェントは答えを得るまで続ける。

最小の動作例

データベースや UI を引っ張り出さずにこのループを端から端まで見せるため、get_weather という偽のツールを組み、「今日オースティンで何を着るべきか」を Claude に尋ねます。Claude は自力では天気を知りようがないので、ツールを呼び、その結果を読み、それから答えを出すしかありません。

スクリプト全体はこうです。

import anthropic

client = anthropic.Anthropic()

# The tools array tells Claude what's available:
# a name, a description, and a JSON schema for the inputs.
tools = [
    {
        "name": "get_weather",
        "description": "Get the current weather for a city.",
        "input_schema": {
            "type": "object",
            "properties": {
                "city": {
                    "type": "string",
                    "description": "The city to get weather for",
                }
            },
            "required": ["city"],
        },
    }
]

# run_tool is just a hardcoded lookup.
# In a real app, this would hit your database, an API, whatever.
def run_tool(name, tool_input):
    if name == "get_weather":
        return f"Weather in {tool_input['city']}: 95F, sunny"
    raise ValueError(f"Unknown tool: {name}")

messages = [
    {"role": "user", "content": "What should I wear in Austin today?"}
]

# The agent loop. Each iteration sends messages to Claude
# and switches on the response's stop reason.
while True:
    response = client.messages.create(
        model="claude-sonnet-4-6",
        max_tokens=1024,
        tools=tools,
        messages=messages,
    )

    if response.stop_reason == "end_turn":
        # Claude is done. Print the final text and break.
        for block in response.content:
            if block.type == "text":
                print(block.text)
        break

    if response.stop_reason == "tool_use":
        # Find the tool use blocks in the response and run each one.
        tool_results = []
        for block in response.content:
            if block.type == "tool_use":
                result = run_tool(block.name, block.input)
                tool_results.append(
                    {
                        "type": "tool_result",
                        "tool_use_id": block.id,
                        "content": result,
                    }
                )

        # Push the assistant's response and our tool results
        # back into messages, then loop again so Claude can answer.
        messages.append({"role": "assistant", "content": response.content})
        messages.append({"role": "user", "content": tool_results})

注目すべき 3 つの部分。

  • tools 配列は、何が使えるかを Claude に伝えます。名前、説明、入力の JSON スキーマ。
  • run_tool は単なるハードコードされたルックアップです。実際のアプリでは、ここがデータベースや API など何であれ叩きに行く部分になります。
  • ループがエージェントループです。各イテレーションで messages を Claude に送り、レスポンスの stop reason で分岐します。end_turn なら Claude は完了 — 最終テキストを表示して break。tool_use なら、tool use ブロックを見つけ、それぞれを実行し、アシスタントのレスポンスとツール結果を messages に戻して、もう一度ループして Claude に答えさせます。

実行する

スクリプトを実行すると、2 つのターンが見えます。

  • ターン 1:stop reason は tool_use。Claude はオースティンの get_weather をリクエストし、あなたのコードが気温と天候を返す。
  • ターン 2:stop reason は end_turn。Claude は「軽くて通気性のいいものを着るように」と教えてくれる。

2 回の API 呼び出し、1 回のツール実行、1 つの最終回答。これがループの全体です。Claude API で作るものはすべて、これと似た形になります。

本番での同じループ

実際の環境では、この同じループが「auto-review エンドポイント」のようなものを動かします。構造レポートを読み、ツール経由で関連する建築基準を調べ、リスクの指摘を 1 件ずつデータベースに書き込んでいくコンプライアンスエージェントです。

ループの形は、あなたがいま実行したものと同一です。違いは次の点です。

  • モックの天気ルックアップではなく、本物のツール。
  • 結果は server-sent events として UI にストリーミングで返る。
  • 指摘(findings)は risk-finding テーブルに永続化される。

まとめ

  • エージェントとは、ループの中の Claude:観察し、判断し、行動し、繰り返す。
  • ループはシンプル:ツール付きで messages を送り、Claude が要求したツールを実行し、結果を返し、stop reason が end_turn になったら止める。
  • ループとツールはあなたのもの。推論は Claude のもの。
  • 同じループの形は、モックの天気デモから本番のコンプライアンスエージェントまでスケールする — 変わるのはツールと配管だけ。
  • ループを自分で持ちたくないときは、マネージドエージェントがこのまったく同じループを Anthropic のインフラ上であなたの代わりに回してくれる。

英語原文

You've made API calls, but a single call only returns one response. If you want to automate a workflow, Claude needs to act, look at the result, decide what's next, and keep going. That pattern is what people mean when they talk about agentic workflows.

What an agent actually is

An agent is an autonomous version of Claude, running both sides of the messaging loop without a human in the middle. An agent receives a task, picks a tool, and executes code in a loop until Claude decides the task is done.

The easiest way to implement an agent loop looks like this:

  • Send a message to Claude with tools available.
  • Claude responds with either a final answer or a request to use a tool you defined.
  • Your code executes that tool.
  • You send the result back to Claude.
  • Repeat until the stop reason is end_turn.

Think of it as a conversation where the turns alternate: the user kicks things off, the agent calls a tool, the tool returns a result, and the agent keeps going until it has an answer.

A minimal working example

To see this loop run end to end without dragging in a database or a UI, we'll wire up a fake tool called get_weather and ask Claude what to wear in Austin today. Claude has no way to know the weather on its own, so it has to call the tool, read the result, and then give you an answer.

Here's the whole script:

import anthropic

client = anthropic.Anthropic()

# The tools array tells Claude what's available:
# a name, a description, and a JSON schema for the inputs.
tools = [
    {
        "name": "get_weather",
        "description": "Get the current weather for a city.",
        "input_schema": {
            "type": "object",
            "properties": {
                "city": {
                    "type": "string",
                    "description": "The city to get weather for",
                }
            },
            "required": ["city"],
        },
    }
]

# run_tool is just a hardcoded lookup.
# In a real app, this would hit your database, an API, whatever.
def run_tool(name, tool_input):
    if name == "get_weather":
        return f"Weather in {tool_input['city']}: 95F, sunny"
    raise ValueError(f"Unknown tool: {name}")

messages = [
    {"role": "user", "content": "What should I wear in Austin today?"}
]

# The agent loop. Each iteration sends messages to Claude
# and switches on the response's stop reason.
while True:
    response = client.messages.create(
        model="claude-sonnet-4-6",
        max_tokens=1024,
        tools=tools,
        messages=messages,
    )

    if response.stop_reason == "end_turn":
        # Claude is done. Print the final text and break.
        for block in response.content:
            if block.type == "text":
                print(block.text)
        break

    if response.stop_reason == "tool_use":
        # Find the tool use blocks in the response and run each one.
        tool_results = []
        for block in response.content:
            if block.type == "tool_use":
                result = run_tool(block.name, block.input)
                tool_results.append(
                    {
                        "type": "tool_result",
                        "tool_use_id": block.id,
                        "content": result,
                    }
                )

        # Push the assistant's response and our tool results
        # back into messages, then loop again so Claude can answer.
        messages.append({"role": "assistant", "content": response.content})
        messages.append({"role": "user", "content": tool_results})

Three pieces to notice:

  • The tools array tells Claude what's available: a name, a description, and a JSON schema for the inputs.
  • run_tool is just a hardcoded lookup. In a real app, this would hit your database, an API, whatever.
  • The loop is the agent loop. Each iteration sends the messages to Claude and switches on the response's stop reason. On end_turn, Claude is done — print the final text and break. On tool_use, find the tool use blocks, run each one, push the assistant's response and your tool results back into messages, and loop again so Claude can answer.

Running it

When you run the script, you'll see two turns:

  • Turn one: the stop reason is tool_use. Claude requests get_weather for Austin, and your code returns the temperature and conditions.
  • Turn two: the stop reason is end_turn, and Claude tells you to wear something light and breathable.

Two API calls, one tool execution, one final answer. That's the entire loop. Everything you build with the Claude API is going to be similar to this.

The same loop in production

In a real environment, this same loop powers something like an auto-review endpoint: a compliance agent that reads a structural report, looks up the relevant building codes via a tool, and writes risk findings back to the database one by one as it works.

The shape of the loop is identical to what you just ran. The differences are:

  • Real tools instead of a mock weather lookup.
  • Results stream back to the UI as server-sent events.
  • Findings get persisted to a risk-finding table.

Recap

  • An agent is Claude in a loop: observe, decide, act, repeat.
  • The loop is simple: send messages with tools, run any tool Claude requests, feed the result back, and stop when the stop reason is end_turn.
  • You own the loop and the tools. Claude owns the reasoning.
  • The same loop shape scales from a mock weather demo to a production compliance agent — only the tools and plumbing change.
  • When you don't want to own the loop, managed agents run this exact loop for you on Anthropic's infrastructure.
↑ 目次へ戻る

Claude Platform 101 | Lesson 05「ツール使用(tool use)とは?(What is tool use?)」

出典: Anthropic Academy / 2026-07-04

日本語ナレッジ(本文の自然な全訳)

あなたの既存のワークフローは、多くの異なるテクノロジーに依存しています。プロジェクト管理ソフト、データベース、ファイルなど。Claude はこれらを自分でチェックすることはできません。代わりに、外部のデータやアクションへのアクセスを与える「ツール(tools)」に頼ります。

ツールとは何か

簡単に言えば、ツールとは、あなたが定義して Claude に公開する関数です。それが何をするか、どんな入力を取るかを記述し、いつ呼び出すかは Claude が判断します。

ここで腹落ちさせておくべき重要点:Claude はツールを実行しません。実行するのはあなたのコードです。 流れはこうです。

  • Claude がツール呼び出しをリクエストする。
  • あなたのコードがその関数を実行する。
  • 結果が Claude に戻り、Claude は続行する。

ツールの定義のしかた

ツールは 3 つのパートを持つ JSON スキーマです。名前(name)、説明(description)、入力スキーマ(input schema)。これらをリクエストボディの tools 配列として Claude に渡します。

description は、そのツールを呼ぶべきかどうかを判断するために Claude が読むものです。 曖昧な説明を書くと、ツール使用が下手になります。これがエージェントが誤作動したり、使えるツールを掴めなかったりする第 1 位の原因です。具体的に書きましょう。

ツール定義はこんな形です。

{
    "name": "lookup_building_code",
    "description": "Look up a specific building code section by its identifier. Returns the full text of that code section.",
    "input_schema": {
        "type": "object",
        "properties": {
            "section": {
                "type": "string",
                "description": "The building code section to look up"
            }
        },
        "required": ["section"]
    }
}

これを使うと何が起こるでしょうか。たとえばエージェントにコンプライアンスレポートを送ったとします。最初のターンで、Claude は stop_reason: "tool_use" で返ってきます。これが私たちのシグナルです。

私たちのループは、Claude がリクエストしたパラメータで lookup_building_code を呼び出し、その結果を tool result として戻します。tool result とは、ツール呼び出しの id に紐づいた tool_result ブロックを含む user メッセージです。

そして Claude は続行します。その時点から、Claude が必要なものを揃えるまで、ツールを呼んで結果を返すことを繰り返せます。

複数のツール:Claude に選ばせる

ツール 1 つでも役に立ちますが、面白いのは Claude に複数のツールを与え、どれをどの順で使うかを Claude が選ぶのを見ることです。

こんなシナリオを想像してください。デンバーへの 3 日間の旅行の荷造りをしていて、今日の天気と、これから数日の予報の両方が知りたい。そこで、1 つではなく 2 つのツールを宣言します。

const tools = [
    {
        name: "get_weather",
        description: "Get today's current weather for a city.",
        input_schema: {
            type: "object",
            properties: {
                city: { type: "string", description: "The city to check" }
            },
            required: ["city"]
        }
    },
    {
        name: "get_forecast",
        description: "Get the weather forecast for the next few days for a city.",
        input_schema: {
            type: "object",
            properties: {
                city: { type: "string", description: "The city to check" }
            },
            required: ["city"]
        }
    }
];

ループはこれまで見てきたエージェントループと同一です。新しい部分は、ツール名で分岐する runTool 関数(switch 文)だけ。このコードブロックが、実際にあなたのコードが走る場所です。

function runTool(name, input) {
    switch (name) {
        case "get_weather":
            return getWeather(input.city);
        case "get_forecast":
            return getForecast(input.city);
    }
}

while (true) {
    const response = await client.messages.create({
        model: "claude-sonnet-4-6",
        max_tokens: 1024,
        messages,
        tools,
    });

    if (response.stop_reason !== "tool_use") {
        // Claude is done — this is the final answer
        break;
    }

    messages.push({ role: "assistant", content: response.content });

    const toolResults = response.content
        .filter((block) => block.type === "tool_use")
        .map((block) => ({
            type: "tool_result",
            tool_use_id: block.id,
            content: runTool(block.name, block.input),
        }));

    messages.push({ role: "user", content: toolResults });
}

これがパターンの全体です。3 つ目のツールが欲しい? 配列に足して、switch に case を足す、それで完了です。

これを実行すると、Claude が get_weather を呼び、それから get_forecast を呼ぶのが見えます。同じターンで両方呼ぶこともあれば、続けて 1 つずつ呼ぶこともあります。そして答えます。「重ね着を持っていけ、今日は雪がちらつくが週の後半にかけて暖かくなる」と。

ここで Claude がどう選んだかに注目してください。description を読み、あなたのプロンプトを「今日の天気」と「これから数日」に対応づけ、それぞれに適したツールを選びました。だからこそ、あなたのツールの description は本当に重要なのです。

ツールランナー:ボイラープレートを省く

いま書いたコードに、あなたはすでに 2 つの危険信号(red flags)に気づいているはずです。

  • たった 2 つの単純なルックアップにしては、コードが多すぎる。
  • 実際のコードベースでは、持っている関数ごとに JSON スキーマを手書きしたくはない。コードを二度書くようなものだ。

そこで登場するのがツールランナー(tool runner)です。これは TypeScript・Python・Ruby 向けの Claude SDK に同梱されています。ランナーはあなたの実際の関数を受け取り、型とドキュメントを読んでスキーマを組み立て、tool use / tool result のループ全体を内部で処理します。

あなたのコードはこう縮みます。ツールを記述し、プロンプトを送り、結果を待つ。同じ 2 ツールの天気デモをツールランナー経由で配線したものがこれです。

// The same two lookups we ran by hand — just plain TypeScript functions
function getWeather(city: string) {
    // ...existing lookup
}

function getForecast(city: string) {
    // ...existing lookup
}

const runner = client.beta.messages.toolRunner({
    model: "claude-sonnet-4-6",
    max_tokens: 1024,
    messages: [
        {
            role: "user",
            content:
                "I'm packing for a three-day trip to Denver. What's the weather today and over the next few days?",
        },
    ],
    tools: [getWeather, getForecast],
});

// Returns the final assistant message after all the tool ping-pong has settled
const finalMessage = await runner.untilDone();

同じシナリオが、わずかなコード量で済みます。

  • while ループも、stop reason の分岐も、ツール結果を手動で messages に戻す作業もない — ランナーがそのすべてを処理する。
  • JSON スキーマがない。だから二度書きにならない。
  • 2 つの関数は、少し前に手で回したのと同じルックアップで、ただのプレーンな TypeScript。
  • runner.untilDone() は、すべてが落ち着いた後に最終的なアシスタントメッセージを返す。

実行すると、同じ答えが得られます。

本物のツールは既存コードをラップする

実際には、あなたのツールはハードコードされた天気データではありません。アプリケーションにすでにある本物の関数をラップします。

コンプライアンスレビューエージェントを考えてみましょう。そのツールは、コードベースにすでに存在する lookup_building_codesearch_building_code 関数の薄いラッパーです。ツールランナーを使えば、それらの関数を直接渡すだけで、エージェントは書き込むすべての指摘(finding)で特定の建築基準セクションを引用します — スキーマの記述は一切不要です。

まとめ

  • ツールは Claude にあなたのシステムへのアクセスを与える。ツールとは、あなたが定義して公開する関数。Claude がいつ呼ぶかを判断し、あなたのコードが実行する。
  • ツールは name・description・input schema を持つ JSON スキーマで、リクエストの tools 配列として渡す。
  • 具体的な description を書く。曖昧な description はエージェントが誤作動する第 1 位の原因。
  • stop_reason: "tool_use" が、ツールを実行して結果を tool result として返すべき合図。
  • 複数ツールでは、ツール名で分岐する。ツールを足すとは、配列に足して case を足すこと。
  • SDK のツールランナー(TypeScript・Python・Ruby)は、あなたの実際の関数からスキーマを作り、ループ全体を処理する — あるいは自分でループを回してもよい。
  • あなたが実行するか、ループを委譲するか。そのスペクトルの遠端では、マネージドエージェントがエージェント全体を Anthropic に委譲する。

英語原文

Your existing workflows rely on a lot of different technologies — project management software, databases, files. Claude can't just check these things itself. Instead, it relies on tools, which give Claude access to external data and actions.

What a tool is

Simply put, a tool is a function you define and expose to Claude. You describe what it does and what inputs it takes, and Claude decides when to call it.

Here's the key thing to internalize: Claude doesn't execute the tool — your code does. The flow looks like this:

  • Claude requests a tool call.
  • Your code executes the function.
  • The result goes back to Claude, and it keeps going.

How tools are defined

Tools are JSON schemas with three parts: a name, a description, and an input schema. You pass them to Claude in the request body as a tools array.

The description is what Claude reads to decide whether to call the tool. If you write a vague description, you get bad tool use. This is the number one reason agents misfire or don't grab the tools that are available to them. Be specific.

Here's what a tool definition looks like:

{
    "name": "lookup_building_code",
    "description": "Look up a specific building code section by its identifier. Returns the full text of that code section.",
    "input_schema": {
        "type": "object",
        "properties": {
            "section": {
                "type": "string",
                "description": "The building code section to look up"
            }
        },
        "required": ["section"]
    }
}

So what happens when we use this? Say we send an agent a compliance report. On the first turn, Claude comes back with stop_reason: "tool_use" — that's our signal. Here's what that response looks like:

Our loop calls lookup_building_code with the parameter Claude requested, then feeds the result back as a tool result — a user message containing a tool_result block tied to the tool call's id:

And Claude keeps going. At that point, we can keep calling tools and returning results to Claude until it has what it needs.

Multiple tools: letting Claude pick

One tool is useful, but the interesting part is giving Claude multiple tools and watching it pick which one to use, in what order.

Picture this scenario: you're packing for a three-day trip to Denver, and you want both today's weather and the forecast for the next few days. So we declare two tools instead of one:

const tools = [
    {
        name: "get_weather",
        description: "Get today's current weather for a city.",
        input_schema: {
            type: "object",
            properties: {
                city: { type: "string", description: "The city to check" }
            },
            required: ["city"]
        }
    },
    {
        name: "get_forecast",
        description: "Get the weather forecast for the next few days for a city.",
        input_schema: {
            type: "object",
            properties: {
                city: { type: "string", description: "The city to check" }
            },
            required: ["city"]
        }
    }
];

The loop is identical to the agent loops we've already seen. The only new piece is a runTool function that dispatches on the tool name with a switch statement — this block of code is just where your code actually runs:

function runTool(name, input) {
    switch (name) {
        case "get_weather":
            return getWeather(input.city);
        case "get_forecast":
            return getForecast(input.city);
    }
}

while (true) {
    const response = await client.messages.create({
        model: "claude-sonnet-4-6",
        max_tokens: 1024,
        messages,
        tools,
    });

    if (response.stop_reason !== "tool_use") {
        // Claude is done — this is the final answer
        break;
    }

    messages.push({ role: "assistant", content: response.content });

    const toolResults = response.content
        .filter((block) => block.type === "tool_use")
        .map((block) => ({
            type: "tool_result",
            tool_use_id: block.id,
            content: runTool(block.name, block.input),
        }));

    messages.push({ role: "user", content: toolResults });
}

And that's the whole pattern. Want a third tool? Add it to the array, add a case to the switch, and you're done.

Run this, and you'll see Claude call get_weather and then get_forecast — sometimes in the same turn, sometimes one after the other. Then it answers: pack layers, expect snow flurries today, warming through the week.

Now notice how Claude chose. It read the descriptions, mapped your prompt to "today's weather" and "the next few days," and picked the right tool for each. That's why your tool descriptions really matter.

The tool runner: skip the boilerplate

You've probably already spotted two red flags with what we just wrote:

  • That's a lot of code for two simple lookups.
  • In a real codebase, you don't want to handwrite JSON schemas for every function you have. It's like writing your code twice.

That's where the tool runner comes in. It ships in the Claude SDK for TypeScript, Python, and Ruby. The runner takes your actual functions, reads the types and docs to build the schema for you, and handles the entire tool use / tool result loop internally.

Your code shrinks down to: describe the tool, send the prompt, wait for the result. Here's the same two-tool weather demo wired through the tool runner:

// The same two lookups we ran by hand — just plain TypeScript functions
function getWeather(city: string) {
    // ...existing lookup
}

function getForecast(city: string) {
    // ...existing lookup
}

const runner = client.beta.messages.toolRunner({
    model: "claude-sonnet-4-6",
    max_tokens: 1024,
    messages: [
        {
            role: "user",
            content:
                "I'm packing for a three-day trip to Denver. What's the weather today and over the next few days?",
        },
    ],
    tools: [getWeather, getForecast],
});

// Returns the final assistant message after all the tool ping-pong has settled
const finalMessage = await runner.untilDone();

Same scenario, a fraction of the code:

  • No while loop, no stop reason switch, no manually pushing tool results back into messages — the runner handles all of that.
  • No JSON schemas, so you don't write things twice.
  • The two functions are the same lookups we ran by hand a minute ago, just plain TypeScript.
  • runner.untilDone() returns the final assistant message once everything has settled.

Run it, and you get the same answer.

Real tools wrap your existing code

In real life, your tools wouldn't be hardcoded weather data. They'd wrap actual functions you already have in your application.

Take a compliance review agent: its tools are thin wrappers around lookup_building_code and search_building_code functions that already exist in the codebase. With the tool runner, you pass those functions in directly, and the agent cites specific code sections in every finding it writes — no schema writing required:

Recap

  • Tools give Claude access to your systems. A tool is a function you define and expose; Claude decides when to call it, and your code executes it.
  • Tools are JSON schemas with a name, a description, and an input schema, passed in the request as a tools array.
  • Write specific descriptions. Vague descriptions are the number one reason agents misfire.
  • stop_reason: "tool_use" is your signal to run the tool and feed the result back as a tool result.
  • For multiple tools, dispatch on the tool name. Adding a tool means adding to the array and adding a case.
  • The SDK's tool runner (TypeScript, Python, Ruby) builds schemas from your actual functions and handles the whole loop — or you can run the loop yourself.
  • You execute, or you delegate the loop. At the far end of that spectrum, managed agents delegate the whole agent to Anthropic.
↑ 目次へ戻る

Claude Platform 101 | Lesson 06「思考(thinking)とは?(What is thinking?)」

出典: Anthropic Academy / 2026-07-04

日本語ナレッジ(本文の自然な全訳)

タスクの中には、素早い答え以上のものを必要とするものがあります。Claude は応答する前に問題を段階的に考え抜くことができます。これが「extended thinking(拡張思考)」という機能です。このレッスンでは、thinking とは何か、どう有効にするか、そしてそれが実際に役立つのはどんなときかを見ていきます。

避けたい失敗モードはこれです。多段階の問いをモデルに投げて即座に答えさせると、自信満々に間違えることがあります。

extended thinking とは何か

extended thinking は、Claude が最終応答を出す前に一歩ずつ推論することを可能にします。有効にすると、Claude は内部の推論トークン(しばしば chain of thought=思考の連鎖と呼ばれる)を生成し、それから答えを届けます。その推論は隠されていません。最終テキストと並んで、レスポンスの中で見ることができます。

Opus 4.7 における適応的思考(Adaptive thinking)

Opus 4.7 では、thinking は適応的(adaptive)です。トークン予算を自分で選ぶ必要はありません。オンにするだけで、いつどれだけ考えるかを Claude が動的に決めます。

Claude がどれだけ考えるかをコントロールするには、effort パラメータを使います。1 つの落とし穴:これは thinking ブロックの隣ではなく output_config の中に入れます。レベルは以下です。

  • low
  • medium
  • high(デフォルト)
  • xhigh(extra high)
  • max

いつ使い、いつ省くか

extended thinking が役立つのは以下です。

  • 数学や多段階の論理
  • コードのデバッグ
  • 規制分析
  • トレードオフや選択肢の比較を伴うもの全般

単純な分類・抽出・定型処理では省きましょう。そうしたタスクでは、結果を改善せずにレイテンシとコストを足すだけになります。

思考を実際に動かす

実際に動かしてみましょう。ここでは、天気ツールを 1 つ持つエージェントループで、Claude にサンフランシスコを出発点とするロードトリップ(2 か所立ち寄り、天気と運転時間を天秤にかける)の計画を頼みます。これは本物のトレードオフで、まさに thinking が真価を発揮する種類の問いです。

import anthropic

client = anthropic.Anthropic()

weather_tool = {
    "name": "get_weather",
    "description": "Get the current weather for a city.",
    "input_schema": {
        "type": "object",
        "properties": {
            "city": {"type": "string", "description": "City name"}
        },
        "required": ["city"],
    },
}

response = client.messages.create(
    model="claude-opus-4-7",
    max_tokens=16000,
    thinking={"type": "adaptive"},
    output_config={"effort": "high"},  # low | medium | high | xhigh | max
    tools=[weather_tool],
    messages=[
        {
            "role": "user",
            "content": "Plan a road trip out of San Francisco with two stops, "
            "weighing weather and drive time.",
        }
    ],
)

これを実行すると、出力は通常より興味深くなります。Claude がトレードオフを考え抜く thinking ブロック、続いて各都市をチェックするツール呼び出し、そして最後に実際の推奨を含む text ブロックが見えます。

推論が見える — それがまさに要点です。

本番でなぜ重要か

本番アプリでは、これは「問題を 1 つずつ見つけるエージェント」と「問題どうしを結びつけるエージェント」の違いになります。コンプライアンスレビューアプリを例に。auto-review 呼び出しで adaptive thinking をオンにすると、エージェントはレポートの各セクションをまたいで推論でき、たとえば第 3 章の風荷重仕様が文書の別の場所の材料仕様と矛盾している、といったことを捉えられます。

まとめ

  • extended thinking は Claude に答える前に推論する余地を与え、その推論はレスポンスの中で見える。
  • Opus 4.7 では thinking: {"type": "adaptive"} でオンにする。トークン予算は不要。いつどれだけ考えるかは Claude が決める。
  • 深さは output_config の中の effort パラメータで調整:lowmediumhigh(デフォルト)、xhighmax
  • 難しく、トレードオフの多い問題に使う。単純な問題では省く。そこではレイテンシとトークンを浪費するだけ。

英語原文

Some tasks need more than a quick answer. Claude can work through a problem before responding — a feature called extended thinking. In this lesson, we'll look at what thinking is, how to turn it on, and when it actually helps. Here's the failure mode we're trying to avoid. Ask a model a multi-step question and have it answer immediately, and it can confidently get it wrong:

What is extended thinking?

Extended thinking lets Claude reason step by step before producing a final response. When it's enabled, Claude generates internal reasoning tokens — often called a chain of thought — and then delivers the answer. The reasoning isn't hidden: you can see it in the response alongside the final text.

Adaptive thinking on Opus 4.7

With Opus 4.7, thinking is adaptive. You don't pick a token budget. You just turn it on, and Claude decides dynamically when to think and how much. To control how much Claude thinks, use the effort parameter. One gotcha: it goes inside output_config, not next to the thinking block. The levels are:

  • low
  • medium
  • high (the default)
  • xhigh (extra high)
  • max

When to use it (and when to skip it)

Extended thinking helps with:

  • Math and multi-step logic
  • Code debugging
  • Regulatory analysis
  • Anything that involves trade-offs or comparing options

Skip it for simple classification, extraction, or boilerplate. For those tasks it just adds latency and cost without actually improving the results.

Thinking in action

Let's see it work. Here's an agent loop with one weather tool, and we'll ask Claude to plan a road trip out of San Francisco — two stops, weighing weather and drive time. That's a real trade-off, the kind of question where thinking earns its keep.

import anthropic

client = anthropic.Anthropic()

weather_tool = {
    "name": "get_weather",
    "description": "Get the current weather for a city.",
    "input_schema": {
        "type": "object",
        "properties": {
            "city": {"type": "string", "description": "City name"}
        },
        "required": ["city"],
    },
}

response = client.messages.create(
    model="claude-opus-4-7",
    max_tokens=16000,
    thinking={"type": "adaptive"},
    output_config={"effort": "high"},  # low | medium | high | xhigh | max
    tools=[weather_tool],
    messages=[
        {
            "role": "user",
            "content": "Plan a road trip out of San Francisco with two stops, "
            "weighing weather and drive time.",
        }
    ],
)

When you run this, the output is more interesting than usual. You'll see thinking blocks where Claude works through the trade-offs, followed by tool calls to check each city, and finally a text block with the actual recommendation. The reasoning is visible — that's the whole point.

Why this matters in production

In a production app, this is the difference between an agent that finds problems one at a time and an agent that connects them. Take a compliance review app: toggling adaptive thinking on the auto-review call lets the agent reason across report sections — catching things like a wind load spec in section three that conflicts with the material spec elsewhere in the document.

Recap

  • Extended thinking gives Claude room to reason before it answers, and the reasoning is visible in the response.
  • With Opus 4.7, turn it on with thinking: {"type": "adaptive"} — no token budget needed; Claude decides when and how much to think.
  • Dial the depth with the effort parameter inside output_config: low, medium, high (default), xhigh, or max.
  • Use it for hard, trade-off-heavy problems. Skip it for simple ones — there it just costs latency and tokens.
↑ 目次へ戻る

Claude Platform 101 | Lesson 07「組み込みツール(Built-in tools)」

出典: Anthropic Academy / 2026-07-04

日本語ナレッジ(本文の自然な全訳)

自作のカスタムツールを作ることもできますが、一部の機能はよく使われるため、Anthropic が事前構築済みで提供しています。あなたはコードを書きません。サンドボックスをホストしません。ツールを宣言するだけで、Anthropic が実行します。

server tools:宣言はあなた、実行は Anthropic

Anthropic は、自社のインフラ上で動く server tools を提供します。これらを実行するのはあなたではなく Anthropic です。つまり、これらの呼び出しにはエージェントループが不要です。Claude が自分でツールを呼び、結果は同じレスポンスの中に返ってきます。

主なものは以下です。

  • Web search — インターネットを検索し、引用(citations)付きで結果を返す
  • Code execution — サンドボックスで Python を書いて実行する
  • Web fetch — URL から全文コンテンツを取得する

1 ファイルに 2 つの server tools

大きなものをいくつか、1 ファイルで見てみましょう。messages.create 呼び出しが 2 つ、1 つは web search、もう 1 つは code execution です。

import anthropic

client = anthropic.Anthropic()

# Call 1: web search — Anthropic runs the search server-side
search_response = client.messages.create(
    model="claude-opus-4-8",
    max_tokens=1024,
    tools=[{"type": "web_search_20260209", "name": "web_search"}],
    messages=[
        {"role": "user", "content": "What is Anthropic's latest model release? Answer in one sentence."}
    ],
)

for block in search_response.content:
    if block.type == "server_tool_use":
        print(f"Tool call: {block.name} — {block.input}")
    elif block.type == "text":
        print(block.text)

# Call 2: code execution — Claude writes and runs Python in a sandbox
code_response = client.messages.create(
    model="claude-opus-4-8",
    max_tokens=1024,
    tools=[{"type": "code_execution_20260120", "name": "code_execution"}],
    messages=[
        {"role": "user", "content": "Calculate the mean and standard deviation of [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"}
    ],
)

for block in code_response.content:
    if block.type == "server_tool_use":
        print(f"Tool call: {block.name} — {block.input}")
    elif block.type == "bash_code_execution_tool_result":
        print(f"stdout: {block.content.stdout}")
    elif block.type == "text":
        print(block.text)

注目すべき点が 2 つ。

  • ここにはエージェントループがありません。 stop_reason で分岐しません。ツール結果を戻しもしません。Anthropic がサーバー側でツールを実行し、レスポンスにはすでに結果が含まれています。
  • レスポンスに新しいブロックタイプがあります。 ツール呼び出しの server_tool_use ブロック、出力の code execution tool result ブロック、そして通常の text ブロック。

実行する

web search では、Claude のツール呼び出しが表示され、続いて最新モデルリリースについての 1 文の答えが、検索の引用を織り込んで返ってきます。

code execution では、Claude が書いた実際の Python、サンドボックスがそれを実行した stdout、そして最後の text の答えが見えます。

私たちは検索クローラーを立ち上げませんでした。Python サンドボックスを走らせませんでした。2 つのツールを宣言しただけで、両方をタダで手に入れました。

もう 1 つのカテゴリ:client tools

もう 1 つのカテゴリが存在することも知っておく価値があります。client tools はあなたのコードが走る場所で動きます。Claude SDK に同梱されているので、スキーマを自分で定義する必要はありません。2 つの例。

  • Memory — Claude がセッションをまたいでメモリを読み書きする
  • Bash — Claude がコマンドを実行できる永続的な bash シェル

これらはカスタムツールと同じ形をしていますが、SDK がスキーマと妥当なランナーを提供してくれます。

本番でなぜ重要か

本番アプリでは、これは本来なら数週間かかる機能への最短経路になります。Web search は、ドラフト内のあらゆる数値・規制上の主張を、ライブの Web に照らして検証する fact-check エンドポイントを動かせます。

ただし 1 つ注意。インターネットで検証されたからといって、それが真実だとは限りません。 常に Claude の作業をダブルチェックしてください。

まとめ

  • server tools(web search、code execution、web fetch)は tools 配列で宣言する。実行は Anthropic。
  • 結果は同じレスポンスの中で得られ、エージェントループは不要。通常の text ブロックと並んで server_tool_use とツール結果ブロックを探す。
  • memory や bash のような client tools はあなたのコードが走る場所で動くが、SDK がスキーマとランナーを同梱してくれる。
  • 「Anthropic がホストする」という発想は最上位までスケールする。マネージドエージェントは、1 つのツールだけでなくエージェント全体にそれを適用する。

英語原文

You can build your own custom tools, but some capabilities are common enough that Anthropic ships them pre-built. You don't write the code. You don't host the sandbox. You just declare the tool, and Anthropic runs it.

Server tools: declared by you, run by Anthropic

Anthropic provides server tools that run on their infrastructure. You don't execute these — Anthropic does. That means you don't need an agent loop for these calls. Claude calls the tools on its own, and the result comes back inside the same response.

The main ones are:

  • Web search — searches the internet and returns results with citations
  • Code execution — writes and runs Python in a sandbox
  • Web fetch — retrieves full content from URLs

Two server tools in one file

Let's check out some of the big ones in one file: two messages.create calls, one with web search and one with code execution.

import anthropic

client = anthropic.Anthropic()

# Call 1: web search — Anthropic runs the search server-side
search_response = client.messages.create(
    model="claude-opus-4-8",
    max_tokens=1024,
    tools=[{"type": "web_search_20260209", "name": "web_search"}],
    messages=[
        {"role": "user", "content": "What is Anthropic's latest model release? Answer in one sentence."}
    ],
)

for block in search_response.content:
    if block.type == "server_tool_use":
        print(f"Tool call: {block.name} — {block.input}")
    elif block.type == "text":
        print(block.text)

# Call 2: code execution — Claude writes and runs Python in a sandbox
code_response = client.messages.create(
    model="claude-opus-4-8",
    max_tokens=1024,
    tools=[{"type": "code_execution_20260120", "name": "code_execution"}],
    messages=[
        {"role": "user", "content": "Calculate the mean and standard deviation of [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"}
    ],
)

for block in code_response.content:
    if block.type == "server_tool_use":
        print(f"Tool call: {block.name} — {block.input}")
    elif block.type == "bash_code_execution_tool_result":
        print(f"stdout: {block.content.stdout}")
    elif block.type == "text":
        print(block.text)

Two things to notice:

  • There's no agent loop here. We don't switch on stop_reason. We don't push tool results back. Anthropic runs the tool server-side, and the response already contains the result.
  • The response has new block types. A server_tool_use block for the tool call, a code execution tool result block for the output, plus the regular text blocks.

Running it

For web search, you'll see Claude's tool call printed, then a one-sentence answer about the latest model release with the search citations folded in.

For code execution, you'll see the actual Python Claude wrote, the stdout from the sandbox running it, and a final text answer.

We didn't have to spin up a search crawler. We didn't run a Python sandbox. We declared two tools and got both for free.

The other category: client tools

Worth knowing the other category exists. Client tools run where your code runs. They're shipped in the Claude SDK, so you don't have to define the schema yourself. Two examples:

  • Memory — Claude reads and writes memory across sessions
  • Bash — a persistent bash shell so Claude can execute commands

They have the same shape as a custom tool, but the SDK gives you the schema and a sensible runner.

Why this matters in production

In a production app, this is the shortest path to features that would otherwise take weeks. Web search can power a fact-check endpoint that verifies every numeric and regulatory claim in a draft against the live web.

One reminder, though: just because something is validated on the internet doesn't mean it's true. Always double-check Claude's work.

Recap

  • Server tools — web search, code execution, web fetch — are declared in your tools array. Anthropic runs them.
  • You get the result in the same response, with no agent loop required. Look for server_tool_use and tool result blocks alongside the regular text blocks.
  • Client tools like memory and bash run where your code runs, but the SDK ships the schema and a runner for you.
  • The "hosted by Anthropic" idea scales all the way up: managed agents apply it to the entire agent, not just one tool.
↑ 目次へ戻る

Claude Platform 101 | Lesson 08「スキル(Skills)」

出典: Anthropic Academy / 2026-07-04

日本語ナレッジ(本文の自然な全訳)

Skills(スキル)は、指示・スクリプト・リソースをまとめたフォルダで、Claude が特殊なタスクの性能を上げるために動的に読み込みます。すべての Skill の中核にあるのが SKILL.md ファイル。一度アップロードすれば、どの messages.create 呼び出しにも紐づけられる、パッケージ化された指示のセットです。あなたは、自分のやり方を Claude に教えているわけです。ステータスレポートのフォーマット、レビューのチェックリスト、リリースノートなど。Claude は Skill を読み、その手順に従い、あなたの形で出力を生み出します。

Skills 対 tools

両者は別々の問題を解くので、違いをはっきりさせておく価値があります。

  • Tools は Claude をデータとアクションに繋ぐ。「このコードセクションを調べる」「このメールを送る」— Claude がツールを呼び、他の何かが実行する。
  • Skills は Claude に手順を教える。「このテンプレートに従って日次ステータスレポートを生成する」— Claude が読んで従うプレイブックで、ときには同梱スクリプトを自分で実行することも含む。

覚え方のコツ:tools は Claude に何ができるか、Skills はあなたがどうやってほしいか。

もう 1 つ知っておく価値のあること。Skills は起動時にコンテキストへ丸ごと読み込まれるわけではありません。 最初は名前と説明だけが読み込まれます。エージェントがその Skill を関連ありと判断したとき、初めて Skill 全体をコンテキストに読み込みます。これにより、多くの Skill が使える状態でもコンテキストをスリムに保てます。

Skill をアップロードする

Skills はワークスペースに一度アップロードし、その後は ID で参照します。Claude Platform 上で直接アップロードすることも、プログラムから行うこともできます。

skill = client.beta.skills.create(
    display_title="Status Report Generator",
    files=files_from_dir("status-report-skill"),  # folder containing SKILL.md
)

print(skill.id)  # reference this ID in future requests

この例では、ステータスレポートジェネレーターが欲しいとします。良いステータスレポートを作るためのルール(セクション、トーン、要約のしかた、ブロッカーの扱い方)はすべて、あらかじめパッケージ化された Skill の中に置きます。アクティビティログそのものは、リクエスト時に渡す単なる文字列です。

Skill をリクエストに紐づける

Skills は container の設定を通じてリクエストに紐づきます。container の中の skills 配列で、各エントリが skill_idversion を指定します。ステータスレポートジェネレーターの完全な呼び出しはこうです。

response = client.beta.messages.create(
    model="claude-sonnet-4-5",
    max_tokens=4096,
    betas=["skills-2025-10-02", "code-execution-2025-08-25"],
    container={
        "skills": [
            {
                "type": "custom",
                "skill_id": skill.id,
                "version": "latest",
            }
        ]
    },
    tools=[
        {
            "type": "code_execution_20250825",
            "name": "code_execution",
        }
    ],
    messages=[
        {
            "role": "user",
            "content": f"Generate the daily status report from this activity log:\n\n{activity_log}",
        }
    ],
)

いくつか指摘しておく点。

  • 標準ではなく client.beta.messages.create を呼び、skills 機能を beta ヘッダー経由で渡しています。この動画時点では、Skills はまだ beta 機能です。
  • container.skills が Skill を紐づける場所です。リストなので、1 つの呼び出しに複数の Skill を重ねられます。
  • ここでは code execution もオンにしています。Skills はしばしば code execution と相性が良い。Skill の手順は、ターミナルでスクリプトを走らせるような本物の作業をこなせるからです。

実行する

出力は、Skill が指定したとおりのフォーマットのステータスレポートです。セクション、トーン、ブロッカーの扱い — そのすべてが、アップロードした SKILL.md から来ます。ユーザープロンプトは 1 行。手順は Skill の中にあります。

本番アプリでは、これがチームが機能全体で出力を標準化するやり方になります。この日次ステータスレポートのエンドポイントでは、誰もテンプレートをプロンプトにコピペすることなく、すべての PM が同じ構造・同じトーン・同じセクションを同じ順序で得られます。

まとめ

  • Skills はあなたの手順をパッケージ化する。SKILL.md ファイル(+任意のスクリプトやリソース)が、あなたのやってほしいやり方を Claude に教える。
  • tools 対 Skills:tools は Claude に何ができるか、Skills はあなたがどうやってほしいか。
  • Skills は段階的に読み込まれる。起動時には名前と説明だけ、エージェントが使うと判断したときに Skill 全体がコンテキストに読み込まれる。
  • client.beta.skills.create で一度アップロードし、任意の messages.create 呼び出しで container.skills に紐づける。リストなので複数の Skill を重ねられる。
  • Skill の手順が本物の作業を必要とするなら、code execution と組み合わせる。
  • 「何を」と同じくらい「どうやって」が重要なとき、Skill に手を伸ばす。

英語原文

Skills are folders of instructions, scripts, and resources that Claude loads dynamically to improve performance on specialized tasks. At the core of every Skill is a SKILL.md file — a packaged set of instructions you upload once and then attach to any messages.create call. You're teaching Claude how you do something: your status report format, your review checklist, your release notes. Claude reads the Skill, follows the procedure, and produces output in your shape.

Skills vs. tools

It's worth being clear on the difference, because the two solve different problems:

  • Tools connect Claude to data and actions. "Look up this code section," "send this email" — Claude calls the tool, and something else runs.
  • Skills teach Claude a procedure. "Generate the daily status report following this template" — it's a playbook Claude reads and follows, which sometimes means running bundled scripts itself.

A simple way to remember it: tools are about what Claude can do, while Skills are about how you want it done.

One more thing worth knowing: Skills don't load fully into context on startup. Only the name and description load at first. When your agent decides a Skill is relevant, it then loads the full Skill into context. That keeps your context lean even when many Skills are available.

Uploading a Skill

Skills are uploaded once to your workspace, then referenced by ID. You can upload directly on the Claude Platform, or do it programmatically:

skill = client.beta.skills.create(
    display_title="Status Report Generator",
    files=files_from_dir("status-report-skill"),  # folder containing SKILL.md
)

print(skill.id)  # reference this ID in future requests

For this example, I want a status report generator. All the rules for what makes a good status report — sections, tone, how to summarize, how to handle blockers — live in a Skill packaged ahead of time. The activity log itself is just a string passed in at request time.

Attaching a Skill to a request

Skills attach to a request through the container configuration — a skills array inside the container, where each entry names a skill_id and version. Here's the full call for the status report generator:

response = client.beta.messages.create(
    model="claude-sonnet-4-5",
    max_tokens=4096,
    betas=["skills-2025-10-02", "code-execution-2025-08-25"],
    container={
        "skills": [
            {
                "type": "custom",
                "skill_id": skill.id,
                "version": "latest",
            }
        ]
    },
    tools=[
        {
            "type": "code_execution_20250825",
            "name": "code_execution",
        }
    ],
    messages=[
        {
            "role": "user",
            "content": f"Generate the daily status report from this activity log:\n\n{activity_log}",
        }
    ],
)

A few things worth pointing out:

  • We're calling client.beta.messages.create, not the standard one, and passing the skills feature via the beta header. As of this video, Skills are still a beta feature.
  • container.skills is where the Skill attaches. It's a list, so you can layer multiple Skills onto one call.
  • Code execution is turned on here too. Skills often pair well with code execution, because Skill procedures can do real work — like running scripts in a terminal.

Running it

The output is a status report formatted exactly the way the Skill says to format it. Sections, tone, blocker handling — all of it comes from the SKILL.md file you uploaded. The user prompt is one line; the procedure lives in the Skill.

In a production app, this is how a team standardizes output across an entire feature. With this daily status report endpoint, every PM gets the same structure, the same tone, the same sections, in the same order — without anyone copy-pasting a template into a prompt.

Recap

  • Skills package your procedures. A SKILL.md file (plus any scripts and resources) teaches Claude how you want something done.
  • Tools vs. Skills: tools are about what Claude can do; Skills are about how you want it done.
  • Skills load progressively. Only the name and description load at startup; the full Skill loads into context when the agent decides to use it.
  • Upload once with client.beta.skills.create, then attach with container.skills on any messages.create call — a list, so you can layer multiple Skills.
  • Pair with code execution when the Skill's procedure needs to do real work.
  • Reach for a Skill when the how matters as much as the what.
↑ 目次へ戻る

Claude Platform 101 | Lesson 09「MCP(MCP)」

出典: Anthropic Academy / 2026-07-04

日本語ナレッジ(本文の自然な全訳)

私たちには tools、skills、connectors があります。では、なぜ MCP が存在するのでしょうか。一見すると、API の上にもう 1 つ API を積み重ねているように見えます。もっともな疑問です。そして答えは、「誰が統合コードをメンテナンスするか」に行き着きます。

メンテナンスの問題

たとえば、あなたのエージェントが Asana からタスクを引き、Google Calendar をチェックし、Slack を検索する、これを一度にやる必要があるとします。カスタムツールなら、3 つの統合を書かねばなりません。そこはやればできます。つらいのはその後です。これらのサービスが API を変更するたびに、その統合をメンテナンスしなければなりません。そしてそれは頻繁に起こります。おめでとうございます、あなたはサードパーティ API ラッパーの山をメンテナンスする身になりました。

MCP はそのメンテナンスをサービス提供者側に移します。Asana が MCP サーバーを公開する。Slack も公開する。Google も公開する。各サーバーが、標準プロトコルを通じて、自身のツールを(説明・スキーマ・認証つきで)公開します。彼らの API が変わったら、彼らがサーバーを更新する。あなたは何も変えません。

tools 対 skills 対 MCP

この 3 つの機能は別々の仕事をします。

  • Tools は Claude をあなたの内部システムに繋ぐ。あなたのデータベース、プロジェクトトラッカー、独自 API。コードを所有するのはあなたなので、メンテナンスもあなたが持つ。
  • Skills は Claude に手順を教える。あなたのレポートテンプレート、レビューのチェックリスト。Skills は指示であって、必ずしも統合ではない。
  • MCP は Claude をサードパーティサービスに繋ぐ。そこでは統合をサービス提供者がメンテナンスする。Asana のラッパーはあなたが書くのではなく、Asana が書いた。

短く言えば:tools はあなたのもの用、skills はあなたのプロセス用、MCP はそれ以外の皆のもの用。

MCP サーバーに接続する

MCP の感触を掴む最もきれいな方法は、任意の MCP サーバーに Claude を向けて、そこに何があるかを発見させることです。この例では、Linear の MCP サーバーを使い、接続の詳細と認証トークンは .env ファイルに保存します。

リクエストの中で 2 つの部分が連携します。mcp_servers キーが接続を宣言します。type、URL、参照用の name、そしてオプションで認証トークン。次に、mcp_toolset タイプのツールが、そのサーバーから Claude が使えるツールを設定します。デフォルトは全ツールですが、スコープを絞りたいならここで行います。

import os
import anthropic

client = anthropic.Anthropic()

response = client.beta.messages.create(
    model="claude-opus-4-8",
    max_tokens=1000,
    messages=[
        {"role": "user", "content": "What tools do you have available?"}
    ],
    mcp_servers=[
        {
            "type": "url",
            "url": "https://mcp.linear.app/mcp",
            "name": "linear",
            "authorization_token": os.environ["LINEAR_MCP_TOKEN"],
        }
    ],
    tools=[
        {
            "type": "mcp_toolset",
            "mcp_server_name": "linear",
        }
    ],
    betas=["mcp-client-2025-11-20"],
)

print(response)

私たちがツールスキーマを 1 つも書いていないことに注目してください。Claude はサーバーをイントロスペクト(内省)し、ツールの一覧とそのスキーマを取得し、プロンプトに適したものを選びます。このレッスン時点では、MCP コネクタは beta です。リクエストの beta ヘッダーに注目。

実行すると、あなたの MCP URL が Linear の MCP エンドポイントを指していれば、Claude は Linear のツールを列挙し、そのうちの 1 つを呼び出します。同じことが、基本的にどんな準拠サーバーでも動きます。私たちはツールを 1 つも定義しませんでした。Linear のクライアントも書きませんでした。それは Linear がメンテナンスしています。

Claude が使えるツールをフィルタリングする

MCP サーバーはしばしば非常に多くのツールを公開します。そして Claude にそのすべてを使ってほしいとは限りません。書き込み権限を持たせたくないかもしれないし、それら全部のツール定義でコンテキストを埋めたくないかもしれない。

対処法:デフォルトですべて無効にし、それから欲しい特定のツールだけを有効にする。 Slack の MCP サーバーでのそのパターンはこうです。

tools=[
    {
        "type": "mcp_toolset",
        "mcp_server_name": "slack",
        "default_config": {
            "enabled": False,
        },
        "configs": {
            "search_messages": {"enabled": True},
            "list_channels": {"enabled": True},
        },
    }
]

これで Claude は Slack を検索したりチャンネルを列挙したりできますが、投稿や削除はできません。読み取りは信頼するが、Claude に勝手に自分の代わりに書き込ませたくない、というサービスに便利です。

まとめ

  • MCP は、他の誰かがすでに作った統合を、あなたがメンテナンスしなくて済むように存在する。サービス提供者が MCP サーバーを公開し最新に保つので、彼らの API が変わってもあなたは何も変えない。
  • 仕事に適した機能を選ぶ。あなたのデータには tools、あなたのプロセスには skills、サードパーティサービスには MCP。
  • 接続は mcp_servers(type、URL、name、オプションの認証トークン)で宣言し、tools 内の mcp_toolset エントリでアクセスを付与する。Claude はサーバーをイントロスペクトし、ツールを自分で発見する — スキーマを書く必要はない。
  • default_config: {"enabled": False} を設定し、configs で特定のツールだけを有効化してアクセスを絞り込む — サーバーを読み取り専用に保つのに便利。
  • MCP コネクタは現在ベータなので、リクエストにベータヘッダーを含める。
  • 利用可能なサーバーの一覧とプロトコルの詳細は modelcontextprotocol.io を参照。

英語原文

We have tools, skills, and connectors. So why does MCP exist? At first glance it looks like a second API stacked on top of the API. Fair question — and the answer comes down to who maintains the integration code.

The maintenance problem

Say your agent needs to pull tasks from Asana, check a Google Calendar, and search Slack — all in one go. With custom tools, you have to write three integrations. That part is doable. The painful part comes after: you also have to maintain those integrations every time one of those services changes its API, which happens often. Congratulations, you're now maintaining a pile of third-party API wrappers.

MCP shifts that maintenance to the service provider. Asana publishes an MCP server. Slack publishes one. Google publishes one. Each server exposes its own tools — with descriptions, schemas, and authentication — through a standard protocol. When their API changes, they update their server. You change nothing.

Tools vs. skills vs. MCP

These three features do different jobs:

  • Tools connect Claude to your internal systems — your database, your project tracker, your proprietary APIs. You own the code, so you also own the maintenance.
  • Skills teach Claude a procedure — your report template, your review checklist. Skills are instructions, not necessarily integrations.
  • MCP connects Claude to third-party services, where the service provider maintains the integration. You don't write the Asana wrapper — Asana did.

The short version: tools are for your stuff, skills are for your processes, and MCP is for everyone else's stuff.

Connecting to an MCP server

The cleanest way to get a feel for MCP is to point Claude at any MCP server and let it discover what's there. For this example, we'll use the Linear MCP server, with the connection details and auth token stored in a .env file.

Two pieces work together in the request. The mcp_servers key declares the connection — a type, a URL, a name to refer to it by, and optionally an auth token. Then a tool with the type mcp_toolset configures which tools Claude can use from that server. The default is all of them, but if you want to scope it down, this is where you do it.

import os
import anthropic

client = anthropic.Anthropic()

response = client.beta.messages.create(
    model="claude-opus-4-8",
    max_tokens=1000,
    messages=[
        {"role": "user", "content": "What tools do you have available?"}
    ],
    mcp_servers=[
        {
            "type": "url",
            "url": "https://mcp.linear.app/mcp",
            "name": "linear",
            "authorization_token": os.environ["LINEAR_MCP_TOKEN"],
        }
    ],
    tools=[
        {
            "type": "mcp_toolset",
            "mcp_server_name": "linear",
        }
    ],
    betas=["mcp-client-2025-11-20"],
)

print(response)

Notice that we never wrote a single tool schema. Claude introspects the server, gets the list of tools and their schemas back, and picks the right one for the prompt. As of this lesson, the MCP connector is in beta — note the beta header in the request.

Run it, and if your MCP URL points at Linear's MCP endpoint, Claude lists Linear's tools and then calls one. The same works for basically any compliant server. We didn't define a single tool. We didn't write a Linear client. Linear is maintaining that.

Filtering which tools Claude can use

MCP servers often expose many, many tools — and you don't always want Claude using all of them. Maybe you don't want it to have write permissions, or you just don't want all those tool definitions taking up context.

The fix: disable everything by default, then enable only the specific tools you want. Here's that pattern with a Slack MCP server:

tools=[
    {
        "type": "mcp_toolset",
        "mcp_server_name": "slack",
        "default_config": {
            "enabled": False,
        },
        "configs": {
            "search_messages": {"enabled": True},
            "list_channels": {"enabled": True},
        },
    }
]

Now Claude can search Slack and list channels, but it can't post or delete. This is useful when you trust a service for reads but don't want Claude writing on your behalf by accident.

Recap

  • MCP exists so you don't have to maintain integrations someone else has already built. The service provider publishes an MCP server and keeps it up to date — you change nothing when their API changes.
  • Pick the right feature for the job: tools for your data, skills for your process, MCP for third-party services.
  • Declare the connection in mcp_servers (type, URL, name, optional auth token) and grant access with an mcp_toolset entry in tools. Claude introspects the server and discovers the tools on its own — no schemas to write.
  • Scope down access by setting default_config: {"enabled": False} and enabling specific tools in configs — handy for keeping a server read-only.
  • The MCP connector is currently in beta, so include the beta header on your requests.
  • Visit modelcontextprotocol.io for the list of available servers and to learn more about the protocol.
↑ 目次へ戻る

Claude Platform 101 | Lesson 10「コンテキスト管理(Context management)」

出典: Anthropic Academy / 2026-07-04

日本語ナレッジ(本文の自然な全訳)

Claude に送るすべてのリクエストには、コンテキストウィンドウがあります。100 万トークンは多く聞こえますが、実際のエージェントをリリースし始めると、思ったより速く尽きます。そこで登場するのがコンテキスト管理です。大事なものを失わずにウィンドウの内側に収まり続けるための方法です。

何がコンテキストに数えられるか

コンテキストとは、あるターンで Claude が見るすべてです。

  • システムプロンプト
  • メッセージ履歴
  • ツール定義とツール結果
  • 添付ファイルと skills
  • thinking ブロック

これはすべての API 呼び出しの入力です。入る側でも支払い、出る側でも支払います。そしてウィンドウが満杯になると、リクエストは失敗します。

だからゴールは「すべてを詰め込む」ことではありません。ゴールは「適切なものを詰め込む」ことです。

Anthropic は、長時間動くエージェントのコンテキスト管理について 4 つのパターンを公開しています。3 つは第一級の API 機能、1 つは設計パターンです。

パターン 1:Just-in-time context(必要な時に読む)

すべてを前もって読み込まない。エージェントが今必要とするものを読み込み、もっと必要になったらツール経由で自分から引かせる。

コンプライアンスレビューエージェントを考えてみてください。建築基準の本を丸ごとシステムプロンプトに詰め込むのではなく、特定のセクションが必要なときに lookup_building_code ツールを呼びます。これは 4 つのうち唯一の設計パターンで、API 上の特別なものは何もなく、「何をいつ読み込むか」という意図的な選択にすぎません。

パターン 2:Server-side compaction(サーバー側の圧縮)

会話が長くなると、Anthropic のサーバー側コンパクションが古いターンを 1 つのブロックに要約します。リクエストに context_management キーを加え、type を持つ edit を保持することでオプトインします。

response = client.messages.create(
    model="claude-sonnet-4-5",
    max_tokens=1024,
    context_management={
        "edits": [
            {"type": "compact"}
        ]
    },
    messages=messages,
)

入力がトリガーしきい値を超えると、API が自動で要約します。会話の長さを自分で追跡する必要はありません。

パターン 3:Prompt caching(プロンプトキャッシュ)

Prompt caching は、リクエストの安定した部分(システムプロンプト、ツール定義、長い文書)をマークし、それらを複数の呼び出しにわたってわずかなコストで再利用させます。

この計算は見た目以上に重要です。システムプロンプトが 4,000 トークンで、それを 1 時間に 100 回呼ぶなら、キャッシュは「使える請求額」と「財務からの電話」の分かれ目になります。

パターン 4:The memory tool(メモリツール)

一部のコンテキストはセッションをまたいで生き延びる必要があります。ユーザーの好み、エージェントの走り書きメモ、先週決めたこと。これに推奨されるプリミティブが memory tool です。

仕組みはこうです。

  • Claude はツール呼び出しを通じて memory ディレクトリを読み書きする。
  • ストレージのバックエンドはあなたがクライアント側で実装する。ファイルシステム、データベース、暗号化ストア、何でも好きなもの。
  • Anthropic は、作業を始める前に memory ディレクトリを確認するよう Claude に指示するシステム命令を自動注入する。

パターンを重ねる

本番アプリでは、たいてい 4 つすべてを同時に重ねます。コンプライアンスレビューエージェントは、システムプロンプトとツール定義をキャッシュし、建築基準のセクションは lookup_building_code 経由で必要な時に引きます。

各パターンは異なる失敗モードに対処します。コスト、ウィンドウサイズ、ステートレス性。今あなたが壊れているものに合うものを選んでください。

まとめ

  • コンテキストはあるターンで Claude が見るすべてで、無料でも無限でもない。ウィンドウが満杯になるとリクエストは失敗する。
  • Just-in-time context:今必要なものを読み込み、残りはツールに引かせる。これは 4 つのうち唯一の設計パターン。
  • Server-side compaction:context_management キーを加えると、入力がトリガーしきい値を超えたとき API が古いターンを自動要約する。
  • Prompt caching:リクエストの安定部分をマークし、複数呼び出しにわたってわずかなコストで再利用する。
  • The memory tool:Claude がツール呼び出しで memory ディレクトリを読み書きする。ストレージのバックエンドはあなたが所有するので、コンテキストがセッションをまたいで生き延びる。
  • 4 つのパターン、1 つのゴール。手作業で組んでもいいし、キャッシュとコンパクションがデフォルトでオンの Claude マネージドエージェントを使ってもいい。

英語原文

Every request you send Claude has a context window. A million tokens sounds like a lot, but it runs out faster than you think once you're shipping a real agent. That's where context management comes in: it's how you stay inside the window without losing what matters.

What counts as context

Context is everything Claude sees on a given turn:

  • The system prompt
  • The message history
  • Tool definitions and tool results
  • Attached files and skills
  • Thinking blocks

It's the input to every single API call. You pay for it on the way in, and you pay for it on the way out. And once the window is full, the request fails.

So the goal isn't to fit everything in. The goal is to fit the right things in.

Anthropic publishes four patterns for managing context in long-running agents. Three are first-class API features, and one is a design pattern.

Pattern 1: Just-in-time context

Don't load everything upfront. Load what the agent needs now, and let it pull more in via tools when it asks.

Think of a compliance review agent. It doesn't get the entire building code book stuffed into its system prompt — it calls a lookup_building_code tool when it needs a specific section. This is the design pattern of the four: nothing special in the API, just a deliberate choice about what you load and when.

Pattern 2: Server-side compaction

When a conversation runs long, Anthropic's server-side compaction summarizes old turns into a single block. You opt in by adding a context_management key to your request, holding an edit with a type:

response = client.messages.create(
    model="claude-sonnet-4-5",
    max_tokens=1024,
    context_management={
        "edits": [
            {"type": "compact"}
        ]
    },
    messages=messages,
)

The API auto-summarizes when the input crosses the trigger threshold. You don't have to track conversation length yourself.

Pattern 3: Prompt caching

Prompt caching lets you mark the stable parts of a request — the system prompt, the tool definitions, a long document — and reuse them across calls at a fraction of the cost.

The math matters more than it looks. If your system prompt is 4,000 tokens and you call it 100 times an hour, caching is the difference between a usable bill and a phone call from finance.

Pattern 4: The memory tool

Some context needs to survive across sessions: user preferences, the agent's running notes, what was decided last week. The recommended primitive for this is the memory tool.

Here's how it works:

  • Claude reads and writes to a memory directory via tool calls.
  • You implement the storage backend client-side — a file system, a database, an encrypted store, whatever you want.
  • Anthropic auto-injects a system instruction telling Claude to check the memory directory before starting work.

Layering the patterns

In a production app, you'll usually layer all four at once. The compliance review agent caches its system prompt and tool definitions, and pulls building code sections in just in time via lookup_building_code.

Each pattern handles a different failure mode: cost, window size, statelessness. Pick the ones that match what's breaking for you.

Recap

  • Context is everything Claude sees on a turn — and it isn't free or infinite. Once the window fills, the request fails.
  • Just-in-time context: load what's needed now, let tools pull in the rest. This is the design pattern of the four.
  • Server-side compaction: add a context_management key, and the API summarizes old turns automatically when input crosses the trigger threshold.
  • Prompt caching: mark stable parts of the request and reuse them across calls at a fraction of the cost.
  • The memory tool: Claude reads and writes a memory directory via tool calls; you own the storage backend, so context survives across sessions.
  • Four patterns, one goal. Wire them up by hand, or use Claude managed agents, which ship with caching and compaction on by default.
↑ 目次へ戻る

Claude Platform 101 | Lesson 11「マネージドエージェントとは?(What are managed agents?)」

出典: Anthropic Academy / 2026-07-04

日本語ナレッジ(本文の自然な全訳)

Claude Managed Agents(マネージドエージェント)は、エージェントを大規模に構築・デプロイするための API 群です。特定のツール・ペルソナ・能力を持つエージェントを定義します。適切なパッケージとネットワーク制御を備えたサンドボックス環境を設定します。そして、あなた自身のアプリケーションからセッションを発火させると、Claude が、完全なファイルシステムアクセス・bash 実行・web search を備えた隔離コンテナの中で作業をこなします。

エージェントループを、あなたの代わりにホストする

内部的には、これはエージェントループです。Claude が推論し、ツールを呼び、結果を読み、仕事が終わるまで繰り返す。以前にエージェントを作ったことがあるなら、この種のループを自分で書いたことがあるはずです。マネージドエージェントは、その同じループを Anthropic のインフラ上でホストするので、あなたが走らせる必要はありません。

Managed Agents は Claude Console の専用セクションにあります。

これが何を解き放つのかを理解する最良の方法は、いくつかの例を歩いてみることです。

例 1:作業をこなすカンバンボード

マネージドエージェントの上に載ったカンバンボードを思い描いてください。チケットを「in progress(進行中)」列にドラッグすると、それが自動でセッションを発火させます。たとえばチケットに「optimize website performance(ウェブサイトのパフォーマンスを最適化せよ)」とあるとします。何が起こるか。

  • あなたのバックエンドがセッションを作成する。
  • そのセッションは、Lighthouse と Puppeteer をプリインストールした、あなたが設定した環境を指す。
  • あなたの GitHub リポジトリがコンテナにマウントされる。

これで Claude はコードベース、ツール、そして「完了とは何か」を定義するルーブリック(採点基準)を手にします。

  • Lighthouse スコアが 90 超
  • レンダリングをブロックするリソースがない
  • すべての画像が遅延読み込み(lazy loaded)されている

Claude は監査を実行し、それから画像を圧縮し、CSS をインライン化し、スクリプトを遅延させ始めます。あらゆるツール呼び出しがイベントストリームを通じてリアルタイムでボードにストリーミングされ、作業の様子をその場で見られます。

そしてルーブリックが効いてきます。独自のコンテキストウィンドウで動く別個の grader(採点者)が、あなたの基準に照らして出力を評価します。Claude はそのフィードバックを読み、戻って、見落としを修正し、再提出します。デモでは、そのループが Lighthouse スコアを 96 まで押し上げます。

もう 1 つ。最初のチケットがまだ走っている間に、2 つ目のチケットをドラッグできます。2 つのセッション、2 つのコンテナ、2 つの別々のタスクが並行して走ります。

例 2:メモリを持つ、定期実行のリサーチエージェント

別の形のエージェント。会社が支払っているすべての SaaS ツールについて、価格と料金プランの変更を追跡し、朝会(stand-up)の前にレポートを用意することが仕事のエージェントです。

各実行で、このエージェントは。

  • 現在の価格ページを Web 検索し、料金プランのティア変更をチェックし、契約に影響しそうな新機能をフラグする
  • サンドボックス内で Python によるコスト分析を実行する
  • Excel スプレッドシートの skill を使い、エグゼクティブサマリーを書く
  • Slack にリンクを投稿し、Asana にレビュータスクを作成する。どちらも MCP サーバー経由

このエージェントは memory ストアの読み書きもします。始める前に、先週何を見つけたかを確認する。終えた後、何が変わったかを保存する。だから次の月曜のレポートは、毎回同じ静的な価格データを列挙する代わりに、「先週からコンピュートコストが 15% 下がった」と言えるのです。

例 3:複数エージェントによるインシデント対応

さて、監視スタックからアラートが発火したと想像してください。あなたのバックエンドのカスタムツールがアラートのペイロードを受け取り、それを tool result として新しいセッションに送り込みます。このセッションはマルチエージェント協調(multi-agent coordination)を使います。

  • コーディネーターエージェントがアラートを受け取り、3 人のスペシャリストに委譲する。
  • 各スペシャリストは、同じ共有ファイルシステム上で、自分のコンテキストウィンドウで動く。
  • スペシャリストが報告を返し、コーディネーターがその発見を 1 つのインシデントサマリーに統合する。

サマリーが Slack に行く前に、パーミッションポリシーが発火します。ドラフトが画面に表示され、あなたが承認すると、メッセージが送られます。センシティブなアクションは人間を待ちます。

メモリがこのすべてを結びつけます。コーディネーターは memory ストアの過去のインシデントを確認し、パターンをフラグします。「これは 2 週間前の DNS 解決の問題に似ている。TTL の設定ミスが原因だったやつだ」と。次に似たアラートが発火したとき、エージェントはゼロから診断する代わりに、その文脈から始められます。

構成要素(building blocks)

これらの例を横断して、マネージドエージェントは、開発者に対して、完全にマネージドでステートフルなエージェント体験を届けるツールを与えます。それは以下の上に構築されています。

  • Agents — 特定のツール・ペルソナ・能力を持つ定義
  • Sessions — あなた自身のアプリケーションから発火させる個々の実行
  • Environments — 適切なパッケージとネットワーク制御を持つサンドボックス
  • Tools — あなたのバックエンド上のカスタムツールを含む
  • MCP — Slack や Asana のようなサービスへの接続
  • Memory — エージェントが開始前に読み、完了時に書き込むストア
  • Outcomes — 「完了」とは何かを定義しチェックする rubric と grader
  • Multi-agent coordination — コーディネーターがスペシャリストに委譲する

まとめ

  • Claude Managed Agents は、エージェントを大規模に構築・デプロイするための API 群で、Anthropic のインフラ上でホストされる。
  • おなじみのエージェントループ — 推論し、ツールを呼び、結果を読み、繰り返す — を、ファイルシステムアクセス・bash 実行・web search を備えた隔離コンテナの中で回す。
  • セッションはあなたが構成した環境で走り、並行して動作し、ツール呼び出しをリアルタイムであなたのアプリにストリーミングで返す。
  • rubric と独立した grader によって成功基準を定義でき、Claude はそれを満たすまで反復する。
  • Memory、MCP サーバー、カスタムツール、パーミッションポリシー、マルチエージェント協調が、ステートフルなエージェント体験を締めくくる。
  • あなたが「完了」の姿を定義する。Claude はそこに到達するまで働く。

英語原文

Claude Managed Agents is a suite of APIs for building and deploying agents at scale. You define agents with specific tools, personas, and capabilities. You configure sandbox environments with the right packages and network controls. Then you fire off sessions from your own application, and Claude does the work inside an isolated container with full file system access, bash execution, and web search.

The agent loop, hosted for you

Under the hood, this is an agent loop: Claude reasons, calls a tool, reads the result, and repeats until the job is done. If you've built agents before, you've probably written this kind of loop yourself. Managed agents takes that same loop and hosts it on Anthropic's infrastructure, so you don't have to run it.

You'll find Managed Agents in its own section of the Claude Console.

The best way to understand what this unlocks is to walk through a few examples.

Example 1: A Kanban board that does the work

Picture a Kanban board sitting on top of managed agents. You drag a ticket into the "in progress" column, and that fires off a session automatically. Say the ticket reads "optimize website performance." Here's what happens:

  • Your back end creates a session.
  • The session points to an environment you configured with Lighthouse and Puppeteer pre-installed.
  • Your GitHub repo gets mounted into the container.

Now Claude has the codebase, the tools, and a rubric that defines what done looks like:

  • Lighthouse score above 90
  • No render-blocking resources
  • All images lazy loaded

Claude runs the audit, then starts compressing images, inlining CSS, and deferring scripts. Every tool call streams back to the board in real time through the event stream, so you can watch the work as it happens.

Then the rubric kicks in. A separate grader, running in its own context window, evaluates the output against your criteria. Claude reads that feedback, goes back in, fixes what it missed, and resubmits. In the demo, that loop takes the Lighthouse score up to 96.

One more thing: you can drag a second ticket over while the first is still running. Two sessions, two containers, two separate tasks running in parallel.

Example 2: A recurring research agent with memory

Here's a different shape of agent: one whose job is to track prices and plan changes across every SaaS tool your company pays for, with a report ready before stand-up.

On each run, the agent:

  • Searches the web for current pricing pages, checks for plan tier changes, and flags new features that might affect your contracts
  • Runs a cost analysis in Python inside the sandbox
  • Uses an Excel spreadsheet skill and writes an executive summary
  • Posts a link to Slack and creates a review task in Asana, both through MCP servers

The agent also reads from and writes to a memory store. Before it starts, it checks what it found last week. After it finishes, it stores what changed. So next Monday's report can say "compute costs are 15% lower since last week" instead of listing the same static pricing data every time.

Example 3: Incident response with multiple agents

Now imagine an alert fires from your monitoring stack. A custom tool on your back end receives the alert payload and sends it into a new session as a tool result. This session uses multi-agent coordination:

  • A coordinator agent receives the alert and delegates to three specialists.
  • Each specialist runs in its own context window on the same shared file system.
  • The specialists report back, and the coordinator synthesizes their findings into a single incident summary.

Before the summary goes to Slack, the permissions policy fires. You see the draft on screen, approve it, and the message goes out. Sensitive actions wait for a human.

Memory ties all of this together. The coordinator checks past incidents in the memory store and flags a pattern: "this looks like the DNS resolution issue from two weeks ago that was caused by a misconfigured TTL." The next time a similar alert fires, the agent starts with that context instead of diagnosing from scratch.

The building blocks

Across these examples, managed agents gives developers the tools to deliver a fully managed, stateful agent experience built on:

  • Agents — definitions with specific tools, personas, and capabilities
  • Sessions — individual runs you fire off from your own application
  • Environments — sandboxes with the right packages and network controls
  • Tools — including custom tools on your back end
  • MCP — connections to services like Slack and Asana
  • Memory — a store the agent reads before starting and writes to when done
  • Outcomes — rubrics and graders that define and check what done looks like
  • Multi-agent coordination — coordinators delegating to specialists

Recap

  • Claude Managed Agents is a suite of APIs for building and deploying agents at scale, hosted on Anthropic's infrastructure.
  • It runs the familiar agent loop — reason, call a tool, read the result, repeat — inside an isolated container with file system access, bash execution, and web search.
  • Sessions run in environments you configure, work in parallel, and stream tool calls back to your app in real time.
  • Rubrics and separate graders let you define success criteria; Claude iterates until it meets them.
  • Memory, MCP servers, custom tools, permissions policies, and multi-agent coordination round out the stateful agent experience.
  • You define what done looks like. Claude works until it gets there.
↑ 目次へ戻る

Claude Platform 101 | Lesson 12「はじめてのマネージドエージェントを作る(Building your first managed agent)」

出典: Anthropic Academy / 2026-07-04

日本語ナレッジ(本文の自然な全訳)

エージェントループを手で作ったことがあるなら、その段取りは知っているはずです。while ループ、stop reason での分岐、ツール実行。それは機能しますし、多くの機能ではむしろそれが正しい形です。でも、ときにそのループは非常に長く走ることがあります。数分、場合によっては数時間。多くのツールをまたぎ、保持すべき状態があり、書き込むファイルがあり、ネットワークの不調のあとに再開すべき作業があります。その段階になると、そのループを自分のサーバーで走らせたくはありません。委譲したい。それがマネージドエージェントです。

マネージドエージェントとは何か

マネージドエージェントは、あなたのインフラではなく Anthropic のインフラ上で走るエージェントループです。エージェントを一度記述し、作業する環境を与え、セッションを開始します。Anthropic がループを走らせ、あなたは作業が進むにつれてイベントをストリームとして読み出すだけです。

マネージドエージェントは、すべての API アカウントでデフォルト有効です。特別なアクセスは不要です。

4 つのプリミティブ

4 つのプリミティブがあり、順番に並んでいます。

  • Agent — ペルソナ:モデル、システムプロンプト、ツールセット。多くの実行にわたって再利用できる。
  • Environment — エージェントが走る場所:クラウドかローカルか、ネットワーク設定など。
  • Session — ある環境の中での、エージェントの 1 回の実行。セッションが作業の単位。
  • Events — 出入りするメッセージ:エージェントのアクション、ツール呼び出し、結果、返答。

各要素はこう噛み合います。あなたのアプリはセッションと会話し、セッションは環境の中で作業を駆動し、起こることすべてがイベントストリームを通じて外へ流れ出ます。

ここでの転換に注目してください。あなたは while ループを走らせていません。イベントを送り、イベントを読んでいます。

実用になる最小のマネージドエージェント

何か役に立つことをする最小のマネージドエージェントを作りましょう。temp ドライブにファイルを作り、その行数を数え、報告する、というものです。

ツールには agent toolset を使います。Anthropic 同梱の file・bash・web ツールです。このタスクには問題なく機能するので、自分でツールを定義する必要はありません。

ステップ 1:エージェントを作る

まずエージェントを作ります。tools 配列の中に直接定義された agent toolset に注目してください。これが同梱ツールセットです。

import anthropic

client = anthropic.Anthropic()

agent = client.beta.agents.create(
    name="Line Counter",
    model="claude-opus-4-8",
    system="You are a helpful agent that completes small file tasks.",
    tools=[
        {"type": "agent_toolset_20260401", "default_config": {"enabled": True}}
    ],
)

覚えておいてください。エージェントは再利用可能です。一度作って、多くのセッションにわたって走らせます。

ステップ 2:環境を作る

次に環境。これはコンテナテンプレートを立ち上げます。クラウドで、ネットワーク制限なし。ここが、ファイルが実際に書き込まれるサンドボックスです。

environment = client.beta.environments.create(
    name="line-counter-env",
    config={
        "type": "cloud",
        "networking": {"type": "unrestricted"},
    },
)

ステップ 3:セッションを作る

続いて、エージェントと環境、それにオプションのタイトルを付けてセッションを作ります。セッションが作業の単位です。

session = client.beta.sessions.create(
    agent=agent.id,
    environment_id=environment.id,
    title="Count lines demo",
)

ステップ 4:ストリームを開いてから、キックオフを送る

さてイベントストリームを開きます。そして、これを先にやることに注目してください。ストリームは、開いた後に発生したイベントだけを配信します。だから、キックオフメッセージを送る前に必ずストリームを開いてください。それから、ライブのストリームにユーザーメッセージを送ります。

with client.beta.sessions.events.stream(session_id=session.id) as stream:
    # Stream is open — now send the kickoff
    client.beta.sessions.events.send(
        session_id=session.id,
        events=[
            {
                "type": "user.message",
                "content": [
                    {
                        "type": "text",
                        "text": "Create a file in the temp directory, "
                        "count its lines, and report back.",
                    }
                ],
            }
        ],
    )

events(複数形)であることに注目。イベントこそが、この API ですべてが流れる手段です。

ステップ 5:ストリームを消費する

最後に、ストリームを消費します。このデモで重要なイベントタイプは 3 つです。

  • agent.message — Claude のテキスト
  • agent.tool_use — Claude が選んだツール
  • session.status_idle — エージェントが完了した
    for event in stream:
        if event.type == "agent.message":
            for block in event.content:
                if block.type == "text":
                    print(block.text, end="", flush=True)
        elif event.type == "agent.tool_use":
            print(f"\n[tool] {event.name}")
        elif event.type == "session.status_idle":
            print("\n--- Agent done ---")
            break

実行すると、出力はエージェントが声に出して推論する様子です。実際のテキスト、選ぶツール、そして最終的な答え。そのすべてが、あなたのものではなく Anthropic のコンテナの中で走っています。

トレードオフ

通常、エージェントでは、すべてを自分でコントロールしなければならない自前のループを持ちます。マネージドエージェントでは、そのループ、サンドボックス、再開可能性(resumability)を委譲し、届いてくるイベントストリームをただ消費するだけです。

本番アプリでは、これは長時間走り、ファイルに触れる「これを整理しておいて」系タスクの形です。ファイル共有のクリーンアップを想像してください。マネージドエージェントが目標のディレクトリ構造仕様を読み、散らかった受信フォルダを歩き回り、ファイルを正しいプロジェクトフォルダへ移し、重複やゼロバイトのゴミをアーカイブし、確信を持って配置できないものをフラグする — そのすべてを、数千のファイルを相手に数分走りうる 1 セッションの中で行います。実際のアプリでの見た目はこうです。エージェントがファイルを仕分け・アーカイブ・フラグする様子をライブでストリーミングする、ファイル共有クリーンアップのダッシュボードです。

まとめ

  • マネージドエージェントとは、あなたの代わりに走らせるエージェントループ — あなたのサーバーではなく Anthropic のインフラ上で。
  • 流れはこう:エージェントを作り、環境を作り、セッションを作り、イベントを送り込み、イベントをストリーミングで受け取る。
  • エージェント(model、システムプロンプト、toolset)は複数の実行で再利用可能。セッションは 1 回の実行。イベントはすべてが流れる経路。
  • kickoff メッセージを送る前にイベントストリームを開く — ストリームは開いた後に発生したイベントしか届けない。
  • 3 つのイベントに注目:agent.message(テキスト)、agent.tool_use(ツール選択)、session.status_idle(完了)。
  • ループが長く走りすぎる、やることが多すぎる、あるいはトラブルを乗り越える必要があるときは、マネージドエージェントに手を伸ばす。フルコントロールが欲しいときは、手動ループに手を伸ばす。

英語原文

If you've built an agent loop by hand, you know the drill: while loops, stop reason switches, tool executions. That works, and for a lot of features it's actually the right shape. But sometimes that loop is going to run for a very long time — minutes, maybe even hours — across many tools, with state to keep, files to write, and work to resume after a network hiccup. At that point, you don't want to run the loop on your server. You want to delegate it. That's what managed agents are.

What is a managed agent?

A managed agent is an agent loop that runs on Anthropic's infrastructure instead of yours. You describe the agent once, you give it an environment to work in, and you start a session. Anthropic runs the loop, and you just stream the events back out as it works.

Managed agents are enabled by default for every API account — no special access needed.

The four primitives

There are four primitives, and they come in order:

  • Agent — the persona: model, system prompt, and toolset. This is reusable across many runs.
  • Environment — where the agent runs: cloud or local, networking config, and so on.
  • Session — a single run of an agent inside a certain environment. The session is the unit of work.
  • Events — the messages flowing in and out: the agent's actions, the tool calls, the results, the replies.

Here's how the pieces fit together: your app talks to a session, the session drives work inside the environment, and everything that happens flows back out through the event stream:

Notice the shift here: you're not running a while loop. You're sending events and reading events.

The smallest possible managed agent

Let's build the smallest managed agent that does something useful: create a file in the temp drive, count its lines, and report back.

For tools, we'll use the agent toolset — Anthropic's bundled file, bash, and web tools. They work fine for this task, so we don't have to define any tools ourselves.

Step 1: Create the agent

First, we create the agent. Note the agent toolset defined right in the tools array — that's the bundled toolset:

import anthropic

client = anthropic.Anthropic()

agent = client.beta.agents.create(
    name="Line Counter",
    model="claude-opus-4-8",
    system="You are a helpful agent that completes small file tasks.",
    tools=[
        {"type": "agent_toolset_20260401", "default_config": {"enabled": True}}
    ],
)

Remember: the agent is reusable. Create it once and run it across many sessions.

Step 2: Create the environment

Next, the environment. This spins up the container template — cloud, with unrestricted networking. This is the sandbox where the file actually gets written:

environment = client.beta.environments.create(
    name="line-counter-env",
    config={
        "type": "cloud",
        "networking": {"type": "unrestricted"},
    },
)

Step 3: Create the session

Then we create a session with our agent and environment, plus an optional title. The session is the unit of work:

session = client.beta.sessions.create(
    agent=agent.id,
    environment_id=environment.id,
    title="Count lines demo",
)

Step 4: Open the stream, then send the kickoff

Now we open the event stream — and notice that we do this first. The stream only delivers events that occur after it opens, so always open it before sending the kickoff message. Then we send the user message into the live stream:

with client.beta.sessions.events.stream(session_id=session.id) as stream:
    # Stream is open — now send the kickoff
    client.beta.sessions.events.send(
        session_id=session.id,
        events=[
            {
                "type": "user.message",
                "content": [
                    {
                        "type": "text",
                        "text": "Create a file in the temp directory, "
                        "count its lines, and report back.",
                    }
                ],
            }
        ],
    )

Notice it's events — plural. Events are how everything flows in this API.

Step 5: Consume the stream

Finally, we consume the stream. There are three event types that matter for this demo:

  • agent.message — Claude's text
  • agent.tool_use — what tool Claude picked
  • session.status_idle — the agent is done
    for event in stream:
        if event.type == "agent.message":
            for block in event.content:
                if block.type == "text":
                    print(block.text, end="", flush=True)
        elif event.type == "agent.tool_use":
            print(f"\n[tool] {event.name}")
        elif event.type == "session.status_idle":
            print("\n--- Agent done ---")
            break

Run it, and the output is the agent reasoning out loud — actual text, the tools it picks, and a final answer. All of it running inside Anthropic's container, not yours:

The trade

Usually with agents, we have our own loop where we have to control everything. With managed agents, you delegate that loop, the sandbox, and the resumability — and just consume the event stream as it comes in.

In a production app, this is the shape for long-running, file-touching, "go organize this for me" tasks. Picture a file share cleanup: a managed agent reads a target directory structure spec, walks the messy incoming folder, moves files into the right project folders, archives duplicates and zero-byte garbage, and flags anything it can't confidently place — all in a session that can run for minutes against thousands of files. Here's what that looks like in a real app — a fileshare cleanup dashboard streaming the agent's activity live as it sorts, archives, and flags files:

Recap

  • Managed agents are the agent loop, run for you — on Anthropic's infrastructure instead of your server.
  • The flow is: create an agent, create an environment, create a session, send events in, and stream events out.
  • The agent (model, system prompt, toolset) is reusable across runs; the session is a single run; events are how everything flows.
  • Open the event stream before sending your kickoff message — it only delivers events that occur after it opens.
  • Watch for three events: agent.message (text), agent.tool_use (tool picks), and session.status_idle (done).
  • Reach for managed agents when the loop would run too long, do too much, or need to survive a hiccup. Reach for a manual loop when you want full control.
↑ 目次へ戻る

Claude Platform 101 | Lesson 13「Claude Code で作る(Building with Claude Code)」

出典: Anthropic Academy / 2026-07-04

日本語ナレッジ(本文の自然な全訳)

Claude API を呼ぶコードを手で書くのは問題なく機能しますが、さらに速い道があります。Claude に書かせるのです。このレッスンでは、Claude Code を使って、スタブ化されたファイルから API 統合を埋めていきます。このコースを通して学んできたのと同じプリミティブを使って。

スタブから始める

プロジェクトはシンプルです。天気を取得する TypeScript ファイルで、2 つのスタブを含みます。

  • getWeather — 都市を受け取り、気温と天候を返す。
  • run — ツールランナーと Claude TypeScript SDK を使うべき関数。

ツールランナーは、ツール呼び出しとエージェントループをあなたの代わりに処理してくれる部品なので、それを手で組み上げる必要はありません。

Claude API skill

Claude Code には Claude API という組み込みの skill が付いています。/claude-api で直接呼び出すこともできますし、あなたが TypeScript SDK を使っていることを Claude Code が検知すると自動で呼び出します。

もし skill が見当たらなければ、マーケットプレイスから追加できます。

/plugin marketplace add AnthropicsSkills

Anthropics の末尾の s に注意。見落としやすいです。

1 つのプロンプト、動くコード

プロジェクトフォルダをターミナルで開き、Claude Code を起動します。そこからは、単一のプロンプトで済みます。良いプロンプトは 3 つのことをします。

  • 変更してほしいファイルを名指しする。
  • 使ってほしいパターンを名指しする。
  • 期待する最終状態を名指しする。

Claude Code はそれから、型に沿って getWeatherrun を埋め、ファイルの末尾に呼び出しを追記し、スクリプトを実行し、出力を報告します。もし何かエラーが出たら、エラーメッセージを読み、その場でコードにパッチを当てます。

Claude Code が生み出したもの

この実行では、Claude Code は入力をパースし city 型に基づいて出力を返す Zod ツールを作りました。また、私たちが頼んだツールランナーと run 関数を作り、エージェントループの最終結果を出力しました。

覚えておくべきパターン

Claude API に対して書くものの大半は、見慣れた形をしています。

  • ツールを定義する。
  • それをランナーに渡す。
  • 結果を返す。

これを毎回、記憶を頼りにタイプする必要はありません。代わりに、ファイルをスタブ化し、Claude Code に渡し、diff をレビューするだけです。

まとめ

  • Claude Code は、あなたのターミナルの中でファイルを編集しコマンドを実行するエージェント。
  • 組み込みの Claude API skill は、Claude Code が TypeScript SDK を検知すると自動で読み込まれる。/claude-api で呼び出すこともできる。
  • ファイル・パターン・最終状態を名指しするプロンプトを与えると、コードを書き、実行し、その場でエラーを直す。
  • Claude API のコードは見慣れた形に従う。ツールを定義し、ランナーに渡し、結果を返す。スタブ化し、委譲し、diff をレビューする。

英語原文

Writing code that calls the Claude API by hand works fine, but there's an even faster path: have Claude write it for you. In this lesson, we'll use Claude Code to fill in an API integration from a stubbed-out file — using the same primitives you've learned throughout this course.

Starting from a stub

The project is simple: a TypeScript file that gets weather. It contains two stubs:

  • getWeather — accepts a city and returns the temperature and conditions.
  • run — a function that should use the tool runner and the Claude TypeScript SDK.

The tool runner is the piece that handles tool calling and the agent loop for you, so you don't have to wire that up manually.

The Claude API skill

Claude Code comes with a built-in skill called Claude API. You can invoke it directly with /claude-api, or Claude Code will invoke it automatically when it detects that you're using the TypeScript SDK. If you don't see the skill, you can add it from the marketplace:

/plugin marketplace add AnthropicsSkills

Note the s at the end of Anthropics — it's easy to miss.

One prompt, working code

Open the project folder in your terminal and launch Claude Code. From there, it takes a single prompt. A good prompt does three things:

  • It names the file you want changed.
  • It names the pattern you want used.
  • It names the end state you expect.

Claude Code then fills in getWeather and run against the types, appends a call at the bottom of the file, executes the script, and reports the output. If something errors out, it reads the error message and patches the code in place.

What Claude Code produced

In this run, Claude Code created a Zod tool that parsed the input and returned the output based on the city type. It also created the tool runner and the run function we asked for, and printed the final results of the agent loop.

The pattern to remember

Most of what you write against the Claude API has a familiar shape:

  • Define a tool.
  • Hand it to a runner.
  • Return the result.

You don't need to type that from memory every single time. Instead, stub the file, hand it to Claude Code, and just review the diff.

Recap

  • Claude Code is an agent that edits files and runs commands inside your terminal.
  • The built-in Claude API skill loads automatically when Claude Code detects the TypeScript SDK, or you can invoke it with /claude-api.
  • Give it a prompt that names the file, the pattern, and the end state — it writes the code, runs it, and fixes errors in place.
  • Claude API code follows a familiar shape: define a tool, hand it to a runner, return the result. Stub it, delegate it, review the diff.
↑ 目次へ戻る

Claude Platform 101 | Lesson 14「Claude Platform 101 クイズ(Claude Platform 101 Quiz)」

出典: Anthropic Academy / 2026-07-04

クイズ(受験は別途)

↑ 目次へ戻る