Skip to content
zeeshare.com

writing / FDE and agents

How Claude Code works

How Claude Code worksPart 6

Context and cost

On this page
  1. The desk
  2. What is on the desk from the start
  3. Your desk tools
  4. Send a helper for the big reads
  5. A morning on the Acme storefront
  6. Where this fits in the bigger picture
  7. Which one fits?
  8. Your setup so far
  9. Three rules of thumb

In short: Claude works at a desk of fixed size: the context window. Everything it is holding sits on that desk: your rules, the conversation, every file it opened and every log it read. A cluttered desk makes a colleague slower and vaguer, and each message costs more because the whole desk is re-read. Keep one task per desk, send noisy jobs to a helper, and load rules only where they apply.

Part 5 decided what Claude may do. This part is about keeping it sharp while it does it. The project in the examples, the Acme storefront, is made up.

Claude Always on the desk The conversation Tool output Fetched only when needed You

The desk

Think of it like this: A colleague with a clear desk finds things fast. Pile three old projects, a printout of every log and last week’s notes on it, and they start missing the page that matters.

Every time you send a message, Claude reads the whole desk again: the rules, the conversation so far and every tool result in it. Two things follow:

  • Focus drops as the desk fills. Old details compete with the task in front of it.
  • Cost grows with what is on the desk, because each message carries all of it.
A fresh session rules and tools rules and tools 12% · your ask 4% After a long afternoon on three tasks rules and tools talk logs and file dumps rules and tools 12% · talk 26% · logs and file dumps 48% After /compact "keep the checkout decisions" rules and tools rules and tools 12% · summary 9%
The desk only holds so much. Old logs and finished tasks crowd out the thing you are working on now.
Under the hood: tokens, caching and compaction
  • Size is measured in tokens, small pieces of text. Both the context limit and the cost are counted in tokens.
  • Claude Code sends the full conversation with each request. Prompt caching makes re-reading the unchanged part cheaper, but it is still counted.
  • When the desk gets close to full, Claude Code compacts automatically: it replaces older history with a summary. /compact does the same on your terms, with your instructions.
  • /compact itself reads the whole conversation, so it is a big request. /clear costs nothing.
  • After a compact, the project’s root CLAUDE.md is read in again, so your standing rules survive.

What is on the desk from the start

Some things sit on the desk in every session. Others are fetched only when the work needs them. Moving things from the first list to the second is the cheapest win there is.

On the desk from the start
  • CLAUDE.md files from the project up to your home folder
  • Rules in .claude/rules/ without a paths list
  • The first 200 lines of auto memory
  • Each skill's one-line description, and tool names
Fetched when needed
  • A skill's full steps, when it is used
  • Rules with a paths list, when Claude reads a matching file
  • CLAUDE.md in a subfolder, when Claude works there
  • An MCP tool's details, when Claude looks it up

Rule: keep CLAUDE.md under about 200 lines. The docs say longer files are followed less reliably, and every line is on the desk for every message.

markdown
---
paths:
  - "src/checkout/**"
---
# Checkout rules
- Money is always integer cents. Never floats.
- Round discounts per line item, not on the total.

That file lives in .claude/rules/checkout.md. It only lands on the desk when Claude opens a checkout file.

Your desk tools

See the desk

/context shows what is taking up room right now: rules, tools, conversation.

See the bill

/usage shows tokens and cost for this session, and on a plan, what is using your limits.

Summarise and keep going

/compact keep the API decisions swaps old history for a summary of what you name.

Clear the desk

/clear starts fresh for unrelated work. The old session is saved; /resume brings it back.

Step back

Esc stops Claude now. /rewind goes back to an earlier point when it went the wrong way.

Right brain for the job

/model and /effort: a lighter setting for simple jobs, the strongest for hard design work.

Send a helper for the big reads

Think of it like this: You do not read the whole printout yourself. You ask someone to read it and tell you the two lines that matter.

Part 2 and Part 3 introduced subagents. Here is why they matter for the desk: the helper’s reading happens on its desk. Only its answer lands on yours.

Read it on your own desk run the test suite 4,000 lines of output desk is half full Send a helper (a subagent) helper runs the tests reads all 4,000 lines "2 fail: cart.test" The helper still costs tokens, but its noise never reaches your conversation.
The helper reads the noise on its own desk and hands you a single note.

A morning on the Acme storefront

  1. 9:00 · One task, one session

    Fix the coupon bug on the Acme storefront. Start fresh so yesterday's work is not on the desk.

    claude
    > Fix ACME-151: coupons apply twice at checkout.
  2. 9:20 · Big read? Send a helper

    The full test run is long. A subagent runs it and reports only the failures.

    > Use a subagent to run the checkout tests and
      tell me only which ones fail and why.
  3. 10:30 · Check the desk

    The session has grown. /context shows most of it is old file dumps.

    /context
  4. 10:32 · Summarise with a focus

    Keep what matters for the next step, drop the rest.

    /compact Keep the coupon fix, the failing test names
    and the decision to round at line-item level.
  5. 11:15 · New task, clear desk

    The bug is done. The next task, the footer links, has nothing to do with it.

    /rename coupon-fix
    /clear
  6. End of day · Look at what it cost

    /usage shows where tokens went. A big CLAUDE.md on every request is a common surprise.

    /usage
Under the hood: other ways to save
  • Ask for specific things. “Add input validation to the login function in auth.ts” reads far less than “improve this codebase”.
  • Plan first for big tasks (Part 5’s plan mode). A wrong direction caught early saves a whole round of rework.
  • Prefer a command-line tool like gh to an MCP server when both work. CLI tools add nothing to the desk until used.
  • A hook can shrink output before Claude sees it, for example passing only failing test lines through.
  • Thinking tokens are billed as output. /effort lowers how hard Claude thinks on simple jobs.

Where this fits in the bigger picture

Think of it like this: The written spec from Part 7 is the one page that must stay on the desk. Everything else can come and go.

A setup that works like you needs focus more than it needs memory. A clear desk with the spec, the current task and the rules that apply beats a desk holding everything that ever happened. Part 10 shows how to hand over between sessions without carrying the clutter along.

Which one fits?

  • I am switching to unrelated work: /clearStart fresh. Rename first with /rename so you can /resume it later.
  • Same task, but the session is long: /compact with a focusTell it what to keep: "keep the schema decisions and failing tests". Details go, decisions stay.
  • A job will spit out lots of output: A subagentTests, logs, long docs. The helper reads them and returns a short answer (Part 2 and 3).
  • My CLAUDE.md keeps growing: Move parts outKeep it under about 200 lines. Move procedures into skills and folder-specific advice into rules with paths.
  • I do not know what fills the desk: /contextIt lists what is loaded right now, so you can see whether it is rules, tools or old conversation.
  • The task is simple: A lighter model or effort/model or /effort. Save the strongest settings for design and hard bugs.

Your setup so far

your setup so far · parts 1 to 6
  1. Part 1 · where it worksYou know which machine does what, and which folders Claude can reach.
  2. Part 2 · what it remembersOne task per notebook; photocopies in their own folder; helpers for noisy side jobs.
  3. Part 3 · how it behavesFridge rules for what is always true, recipe cards for procedures, alarms for musts, specialists for checks.
  4. Part 4 · what it can reachPhone lines to your tracker and tools, checked before trusted; your setup packed as one toolbox.
  5. Part 5 · what it may doKeys for routine work, a knock for anything that publishes, locked doors for secrets.
  6. Part 6 · how it stays sharpA clear desk: fresh sessions, focused summaries, helpers for big reads, rules only where they apply.
  7. NextPart 7 · specs as the source of truth

Three rules of thumb

One task, one desk

Clear between unrelated tasks. Stale history costs on every message and blurs the focus.

Noise goes to a helper

Anything that produces pages of output runs in a subagent and comes back as a note.

Load rules where they apply

A short CLAUDE.md for what is always true. Skills and path rules for the rest.

QuizYou finished a bug fix and now want to update the footer links, which has nothing to do with the fix. The session is long. What is best?

Show the answer

Answer: /rename the session, then /clear

The new task needs none of the old desk. Clearing is free and gives a sharp start, and renaming lets you /resume the bug fix later if you need it.

Words in this post:

  • Context window: how much Claude can hold in mind at once. The desk.
  • Token: a small piece of text. Limits and costs are counted in tokens.
  • Compact: replace older history with a summary to free room.
  • Path rule: a rule file with a paths list that loads only for matching files.
  • Subagent: a helper with its own desk that returns only its answer.

Facts here were checked against the Claude Code documentation on costs and memory in November 2026. These features change often, so the docs are the final word for your version.

Next, Part 7: Specs as the source of truth puts one page at the centre of the desk: the written spec.

Setting up Claude Code or AI agents for your team?

I help teams build this: agents, RAG search and Claude Code setups that hold up in production.

See services
Next in this seriesHow Claude Code worksSpecs as the source of truth4 min read