---
title: "Writing CLAUDE.md the right way"
url: "https://zuey.me/articles/viet-claude-md-cho-dung?lang=en"
locale: en
access: members
full_text: false
published_at: "2026-08-02T02:00:00.000Z"
tags: ["Claude Code", "AI", "Programming"]
translations:
  vi: "https://zuey.me/articles/viet-claude-md-cho-dung.md?lang=vi"
  zh: "https://zuey.me/articles/viet-claude-md-cho-dung.md?lang=zh"
  ko: "https://zuey.me/articles/viet-claude-md-cho-dung.md?lang=ko"
  ja: "https://zuey.me/articles/viet-claude-md-cho-dung.md?lang=ja"
---
# Writing CLAUDE.md the right way

> 4 studies, thousands of real agent runs: CLAUDE.md barely helps agents solve tasks, yet it bumps cost by 20%+. So how do you write it right, and why did I pull the default file out of AgentKit?

*4 studies, 1 filter, and why I pulled the default `CLAUDE.md` out of AgentKit.*

More than 60,000 open-source repos have an AGENTS.md or CLAUDE.md file in their root.

And 4 independent studies, thousands of real agent runs on real repos in total, all land on the same jaw-dropping conclusion: those files **barely improve task success rates**. Some even make it worse. And almost all of them **push inference cost up by more than 20%**.

A while ago I read the papers, then tested things every which way, and in the end I made a call: rip the default `CLAUDE.md`/`AGENTS.md` file out of AgentKit entirely...

I bet a lot of you are about to close this tab and go delete the file. Hold on. Read to the end first! 😁

I read all 4 papers carefully, and here's my thesis: **CLAUDE.md is not knowledge memory, it's process memory.** It doesn't make the agent smarter (no markdown file can do that), but it does steer the agent's *behavior*, and behavior is exactly where you're burning money. The problem is that 90% of the `CLAUDE.md` files out there are written with the useless part and skip the part that actually works.

This post is about rewriting it the right way, based on data & experiments, not on gut feeling.

---

### TL;DR

- Evidence: context files do **not** improve correctness (3 independent studies), but they **do** change agent behavior in a measurable way.
- Agents fail because they lack **implementation skill**, not because they lack knowledge about the repo. A markdown file can't fix the former.
- Agents follow instructions (commands) really well. Overviews (scenery descriptions) are useless, and that's measurable.
- A context file is only valuable when it's the **only source of that information**. Duplicating existing docs/README = zero value, positive cost.
- Every line costs something: +20-23% cost, +14-22% reasoning tokens. So every line has to "earn its place".
- The fix: a 4-question filter, splitting files into `.claude/rules/` with path scoping, and pushing anything mandatory down into settings/hooks instead of writing it in markdown.

---

### 1/ The four studies I found most valuable

A few months ago I read a few others too, but with today's models they're all outdated. These 4 recent ones are the ones I find the most accurate (at least for me):

**Lulla et al., January 2026** (University of Canterbury, King's College London, Bayreuth, Singapore Management University). 10 repos, 124 pull requests, running agents with and without AGENTS.md. Result: median runtime **down 28.64%**, output tokens **down 16.58%**, task completion about the same. Their conclusion: the file helps with *efficiency*.

Paper: [arXiv:2601.20404](https://arxiv.org/abs/2601.20404)

**Gloaguen, Mündler, Müller, Raychev, Vechev, February 2026** (ETH Zurich's SRI Lab, the same shop LogicStar came out of). This is the heaviest paper of the bunch. They built a whole new benchmark called AGENTbench: 138 instances from 12 *lesser-known* Python repos that have context files written by their own developers, plus SWE-bench Lite. Four agents: Claude Code with Sonnet-4.5, Codex with GPT-5.2 and GPT-5.1 mini, Qwen Code with Qwen3-30b-coder.

Result: **hand-written** files by developers improved things by **+4%** on average. Files **generated by an LLM** (the `/init` kind) made things **3% worse**. Both types **raised cost by 20-23%**.

Paper: [arXiv:2602.11988](https://arxiv.org/abs/2602.11988)

**Khatri, July 2026** (independent researcher, single author). 288 runs graded with gold tests, 17 tasks, 3 repos, 2 agents. The independent variable is *how context is fed in*: nothing at all, the full file stuffed into the system prompt every turn, or a wiki the agent reads on its own. Pass rates: 53.3% / 55.6% / 55.6% for Claude. The difference is within noise.

**Claude's pass rate by context delivery mode (Khatri, %)** (bar chart)

| Label | Pass rate (%) |
| --- | --- |
| No context file | 53.3 |
| Full file in system prompt | 55.6 |
| Wiki the agent reads itself | 55.6 |

Paper: [arXiv:2607.27250](https://arxiv.org/abs/2607.27250)

**Chatlatanagulchai et al., November 2025** (NAIST, Queen's University, Kasetsart). They didn't measure effectiveness; they surveyed **2,303 context files from 1,925 repos**. Their finding: devs prioritize implementation details (69.9%), architecture (67.7%), build/run commands (62.3%). Security and performance? Only 14.5% each.

**What devs write in context files (% of 2,303 files)** (bar chart)

| Label | % of files with this content |
| --- | --- |
| Implementation details | 69.9 |
| Architecture | 67.7 |
| Build/run commands | 62.3 |
| Security | 14.5 |
| Performance | 14.5 |

Paper: [arXiv:2511.12884](https://arxiv.org/abs/2511.12884)

| Paper | Scale | What it measures | Key result |
| --- | --- | --- | --- |
| Lulla et al. (1/2026) | 10 repos, 124 PRs | Efficiency | Runtime **-28.64%**, output tokens **-16.58%**, similar task completion |
| Gloaguen et al., ETH (2/2026) | AGENTbench 138 instances / 12 repos + SWE-bench Lite, 4 agents | Correctness | Hand-written by devs **+4%**, LLM-generated **-3%**, cost **+20-23%** |
| Khatri (7/2026) | 288 runs, 17 tasks, 3 repos, 2 agents | Mechanism (how context is fed in) | 53.3% / 55.6% / 55.6%, within noise |
| Chatlatanagulchai et al. (11/2025) | 2,303 files from 1,925 repos | What devs put in the file | Architecture 67.7%, security & performance only 14.5% |

If you only skim, paper 1 says "it helps" while papers 2 and 3 say "it doesn't". But read closely and **all three measure three different things**: efficiency, correctness, and mechanism. They don't conflict. Quite the opposite, they piece together into a clearer signal.

And paper 4 explains why you're writing it wrong: the thing devs write the most (architecture, 67.7%) is exactly what the data says is the most useless.

---

### 2/ Why doesn't a markdown file make the agent code better?

Khatri did something I find more valuable than the pass-rate number: **failure-mode triage**. He pulled out the tasks where the agent failed only 1-4 gold tests (the closest to passing, the most likely to flip if you add exactly one piece of information), and dissected each one:

- A task needed a union-expansion optimization. The agent built the whole optimization pass but slipped in a correctness bug. **Missing: technical precision.**
- A task needed proactive auth-token refresh. The agent implemented reactive retry. **Missing: the right architectural pattern choice.**
- A task needed to reject V2 validator arguments. The agent *knew* the V3 rule (it read it from the code), but wired it in the wrong place. **Missing: a precise behavioral spec.**

None of them failed for lack of a *fact* that a markdown file could provide.

Then he ran a "manipulation probe": took the two closest-to-passing tasks, reran them 3 times, in all 3 modes, on both agents, 36 cells. Result: **the real AGENTS.md file never once turned a near-miss into a pass**, on any agent.

This is where I see a lot of people get it wrong. The conclusion isn't "context files are useless". It's: **context files can't replace model capability.** Knowledge, the model already has plenty of. Skill, not so much.

And today's agents are **bottlenecked on skill**, not on knowledge.

The consequence: if the agent is getting the architecture wrong, writing another 300 lines of `CLAUDE.md` explaining the architecture won't save you one bit. What you SHOULD do is break the task down, write a clearer spec, **make the architecture agent-friendly**, or simply... switch models.

> **WARN:** **Don't pour more markdown into a problem that isn't a markdown problem.**

---

### 3/ Three findings that decide how to write it

So how should you write it? If you only remember three things from this post, remember these:

#### 3.1. Commands get followed. Prose gets tossed.

The ETH team measured how often tools got called depending on whether the tool was mentioned in the context file:

- `uv`: called **1.6 times/instance** when mentioned in the file, versus **under 0.01 times** when not.
- Repo-specific tooling: **2.5 times/instance** when mentioned, versus **under 0.05 times** when not.

That's a gap of more than 100x. Instruction-following is not a problem at all for today's top models. Agents read and obey like good kids.

But when they measured overviews, it was the opposite. The method (pretty clever): count how many steps the agent takes before *touching the first file that's in the original PR patch*. If overviews actually guide the way, that number should drop. Result on both **SWE-bench Lite** and **AGENTbench**: **no significant drop** :)))

Of the 12 developer-written files in **AGENTbench**, 8 had an overview section and 4 listed the whole directory tree. **Useless.**

LLM-generated files were even worse: **100%** of files generated by Sonnet-4.5 had an overview, 99% for GPT-5.2, 95% for Qwen3.

> **TIP:** **Principle 1: write commands, not scenery descriptions.** "Run tests with `pnpm vitest run`" works. "The project has 3 modules, module A is responsible for handling..." doesn't.

#### 3.2. A context file is only valuable when it's the single source of truth (SSOT)

This is my favorite experiment in all 4 papers. Because it's the exact same expensive lesson I wrote about recently, on what happens when you worship SDD (Spec-driven Development)...

The ETH team suspected context files are useless because they **duplicate** existing docs. So they did something simple: delete every `.md` file, all example code, and the `docs/` folder from the repo *after* generating the context file, then reran.

*(Yup, I've done that too, deleted all the redundant ADRs & plans)*

Under those conditions, LLM-generated files **improved performance by 2.7%** and even beat the human-written ones.

Meaning: the agent doesn't need you to *retell* what it can read on its own. It needs what it **can't** read. And that also explains why the community's "assumptions" drift from the data: people see `CLAUDE.md` actually working because their repos have few docs. Benchmarks, on the other hand, all run on well-documented repos.

---

*Phần còn lại dành cho thành viên có quyền đọc toàn bài (Knowledges, Kết hợp, Cộng đồng) — see plans at https://zuey.me/pricing*
