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로 deliverable
Opus 5.5에서 전형적인 Claude Code 코딩 루프는 세 층 JSON 계약으로 정리된다:
- 관찰층: 모델이
Read/Greptool_use를 보내고, 호스트가 파일 조각이나 ripgrep hit를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 write-back. 호스트가 줄 번호·긴 파일 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 deliverable. 동일 또는 다음 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 constrained sampling | 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로 한 번 통과한 뒤 실제 repo:
- 처음 Read + Grep만. 검증 로직 위치; 1단계 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·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는 브라우저 로컬—실제 repo·키 업로드 금지.
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 인자 vs 최종 json_schema 응답 분리.
Plan Mode plan.md는 JSON?
아니다. Markdown 계획; 기계가 읽을 수 있는 진행은 deliverable schema 또는 호스트 state JSON.
Read limit 크기?
호스트 정책. 예시 500줄 cap으로 tool_result context 폭주 방지; 큰 파일은 분할 Read.
Gemini 2026 구조화 출력 뉴스와 대조?
같은 「schema-constrained sampling」 화두; 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 개발 노트
변경: 최초 게시