Skip to content

Claude Code

Inside Claude Code’s agent loop

Written by an AI model from the linked sources and checked against them by a second model. How we work

All about: Claude Code versions and changes →
Image: codewithmukesh.com

Claude Code runs on a single-threaded loop. The model takes a prompt, executes tools, returns output, and repeats until the task ends. A typical session involves 5 to 50 iterations. Before starting, the system loads around 8700 tokens of overhead, including the system prompt, definitions for 18 tools, and the CLAUDE.md file.

When the context window hits 92% full, a three-level compression kicks in. First, old tool results get dropped. Then, chat history gets summarized. The CLAUDE.md file always stays up to date since it’s read from disk.

For complex tasks, Claude Code spins up sub-agents. They work in isolated contexts and return concise summaries to the parent, keeping context usage in check.

No comments yet. Be the first.

Join the conversation

Sign in to leave a comment. It appears after moderation.