The 90% number is what pulled me in. Claude Code — Anthropic’s command-line coding agent — supposedly wrote 90% of its own source code. So I went and looked at how the thing is actually built, expecting a tangle of orchestration: task queues (waiting lines for units of work), agent hierarchies (agents calling sub-agents), state machines (code that steps through a fixed sequence of stages). What I found was four lines inside a while loop — a while loop being the plain programming construct that repeats a block of steps until some condition flips. That’s the whole engine.
Here’s the takeaway before I go deep: Claude Code’s entire architecture is fundamentally just one while loop. Not as a simplification — literally. And the bet behind it is the part worth stealing. When the model is smart enough, the best thing you can build around it is almost nothing. Trust the model, hand it tools, get out of the way. While competitors ship orchestration frameworks with task queues, agent hierarchies, and complex state machines, Anthropic shipped a CLI — a command-line tool — that writes 90% of its own code using the simplest control flow there is, the plainest way to order what runs when.
This isn’t dumbing the problem down. It’s a philosophical stance on what an AI agent architecture should be: trust the model, don’t over-engineer around its limitations, and recognize that simplicity scales better than complexity.

The Philosophy: Simple Beats Complex
When I first opened up Claude Code’s architecture, I expected layers of abstraction — intermediate code that hides messy details behind simpler interfaces. What I found was closer to a Unix pipeline (small programs passing output to each other) than a microservices mesh (small services talking over a network). The core execution loop looks approximately like this:
while not task_complete:
user_input = get_input()
model_response = call_claude(user_input, context)
results = execute_tools(model_response.tool_calls)
context.append(results)
Four lines. One loop. That’s it.
This violates everything we’ve been taught about “proper” AI agent architecture. Where’s the planning layer? The reflection mechanism — the step where the agent looks back at what it just did? The multi-agent coordination? The sophisticated memory management?
The answer: trust the model to handle it.
I keep waiting for this to break, honestly. It doesn’t.
Counter to Industry Trends
Compare this to what the industry has been building. OpenAI’s Codex-based systems layer complexity on complexity:
- Orchestration frameworks that route tasks between specialized agents
- Planning modules that decompose problems into dependency graphs (maps of which step depends on which)
- Verification layers that check code before execution
- State machines that manage agent lifecycles
- Message queues — async waiting lines that coordinate operations running out of order
All of that infrastructure exists because of one underlying assumption: the model isn’t smart enough, so we need systems to compensate.
Claude Code takes the opposite bet. Claude Sonnet 4.5 is smart enough. Give it tools, give it context, and get out of the way.
Bash as Universal Adapter
The most elegant decision in Claude Code isn’t what it includes — it’s what it leaves out. Instead of implementing 100 specialized tools (read_file, write_file, list_directory, search_code, run_tests, git_commit, and so on), Claude Code provides one flexible tool: Bash. A tool, in this world, is a defined action the model can ask your code to run.
// Not this:
const tools = [
readFileTool,
writeFileTool,
searchFileTool,
gitTool,
npmTool,
dockerTool,
// ... 94 more tools
];
// This:
const tools = [bashTool];
Why does this work? Because Bash is already a universal adapter. Bash is the default shell on Unix systems — the program that runs text commands like ls and grep. Every operation you need — file manipulation, process management, network requests, version control — already has a battle-tested command-line tool behind it. Claude learns to compose those tools instead of learning bespoke, purpose-built APIs.
The benefits compound:
- Zero maintenance burden — Bash tools evolve independently; Claude Code inherits improvements for free.
- Infinite extensibility — any CLI tool is immediately available without framework changes.
- Familiar mental model — developers already know these tools, so agent behavior is predictable.
- Cross-platform compatibility — standard Unix tools work everywhere.
- Composability — tools chain naturally (
grep | sed | awk— search, then transform, then extract, piped end to end — versus implementing search + transform + extract as three separate APIs).
When you give Claude Code a task like “find all TypeScript files importing React and count their lines,” it doesn’t need a specialized code-analysis tool. It just runs:
find . -name "*.ts" -exec grep -l "import.*React" {} \; | xargs wc -l
This is the Unix philosophy applied to AI agents: do one thing well (Bash execution), and compose to handle complexity.
Context Management Philosophy
Here’s where Claude Code diverges most sharply from competitors: context strategy. Context is the running transcript of the conversation the model can see — its working memory for the task.
Most AI agent frameworks obsess over preserving every detail. They build elaborate memory systems — short-term, long-term, episodic, semantic. They implement retrieval mechanisms that surface relevant past interactions. They maintain persistent knowledge graphs (structured maps of facts and their relationships).
Claude Code’s philosophy: the longer the context, the stupider the agent.
That sounds counterintuitive. Don’t agents get smarter with more information? Yes, to a point. Then they get confused. They overthink. They chase irrelevant patterns. They hallucinate connections that don’t exist.
Claude Code aggressively prunes context. Each interaction gets a clean slate with minimal carry-forward. Only essential state survives between turns:
- Current working directory
- Recent file contents (only what’s been read)
- Last few commands and their outputs
- Explicit user instructions
That’s it. No elaborate memory systems. No sophisticated retrieval. Just enough context to maintain continuity, then reset.
The result: Claude Code stays focused. It doesn’t get lost in its own history. It doesn’t over-optimize for an edge case from three days ago. It solves the current problem with fresh eyes.
Trust the Model, Don’t Engineer Around It
This philosophy shows up everywhere in Claude Code’s design decisions.
No Planning Layer
Competitors implement explicit planning phases. The agent must first decompose the task, build a dependency graph, identify risks, then execute.
Claude Code: just start. The model is smart enough to plan implicitly while working. If it needs to think through architecture, it will. If the task is obvious, it won’t waste time.
No Verification Layer
Many frameworks require code to pass through verification before execution. Static analysis (automated checks that read code without running it), security audits, confirmation prompts.
Claude Code: execute and observe. If something breaks, the model sees the error and fixes it. This turns out to be faster than trying to verify everything upfront. The model learns from failures more effectively than from pre-execution checks.
No Multi-Agent Coordination
Current AI agent research focuses heavily on multi-agent systems. Specialized agents for different domains, communicating through protocols, voting on decisions.
Claude Code: one agent, one model. Specialization happens through tool selection and context framing, not agent proliferation. One coherent intelligence working the problem beats a committee of narrow specialists.
No State Machines
Frameworks like LangChain — a popular library for wiring agent steps together — implement elaborate state machines to manage agent lifecycles: initialize → plan → execute → reflect → update.
Claude Code: the while loop is the state machine. The model decides when to gather information, when to act, when to verify, when to complete. State transitions happen naturally in the conversation flow, not through enforced checkpoints.
The 90% Self-Written Stat
The most remarkable part: Claude Code wrote 90% of its own implementation. This isn’t marketing spin — it’s a natural consequence of the architecture.
When your system is simple enough that the AI can understand it, the AI can extend it. The development loop becomes:
- Human: “We need a feature to handle X”
- Claude: reads codebase, understands architecture, implements feature
- Human: reviews, merges
This works because Claude Code’s architecture has minimal abstraction layers. There’s no framework-specific DSL — no custom mini-language you have to learn to drive the framework. No elaborate object hierarchies to navigate — no deep nested taxonomies of code objects. Just straightforward TypeScript (a typed flavor of JavaScript) implementing a simple control loop, the repeating cycle that drives the agent step by step.
The implications land hard. As Claude models improve, Claude Code improves — not through manual development, but through self-modification. The tool evolves with the model that powers it.
Comparison: OpenAI Codex Architecture
Contrast that with OpenAI’s approach. Codex-based systems (like GitHub Copilot’s agent features) need five specialized subsystems just to run one task. Claude Code needs one while loop. The Codex approach assumes the model needs extensive scaffolding. The Claude approach assumes the model is the scaffolding.
the mechanism — how the loop actually works give me the detail
The Anthropic Messages API returns a stop_reason of "tool_use" when the model wants to invoke a tool. Your loop re-calls the API with the tool result appended as a tool role message — that’s the entire protocol. No framework required.
Here’s a runnable TypeScript skeleton using @anthropic-ai/sdk that implements this exactly — one Bash tool, one loop, nothing else:
import Anthropic from "@anthropic-ai/sdk";
import { execSync } from "child_process";
const client = new Anthropic(); // reads ANTHROPIC_API_KEY from env
const bashTool: Anthropic.Tool = {
name: "bash",
description: "Run a shell command and return stdout+stderr.",
input_schema: {
type: "object",
properties: { command: { type: "string" } },
required: ["command"],
},
};
async function run(task: string) {
const messages: Anthropic.MessageParam[] = [
{ role: "user", content: task },
];
while (true) {
const response = await client.messages.create({
model: "claude-sonnet-4-5",
max_tokens: 4096,
tools: [bashTool],
messages,
});
// Append the assistant turn verbatim
messages.push({ role: "assistant", content: response.content });
if (response.stop_reason !== "tool_use") break; // done
// Execute every tool call the model requested
const toolResults: Anthropic.ToolResultBlockParam[] = response.content
.filter((b): b is Anthropic.ToolUseBlock => b.type === "tool_use")
.map((b) => {
const cmd = (b.input as { command: string }).command;
let output: string;
try {
output = execSync(cmd, { encoding: "utf8", timeout: 30_000 });
} catch (e: any) {
output = e.stderr ?? e.message;
}
return { type: "tool_result", tool_use_id: b.id, content: output };
});
messages.push({ role: "user", content: toolResults });
}
// Final text response
return response.content
.filter((b): b is Anthropic.TextBlock => b.type === "text")
.map((b) => b.text)
.join("\n");
}
run("Count how many TypeScript files are in the current directory.").then(console.log);Try it: npx ts-node agent.ts in any project directory. The model will call bash with something like find . -name "*.ts" | wc -l, your code runs it, feeds back the number, and the model returns a plain-English answer — no framework, no planner, no state machine.
Why context pruning is the real lever: the messages array above is your entire working memory. In production you’d trim it — drop old tool_result blocks once they’re no longer load-bearing, summarize long file reads into a single replacement message. That one discipline (treating context as a budget, not a log) is what prevents the model from drowning in its own history on longer tasks.
When Simplicity Fails
To be fair, this philosophy has real limitations. I’m not fully convinced the trade-offs are always worth it — here’s where I’d hesitate.
Long-Running Tasks
For tasks spanning hours or days, Claude Code’s stateless approach struggles. There’s no checkpoint system — no saved snapshot to resume from — and no resume mechanism. If execution fails midway through a 100-step migration, you start over.
Complex frameworks win here with their state persistence and recovery.
Multi-Domain Expertise
When a task needs specialized knowledge from multiple domains (legal + technical + financial), a single generalist agent may underperform a team of specialized agents.
The multi-agent frameworks have an edge for genuinely cross-functional work. I’d still reach for one there.
Audit Requirements
In regulated industries, you need detailed logs of decision-making. Why did the agent choose option A over B? What information informed that choice?
Claude Code’s implicit reasoning is harder to audit than frameworks with explicit planning phases that log the rationale for each decision.
Resource Optimization
When you run hundreds of agents in parallel, sophisticated orchestration frameworks can optimize resource allocation, queue management, and load balancing (spreading work evenly across machines).
Claude Code’s simple loop doesn’t optimize for multi-tenancy — serving many independent users on shared infrastructure — or resource efficiency at scale.
Why It Works Anyway
Despite those limitations, Claude Code’s architecture succeeds because it optimizes for the common case:
- Most tasks are short-lived (minutes to hours, not days)
- Most tasks are single-domain (write code, debug an issue, refactor a module)
- Most developers prefer transparency over auditability
- Most use cases are single-user (a developer with their CLI)
For this 80% use case, the simple architecture outperforms the complex alternatives. It’s faster to build, easier to understand, simpler to debug, and more reliable in production.
And when you do need the complex features, you can layer them on top. A simple foundation supports extension better than a complex foundation supports simplification.
Architectural Principles
What can we extract as general principles from Claude Code’s design?
1. Prefer Implicit Over Explicit
Let the model handle planning, verification, and coordination implicitly rather than building explicit systems for each. Trust model intelligence over framework intelligence.
2. Minimize Abstraction Layers
Every abstraction layer between the model and the task adds latency, complexity, and failure modes. Keep the path short.
3. Use Existing Tools
Don’t build bespoke AI agent tools. Integrate existing CLI tools that are already robust, well-documented, and familiar to users.
4. Context is a Budget, Not a Resource
More context isn’t always better. Be aggressive about pruning irrelevant information to keep the model focused.
5. Fail Fast and Observe
Rather than preventing failures through elaborate verification, let failures happen quickly, observe them, and recover. The model learns more from errors than from prevention.
6. One Loop, Not Many States
Complex state machines create cognitive overhead for both developers and models. A simple loop with implicit state transitions is easier to reason about.
Practical Takeaways
If you’re building AI agent systems, consider:
Start simple. Implement the minimal viable control loop first. Add complexity only when you hit an actual limitation, not an anticipated one.
Trust your model. If you’re using frontier models (GPT-4, Claude 3.5+, Gemini Ultra), they’re smarter than your orchestration framework. Give them good tools and get out of the way.
Prune aggressively. More context usually means worse performance. Keep only what’s immediately relevant.
Use Bash. Seriously. Before implementing a specialized tool, check if a Bash command would do the job. You’ll be surprised how often it does.
Measure simplicity. Track the lines of code in your agent framework. If it’s growing faster than your capabilities, something’s wrong.
Let the AI maintain it. If your architecture is simple enough, the AI should be able to extend and modify it. That’s a forcing function for clarity.
The Philosophy Wins
Claude Code’s architecture isn’t about cutting corners or shipping an MVP. It’s a deliberate philosophical stance: simple systems scale better than complex ones when powered by sufficiently capable models.
That inverts the traditional engineering wisdom. We’re used to building systems that compensate for weak components. When you have weak CPUs, you build elaborate caching layers. When you have unreliable networks, you build sophisticated retry mechanisms. When you have buggy code, you build comprehensive test suites.
But what do you do when the component is extremely capable? When the model can plan, verify, and coordinate on its own?
You get out of the way. You provide the minimal interface — tools, context, and a control loop. Then you trust.
That’s the bet Claude Code makes. Based on the results — a tool developers actually use, that maintains itself, that handles real-world complexity — it’s a bet that paid off.
The four-line architecture beat the complex frameworks not by matching their features, but by recognizing most of those features aren’t necessary when you trust the model to be smart.
Sometimes the most sophisticated thing you can build is something simple.
Jon Roosevelt is an AI architect and healthcare technology executive. He builds production AI systems at scale and thinks deeply about what makes software maintainable, reliable, and actually useful. This analysis is based on examining Claude Code’s behavior, architecture patterns, and public documentation — not insider information.