TL;DR
This paper provides a rare, source-level architectural analysis of Anthropic’s Claude Code, revealing that its effectiveness stems not from complex AI planning logic, but from a robust "operational harness" that accounts for 98.4% of its codebase. By mapping thirteen design principles across safety, context management, and human authority, the authors define the emerging design space for production-grade AI agents.
What Problem Does This Paper Address?
AI coding assistants are rapidly evolving from simple "autocomplete" tools (like GitHub Copilot) to autonomous agents that can execute shell commands, edit files, and iterate on their own work. This shift introduces a massive "design space" of unanswered questions: How do you manage a finite context window during a long-running task? How do you ensure an agent doesn't accidentally delete a production database?
While product documentation exists, there is a significant gap in detailed architectural descriptions for production-grade agents. This paper aims to fill that gap by reverse-engineering Claude Code to understand how a leading commercial system navigates the trade-offs between autonomy, safety, and reliability.
Methods
The authors conducted a "design-space analysis" grounded in three tiers of evidence:
- Tier A (Product-documented): Official Anthropic documentation and publications.
- Tier B (Code-verified): Direct analysis of the extracted Claude Code TypeScript source code (v2.1.88).
- Tier C (Reconstructed): Comparisons with two independent open-source agent systems, OpenClaw and Hermes Agent.
They identified five core human values (e.g., Human Decision Authority, Safety) and traced them through thirteen design principles to specific implementation choices in the code, such as the permission system and the context compaction pipeline.
Datasets
The primary "dataset" for this study is the Claude Code source corpus, comprising approximately 1,884 files and 512,000 lines of TypeScript. For comparative analysis, the authors used the source code of OpenClaw and Hermes Agent. The paper also references internal Anthropic surveys of engineers and external benchmarks like SWE-bench and HumanEval to contextualize the agent's performance.
Key Insights and Ideas
- The "Harness" is the Hero: A striking finding is that only 1.6% of Claude Code’s codebase is dedicated to AI decision logic. The remaining 98.4% is the "operational harness"—the deterministic infrastructure (permission gates, tool routing, recovery logic) that allows the model to function. The authors argue that the harness, not the "brain," is the primary differentiator for production agents.
- Graduated Layering: Rather than using a single monolithic mechanism for safety or context, Claude Code employs "graduated layering."
- Safety: A seven-stage permission pipeline (Figure 4) ranges from "deny-first" rules to an ML-based classifier.
- Context: A five-layer compaction pipeline (budget reduction, snip, microcompact, context collapse, and auto-compact) manages the context window with increasing aggressiveness.
- Minimal Scaffolding, Maximal Autonomy: Unlike systems that use rigid state graphs (like LangGraph), Claude Code uses a simple
while-loop(the ReAct pattern). It trusts the model to reason freely within the "guardrails" provided by the harness. - The Paradox of Supervision: The authors highlight a "cross-cutting concern": while agents amplify short-term productivity, they may lead to "cognitive offloading," where developers lose the deep codebase understanding required to supervise the agent effectively.
Key Results
- Architectural Decomposition: The paper identifies a 7-component structure (Figure 1) and a 5-layer subsystem architecture (Figure 3) that defines how requests flow from the user interface to the execution environment.
- Safety Posture: Claude Code defaults to a "deny-first with human escalation" posture. The study notes that users approve ~93% of prompts, leading to "approval fatigue," which the system mitigates through defined safety boundaries (sandboxing) rather than just more warnings.
- Context Management: The system treats the context window as the "binding resource constraint." The five-layer pipeline ensures that the model always sees the most relevant information without hitting token limits.
- Comparative Findings: The contrast with OpenClaw and Hermes Agent shows that deployment context dictates architecture. For example, Claude Code emphasizes per-action safety for a single user, while OpenClaw focuses on perimeter-level access for a multi-channel gateway.
Limitations and Future Work
- Static Snapshot: The analysis is limited to a specific version (v2.1.88) and cannot account for rapid updates or server-side changes not reflected in the CLI source.
- Observability-Evaluation Gap: A major open challenge is "silent failure"—when an agent makes a mistake that doesn't cause a crash but introduces subtle bugs. Current architectures provide visibility into tool calls but lack robust internal evaluation interfaces.
- Long-term Capability: Future research is needed to determine if agent architectures can be designed to improve human understanding and codebase coherence over time, rather than just accelerating task completion.
Summary updated