Lesson 01 / 14
01. What is Claude Code: harness, agent loop, and your place in it
Claude Code is a harness around an LLM, not the model itself. The model decides which tool to call; the harness executes it, returns the result, and runs the agent loop until the final answer.
Before diving into
CLAUDE.md, skills, and subagents, we need to agree on terminology. Otherwise, discussions about “cache” and “context” turn into arguments about different entities.
1.1. Chatbot vs agent
Chatbot — this is model.complete(messages). It takes text and returns text. If you want it to read something, you copy the file contents into the prompt yourself.
Agent — this is a loop where the model:
- Receives a user request.
- Decides which tool to call (Read a file, Bash command, code search).
- Gets the tool result back.
- Decides: either call another tool or respond to the user.
This loop is called the agent loop. In Claude Code, it’s hardcoded into the CLI (harness).
Key insight: the model doesn’t do anything on your machine by itself. All actions — reading files, running commands, calling MCPs — are tool calls executed by the harness. The model only decides what to call.
1.2. What is harness
Harness — this is a local program (Claude Code CLI or IDE plugin) that:
| Function | What it does |
|---|---|
| Prompt assembly | Concatenates system prompt + CLAUDE.md + skills + history + tool results |
| Tool dispatch | Receives tool_use from model, executes it, returns result |
| Permission gating | Asks user permission for “dangerous” tools (Bash, Edit) |
| Cache management | Marks cacheable blocks, updates TTL |
| Subagent orchestration | Launches child sessions on Agent tool call |
| Hooks | Triggers your scripts on lifecycle events |
| MCP transport | Supports stdio/SSE/HTTP connections to MCP servers |
Harness is not the model. The model is in Anthropic’s cloud. Harness is the model’s eyes, hands, and memory.
⚠️ This is important to understand: when we say “the model read a file” — this is shorthand for “the model made a tool_use Read call, the harness read the file, returned the contents in tool_result, the model saw this in the next step”. The model has no direct disk access.
1.3. What actually makes up the “context” in each request
Each request to the Anthropic API contains:
messages.create(
model="claude-opus-4-7",
system=[ # ← кэшируемый префикс
{"type": "text", "text": SYSTEM_PROMPT}, # ~4.2k токенов
{"type": "text", "text": CLAUDE_MD_CONCAT}, # ваши memory-файлы
{"type": "text", "text": LOADED_SKILLS}, # SKILL.md тех скиллов, что подгружены
],
tools=[...], # ← кэшируемый префикс (определения всех tools)
messages=[ # ← НЕ кэшируется целиком, только префикс
{"role": "user", "content": "..."},
{"role": "assistant", "content": [{"type": "tool_use", ...}]},
{"role": "user", "content": [{"type": "tool_result", ...}]},
...
],
)
📘 From docs (how-claude-code-works): “Claude’s context window holds your conversation history, file contents, command outputs, CLAUDE.md, auto memory, loaded skills, and system instructions”.
This is all — one long document for the model. The size of this document is measured in tokens and limited by the context window (200k for Haiku, 1M for Sonnet/Opus with beta flag).
See details in 02-context-and-cache.md.
1.4. Versions and releases
As of 04.23.2026, current versions are:
- Claude Code v2.1.89 (CLI, IDE plugins)
- Default models on Anthropic API:
opus→ Opus 4.7 (released 04.16.2026)sonnet→ Sonnet 4.6haiku→ Haiku 4.5
- On Bedrock/Vertex/Foundry defaults are shifted:
opus→4.6,sonnet→4.5 (new models arrive later).
🧪 Agent Teams — experimental feature, requires CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1. See 10-agent-teams.md.
⚠️ Opus 4.7 has a new tokenizer — on the same texts it consumes up to 35% more tokens than Opus 4.6. If you’re upgrading from 4.6 — recalculate your limit estimates.
1.5. End-to-end example: Travel Agent
One project runs through the entire guide — Travel Agent. This is an AI service for travel planning:
In each chapter we’ll answer the question: “How do I apply this to Travel Agent?” — with concrete config snippets, code, or CLAUDE.md.
In 12-travel-agent-blueprint.md the final repository structure with all artifacts comes together.
1.6. Quick reference of CLI commands used in the guide
| Command | What it does | Chapter |
|---|---|---|
/context | Visualizes current window fill | 02 |
/compact [hint] | Compresses history, frees space | 02 |
/clear | Full session reset (restarts, cache lost) | 02 |
/model [name] | Switch model in current session | 02, 10 |
/agents | Subagent manager | 09 |
/plugin install <ref> | Install plugin from marketplace | 07 |
/mcp | List connected MCP servers | 06 |
/permissions | Current allow/deny rules | 05 |
/release-notes | Changes in version | — |