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
-
Subagentsyou set up
not needed this time
MCP connectionsyou set up
not needed this time
-
Hooksyou write
Runs the linter before the commit.
-
Skillsyou write
The design skill loads: tokens and dark mode rules.
-
Toolsbuilt in
Reads six files, edits two, runs the build.
-
MemoryClaude writes
Its notes: Jasper wants a short summary at the end.
-
Instructionsyou write
Your rules: use our colour tokens, never use em dashes.
-
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:
- Model (made by Anthropic): Reads text and writes text. Knows nothing about your project until it is told.
- Instructions (you write): Plain-text rules (CLAUDE.md) loaded with every request: your global file plus the project file.
- Memory (Claude writes): Short notes Claude keeps about you and the project, loaded next time.
- Tools (built in): Read files, edit files, run commands, search. Each tool is described to the model in text.
- Skills (you write): Know-how for one kind of task. Only a one-line description is always loaded.
- Hooks (you write): Your own scripts that run before or after a tool. Code, not advice: they can block.
- 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.
| Request | Layers it switches on | You get back |
|---|---|---|
| Make the settings page work in dark mode | Tools: 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 dates | Tools: 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."
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
- +10You type the request. Eight words, about 10 tokens.
- +21,300The setup loads. System prompt and tool descriptions 16,000, instructions 3,500, skill descriptions 1,200, memory 600.
- +2,400A skill matches. The request fits the design skill's description, so its full text loads.
- +17,000Tools run. Six files read (14,000) and the build output (3,000).
- +150A hook checks. The linter fails, the commit is blocked and the error goes back to Claude.
- +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.
- You type the request: +10 tokens. Eight words, about 10 tokens.
- The setup loads: +21,300 tokens. System prompt and tool descriptions 16,000, instructions 3,500, skill descriptions 1,200, memory 600.
- A skill matches: +2,400 tokens. The request fits the design skill's description, so its full text loads.
- Tools run: +17,000 tokens. Six files read (14,000) and the build output (3,000).
- A hook checks: +150 tokens. The linter fails, the commit is blocked and the error goes back to Claude.
- 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.
- You type the request: +8 tokens. Six words, about 8 tokens.
- The setup loads: +21,300 tokens. The same setup as for any request, however small.
- No skill matches: +0 tokens. Nothing new loads. The one-line descriptions are already in the setup.
- Tools run: +1,400 tokens. One file read, one word changed.
- A hook checks: +40 tokens. The linter passes, so nothing is blocked.
- 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.
- You type the request: +10 tokens. Eight words, about 10 tokens.
- Turn 1 is read again: +43,360 tokens. Everything from the dark mode request comes along: setup, skill, files, output and answer.
- The skill is still there: +0 tokens. The design skill loaded in turn 1, so it costs nothing new.
- Tools run: +12,000 tokens. The profile page and its styles, plus the build.
- A hook checks: +40 tokens. The linter passes this time.
- The answer: +1,800 tokens. The change and a short summary.
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.
Full text loads: 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.
-
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
No description fits this request, so no skill loads.
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
| Request | Matching description | What loads |
|---|---|---|
| Make the settings page work in dark mode | design-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 staging | deploy: 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? | None | Nothing 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.
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
- Claude commits. The hook runs the linter first, as it does every time.
- Blocked: lint failed, 1 error in Settings.tsx line 42. The reason goes back to Claude.
- 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.
- Step 1 of the session: "always lint before committing". By step 40 it is one line among thousands.
- Claude commits. Nothing checks it, and this time the lint step is missed.
- The commit lands with 1 lint error in Settings.tsx.
With a hook. The commit lands: lint clean.
- Claude commits. The hook runs the linter first, as it does every time.
- Blocked: lint failed, 1 error in Settings.tsx line 42. The reason goes back to Claude.
- Claude removes the unused import and commits again. The linter passes.
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 files | Added to the main conversation | Read again over the next 10 turns |
|---|---|---|
| The main conversation | 45,000 tokens | 450,000 tokens |
| A subagent, in its own window | 400 tokens: only its summary | 4,000 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
-
1Is it a long how-to for one kind of task?no
SkillLoads only when a task matches it.
-
2Would one slip break something?no
HookCode that runs every time and can block.
-
3Did Claude pick it up about you along the way?no
MemoryNotes Claude keeps for next time.
-
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.
| Rule | Answers | My pick and why |
|---|---|---|
| Never use em dashes in anything you write. | 1: no, 2: no, 3: no | Instructions. 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: yes | Hook. "No exceptions" means code: a hook runs every time and can block the commit. |
| How we deploy: twelve steps, checks and rollback. | 1: yes | Skill. 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: yes | Memory. 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: yes | Skill. Detailed reference needed for UI work only: a skill. |
| Never push to the main branch directly. | 1: no, 2: yes | Hook. A safety line: a hook (or branch protection on the server) enforces it. |
Instructions for what always applies, skills for how-to, hooks for must-never, memory for what Claude learns about you.