First Setup: What Changes with a Single CLAUDE.md

작성자

카테고리:

← 피드로
DEV Community · Sungsoo Youn · 2026-09-05 개발(SW)

This is chapter 2 of my book **Building Autonomous AI Agents with Claude Code* — a field guide to turning Claude Code from a coding assistant into an agent that remembers, verifies its own work, and knows when to stop. Everything below is from a system I actually run every day on one Windows PC.*

1. CLAUDE.md Is a “Contract Read Every Time”

Every time Claude Code starts a session, it injects the global settings (~/.claude/CLAUDE.md) and the project’s
CLAUDE.md into the system context. In other words, every sentence written here is a standing instruction that
automatically attaches to every conversation
. This property is both the strength and the trap.

The strength is clear. You gain “things you no longer have to say every time.”
The trap is this: every sentence written here competes with every other one, every turn.

2. Shorter Gets Followed — A Fact Confirmed by Measurement

There is a common failure path. Rules pile up one by one past 1,000 lines, and at some point the AI
starts missing the most important rules. Inside a long document, instructions bury each other.

In actual operation, when we removed a general-purpose rule set that had grown past 1,300 lines and cut the injected volume by about 89%,
compliance with the core rules went up noticeably. The attempt to raise compliance by adding
more rules had itself been the cause.

Keep only “things that cause real damage when violated” in CLAUDE.md, and move everything else out.

One counterintuitive case is worth adding. We once listed the “expressions not to use” in the rules —
and then removed the list. Showing those words every turn was actually producing an imprinting effect.
The list now lives in a separate file, and a checker filters output just before it is sent.
Writing something in the rules and blocking it with a system are different things.

3. Split into a Three-Layer Structure

Layer File What it holds Size guideline Global ~/.claude/CLAUDE.md Identity, tone, security, prohibitions common to all projects Under 100 lines Rule fragments ~/.claude/rules/*.md Rules by topic (encoding, paths, DB) Under 30 lines per file

The reason for splitting off rule fragments is to load them only when needed. The DB rules only
need to be present when you touch the DB. If they are always injected, they take up space that other rules need.

4. Three Traits of a Well-Written Rule

① It can be verified through behavior.

Enter fullscreen mode Exit fullscreen mode

“Be careful” cannot be verified. The AI cannot judge whether it was careful, either.

② It carries a one-line reason.

Enter fullscreen mode Exit fullscreen mode

When the AI knows the reason, it keeps the intent even in situations the rule didn’t anticipate. A rule
without a reason gets dismissed as “doesn’t apply in this case” the moment the situation shifts slightly.

③ It states a replacement behavior, not just a prohibition.

Enter fullscreen mode Exit fullscreen mode

With only a prohibition, the AI improvises a creative workaround at the blocked spot. That workaround is
usually worse.

5. What Must Go into the Project CLAUDE.md

The global file differs from person to person, but there are things every project file should share.




Enter fullscreen mode Exit fullscreen mode

The “confirmed facts (do not ask again)” section is surprisingly effective. If you have been asked the same
question three times, write the answer here. Then there is no fourth time.

6. Signals When Rules Keep Growing

If your rule file is growing, check the following.

Signal Response Three or more rules on the same topic are scattered around Bundle them into a rule fragment file and move them out A rule contains “as an exception” That rule is already wrong — rewrite its condition A rule keeps being ignored Don’t rewrite the sentence — turn it into a hook (Chapter 4)

The last row is the key. If saying it three times doesn’t work, build it into the structure. Rewriting a rule
in a stronger tone almost never works.

Want the whole system? The book has 10 chapters plus 4 ready-to-use templates (CLAUDE.md starter, memory files, auditor checklist, measurement guide) and a hands-on section for every chapter. It’s $9.99 as a PDF: https://dbsoul.gumroad.com/l/autonomous-ai-agents-claude-code

Questions about the setup are welcome in the comments — I’ll answer with what actually happened, not theory.

원문에서 계속 ↗