Claude Seekho

Big Picture 2: How the Context Window Is Built

You type one line, but the request sent to Claude is much bigger. It is the context window, which can hold up to 1M tokens. The API is stateless: Claude does not remember the previous request, so the whole context is sent again every time. The order is fixed: tools, then system, then messages.

Order of the request
  1. 1.Tools definitions (client, server, MCP tools)
  2. 2.System prompt (role, rules, CLAUDE.md, skill descriptions, memory)
  3. 3.Documents / Files / Images / PDFs
  4. 4.Cache breakpoint: the prefix up to here is cached
  5. 5.Conversation history (turns, thinking blocks, tool_use + tool_result)
  6. 6.New user message (always last, volatile)
  7. 7.Params + output control, sent over HTTPS to the API gateway

Stable things on top, changing things at the bottom.

The layers of the context

  • Tools definitions: which tools Claude may use, as client tools, server tools or MCP tools. With many MCP tools, they are deferred and loaded later through search.
  • System prompt: Claude's role and rules. CLAUDE.md, skill descriptions and memory are added here too.
  • Documents / Files / Images / PDFs: whatever file you give becomes part of the same context.
  • Cache breakpoint: everything up to this point (the prefix) is cached, and reading it again costs roughly 0.1x. That is why unchanging things sit at the top.
  • Conversation history: every user and assistant turn, thinking blocks, and each tool_use with its tool_result, all sent again every time.
  • New user message: always at the end because it changes every time (volatile).
  • Params: model, max_tokens, thinking, output_config.effort and stream.
  • Output control: structured output (JSON schema), citations and stop sequences.

Where the context content comes from

  • CLAUDE.md: project rules (Claude Code).
  • Memory: past conversations, MEMORY.md.
  • Skills: only the name and description go in first. The body loads on demand.
  • Plugins: bring their own skills, agents, hooks and MCP servers.
  • Project knowledge: claude.ai Projects. If it is very large, RAG is used.
  • MCP servers: tools, resources and prompts.
  • RAG: relevant chunks pulled from a vector DB.
  • Files API: attach documents and images by sending a file_id.
  • Images: they become tokens too, roughly (width / 28) x (height / 28), so images cost money.

The finished request goes over HTTPS with an x-api-key and anthropic-version header to the gateway (next stage), where some checks can stop it. Note: stateless plus fixed order is the base of both caching and cost, which later stages build on.