Lab / Explainer / 7 layers

No. 02Explainer8 min

What happens when you press Enter

The layers around one request in Claude Code: instructions, skills, tools, hooks, subagents and connections, and where your team rules belong.

Short version

Your sentence is the smallest part of what the model reads. Instructions say what you want, skills say how, hooks make sure, and subagents keep the main conversation clean.

I coach colleagues who start with Claude Code, and the first question is always some form of "how does it know that?". The answer is a set of layers around your request. This page takes them apart. The token numbers are illustrative but in the right range for a real session, and every request on it is invented.

01 · The stack

Your request travels through seven layers.

Read the stack from the bottom. Each layer adds something the model could not do on its own. Instructions and memory come along with every request; the other layers only join in when a request needs them. Pick a request and watch which ones switch on.

You type

"Make the settings page work in dark mode"

Seven layers, read from the bottom

  1. Subagentsyou set up

    not needed this time

    MCP connectionsyou set up

    not needed this time

  2. Hooksyou write

    Runs the linter before the commit.

  3. Skillsyou write

    The design skill loads: tokens and dark mode rules.

  4. Toolsbuilt in

    Reads six files, edits two, runs the build.

  5. MemoryClaude writes

    Its notes: Jasper wants a short summary at the end.

  6. Instructionsyou write

    Your rules: use our colour tokens, never use em dashes.

  7. Modelmade by Anthropic

    Plans the change, writes the edits and the summary.

You get back

The settings page works in dark mode, committed once the linter passed.

"you write" layers are written once and help with every request after

Show as text

The seven layers, from the bottom:

  1. Model (made by Anthropic): Reads text and writes text. Knows nothing about your project until it is told.
  2. Instructions (you write): Plain-text rules (CLAUDE.md) loaded with every request: your global file plus the project file.
  3. Memory (Claude writes): Short notes Claude keeps about you and the project, loaded next time.
  4. Tools (built in): Read files, edit files, run commands, search. Each tool is described to the model in text.
  5. Skills (you write): Know-how for one kind of task. Only a one-line description is always loaded.
  6. Hooks (you write): Your own scripts that run before or after a tool. Code, not advice: they can block.
  7. Subagents (you set up): Helpers with their own context window. They do a job and hand back a short answer. MCP connections (you set up): Tools for outside systems, such as a calendar, a database or a Home Assistant sensor.
RequestLayers it switches onYou get back
Make the settings page work in dark modeTools: Reads six files, edits two, runs the build. Skills: The design skill loads: tokens and dark mode rules. Hooks: Runs the linter before the commit.The settings page works in dark mode, committed once the linter passed.
What is on my calendar tomorrow?MCP connections: The calendar connection reads tomorrow's events.Three meetings tomorrow, the first one at 9:00.
Find every place we format datesTools: Search runs 30 times, inside the helper. Subagents: A helper reads 30 files in its own window and reports back.Twelve places in nine files, listed in one short paragraph.

For every request, the model, the instructions and memory take part: "Your rules: use our colour tokens, never use em dashes." and "Its notes: Jasper wants a short summary at the end."

fig. 1 Instructions and memory come along with every request. The layers in the pen colour are the ones this request switched on.

Most of what makes Claude Code good for your team lives in layers you write once: instructions, skills and hooks.

02 · One request

Your words are the smallest part of what the model reads.

Follow one invented request, "make the settings page work in dark mode", from Enter to answer. The dots are the conversation's working memory (the context window), drawn to scale: each dot is 500 tokens, and the window holds 400 of them. Try the small typo fix too, and the next turn.

You type

"Make the settings page work in dark mode"

10 tokens

What gets added, step by step

  1. +10You type the request. Eight words, about 10 tokens.
  2. +21,300The setup loads. System prompt and tool descriptions 16,000, instructions 3,500, skill descriptions 1,200, memory 600.
  3. +2,400A skill matches. The request fits the design skill's description, so its full text loads.
  4. +17,000Tools run. Six files read (14,000) and the build output (3,000).
  5. +150A hook checks. The linter fails, the commit is blocked and the error goes back to Claude.
  6. +2,500The answer. The fix, a commit that passes and a short summary.

What the model reads, to scale43,360 of 200,000 tokens

your request: 10 tokens

1 dot = 500 tokens; a smaller dot is the part left over. The pale dots are the rest of the window.

Show as text

"Make the settings page work in dark mode": 43,360 of 200,000 tokens in use, of which 10 are your own words.

  1. You type the request: +10 tokens. Eight words, about 10 tokens.
  2. The setup loads: +21,300 tokens. System prompt and tool descriptions 16,000, instructions 3,500, skill descriptions 1,200, memory 600.
  3. A skill matches: +2,400 tokens. The request fits the design skill's description, so its full text loads.
  4. Tools run: +17,000 tokens. Six files read (14,000) and the build output (3,000).
  5. A hook checks: +150 tokens. The linter fails, the commit is blocked and the error goes back to Claude.
  6. The answer: +2,500 tokens. The fix, a commit that passes and a short summary.

"Fix the typo in the footer": 22,948 of 200,000 tokens in use, of which 8 are your own words.

  1. You type the request: +8 tokens. Six words, about 8 tokens.
  2. The setup loads: +21,300 tokens. The same setup as for any request, however small.
  3. No skill matches: +0 tokens. Nothing new loads. The one-line descriptions are already in the setup.
  4. Tools run: +1,400 tokens. One file read, one word changed.
  5. A hook checks: +40 tokens. The linter passes, so nothing is blocked.
  6. The answer: +200 tokens. One line: fixed.

"Now do the same for the profile page": 57,210 of 200,000 tokens in use, of which 10 are your own words.

  1. You type the request: +10 tokens. Eight words, about 10 tokens.
  2. Turn 1 is read again: +43,360 tokens. Everything from the dark mode request comes along: setup, skill, files, output and answer.
  3. The skill is still there: +0 tokens. The design skill loaded in turn 1, so it costs nothing new.
  4. Tools run: +12,000 tokens. The profile page and its styles, plus the build.
  5. A hook checks: +40 tokens. The linter passes this time.
  6. The answer: +1,800 tokens. The change and a short summary.
fig. 2 Your request is the speck in the circle. Everything else comes along with it: the setup, a skill, files and results. On the next turn, all of it is read again.

A request of 10 tokens can carry 43,000 tokens of context, and all of it is read again on the next turn.

03 · Skills

Skills cost almost nothing until they are needed.

A skill is a folder with instructions (and sometimes scripts) for one kind of task. Only its name and a one-line description sit in every request, about 30 tokens. When your request matches the description, the full text loads. That is why a team can have dozens of skills without slowing anything down.

The catch: the description is all the model has to go on. "Helps with frontend" matches almost everything, or nothing in particular. "Use before building or changing a page or component: our colour tokens, phone layout and dark mode rules" says exactly when.

You type

"Make the settings page work in dark mode"

The skills, one line each

  • design-system Use before building or changing a page or component: our colour tokens, phone layout and dark mode rules.

    Full text loads: 2,400 tokens

    • Colours come from the tokens file, never a hex code.
    • Check every page at 375 pixels wide.
    • Dark mode: test both themes before you commit.
  • deploy Use when you deploy to staging or production: twelve steps, checks and rollback.

  • release-notes Use when writing release notes from merged changes.

  • db-migration Use before changing the database: checks that keep the data safe.

  • meeting-notes Use to turn a meeting transcript into decisions and actions.

  • and 35 more, one line each

Skills in the context window, to scale

  • 40 one-line descriptions: 1,200 tokens, in every request
  • The skill that matched, in full: 2,400 tokens
  • All 40 skills in full would be 96,000 tokens: the dashed rings

1 dot = 500 tokens, as in fig. 2.

Show as text
RequestMatching descriptionWhat loads
Make the settings page work in dark modedesign-system: Use before building or changing a page or component: our colour tokens, phone layout and dark mode rules. (shared words: page, dark mode)The full text, 2,400 tokens: Colours come from the tokens file, never a hex code. Check every page at 375 pixels wide. Dark mode: test both themes before you commit.
Deploy the new version to stagingdeploy: Use when you deploy to staging or production: twelve steps, checks and rollback. (shared words: deploy, staging)The full text, 2,400 tokens: Run the tests and the build first. Deploy to staging and open the site. Twelve steps later: if anything fails, roll back.
What does this error message mean?NoneNothing more. The 40 one-line descriptions (1,200 tokens) stay as they are.

The skills on the shelf: design-system ("Use before building or changing a page or component: our colour tokens, phone layout and dark mode rules."); deploy ("Use when you deploy to staging or production: twelve steps, checks and rollback."); release-notes ("Use when writing release notes from merged changes."); db-migration ("Use before changing the database: checks that keep the data safe."); meeting-notes ("Use to turn a meeting transcript into decisions and actions."); and 35 more.

fig. 3 Until a request matches it, a skill is one line. Forty one-line descriptions together take 1,200 tokens; only the skill that matches adds its full text.

Write skills generously, but write their one-line description carefully: it is what triggers them.

04 · Hooks

Hooks are the rules that cannot be forgotten.

Instructions and skills are text the model reads, so on a long day it can miss one. A hook is a small script that Claude Code itself runs at a fixed moment, for example before every command. If the script says no, the action does not happen, and the reason goes back to Claude.

Claude's session, 40 steps

Step 1 held your instruction: "always lint before committing".

Claude commits: "dark mode for settings"

Hook runs the linter before every commit

  1. Claude commits. The hook runs the linter first, as it does every time.
  2. Blocked: lint failed, 1 error in Settings.tsx line 42. The reason goes back to Claude.
  3. Claude removes the unused import and commits again. The linter passes.

Main branch

  • fix typo in the footer
  • new photo on the profile page
  • dark mode for settingslint clean
Show as text

Only an instruction. The commit lands: 1 lint error went in.

  1. Step 1 of the session: "always lint before committing". By step 40 it is one line among thousands.
  2. Claude commits. Nothing checks it, and this time the lint step is missed.
  3. The commit lands with 1 lint error in Settings.tsx.

With a hook. The commit lands: lint clean.

  1. Claude commits. The hook runs the linter first, as it does every time.
  2. Blocked: lint failed, 1 error in Settings.tsx line 42. The reason goes back to Claude.
  3. Claude removes the unused import and commits again. The linter passes.
fig. 4 An instruction is a line the model has to remember forty steps later. A hook is a gate every commit passes through, so a slip is caught every time.

If a rule must hold every single time, make it code. Text is advice; a hook is a gate.

05 · Subagents and MCP

Subagents do the reading in their own room.

A subagent is a helper with its own empty context window. Claude gives it a task ("find every place we format dates"), it reads 30 files in its own room and returns a one-paragraph answer. The main conversation grows by a paragraph instead of 30 files. MCP connections work alongside: they give Claude tools for outside systems, such as reading a calendar, querying a database or checking a Home Assistant sensor.

The job

"Find every place we format dates"

30 files, 45,000 tokens

The subagent's own window

not used this time

Its task and instructions (4,000), then the files (45,000)

The main conversation

+400 tokens: only the summary

Read again on each of the next 10 turns: 4,000 tokens in all.

1 dot = 500 tokens, as in fig. 2. Each window holds 200,000 tokens. The main conversation already had 22,000 in it.

Show as text
Who reads the 30 filesAdded to the main conversationRead again over the next 10 turns
The main conversation45,000 tokens450,000 tokens
A subagent, in its own window400 tokens: only its summary4,000 tokens
fig. 5 The same 30 files, read in two places. In the main conversation they stay and are read again every turn. A subagent reads them in its own window and hands back a summary of 400 tokens.

Send big reading or searching jobs to a subagent; keep the main conversation for decisions.

06 · Your turn

Where does each rule belong?

Six rules a team might want. Three questions, asked in order, sort almost any rule: the first yes decides where it goes. Pick a rule, guess where it lands, then follow it down.

The rule

"Never use em dashes in anything you write."

Asked in orderWhere it goes

  1. 1Is it a long how-to for one kind of task?no

    SkillLoads only when a task matches it.

  2. 2Would one slip break something?no

    HookCode that runs every time and can block.

  3. 3Did Claude pick it up about you along the way?no

    MemoryNotes Claude keeps for next time.

  4. No to all three

    InstructionsShort rules loaded with every request.

A short rule for every task: instructions. A slip looks wrong but breaks nothing. If it keeps slipping, add a hook that checks the text.

Show as text

The three questions, in order: 1. Is it a long how-to for one kind of task? If yes: Skill. 2. Would one slip break something? If yes: Hook. 3. Did Claude pick it up about you along the way? If yes: Memory. No to all three: Instructions.

RuleAnswersMy pick and why
Never use em dashes in anything you write.1: no, 2: no, 3: noInstructions. A short rule for every task: instructions. A slip looks wrong but breaks nothing. If it keeps slipping, add a hook that checks the text.
Run the linter before every commit, no exceptions.1: no, 2: yesHook. "No exceptions" means code: a hook runs every time and can block the commit.
How we deploy: twelve steps, checks and rollback.1: yesSkill. Long know-how for one kind of task: a skill, so it only loads when you deploy.
Jasper prefers one question at a time.1: no, 2: no, 3: yesMemory. A preference learned along the way: memory. Promote it to instructions if it matters everywhere.
Our design tokens and how to use them in components.1: yesSkill. Detailed reference needed for UI work only: a skill.
Never push to the main branch directly.1: no, 2: yesHook. A safety line: a hook (or branch protection on the server) enforces it.
fig. 6 The first yes decides. A rule that gets three no's is a short rule for every task: it goes in your instructions.

Instructions for what always applies, skills for how-to, hooks for must-never, memory for what Claude learns about you.

Questions

Where should a rule go that Claude must never break?

In a hook. Instructions and skills are read by the model and can be missed; a hook runs as code every time.

What is the difference between a skill and CLAUDE.md?

CLAUDE.md is loaded with every request. A skill only loads when its description matches the task, so it can be long without costing anything the rest of the time.