AI Commentary · Part 10 of 10

Claude Code Analysis Paper

Claude Code Analysis Paper

Recently, there’s an excellent paper that does a deep dive of Claude Code. It’s an insightful look at the design decision of Claude Code and how it works. In this blog, we’ll highlight some of the key findings of the paper.

The paper is titled “Dive into Claude Code: The Design Space of Today’s and Future AI Agent Systems” by Jiacheng Liu, Xiaohan Zhao, Xinyi Shang, Zhiqiang Shen.

Claude Code has the following architecture:

Architecture

Here’s a brief description of each:

  1. User: submits prompts, approves permissions and reviews outputs. They use the interactive CLI or Agent SDK or IDE/Desktop/Browser.
  2. Agent loop: the iterative cycle of LLM model calls.
  3. Permission system:
  4. Tools: up to 54 built-in tools and additional plugins through MCP servers
  5. State & persistence: session transcripts, prompt history and subagent sidechain files
  6. Execution environment: there’s a sandboxing option (shouldUseSandbox.ts)

Claude Code follows the ReAct pattern: the LLM generates reasoning and tool invocations, the harness executes actions and results are fed to the next iteration. There’s no explicit routing. This is very different from LangChain’s explicit graph based routing. This has its pros and cons.

  • Pros
    • The agent has more freedom since it’s not limited by the predetermined routing and it can handle all tasks.
    • It requires less user involvement for each task since the agent can decide its own next step. Users don’t need to plan the routing for the agents.
  • Cons
    • Lack of predictability which is problematic for specific workflows.
    • There’s an added risk due to no explicit routing, one wouldn’t be able to tell if the agent is misbehaving or not since any routing is possible.

BetterClaw is an attempt to have the best of these two worlds. It’s a workflow-enforcement layer for Claude Code and OpenClaw. It allows one to describe a task in natural language, and creates a workflow graph. If the agent’s invocation of tools is outside of the workflow, it’d block it. This also provides an audit trail of the tool calls by the agent.