Visualizationsby Kickshot Studio 12 steps · ~12 min
How Claude Code works

Where your prompt goes and how it works

Follow one prompt through Claude Code: out of your terminal, across the internet, through the model, back into your files and around again until the job is done. Every step is tagged with where it runs.

Your computer The internet Model provider's cloud
~/code/webapp — claude
✻ Welcome to Claude Code cwd: ~/code/webapp>
YOUR COMPUTER INTERNET PROVIDER CLOUD waiting for you to press Enter
∑The whole journey at a glance

One prompt, end to end

Every step has its own interactive visualization below. Hover a step for a summary, click to jump to it or just scroll.

The bigger picture:References
01Your computer

Your prompt is read on your computer first

Claude Code is a program running on your machine. Before anything goes to a model, it checks your input for special syntax, and some input never leaves your computer at all. Try it:

>
02Your computer

The model only knows what is packed in

The model has no memory between requests and can't see your disk. So on every request, Claude Code packs everything it needs into one bundle, the context window: instructions, tools, project notes and the whole conversation so far.

Context window · 1M tokens on current default models
024K used1M
zoom: what fills the used part (typical sizes)hover a segment


      
03The internet

One HTTPS request carries it all

The bundle becomes a single JSON Messages API request, encrypted with TLS. Claude Code asks for a streamed reply so text can appear while the model is still writing.

Provider

      
  • IDWho you are. With a Claude subscription, Claude Code sends the OAuth token it saved when you logged in. Otherwise an API key, or your AWS, Google Cloud or Azure credentials.
  • ⇄Stateless. Our example makes 6 requests for one prompt, and each one resends the entire conversation.
  • ⚙Your choices ride along: /model and /effort go with every request.
04Model provider's cloud

Check the request at the door

Before any model runs, the provider's API front end checks who you are and whether you have capacity, then routes the request to servers running the model.

fails: 401
CHECK 1

Authenticate

Valid token or key? Which organization and plan?

fails: 429
CHECK 2

Limits

Within your rate limits and plan usage?

fails: 400
CHECK 3

Validate

Well-formed JSON? Fits the context window?

THEN

Route

To one of many copies of the model in the provider's data centers.

↻If the service is busy or the connection drops, Claude Code retries automatically.
!Nothing in the cloud can touch your files. The model only ever produces text. Reading, editing and running commands all happen back on your machine, after a permission check.
05Model provider's cloud

Inside the neural network

Embed looks up each token's starting list of numbers in a table the model learned. Prefill then runs every prompt token up through the layers, computing a key/value pair for each token at every layer based on the model's weights. Decode writes the reply one token at a time, picking each one from the odds computed at the top of the previous token's column.

Where it runs, typically: data centers→ many model copies→ one copy = many chips→ shared by many users
One request, layer by layer
embedcomputingkey/value pairscached from request 1
Input

next-token odds
06The internet

The reply streams back

Tokens flow back over the same connection as server-sent events, and the terminal shows text the moment it arrives. A tool call arrives as JSON in pieces and only runs once complete. Thinking, if it's shown at all, arrives as a summary. Each event lights up what it produced.

Raw event stream
What you see
claude
07Your computer

Answer or tool call?

Every reply ends with a stop_reason. It is the switch that drives everything: if the model stopped to use tools, Claude Code runs them and calls the model again. If it's finished, you get the answer.

reply arrives stop_reason = ? "tool_use" "end_turn" check permission → run tool(s) add results, call the model again (↺ step 03) show the final answer Stop hook runs, then wait for your next prompt

A reply can ask for several tools at once. Each one still passes the permission gate, and read-only ones, like reading or searching files, run at the same time.

08Your computer

The permission gate

Whether a requested tool actually runs is decided locally, by a fixed chain of checks. One is your hooks: your own scripts that Claude Code runs at set moments, such as before each tool. They're plain code, so the model can't talk its way past them. Pick a tool call, a mode and some rules. Then drop it through the gate.

Tool call from the model
Permission mode (Shift+Tab switches)
settings.json

Sandboxing (optional) also fences commands into your project at the operating-system level.

Decision chainfirst decisive check wins
09Mostly your computer

Tools do the work

Each tool is code inside Claude Code (or an MCP server) with the schema the model saw in step 02. The bar on each tile shows where it runs. Code reaches the model as plain text, never a parse tree: Claude finds its way with search, not a pre-built index. Hover a tool.

your computerprovider clouda remote server

    Model sends · tool_use
    Comes back · tool_result
    10Your computer

    The answer lands

    The final reply streams in as formatted Markdown. Any Stop hook you've set up runs (it can even send Claude back to work if tests still fail). The whole session is written to disk locally.

    claude
    ● Fixed. cart.js read each item's qty, but cart items store it as quantity. Every line came out as "not a number" (NaN), which the price formatter shows as $0.00. src/cart.js - sum + item.price * item.qty, 0); + sum + item.price * item.quantity, 0); The two-item test cart now totals $42.50, and all 8 cart tests pass. >
    On your disk
    ~/.claude/ ├── settings.json rules, hooks ├── CLAUDE.md your global notes └── projects/ └── -Users-you-code-webapp/ ├── 3f2a…e91.jsonl full transcript └── memory/ auto memory ~/code/webapp/ ├── CLAUDE.md project notes └── .claude/settings.json shared rules

    Resume with claude --continue or --resume. Edits made with Claude's file tools are checkpointed: EscEsc or /rewind rolls them back. Files changed by shell commands, deploys and database writes can't be undone this way.

    11Back and forth

    The agentic loop

    Steps 03 → 09 repeat: each tool result joins the conversation, the whole conversation goes back to the model and it picks the next move. Drag through our prompt (run in Manual mode with npm test allowed by a rule, so you'll see Claude ask only before editing). Esc interrupts at any point.

    request: whole conversation reply: text + tool calls Model · cloud Your computer API CALL 0 drag to start
    ~/code/webapp — claude
    this request's input24,000 tokens
    0API calls
    0tools run
    0input tokens sent
    0%of those cached
    12As needed

    Subagents: loops inside the loop

    For broad research the model can call the Agent tool. Claude Code starts a subagent: a fresh conversation with its own context window, system prompt and tools, running its own loop of API calls. Only its final report returns.

    Main conversation~29,500 tokens

    Subagents can run in parallel or in the background, with fewer tools or a cheaper model. You can also define your own.

    13As needed

    When the window fills up: compaction

    Long sessions grow toward the limit. Near it, Claude Code auto-compacts: it first clears old tool outputs, then asks the model to summarize the conversation and continues from that summary plus recent messages. Keep working and watch.

    AUTO-COMPACT
    0384K / 1M1M

    /compact summarizes on demand and /clear starts fresh. After compaction your project notes are loaded again, so standing instructions aren't lost.

    ∑Your data

    What leaves your computer and what doesn't

    Only what crosses the internet lane leaves your machine. Everything else stays local.

    Leaves your computer
    • To the model provider: your prompts and images, Claude Code's instructions and tool definitions, CLAUDE.md and memory, and everything tools return (file contents, search hits, command output, fetched pages)
    • Usage metrics and error reports, which you can turn off
    • WebFetch safety check: the hostname only, sent to Anthropic before a fetch
    • Remote MCP traffic goes to that MCP server, not to the model provider
    • Feedback you choose to send with /feedback
    Stays on your computer
    • Files Claude never reads; there's no repo upload or index
    • Execution: every edit and shell command runs locally
    • Permission rules, hooks and the sandbox, all enforced locally
    • Transcripts and checkpoints in ~/.claude
    • Local MCP servers and their credentials

    Server-side retention depends on your account: commercial accounts default to 30 days; consumer accounts depend on your model-training setting.

    §Sources

    References and further reading

    Product details here were checked against Anthropic's documentation in October 2026. What happens inside the provider's data centers (steps 04–05), including where the model runs and how cached results are stored, is described from public documentation and standard techniques for serving large models. Anthropic doesn't publish its internal implementation, so the real details may differ.

    Claude Code documentation

    Claude API documentation

    Anthropic engineering

    Background: how transformers run