98% of Claude Code Is Not AI
A new 46-page study reverse-engineers Claude Code’s architecture from its open-source TypeScript codebase.
In Short
Scaffolding-side reasoning is growing…
A new 46-page study reverse-engineers Claude Code’s architecture from its open-source TypeScript codebase.
The headline finding, by one community estimate, only about 1.6% of the codebase constitutes AI decision logic.
The other 98% is operational infrastructure…permissions, context management, safety layers, extensibility, session persistence.
The core agent loop is a trivially simple while-loop: call the model, execute tools, repeat.
Everything that makes Claude Code a production-grade tool lives in the systems wrapped around that loop.
This paper confirms something I’ve been arguing across several posts… the model is a commodity input.
The harness is the product.
The model’s only interface to the outside world is the structured tool_use protocol, which the harness validates before execution.
Community analysis of the extracted source estimates that only about 1.6% of Claude Code’s codebase constitutes AI decision logic, with the remaining 98.4% being operational infrastructure.
The philosophy they call minimal scaffolding, maximal operational harness.
The while-loop at the centre
The researchers traced Claude Code’s execution flow through its source files and found a remarkably simple core.
The queryLoop() function in query.ts is an async generator that:
1. Assembles context (settings, conversation history, instructions)
2. Calls the Claude model
3. Parses tool-use requests from the response
4. Routes them through a permission gate
5. Executes approved tools and collects results
6. Repeats until the model produces a text-only response
That’s it. That’s the AI agent. A while (true) loop with a model call inside.
The paper traces this to a deliberate design philosophy they call “minimal scaffolding, maximal operational harness.”
The architecture doesn’t invest in scaffolding-side reasoning, no explicit planner, no state graph, no decision tree.
Instead, it invests in infrastructure that lets the model reason freely within safe, well-managed boundaries.
Where the other 98% ives
If the loop is simple, what fills the rest of the codebase?
The paper identifies five major subsystems, each addressing a problem that the model alone cannot solve…
A deny-first permission system with seven modes
Every tool invocation passes through a multi-layer authorisation pipeline.
Deny rules always override allow rules, even when the allow rule is more specific.
An ML-based classifier evaluates tool safety in auto mode.
Shell sandboxing operates independently of the permission system.
The paper documents that Anthropic found users approve 93% of permission prompts…essentially rubber-stamping everything…which is why the architecture can’t rely on human vigilance as its primary safety mechanism. The safety has to be structural.
The message for builders
If you’re building AI agents, this paper is a 46-page argument for where to invest your engineering effort…
Not in the model.
The model is necessary but not sufficient.
Claude Code proves that even the most capable frontier model needs 200,000 lines of infrastructure to be production-useful.
The model is one function call inside a harness that handles context, permissions, recovery, persistence, and extensibility.
In the harness
Context engineering, safety architecture, tool orchestration, compaction strategies, memory systems…these are hard engineering problems with no shortcut.
You can’t prompt-engineer your way to a good harness.
And as models commoditise, with multiple frontier models achieving similar capability levels, the harness becomes the differentiator.
In the orchestration layer
Whether you’re routing between models like OpenAI’s top-down orchestrator, escalating to advisors like Anthropic’s bottom-up strategy, or managing context pressure across long sessions like Claude Code’s compaction pipeline, the orchestration infrastructure is where production reliability lives.
The model gives you intelligence.
The harness gives you reliability.
The 98% that isn’t AI is the part that actually works.
A five-layer context compaction pipeline
The context window is the binding resource constraint.
Before every model call, five sequential shapers compress the conversation…
budget reduction caps individual tool results,
snip trims older history,
micro compact applies cache-aware compression,
context collapse creates virtual projections over history, and
auto-compact triggers full model-generated summaries as a last resort.
Chief AI Evangelist @ Kore.ai | I’m passionate about exploring the intersection of AI and language. From Language Models, AI Agents to Agentic Applications, Development Frameworks & Data-Centric Productivity Tools, I share insights and ideas on how these technologies are shaping the future.
Dive into Claude Code: The Design Space of Today’s and Future AI Agent Systems Claude Code is an agentic coding tool that can run shell commands, edit files, and call external services on behalf of…arxiv.org







