이 페이지는 아직 번역되지 않았습니다 — 영어 버전을 표시합니다.

A CLAUDE.md that follows

강의 27분
Sign in to save your progressYou can keep reading without an account, but completed lessons won't be saved.
Sign in

A CLAUDE.md that follows

Here's a trap that catches almost everyone: your CLAUDE.md file keeps growing. You hit a problem, you add a rule. You hit another, you add another rule. Before long you've got one giant file, and Claude starts ignoring parts of it. That's not a bug in Claude. It's how the file works.

The key thing to understand is that CLAUDE.md is not enforced configuration. It's guidance. Every line competes with every other line for Claude's attention. The longer the file gets, the more it competes with itself, and the less reliably Claude follows any single rule. So the goal isn't to write down everything. The goal is to keep the file tight. The leaner the file, the more of it Claude actually follows.

한국어 대본
  • 00:00CLAUDE.md 파일은 강제되는 설정이 아닙니다. 즉, 하나의 거대한 파일에 계속 추가할수록,
  • 00:06Claude가 이를 올바르게 따르기 어려워집니다. CLAUDE.md 파일을 간결하게 유지하면서
  • 00:11지침을 훨씬 안정적으로 따르게 하는 방법은 다음과 같습니다. 간단히 말하면 파일이 길어질수록,
  • 00:18서로 경쟁해야 할 내용이 많아집니다. 먼저 CLAUDE.md가 작업에 맞는 도구인지 확인하세요.
  • 00:23main에 절대 푸시하지 말라는 하드 규칙은 pre-tool use hook에 두는 편이 좋습니다. 훅은
  • 00:28Claude가 실제로 시도하더라도 푸시를 중단하도록 설계되었습니다. Claude MD 파일은 프로젝트 파일에만
  • 00:34존재하는 것이 아닙니다. 다른 곳이 세 군데 더 있습니다. 먼저 관리형 정책, 다음은 사용자 파일,
  • 00:39그다음 프로젝트 파일, 마지막은 로컬입니다. Claude는 모든 메모리 파일을 함께 로드합니다. 빠지는 것은 없고
  • 00:44조직 정책은 항상 적용됩니다. 로컬은 이 프로젝트에서만 필요한 설정에 사용합니다. 예를 들어
  • 00:50스프린트 범위를 벗어나 리팩터링하면서 Claude가 아키텍처 결정을 기억하도록 하려면,
  • 00:54공유 프로젝트 파일이 아니라 로컬에 넣으세요. claude.md 파일을 더 쉽게 유지 관리하려면,
  • 01:01path to file 구문을 사용해 지침을 나누세요. 다만 이것이 무엇을 해 주는지는 알아야 합니다.
  • 01:06Claude는 시작할 때 가져온 파일을 이를 참조하는 파일 바로 옆에서 인라인으로 확장합니다.
  • 01:11가져오기를 사용하면 큰 claude.md 파일을 정리할 수 있지만, 모든 내용은 여전히 처음에 로드되며
  • 01:15컨텍스트가 줄어들지는 않습니다. 따라서 claude.md 파일 자체를 훨씬 짧게 만들 수 있습니다. Claude가 이를 따를지는
  • 01:23표현에 달려 있으며, 대부분의 규칙은 너무 모호해서 실패합니다. 먼저 구체적이고 확인 가능하게 작성하세요.
  • 01:28'모범 사례를 따르세요' 같은 내용을 넣지 마세요. 그것이 무슨 뜻인지 알 수 있습니까? 그렇다고
  • 01:33claw가 마법처럼 알아서 하기를 기대하지 마세요. 새 API 라우트와 소스 API 핸들러를 파일마다 하나씩 넣으세요. 이렇게 하면 명확합니다.
  • 01:40그러니 대신 이렇게 작성하세요. 교체 대상을 명시하세요. default exports를 사용하지 말라는 말만 하면 대안이 열려 있습니다.
  • 01:45default exports가 아니라 named exports를 사용하라고 하면 그런 오해의 여지를 닫을 수 있습니다.
  • 01:49그리고 강조에도 예산이 있다는 점을 깨달으세요.
  • 01:53Important와 you must는 규칙의 우선순위를 높이지만, 주변의 덜 강조된 모든 내용에 상대적으로만 높입니다.
  • 01:59위반했을 때 문제가 되는 두세 가지 규칙에 사용하세요.
  • 02:02파일도 계속 수정해야 합니다.
  • 02:04Claude가 잘못된 동작을 하면 Claude.md 파일에 대한 버그 리포트로 여기세요.
  • 02:09Claude에게 Claude.md 파일에 추가하라고 말하면 그 규칙을 대신 작성합니다.
  • 02:13Claude MD 파일을 프로덕션 코드처럼 다루세요.
  • 02:20한 줄을 정당화할 수 없다면 삭제하세요.
  • 02:23강제 적용은 훅으로 옮기고, 가져오기로 정리하고, 경로별 규칙의 범위를
  • 02:28규칙에 지정해 적용될 때만 로드되도록 하세요.
  • 02:31파일이 간결할수록 Claude가 더 많은 내용을 따릅니다.
Watch on YouTube

First, ask if CLAUDE.md is even the right tool

Before you write a rule, ask whether it belongs in CLAUDE.md at all. Some rules are guidance, and some rules are hard lines that must never be crossed. Those are two different jobs.

Take a rule like "never push to main." If you put that in CLAUDE.md, you're hoping Claude reads it and respects it. Most of the time it will. But "most of the time" isn't good enough for something that dangerous. A hard rule like that belongs in a pre-tool-use hook instead.

The difference matters. A hook is code that runs before Claude takes an action, and it can actually block the action. So even if Claude does try to push to main, the hook stops it. That's real enforcement, not a polite request. Move your hard rules to hooks and let CLAUDE.md handle the softer conventions.

The four locations

CLAUDE.md isn't just one file sitting in your project. There are four places it can live, and Claude loads all of them together at launch. Nothing gets dropped, and they stack.

Here's what each one is for:

  • Managed policy — the org-level file your platform team controls. You can't exclude it, so org policy is always in play.
  • User — your personal preferences that follow you across every project on your machine.
  • Project — the file shared with your team, checked into the repo.
  • Local — ignored by git. Your personal notes for this one repository only.

That last one, local, is easy to overlook but really handy. Say you're refactoring off in your own branch and you want Claude to hold some architectural decisions in mind while you work. That doesn't belong in the shared project file where it'd affect your whole team. It goes in local, where it's just yours for this repo.

Split up a big file with imports

When your project file starts getting long, you can break it into pieces using the path-to-file import syntax. Instead of one wall of text, you point to other files:

@.claude/conventions/code-style.md
@.claude/conventions/testing.md
@.claude/conventions/workflow.md

This is great for organizing. But know exactly what it buys you, because it's easy to get the wrong idea. When Claude launches, it expands those imported files inline, right where you referenced them. So imports help you keep things tidy, but everything still loads up front. They do not reduce the amount of context Claude has to read. Use imports to organize, not to shrink the load.

Phrasing is what makes rules stick

Once you've decided a rule belongs in CLAUDE.md, whether Claude actually obeys it comes down to how you phrase it. Most rules fail because they're vague. Here's how to fix that.

Be specific and checkable

Don't write "follow best practices." Do you even know exactly what that means? If you can't check whether it was followed, neither can Claude. Compare these two:

  • Vague: "Follow best practices for API routes."
  • Specific: "Put new API routes in src/api/handlers, one per file."

The second one is explicit. You can look at the result and immediately tell if it was done right. That's the bar every rule should clear.

Name the replacement, don't just ban something

When you tell Claude not to do something, say what to do instead. Otherwise you've left the door open.

  • Leaves it open: "Don't use default exports." Okay, but then what?
  • Closes it: "Use named exports, not default exports."

The second version names the replacement, so there's nothing left to misinterpret.

Emphasis is a budget

Words like "IMPORTANT" and "YOU MUST" do raise a rule's priority. But only relative to everything quieter around it. If every rule shouts, then nothing stands out and the emphasis means nothing. So treat emphasis like a budget. Spend it on the two or three rules that really hurt when they get broken, and let the rest sit at normal volume.

Keep the file under revision

Your CLAUDE.md file is never finished. Treat it like living code that keeps getting edited.

When Claude does the wrong thing, don't just sigh and fix it by hand. Treat it as a bug report against your CLAUDE.md file. You can even tell Claude directly: "add that to the CLAUDE.md file," and it'll write the rule for you. That way the file gets better every time something goes wrong.

The bottom line

Treat your CLAUDE.md like production code. If you can't justify a line, delete it. To keep the file lean and followable:

  1. Move hard rules to hooks, where they're actually enforced.
  2. Organize long files with imports (just remember they don't reduce context).
  3. Make every rule specific and checkable, and name the replacement.
  4. Spend your emphasis budget on the few rules that matter most.
  5. Keep revising the file whenever Claude gets something wrong.

The whole idea is simple. The leaner the file, the more of it Claude follows.