Reliable autonomous coding agents come from architecture — deterministic stop signals, isolated context, programmatic gates — not smarter models.
The loop is dictated entirely by the stop reason field in Claude's structured JSON metadata. A stop reason of tool_use pauses generation so your application executes the tool and appends the result to the conversation history as a new message. The loop terminates only when stop reason returns end turn.
Regex patterns hunting for phrases like "I am finished" or "task complete" break because natural language is inherently variable. The model might write "I am finished with step one, now moving to step two" — your regex fires, the loop crashes, and the migration halts halfway through.
No, it wakes up completely blank, holding only its system prompt and the highly specific context the coordinator explicitly passes in that invocation. Sending forty turns of architectural debate to an agent writing unit tests causes attention dilution — it might start redesigning the database instead of writing the test.
It uses the task tool, the explicit mechanism for spawning subagents, and the system configuration's allowed tools array must include tasks. The architecture supports parallel spawning: the coordinator can emit multiple task tool calls in a single response turn, waking five analysis agents simultaneously to map different parts of the monolith.
Prompt instructions are probabilistic with a non-zero failure rate — caps lock and exclamation points included. They work about 99% of the time, but a weird context can make the model reason past them. Programmatic prerequisite gates, built with tool call interception hooks, physically block the call and return an error.
The governing principle is strict scope: a highly focused four or five, not eighteen or fifty, because decision complexity increases exponentially and selection reliability degrades. Agents holding tools outside their specialization suffer attention drift. If the database agent needs AWS, it passes a request back to the coordinator, who routes it.
Language models are notoriously bad at counting exact line numbers over massive contexts. Feed an LLM a 1,000-line file and tell it to edit line 412, and its internal token representation might replace line 415, introducing a catastrophic syntax error. Unique string matching forces semantic precision despite line drift.
Plan mode is for complex multi-file architectural changes — migrating a core authentication library affecting 45 files. It forces the agent to explore, map dependencies and present a design document before writing any code, using the Explore subagent to keep discovery out of your context. Direct execution suits single-file bug fixes.
You define a dummy extraction tool, supply a strict JSON schema as its input parameter definition, and force the model to call it using tool choice forced selection. The API then enforces conformance, eliminating missing brackets, trailing commas and unescaped quotes — though semantic errors are still possible.
If you mark a field required — say a secondary database key — and the source legacy file contains no such key, the model must still provide a string to satisfy API validation, so it fabricates one. Making fields optional or nullable, plus enum values like unclear, prevents that fabrication.
“You can, and honestly, it'll work 99% of the time.”
“Yes, that description is the only user interface the model has.”
“The governing principle is strict scope.”
“We're essentially recreating corporate organizational structures in silicon.”
“Claude Architect Exam Guide.” https://www.youtube.com/watch?v=BTqqFA3jZoY. Transcript summary by WhipScribe, https://whipscribe.com/transcript-pages/claude-architect-exam-guide.html.