다중 패스 분해
파일별 로컬 패스를 먼저 수행한 뒤 파일 간 통합 패스를 수행합니다
다중 패스 분해은(는) CoddyKit의 무료 Claude Architect 강의입니다. 이것은 4개 중 2번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Claude Architect 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Claude Architect 강의에는 총 4개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
Why One Pass Isn't Enough
When you ask Claude to review a changeset spanning many files in a single pass, attention gets diluted. The model spreads finite focus across every file at once, so subtle per-file bugs slip through and genuine cross-file issues get buried.
The architect's answer is multi-pass decomposition: split the work into a per-file local pass first, then a separate cross-file integration pass. Each pass has one clear job, so attention stays sharp.
Two Different Questions
The two passes ask fundamentally different questions, which is exactly why they shouldn't be merged:
- Local pass: "Is THIS file internally correct?" — logic errors, null handling, naming, dead code, style within the file's own boundary.
- Integration pass: "Do these files work TOGETHER?" — mismatched function signatures, broken contracts, inconsistent assumptions across module boundaries.
Single-pass review forces both questions into one diluted prompt. Two passes keep each focused.
Pass 1 — Find the Files
The local pass starts with discovery. Use Claude Code's built-in tools incrementally: Glob to find files by pattern, then Read each one in isolation.
Reviewing one file per request keeps the context small and the attention concentrated. This is the opposite of dumping the whole diff into a single prompt.
# Discover changed source files, review each on its own
glob '**/*.py' | grep -Ff <(git diff --name-only main)
# Then, per file, a focused review request:
claude -p "Review ONLY src/billing/refund.py for local correctness: \
logic errors, null handling, edge cases. Do not assume anything \
about other files." --output-format jsonOne File, One Request
In the local pass, give Claude a tight, explicit boundary: review only this file, and judge it on its own terms. Vague instructions like "be thorough" underperform; explicit criteria win.
State exactly what counts as a finding so the model doesn't drift into speculation about files it hasn't seen.
from anthropic import Anthropic
client = Anthropic()
def local_pass(path, source):
return client.messages.create(
model="claude-sonnet-4-5",
max_tokens=1500,
system=("You review ONE file in isolation. Flag a finding ONLY "
"when the code is internally wrong, never on guesses "
"about unseen files."),
messages=[{"role": "user",
"content": f"File: {path}\n\n{source}"}],
)Structured Findings Per File
Have each local pass emit structured output so findings are machine-mergeable for the next pass. Use tool_choice with a schema-backed tool to guarantee well-formed JSON.
Critically: mark a field required only if it is always present. Never require a field that may be absent — the model will fabricate a value to satisfy the schema.
tools = [{
"name": "report_findings",
"description": "Record local-pass findings for a single file.",
"input_schema": {
"type": "object",
"properties": {
"file": {"type": "string"},
"findings": {"type": "array", "items": {"type": "string"}},
},
"required": ["file", "findings"], # always present
},
}]
# force structured output -> no free-text parsing
resp = client.messages.create(model="claude-sonnet-4-5", max_tokens=1500,
tools=tools, tool_choice={"type": "tool", "name": "report_findings"},
messages=[{"role": "user", "content": file_blob}])Pass 2 — Cross-File Integration
Once every file passes its local review, run a separate integration pass. Now the goal flips: you deliberately load the relevant files together and ask whether their contracts line up.
Typical integration defects:
- A caller passes three arguments; the callee now expects four.
- One module returns
Noneon "not found"; the consumer treats it as an empty list. - A renamed enum value still referenced by a sibling file.
Tracing the Seams
The integration pass mirrors incremental investigation. Start at the boundaries and follow the wiring: Grep for a changed function's name to find every call site, then Read those consumers.
This way the integration pass concentrates on the seams between files — the exact place single-pass review tends to miss.
# Find everyone who calls the changed function, then read them
claude -p "Cross-file pass. process_refund() signature changed in \
refund.py. Grep its call sites, Read each consumer, and report \
ONLY mismatched arguments, return-type assumptions, or broken \
contracts across files." --output-format jsonWhy Order Matters
Run local before integration, not the reverse. If a file is internally broken, integration findings about it are noise — you'd flag a contract mismatch that disappears once the local bug is fixed.
Clean each file in isolation first, then the integration pass can trust that every file is locally sound and focus purely on how they fit together.
Fixed Pipeline, Not Improvised
Because the steps are known and sequential — discover, local pass, integration pass, report — this is a job for a fixed pipeline (prompt chaining), not adaptive, open-ended exploration.
Reserve adaptive decomposition for genuinely open investigations ("why is this flaky?"). Multi-pass review has a defined shape, so encode that shape.
def review_changeset(files):
# Stage 1: local pass, one request per file
local = {f: local_pass(f, read(f)) for f in files}
# Stage 2: integration pass over the seams
integration = cross_file_pass(files, local)
return merge(local, integration)Run It in an Isolated Session
Run each review pass in a fresh, isolated session, separate from whatever session generated the code. Independent review beats same-session self-review: an author retains its own reasoning and won't challenge its own assumptions.
In CI, drive this non-interactively with -p / --print and --output-format json so results are parseable. When re-running, feed in prior results and report only new or still-unfixed issues.
# CI: isolated, non-interactive, machine-readable
claude -p "$LOCAL_PASS_PROMPT" --output-format json > local.json
claude -p "$INTEGRATION_PROMPT" --output-format json > integ.json
# fresh process each pass -> no generation-context biasScaling with Subagents
For large changesets, fan out the local pass across subagents in a hub-and-spoke pattern: the coordinator splits files among parallel workers, then runs the integration pass itself once results return.
Remember the rule: subagents do not inherit the coordinator's history. Each subagent prompt must carry all the context it needs explicitly. Multiple Task calls in one response run in parallel.
# Coordinator: parallel local passes, then one integration pass
# (each Task gets full context — subagents inherit no history)
Task(subagent="reviewer", prompt=local_prompt_for("refund.py"))
Task(subagent="reviewer", prompt=local_prompt_for("ledger.py"))
# ...both run in parallel; coordinator aggregates, then integratesQuick Check
An architect must review a 9-file pull request and wants the highest-quality findings. What is the soundest decomposition?
Recap
Multi-pass decomposition, distilled:
- Two passes, two questions: local = is each file internally correct; integration = do the files work together.
- Local first, then integration — a broken file makes integration findings noise.
- One file per local request to keep attention sharp; emit structured output for clean merging.
- Fixed pipeline (discover → local → integration → report), not adaptive improvisation.
- Isolated/fresh sessions beat same-session self-review; in CI use
-pand--output-format json. - Scale the local pass across parallel subagents — each one needs context passed explicitly.
Single-pass multi-file review is the anti-pattern. Decompose, and your reviews get sharper, not just longer.
자주 묻는 질문
“다중 패스 분해” 강의는 무료인가요?
네 — “다중 패스 분해” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Claude Architect 강의 전체를 잠금 해제할 수 있습니다. Claude Architect 강의에는 총 4개의 강의가 포함되어 있습니다.
“다중 패스 분해”에서 뭘 배우나요?
파일별 로컬 패스를 먼저 수행한 뒤 파일 간 통합 패스를 수행합니다 브라우저에서 직접 실행하는 실습 코드로 Claude Architect을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
Claude Architect을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 Claude Architect은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 2번째 강의입니다.
“다중 패스 분해” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 Claude Architect 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 Claude Architect 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.