Claude Code と Opus 5.5 はファイルをどう読み、ツールを呼び、JSON を返すか?2026 strict Tools と Structured Output 実践
2026 年 11 月前後、Structured Outputs が Opus 5.5 で GA し、Claude Code も同モデルで Plan Mode(編集可能な plan.md)を強化した。工学上の分割は変わらない:読取は tool_use JSON、リポ変更は宿主実行、UI/CI 向け要約は output_config.format—三種類を一段 markdown に混ぜない。
読む前の早見
| 段階 | Claude Code / API | 宿主 JSON |
|---|---|---|
| リポ読取 | Read / Glob / Grep の tool_use.input | file_path、offset/limit 監査 |
| 変更と実行 | Edit / Write / Bash;strict で引数検証 | 権限ゲート、cwd、allowed roots |
| 構造化デリバリ | output_config.format json_schema | deliverable_schema、risk、next_tool |
| Plan Mode | plan.md を人が編集してから実行 | plan_path、turn、plan_mode |
| 長タスク | 依然 Messages + tool ループ | Compaction 記事参照—本篇では省略 |
事実は 2026-11-05 まで:Anthropic Structured Outputs / strict tool use、Claude Code Plan Mode with Opus 5.5。パスと toolu_read_01 は架空例。
先に Read、次に strict ツール、最後に json_schema でデリバラブル
Opus 5.5 上の典型的な Claude Code コーディングループは三層 JSON 契約に整理できる:
- 観察層:モデルが
Read/Grepのtool_useを送り、宿主がファイル断片や ripgrep ヒットをtool_resultに書き戻す—「読んだふり」ではない。 - 実行層:自前 harness や監査コピーでは Messages リクエストでツールに
strict: trueを付け、inputを必ずinput_schema通過させる;Claude Code 組込み面は製品がラップするが形状は同じ。 - デリバリ層:ダッシュボード、PR テンプレ、CI gate 向けオブジェクトは
output_config.format.type: json_schema—ツール引数と分離。Structured Output は「最後に何を言うか」、strict は「関数の呼び方」。
Claude Code 製品入門:Coding Agent 入門。Opus 5.5 Messages と effort:Opus 5.5 ツール JSON。Compaction と checklist state:長タスク state—本篇は「読取 + 構造化デリバリ」実践のみ補う。
Read ブロック、strict ツール表、Structured Output、宿主 turn
1. Read の tool_use。 Opus 5.5 も content block;Claude Code で最も多い第一歩:
{
"type": "tool_use",
"id": "toolu_read_01",
"name": "Read",
"input": {
"file_path": "src/orders/lookup.ts",
"offset": 1,
"limit": 120
}
}
2. tool_result 書き戻し。 宿主が行番号付与・長大ファイル truncate;次ターンでモデルが見るのはこの文字列のみ:
{
"type": "tool_result",
"tool_use_id": "toolu_read_01",
"content": " 1|export function lookupOrder(id: string) {\n 2| // TODO: validate A-1042 pattern\n 3| return fetch(`/api/orders/${id}`);\n 4|}"
}
3. strict ツール表(Messages リクエスト)。 Claude Code ツール面に合わせた offline replay や CI 監査向け:
{
"model": "claude-opus-5-5",
"max_tokens": 8192,
"tools": [
{
"name": "Read",
"description": "Read a slice of a file. Paths must stay under the workspace root.",
"strict": true,
"input_schema": {
"type": "object",
"properties": {
"file_path": { "type": "string" },
"offset": { "type": "integer", "minimum": 1 },
"limit": { "type": "integer", "minimum": 1, "maximum": 500 }
},
"required": ["file_path"],
"additionalProperties": false
}
},
{
"name": "Grep",
"description": "Search the repo with ripgrep.",
"strict": true,
"input_schema": {
"type": "object",
"properties": {
"pattern": { "type": "string" },
"path": { "type": "string" },
"glob": { "type": "string" }
},
"required": ["pattern"],
"additionalProperties": false
}
}
],
"messages": [{
"role": "user",
"content": "Find where order A-1042 is validated before calling lookup."
}]
}
4. Structured Output デリバラブル。 同一または次 hop;UI/gate 用フィールド:
{
"model": "claude-opus-5-5",
"max_tokens": 4096,
"tools": [{ "name": "Read", "strict": true, "input_schema": { "type": "object", "properties": { "file_path": { "type": "string" } }, "required": ["file_path"], "additionalProperties": false } }],
"output_config": {
"format": {
"type": "json_schema",
"schema": {
"type": "object",
"properties": {
"order_id": { "type": "string", "pattern": "^[A-Z]-\\d{4}$" },
"files_touched": { "type": "array", "items": { "type": "string" } },
"risk": { "type": "string", "enum": ["low", "medium", "high"] },
"next_tool": { "type": "string", "enum": ["Read", "Edit", "Bash", "none"] }
},
"required": ["order_id", "files_touched", "risk", "next_tool"],
"additionalProperties": false
}
}
},
"messages": []
}
5. Claude Code 宿主 turn(示意)。 Plan Mode と deliverable 版を state に入れセッション diff しやすく:
{
"session_id": "cc_sess_demo_01",
"model": "claude-opus-5-5",
"plan_mode": true,
"plan_path": ".claude/plan.md",
"turn": 3,
"last_blocks": ["tool_use:Read", "tool_result", "tool_use:Grep"],
"deliverable_schema": "task_summary_v1",
"awaiting": "tool_result"
}
三種類の JSON が役割分担
「チャット markdown」と「機械可読オブジェクト」を分けると Review が楽になる:
| オブジェクト | 生成者 | 典型フィールド |
|---|---|---|
| tool_use / tool_result | モデル提案 + 宿主実行 | name、input、tool_use_id |
| strict input_schema | API 制約サンプリング | additionalProperties: false |
| output_config.format | モデル最終テキスト block | order_id、risk、next_tool |
| plan.md | Plan Mode 人間編集 | ステップ一覧—tool 引数ではない |
Bash / Edit は権限ゲート経由;Read は緩めだが workspace root 内に留める。権限モデル 参照。
staging で A-1042 を五ステップ通す
架空注文 A-1042 で一度通してから本番リポへ:
- 最初は Read + Grep のみ。 検証ロジックを特定;第一歩で Bash 禁止。
- tool_use / tool_result を記録。 各 id を整合;state に last_blocks。
- ファイル変更が必要なら Edit を開く。 path は allowlist 内のみ。
- デリバリは json_schema。 risk / next_tool を人または CI へ—tool_result から secret をコピーしない。
- Plan Mode は先に plan.md。 人がステップを直してから auto;plan_path を state に diff 用。
五つすべて JSON 上にあって初めて Claude Code セッションが replay 可能—さもなければ「直した」と言っただけになる。
軌跡を審査し、prose ではない
Opus 5.5 + Structured Output は parse 失敗を減らすが、権限審査の代わりにはならない:
- 整形 で messages 展開;Schema 検証 で strict schema と deliverable schema。
- JSONPath で
$.content[?(@.type=='tool_use')].input.file_path等のパス抽出。 - Plan 前後で state を JSON Diff;plan_mode 切替で deliverable_schema が落ちないか。
- Structured ブロックの order_id は tool チェーン(A-1042)と一致させる。
- JSONSort はブラウザローカル;本番リポや鍵をアップロードしない。
deliverable JSON を単体検証できて初めて「構造化出力」接続完了—pretty print の追加ではない。
よくある誤り
- Structured Output を tool 引数と混同。 format は返答テキスト;Edit は依然 tool_use。
- Read を飛ばして Edit。 Opus 5.5 は大胆に直す—宿主は「先読後改」を強制。
- strict を半分だけ。 Read のみ strict、Edit なし—監査が途切れる。
- plan.md と deliverable schema を混写。 plan は人向け;schema はプログラム向け。
- tool_result に未 truncate ログ。 依然 JSON 文字列;先に整形して表示フィールドを truncate。
- Coding Agent 入門の書き直し。 製品比較は別記事;本篇は Opus 5.5 読取/ツール/構造化の三角のみ。
FAQ
Claude Code 組込みツールにも自前で strict が要る?
ターミナル製品が実行と確認ゲートをラップしている。offline replay、コンプライアンス監査、自前 harness では Messages 層で同一 input_schema を mirror し strict を有効化。
Structured Output と strict tool を同一リクエストで?
可能。Anthropic ドキュメントは両者を補完関係と明記:tool 引数と最終 json_schema 返答を別々に制約。
Plan Mode の plan.md は JSON?
いいえ。Markdown 計画;機械可読な進捗は deliverable schema または宿主 state JSON 推奨。
Read の limit はどの程度?
宿主ポリシー次第。例は 500 行 cap で tool_result の context 爆発を防ぐ;大ファイルは分段 Read。
Gemini 2026 構造化出力ニュースとの対照?
同じ「Schema 制約サンプリング」話題;Claude Code スタックは Messages + strict + output_config。ベンダ横フィールドは Opus vs Astra 記事—本篇では省略。
結論
Claude Code + Opus 5.5 では 読取 = tool_use JSON、確実な改庫 = 権限 + strict ツール、システム向け結論 = output_config.format。Plan Mode が「計画」を人に、Structured Output が「デリバリ」を schema に。
モデルは JSON を埋めるだけ;ディスク読み、コマンド実行、schema 検証は常に宿主。A-1042 の軌跡を replay 可能にしてから full auto。
関連記事
- Claude Code と GPT Agent ツールチェーン Coding Agent 入門と JSON ループ
- Claude Opus 5.5 とツール JSON Messages、effort、tool_use
- Opus 5.5 長タスク JSON State Compaction、checklist
- Coding Agent 権限モデル Shell / Git / ファイルシステム
- すべての記事 JSON と AI 開発メモ
更新: 初出