Single logo
  • Courses
  • Blog
  • About
Join on SkoolJoin on Skool

In this topic

Claude
  • Claude.ai Interface Tour: Every Control You Need on One Screen
  • The AI Fluency Model: Delegation, Description, Discernment and Diligence
  • Working With Claude: Pick the Surface, Match the Model, Keep the Context Clear
  • Claude's Four Entry Points: Choose Chat, Projects, Artifacts or Research Before You Type
  • What Claude Can Do: Extended Thinking, Web Search, Artifacts and File Analysis
  • Getting More From a Claude Chat: Steer the Conversation Instead of Starting Over
  • Claude Research Mode End to End: From One Prompt to a Cited Briefing
  • Claude's Capability Layer: When to Use Skills, Code Execution or Memory
  • Code Execution and File Creation in Claude: Calculated Numbers and a Real Excel File
  • Adding and Using Skills in Claude: Let Claude Pick the Skill, Then Teach It Your Format
  • Claude Memory, Curation and Incognito: Keep What Helps, Remove What Has Gone Stale
  • Claude Styles, Preferences and Project Instructions: Three Dials, Three Scopes
  • Claude Projects: Knowledge, Instructions and a Real Workspace You Set Up Once
  • Keeping a Claude Project Current and Connected: Refresh, Prune and Grant the Least
  • Claude Scheduled Tasks: Let Claude Work on a Schedule and Email You the Result
  • Claude Code and Claude for Chrome: What They Are and Who They Are For
  • Anatomy of a Good Prompt: Role, Context, Task, Format and Examples
  • Shaping Claude's Output: Format, Tone and Length in a Few Words
  • Iterating and Refining a Prompt: Read, Diagnose, Adjust, Repeat
  • Five Prompting Patterns for Work: Summarise, Extract, Rewrite, Classify and Draft
  • Why Evaluating AI Output Matters Most: Trust, Then Verify
  • Spotting AI Hallucinations and Fabrications: Four Tells and Where Risk Spikes
  • Fact-Checking Claude's Answers: Four Techniques and a Line-by-Line Claim Log
  • Judging AI Output Quality: Four Questions That Score Any Answer
  • Adapting AI Output for Your Audience: One Answer, Three Readers
  • When a Human Must Review AI Output Before It Ships
  • A Personal Validation Checklist for AI Output: Six Lines, Any Draft
  • Fitting Claude Into Real Work: Where It Helps and Where It Never Should
  • Breaking Big Tasks Into Steps With Claude: Small Asks, Checked Hand-offs
  • Designing a Repeatable Claude Workflow: A Reusable Weekly Report Template
  • Measuring If Claude Is Actually Working: One Number, Before and After
  • Communicating AI Value and Limitations to Stakeholders: The Honest Pitch
  • Data Privacy With Claude: What Never Goes in a Prompt, and How to Redact a Document Before You Paste It
  • Responsible AI Use and Transparency: Helpful, Honest, Harmless, and One Honest Line
  • Troubleshooting a Weak Claude Answer: Name the Cause, Fix One Thing, Then Make It Cheaper
  • CLAUDE.md, settings.json and Plugins: Which Claude Code File Advises, Which Enforces, Which Packages
  • Authoring a Claude Skill: SKILL.md, Frontmatter, Progressive Disclosure and the Description That Triggers It
  • One Change, Four Environments: Where a Claude Config Edit Lands in Dev, Staging, Prod and CI
  • Claude in the SDLC: Prompts in Git, a Change Gate by Path, a Claude Review That Advises and a Person Who Merges
  • Hooks That Block Destructive Actions: a PreToolUse Gate That Allows, Asks or Denies
  • Choosing a Claude Code Extension: Skill, Hook, Rules File, Subagent, Slash Command or Plugin
  • Rolling Out Claude Code to a Team: Settings Precedence, dontAsk in CI, a Hook for Every-Time Rules and a Plugin for Five Repos
  • A Claude Code Review Bot in CI: Headless -p, JSON Findings, Team Rules in Git and a Person on the Merge
  • Lab: Three Planted Bugs in a Claude Code CI Repo, a Permission Mode, a Plugin Path and an MCP Token Variable
  • Configuring MCP Servers in Claude Code: A Command or a URL, Three Scopes, and Three Moves When One Breaks
  • Claude Code's Built-in Tools: Read, Write, Edit, Bash, Grep and Glob, and When Each One Is the Right Pick
  • The CLAUDE.md Hierarchy: User, Project and Directory Files, How They Stack, and the Team Rule Stuck on One Laptop
  • Split a 600-Line CLAUDE.md: @import Lines, .claude/rules Files and Which One to Pick
  • Path-Specific Rules in Claude Code: paths Globs, When a Rule Loads and the Glob That Matches Nothing
  • Claude Code Slash Commands and Skills: Project vs User Scope, $ARGUMENTS, context: fork and allowed-tools
  • Iterative Refinement with Claude Code: Input/Output Examples, Tests First and the Interview Pattern
  • Claude Code Sessions: Resume by Name, Fork From a Baseline, or Start Fresh With a Summary Card
  • CI Reviews That Don't Repeat Themselves: Prior Findings, Existing Tests and Test Standards in CLAUDE.md
  • The Claude Messages API: Your First Call, Field by Field
  • Claude Tool Use: How tool_use and tool_result Work in the Messages API
  • Claude Client SDKs Wrap One REST API: Raw HTTP, Python, TypeScript and Async Calls Compared
  • Anthropic SDK Timeouts, Retries and Error Classes: Configure the Client Once, Then Give 429, 529, 400 and Timeouts Their Own Move
  • Claude Streaming Events: The Event Order, message_stop, Tool Arguments, Stop Reasons and a WebSocket Relay
  • Images, PDFs and Thinking Blocks in the Claude Messages API: Typed Blocks In, Typed Blocks Out
  • Getting Data Into Claude: PDF Documents, the Files API, Search Results and Citations
  • Opus, Sonnet or Haiku: Pick the Claude Model per Job, and Test the Request When a New Release Arrives
  • Adaptive Thinking and Effort in Claude: Two Dials, Set per Workload, and the Thinking Block You Must Pass Back
  • Claude Cost Tracking From usage: Count Before, Cap During, Read After, Then Find the Line That Drives the Bill
  • Claude Cache Breakpoints: Where to Put cache_control, How to Move It With the Chat, and Why the Reads Stay at Zero
  • Claude Message Batches or Real Time: Choose by Who Is Waiting, Match by custom_id, Resend Only the Failures
  • Calling Claude Through Amazon Bedrock, Google Cloud and Microsoft Foundry: Same Call, Different Door
  • The Life Cycle of a Claude App: Six Phases, a Model That Retires, and a Release Gate for Every Change
  • Pinning Claude Model IDs and Upgrading Safely: One Change at a Time, a Golden-Set Replay and a Staged Rollout
  • Content Boundaries and Schema Design for Claude: Fence the Input in a Tag, Let the Output Say I Don't Know
  • The Agentic Loop and stop_reason: Keep Turning on tool_use, Stop on end_turn, Cap the Turns
  • The Claude Agent SDK: query(), ClaudeAgentOptions and @tool, in Python and TypeScript
  • Fix the Agent: Four Broken Claude Agent SDK Configs, From the Symptom to the One Wrong Line
  • Claude Managed Agents: Cloud Sandbox, Self-Hosted Sandbox or Self-Hosted Service
  • Agent SDK Hooks for Deterministic Actions: PreToolUse, PostToolUse, and Four Hooks That Fail Silently
  • Memory and Context-Window Patterns for Claude Agents: Context Editing, Compaction and the Memory Tool
  • Reading an Agent Trace: Five Signatures, Five Missing Patterns, and How Long a Fact Must Live
  • Tool Descriptions for Claude: How Claude Picks a Tool, and How to Stop It Picking the Wrong One
  • Tool Input Schemas and Error Responses for Claude: Required Fields, Enums, is_error and a Retry Flag
  • Tool Response Shaping and a Lean Tool Set: Give Claude a Sticky Note, Not the Filing Cabinet
  • Fix the Tool Schema: Read the Trace, Fix the Card, Re-Run (Four Real Schema Bugs)
  • Client Tools, Server Tools and Approval Gates: Who Runs the Tool, and Who Says Yes First
  • Built-in Tool, Custom Tool, Skill or MCP Server? Pick the Lightest One That Fits
  • System Prompt or User Turn: Where Each Instruction Goes, and Output Limits Your Code Enforces
  • Refine the Prompt One Line at a Time, Then Clean and Fence the Customer's Text
  • Prompt Revision Driven by Evals: Name the Cause, Change One Thing, Rerun the Whole Suite
  • Long-Running Sessions: Compact, Prune, Isolate or Start Fresh, Decided by Naming the Failure
  • Context Isolation Through Subagents: Read the Logs Elsewhere, Keep One Line
  • Defensive Parsing of Claude Replies: Check the Stop Reason, Read the Block or the Text, Then Validate the Values
  • Full Context or Retrieval: Choose by Corpus Size, Cost and Freshness
  • Skepticism Toward Confident Output: Check the Quote, the Record and the Sum Before You Send
  • Debugging a Claude App: Three Error Types, the Recovery Each One Earns, and the First Failing Row
  • Six Ways a 200 Can Still Be Wrong: Hallucination, Refusal, Under-Acting, Context Loss, Format Drift and Inconsistency
  • Fix the Cause, Not the Symptom: Four Recovery Drills for an LLM App, Each Checked on a New Input
  • Integration Layer or Model Output? Three Taps and Three Questions to Find Where a Wrong Answer Lives
  • Which Test Layer Owns the Failure? Unit, Functional, Integration and End-to-End Tests for a Claude App
  • Designing an Overnight Document Pipeline on Claude: Batch Lane, Live Lane, a Cached Prefix and a custom_id Reconcile
  • Proving a Model Upgrade Is Ready: A Frozen Golden Set, a Calibrated Judge, the Right Layer and a Release Gate
  • From Requirement to Design for a Claude App: Eight Requirements, Five Elements and a Trace With No Gaps
  • Build a Claude Refund App: the Messages API, Two Tools, an MCP Server and a Hook in One Loop
  • Ship a Claude App: an Eval Gate, Two Guardrail Layers, a Cost Check From usage and a Pinned Model
  • Lab: a 30-Case Golden Set, a Calibrated Judge and a Per-Slice CI Gate on a Claude Refund App
  • Lab: Cut a Claude App's Bill by 62 Percent With Usage Data, Layered Cache Breakpoints and a Batch Job
  • Lab: Three Planted Bugs in a Claude App, a Vague Prompt, a Mistyped Tool Schema and a Broken Stream Handler
  • Lab: Three Planted Bugs in a Claude Code CI Repo, a Permission Mode, a Plugin Path and an MCP Token Variable
  • Lab: Harden a Claude App, an Uncalibrated Judge, a Retry Loop That Retries Everything and a Hook Matcher With a Gap
  • Lab: Turn a Claude App Into a Reusable Template, One Pinned Model Id, No Key in Code and Evals Built From Data
  • Building an MCP Server: Tools, Resources and Prompts in Python and TypeScript
  • MCP Transports: stdio or Streamable HTTP, and Who Starts the Server
  • Deploying and Authenticating an MCP Server: Environment Keys for stdio, Bearer Tokens and Scopes for HTTP
  • Validation-Retry Loops for Claude Extraction: Send Back the Exact Errors, and Stop When a Retry Cannot Help
  • Multi-Pass and Multi-Instance Code Review with Claude: A Fresh Reviewer, Per-File Passes and an Integration Pass
  • When a Claude Support Agent Should Escalate: Three Clear Triggers, Not Mood or a Confidence Score
  • Error Propagation Across Subagents: Retry Locally, Then Report the Failure, the Attempts and What You Found
  • Human Review and Confidence Calibration: Check Accuracy by Type and Field Before You Stop Looking
  • Provenance in Multi-Source Research: Keep Every Claim With Its Source and Date, and Show Conflicts Instead of Settling Them
  • Lab: An Extraction Pipeline With a Nullable Schema, Validation-Retry, a 100-Request Batch and Human Review
  • Lab: A Research Pipeline With Parallel Subagents, a Timeout That Keeps Its Partial Results, and a Report With Its Trail
  • Coordinator and Subagents: Decompose, Delegate, Check Coverage, and Call Only the Spokes You Need
  • Passing Context to Subagents: Nothing Is Inherited, So Put Findings, Goal and Criteria in the Prompt
  • Parallel Subagents: Several Task Calls in One Response, Every Result Back in One User Turn
  • Task Decomposition: a Fixed Prompt Chain With an Integration Pass, or a Dynamic Plan That Adapts
  • Prompt Guidance vs Programmatic Gates: Block the Refund Until the Customer Is Verified, Then Hand Off a Card That Stands Alone
  • Scoped Tools per Agent and tool_choice: Three to Five Tools per Role, a Shared One, and auto, any or a Forced Tool
  1. Blog
  2. /
  3. Claude
  4. /
  5. Building with the Claude API

Multi-Pass and Multi-Instance Code Review with Claude: A Fresh Reviewer, Per-File Passes and an Integration Pass

The same session reviews its own refund code and finds nothing. A fresh instance per file finds three local notes, an integration pass finds the real bug (cents sent to a function that wants dollars), and each finding's confidence decides whether it is posted or queued for a person.

Chaand Sheikh

·27 November 2026Building with the Claude API

What you will learn

  • Explain why the session that wrote the code is a poor reviewer of it
  • Review with a fresh instance that gets only the code, with no history
  • Split a pull request review into per-file passes and one integration pass across files
  • Route each finding by its confidence: a PR comment or a human queue

Before you start

  • Explicit criteria vs vague prompts
  • Claude Messages API basics
  • Basic Python

You just wrote the refund code for a shop with Claude, and in the same conversation you ask: now review your work. The answer comes back: looks good to me, no issues. Zero findings.

But refunds.py sends the amount in cents, and utils.py expects dollars. The refund is 100 times too large. The bug ships, because nobody questioned it.

The session that wrote the code is a poor judge of it. This article shows four fixes in one small script: a fresh instance, a pass per file, a pass across files, and a confidence on every finding so you know where it goes.

Why the writer misses it

Think of proofreading your own essay. The line says the refund is paid in dollers. You know what you meant to write, so your eyes slide over the mistake. Looks perfect. A friend reads it fresh. They have no idea what you meant, they read only what is on the page, and right away they ask: dollers?

A writer who reads their own work reads what they meant, not what is there. So the fix isn't trying harder. The fix is a reader who didn't write it.

It's the same with Claude. In the writing session, the conversation already holds the task, the plan and the code. The plan even says cents go to round_money. Ask that session to review, and it reads the code through its own plan. A fresh instance starts with an empty history. It gets only the code, as text, and the request to review it. With no plan to defend, it sees cents going into a function that wants dollars.

Same session versus a fresh instance self-review: same session user: Write the refund code. assistant: Cents go to round_money. user: Now review your own work. reads the code through its own plan 0 findings independent: fresh instance history: empty, no plan user: the code, as text plus "review this code" no reasoning to defend 1 finding cents go into round_money(dollars)
The reviewer that did not write the code has nothing to defend, so it questions the code.

Asking the same session to "review again", or giving it extended thinking, keeps the same reasoning. An independent instance does better because it never had that reasoning in the first place. This is the same move as context isolation with subagents: what a call doesn't see can't steer it.

One big review spreads attention thin

The second problem is size. Put a whole pull request into one reviewer, everything at once, and the notes get thin: a rename here, a brief look at refunds, and for utils one note says rounding is fine while another says rounding is wrong. Attention is spread across everything and the notes can contradict each other.

So split the work into small focused passes:

  • Pass 1, per file. Each file gets its own fresh reviewer and is checked for local issues only.
  • Pass 2, integration. One more fresh reviewer gets all the files and is asked about one thing: how data flows between them.

A bug that lives between two files is invisible to a reviewer who sees one file. That's what pass 2 is for.

Per-file passes, an integration pass, then routing pass 1: one fresh instance per file orders.py local: empty list? refunds.py local: paid check? utils.py local: rounding? pass 2: one more fresh instance, all three files integration reviewer: data flow only refunds.py sends cents, utils.py expects dollars 4 findings, each with a self-reported confidence 0.8 or more: comment on the PR 0.90 (the cross-file bug) below 0.8: human queue 0.55, 0.70, 0.40 (local notes)
Local first, then across files. Each finding's confidence decides where it goes.

The pull request

The project keeps the three files of the pull request as text in fake_model.py, so the reviewers have something to read:

FILES = {
    "orders.py": ("def total(order):\n"
                  "    return sum(i.price for i in order.items)\n"),
    "refunds.py": ("from utils import round_money\n\n"
                   "def refund(order):\n"
                   "    cents = order.total_cents\n"
                   "    return round_money(cents)\n"),
    "utils.py": ("def round_money(dollars):\n"
                 "    return round(dollars, 2)\n"),
}

Each file looks fine on its own. refund() passes cents; round_money() names its parameter dollars. You only see the problem when you look at both.

review_passes.py: three kinds of call

Every call goes through one helper that asks for findings as JSON: where, text and a confidence from 0 to 1.

FORMAT = " Reply with a JSON list: where, text, confidence 0 to 1."


def ask(system, messages):
    reply = client.messages.create(
        model="claude-sonnet-5-5", max_tokens=800,
        system=system + FORMAT, messages=messages)
    return json.loads(reply.content[0].text)


def self_review():
    """Same session: the writing reasoning is still here."""
    history = [
        {"role": "user", "content": "Write the refund code."},
        {"role": "assistant",
         "content": "Done. Cents go to round_money."},
        {"role": "user", "content": "Now review your own work."}]
    return ask("You review code.", history)


def file_pass(name):
    """A fresh instance sees ONE file and nothing else."""
    text = f"FILE {name}\n{FILES[name]}"
    return ask("Review ONE FILE for local issues.",
               [{"role": "user", "content": text}])


def integration_pass():
    """Another fresh instance sees all files, for data flow only."""
    text = "\n".join(f"FILE {n}\n{t}" for n, t in FILES.items())
    return ask("Review data flow ACROSS FILES.",
               [{"role": "user", "content": text}])

The difference between the calls is only in the messages list:

  • self_review keeps the assistant turn from the writing. That's the same session, with its plan still in view.
  • file_pass is a fresh instance: one new user message, one file, no history.
  • integration_pass is another fresh instance: all the files, and a system prompt that asks about data flow across files and nothing else.

A narrow request like "data flow ACROSS FILES" works for the same reason a clear check does in explicit criteria vs vague prompts: the reviewer knows exactly what to look for.

Route each finding by confidence

def route(finding):
    if finding["confidence"] >= 0.8:
        return "comment on the PR"
    return "human queue"

Sure findings go straight to the pull request. Unsure ones wait for a person. The line at 0.8 is the demo's own choice; pick the number that fits your team.

The rest of the script runs the passes and prints the routes:

print("self-review, same session:", len(self_review()), "findings")
print("pass 1: one fresh instance per file")
findings = []
for name in FILES:
    found = file_pass(name)
    print(f"  {name:11}{len(found)} finding")
    findings += found
print("pass 2: integration across files")
bridge = integration_pass()
print(f"  {len(bridge)} finding")
findings += bridge
print("routing by self-reported confidence")
for f in findings:
    print(f"  {f['confidence']:.2f}  {f['where']:28}{route(f)}")

Run it

The project uses a stand-in model: fake_model.py plugs a mock HTTP transport into the Anthropic client and returns scripted replies, so no API key is needed and every finding and confidence number is scripted. It follows simple rules that act out the pattern: a request that already holds an assistant turn gets no findings, a request whose system prompt says ACROSS FILES gets the cross-file finding, and a single-file request gets that file's local note.

    if "assistant" in roles:       # same session: reasoning is kept
        found = []
    elif "ACROSS FILES" in body["system"]:
        found = BRIDGE
    else:
        found = next(v for k, v in LOCAL.items()
                     if f"FILE {k}" in last)

Running python review_passes.py:

self-review, same session: 0 findings
pass 1: one fresh instance per file
  orders.py  1 finding
  refunds.py 1 finding
  utils.py   1 finding
pass 2: integration across files
  1 finding
routing by self-reported confidence
  0.55  orders.py:2                 human queue
  0.70  refunds.py:4                human queue
  0.40  utils.py:2                  human queue
  0.90  refunds.py:5 -> utils.py:1  comment on the PR
  • Self-review: zero findings, the same answer the writing session always gave.
  • Pass 1: one local note per file. In the scripted replies these are an empty items list not handled (orders.py), no check that the order was paid (refunds.py), and round() using banker's rounding (utils.py).
  • Pass 2: the cross-file bug, refunds.py:5 -> utils.py:1, with the text "refunds sends cents, round_money wants dollars".
  • Routing: 0.90 is above the line, so it becomes a comment on the PR. The three local notes are below it, so a person looks at them.

Common mistakes

  • Reviewing in the writing session. The plan is still in the messages, so the review reads what was meant.
  • "Review again" or more thinking time. Same session, same reasoning. Start a new instance instead.
  • One giant review of the whole pull request. Attention spreads thin and notes can contradict each other.
  • Per-file passes only. Each file looks fine alone; the cents-vs-dollars bug lives between two of them. Add the integration pass.
  • Posting every finding. Without a confidence on each one, the sure and the unsure land in the same place.

Recap

StepWhat the reviewer seesIn the run
Self-reviewThe writing session, plan included0 findings
Pass 1, per fileOne file, no history1 local note per file
Pass 2, integrationAll files, data flow onlyCents sent, dollars expected
RoutingEach finding's confidence0.90 to the PR, three to the human queue

Exam lens: when a model missed an issue in its own output, choose a second independent instance; when a large review misses cross-file problems, choose per-file passes plus an integration pass.

Try it yourself

Add a fourth file to FILES, say a receipts.py that calls refund(), give it a local finding in LOCAL, and run again to see it get its own pass. Then move the line in route() from 0.8 to 0.5 and watch which findings move from the human queue to the PR.

Tried the exercise? Share your answer or ask a question.

The StudyEasy AI Community is free to join, with the lesson files, notebooks and code.

Join free on Skool

Keep going in Claude · 111 of 123

Previous
Validation-Retry Loops for Claude Extraction: Send Back the Exact Errors, and Stop When a Retry Cannot Help
Next post
When a Claude Support Agent Should Escalate: Three Clear Triggers, Not Mood or a Confidence Score

Related course on Udemy

Claude Certified Architect - Foundations (CCAR-F) Exam Prep

Agentic loops, tools, MCP, Claude Code, prompts, structured output and context.View on Udemy ↗: Claude Certified Architect - Foundations (CCAR-F) Exam Prep (paid course, opens in a new tab)

Related posts

The Claude Messages API: Your First Call, Field by Field

One request in, one Message out. The four fields of a Messages API call (model, max_tokens, system, messages), how to read content blocks, stop_reason and usage, and why every turn resends the history.

Claude Tool Use: How tool_use and tool_result Work in the Messages API

Follow one order question through Claude's tool round trip: define a tool, read the tool_use block, run your own function and send a matching tool_result back, including parallel calls and is_error.

Claude Client SDKs Wrap One REST API: Raw HTTP, Python, TypeScript and Async Calls Compared

Every Claude client SDK wraps the same REST request: a POST to /v1/messages with a JSON body. See it built by hand, through the Python and TypeScript SDKs, as typed errors, and as async calls that wait together.

Anthropic SDK Timeouts, Retries and Error Classes: Configure the Client Once, Then Give 429, 529, 400 and Timeouts Their Own Move

Configure the Anthropic SDK client (timeout, max_retries, with_options, async, pagination), see which errors it retries by itself, then repair a retry wrapper so a 429, a 529, a 400 and a timeout each get the move the docs support.

On this page

  • Why the writer misses it
  • One big review spreads attention thin
  • The pull request
  • review_passes.py: three kinds of call
  • Route each finding by confidence
  • Run it
  • Common mistakes
  • Recap
  • Try it yourself
Community · Free to join
Single logo

StudyEasy AI Community

Hosted onSkool

Learn AI engineering, share what you build, and connect with other learners.

  • Free resources: lesson files, notebooks and code

  • Ask questions and join engineering discussions

  • Meet real people learning and building with AI

Join free on Skool

Related course on Udemy

Claude Certified Architect - Foundations (CCAR-F) Exam Prep

Agentic loops, tools, MCP, Claude Code, prompts, structured output and context.View on Udemy ↗: Claude Certified Architect - Foundations (CCAR-F) Exam Prep (paid course, opens in a new tab)

Single logo

Empowering Education, One Course at a Time

About
About usContact us
Legal
Terms of UsePrivacy Policy

© 2026 StudyEasy Organization. All rights reserved.