# Mission 15.4: Our CLAUDE.md has 400 lines. Why doesn’t Claude follow it?

Part of the course “AI from Zero to Autonomous Agents” (https://llm.yoga/en). Web page: https://llm.yoga/en/einsatz-15-4

Part of [Chapter 15: Wrappers and harnesses](https://llm.yoga/en/15-wrapper-harness.md).

Structure: case, explanation, hands-on part, check questions, and wrap-up. The answers to all questions are collected at the end.

## The case

**Martin**, sales analyst:

> “Our team writes reports with Claude Code. I put everything we need into our CLAUDE.md: ten procedures, from the customer report to the quarterly analysis, plus how to pull revenue figures from the CRM, 400 lines by now. Claude still mixes up the outlines, and last week it overwrote an approved report in the freigegeben/ folder, even though line 212 forbids exactly that. Should I put the important rules in bold and all caps?”

`CLAUDE.md` is a project’s instruction file, which Claude Code reads at the start of every session. Martin wants to know what to change in his file. The folder name freigegeben is German for approved.

**Question 1 (decision):** What do you advise Martin?

- A) Yes, put the rules in bold and move them to the very top of the file.
- B) Move the procedures into skills and turn the ban into a hook.
- C) Split the file into ten parts and pull them back in with imports.

## What’s behind it

Imagine someone reading the department’s entire handbook aloud to a new colleague every morning before she answers her first question. The important parts get lost. A long `CLAUDE.md` works the same way, because Claude Code reads all of it at the start of every session. The documentation recommends fewer than 200 lines, because longer files take up more context and are followed less reliably. If two instructions contradict each other, Claude might pick one of them arbitrarily.

For procedures, there are **skills**. A skill is more like an onboarding binder that you open only when the task comes up. It’s a folder with a `SKILL.md` file whose header holds a name and a description. Only those two items stay in the context permanently. Claude loads the instructions only when a request matches the description, and a template in the folder only when the instructions call for it. That is why the description decides whether the skill gets used. If Claude Code has summarized a long conversation, invoking the skill again brings back all of its instructions. A third-party skill can bring scripts along and use the header field `allowed-tools` to approve tools without asking you.

A **hook** is a script that the harness, here Claude Code, runs on a defined event, for example before every write. It can block writes to `freigegeben/` regardless of what the model is paying attention to. The model reads the prompt, `CLAUDE.md`, and skills and decides for itself what to do with them. The harness, by contrast, enforces a hook like this every time.

So Martin’s 400 lines can be split up. `CLAUDE.md` keeps a few facts that every session needs, such as the filing folder and the language. The ten report procedures become ten skills with clear descriptions, and the ban on overwriting approved reports becomes a hook. Claude gets revenue figures from the CRM, the sales team’s customer database, through an MCP server that offers it a tool for that.

### In more detail: what is in the context, and when

According to the specification of the open Agent Skills format, the name and description take up about 100 tokens per skill. For the instructions, it recommends under 5,000 tokens and under 500 lines. Longer reference material belongs in separate files in the skill folder, which the model reads only when needed. Source: [Agent Skills Specification](https://agentskills.io/specification). When a script from the folder runs, only its output enters the context ([Agent Skills in the Claude documentation](https://platform.claude.com/docs/en/agents-and-tools/agent-skills/overview)).

By default, Claude Code limits the list of all skills to 1 percent of the context window. In this list, each description, together with the `when_to_use` field, is cut to 1,536 characters. If the list still gets too long, Claude Code drops the descriptions of rarely used skills first. A loaded skill stays in the context on later turns. When Claude Code summarizes a long conversation, it reattaches at most the first 5,000 tokens of each skill’s most recent invocation, and at most 25,000 tokens for all of them combined. It fills this budget starting with the most recently invoked skill, so older ones can drop out entirely. That is why the most important instructions belong at the top. Source: [Claude Code documentation: Skills](https://code.claude.com/docs/en/skills), as of November 27, 2026.

A hook that runs before the tool call (PreToolUse) blocks the pending call with exit code 2 ([chapter 16](https://llm.yoga/en/16-agenten-3.md)). It only applies to the tools it is registered for. A hook on the write tool therefore doesn’t catch a copy made with a shell command. For a reliable block, the documentation recommends a hook that runs a script, with the setting `onFailure: "block"` so that the action is stopped even if the script crashes ([Best practices](https://code.claude.com/docs/en/best-practices)). A hook that runs after the call can no longer undo a write.

### How tybo does it: the same skills for Codex

tybo, the assistant used as an example throughout this course, starts Claude Code by default and can switch to Codex ([chapter 15](https://llm.yoga/en/15-wrapper-harness-5.md)). So that Codex can use the same procedures, tybo takes every suitable skill in the project’s `.claude/skills/` and in `~/.claude/skills/` and creates a symbolic link to it in the project’s `.agents/skills/`, the folder where Codex looks for skills. It copies nothing and rewrites neither `SKILL.md` nor the configuration of Claude Code or Codex. Only the original file is maintained.

tybo links a folder only if its `SKILL.md` has a header with a non-empty `description` within the first 8 KiB. If the same name exists in the project and in the personal folder, the project skill wins, and skills with the same name that Codex already knows, for example from `~/.agents/skills/`, take precedence. Fields that only Claude Code understands, such as `user-invocable` or `argument-hint`, didn’t keep the skill from loading under Codex (tested with Codex CLI 0.169.0). They don’t make Claude-specific tools available there, though. You can turn this off with `"skills": false` under `engine.codex` in `config/settings.json`. OpenCode finds the skills on its own. Sources: `docs/erweiterungen.md`, section „Skills für Codex“ (skills for Codex), and `src/lib/engines/codex-skills.ts` in the tybo repo.

## Try it

**Sort: where each line belongs**

**Task:** Assign each item from Martin’s `CLAUDE.md` to the place where it belongs.

Categories: CLAUDE.md · Skill · Hook · MCP server

1. Reports go in berichte/, and file names start with the date.
2. Outline and steps for the customer report after a meeting, with a template.
3. Never overwrite a file in the freigegeben/ folder.
4. Quarterly analysis with a Python script that totals the figures from the CRM export.
5. Fetch current revenue per customer from the CRM.
6. Reports are in German, and customers are addressed formally.
7. Checklist for the competitor comparison, 80 lines, needed twice a year.

## Check

**Question 2 (check question):** Martin sets up the customer report as a skill named kb3, with the description “Helps with reports.” Sometimes Claude uses the skill, sometimes it doesn’t. What is the most likely reason?

- A) Claude loads skills only when someone invokes them by name.
- B) The description doesn’t say which reports and requests are meant.
- C) The instructions are too long; past 500 lines, Claude stops reading.

**Question 3 (check question):** A colleague finds a skill online that typesets reports as PDFs and includes a script. What do you check before using it?

- A) The description is enough, since that’s all Claude sees before loading.
- B) Every file in the folder, especially scripts, URLs, and allowed-tools.
- C) The location, since a project skill works only in its own repository.

**Question 4 (check question):** In a long session, Claude Code has summarized the conversation. After that, Claude skips step 4 of the customer report skill. What does the documentation recommend in this case?

- A) Invoke the skill again and move key points to the top of SKILL.md.
- B) Copy the skill into CLAUDE.md and put the rule there in bold.
- C) Make the description longer and repeat step 4 in it.

## Done

**What you can do now**

- You can explain why a long `CLAUDE.md` is followed less reliably and what a skill changes about that.
- You can sort instructions into `CLAUDE.md`, skills, hooks, and MCP servers.
- When a skill doesn’t load reliably, you check its description first. You audit a third-party skill file by file before using it.

### Two cards for review

**Card 1:** True or false? “The more detailed your CLAUDE.md, the more closely Claude follows every procedure in it.”

**Card 2:** By default, what does the model have in its context from a skill before the skill is used?

- A) Only the name and description
- B) The entire SKILL.md file
- C) Every file in the skill folder
- D) Nothing until you invoke it with /name

- [Next mission: Cancel order 4711 if it has not shipped](https://llm.yoga/en/einsatz-16-1.md)
- [Try it on your Mac](https://llm.yoga/en/mac-15-4.md)

## Read more in the chapter

The detailed text in the chapter, with step-by-step reasoning and sources:

- [Skills](https://llm.yoga/en/15-wrapper-harness-2.md)
- [What a harness adds](https://llm.yoga/en/15-wrapper-harness-2.md)
- [Supply chain: MCP servers, skills, and extensions](https://llm.yoga/en/18-sicherheit-3.md)

## Answers: reveal them only after the learner has answered or explicitly asks

**Question 1:** The correct answer is B.
- A: According to the documentation, adding IMPORTANT to a line Claude keeps ignoring probably won’t fix it, because the line gets lost in a long file or is a rule that can’t have exceptions. All 400 lines would still sit in the context in every session, and a rule in bold doesn’t block a write either.
- B, correct: Then only each procedure’s description stays in the context permanently, and the rest is added when a request matches. A script checks the ban before every write, no matter what the model is paying attention to.
- C: With references of the form `@path`, a `CLAUDE.md` pulls in other files. That makes the file easier to manage but doesn’t reduce what’s in the context. According to the documentation, imported files load together with the `CLAUDE.md` that imports them.

- Card 1: **CLAUDE.md:** The folder name berichte means reports. This short convention applies in every session and to every report. It’s one of the few facts that should stay in the context permanently.
- Card 2: **Skill:** This is a multi-step procedure for a particular task. As a skill, only its description stays in the context permanently. The instructions are added for a customer report, and the template only when the instructions call for it.
- Card 3: **Hook:** This rule has to hold without exception. A hook before every write blocks the call even when the model happens to overlook the rule.
- Card 4: **Skill:** This is also a procedure for a particular occasion. The script sits in the skill folder and runs there, and only its output enters the context.
- Card 5: **MCP server:** This isn’t a procedure but access to data from outside. For that, an MCP server offers the model a tool ([chapter 12](https://llm.yoga/en/12-integrationen.md)).
- Card 6: **CLAUDE.md:** This applies to all ten report types and is short. If it were in every skill, the team would have to maintain it in ten places.
- Card 7: **Skill:** It’s long and rarely needed. In CLAUDE.md it would sit in the context in every session; as a skill, only when a competitor comparison comes up.

**Question 2:** The correct answer is B.
- A: By default, Claude can also load a skill on its own when a request matches the description. Invoking it by hand is the second way, not the only one.
- B, correct: Before loading, Claude sees only the name and description. “Helps with reports” doesn’t say which reports are meant, so whether the skill loads depends on how the request is worded. A descriptive name such as kundenbericht (customer report) sometimes makes up for that, but Martin can’t count on it.
- C: 500 lines is a recommendation for the length of `SKILL.md`, not a limit past which Claude stops reading. Besides, Claude sees the instructions only after it has loaded the skill.

**Question 3:** The correct answer is B.
- A: That’s true before loading, but afterward Claude reads all the instructions, and scripts run with the session’s permissions. Anthropic advises auditing third-party skills completely.
- B, correct: A third-party skill brings instructions and code with it. A project skill can use `allowed-tools` to approve tools without asking for permission, according to the documentation even with `-p` in a folder that isn’t trusted ([chapter 18](https://llm.yoga/en/18-sicherheit-3.md)).
- C: The location determines who gets the skill, not whether it’s safe. A project skill even affects everyone who works in the repository.

**Question 4:** The correct answer is A.
- A, correct: After a summary, Claude Code reattaches at most the first 5,000 tokens of each skill, and if many skills were invoked, older ones can drop out entirely. Invoking it again brings back the full text. If the rule has to hold without exception, it belongs in a hook.
- B: That would take Martin back to where he started: everything would sit in the context in every session, and the file would grow even longer. According to the documentation, emphasis probably won’t help either.
- C: The description decides whether the skill is loaded. It doesn’t change how closely Claude follows the loaded instructions, and a longer description takes up more space in every session.

**Card 1:** **False.** Claude Code reads all of `CLAUDE.md` at the start of every session. The documentation recommends fewer than 200 lines, because longer files take up more context and are followed less reliably. Procedures for particular tasks belong in skills. Rules that must be enforced without exception belong in a hook.

**Card 2:** Correct: A, Only the name and description At startup, the harness loads only the name and description of each skill, about 100 tokens according to the specification. The instructions are added when a request matches the description, and other files only when needed. That is why the description decides whether the skill gets used. Only with `disable-model-invocation: true` does the description stay out as well.
