0Pricing
Claude Architect · Lekcja

Poziomy użytkownika, projektu i katalogu

Gdzie znajduje się każdy plik CLAUDE.md i kogo dotyczy

Poziomy użytkownika, projektu i katalogu to bezpłatna lekcja Claude Architect na CoddyKit. To lekcja 1 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Claude Architect, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Claude Architect zawiera 4 lekcji w sumie.

Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.

Three Places a CLAUDE.md Can Live

Claude Code reads memory from three levels, and each one answers a different question: who does this rule apply to?

  • User level — ~/.claude/CLAUDE.md: your personal preferences, on your machine only.
  • Project level — ./CLAUDE.md or .claude/CLAUDE.md: shared with the whole team via version control.
  • Directory level — a CLAUDE.md inside a subfolder: scoped to that subtree only.

Knowing which file a rule belongs in is a core Claude Certified Architect skill. Put it in the wrong place and either your teammates miss it, or your personal habits leak into everyone's workflow.

User Level — Personal, NOT Shared

The user-level file at ~/.claude/CLAUDE.md lives in your home directory. It applies to every project you open on this machine, but it travels with you, not the repo.

Critically, it is NOT shared via version control. A new teammate cloning the repo will never see it. So it is the right home for personal taste: your preferred commit-message style, how chatty you like responses, or shell aliases you favor.

It is the wrong home for anything the team must agree on — coding standards, build commands, security rules.

# ~/.claude/CLAUDE.md  (personal, machine-local, never committed)

## My preferences
- Keep explanations short; show the command, not a paragraph.
- Prefer `rg` over `grep` and `fd` over `find` on my machine.
- Use Conventional Commits for messages.

Project Level — Shared via VCS

The project-level file lives at the repo root as ./CLAUDE.md (or .claude/CLAUDE.md). Because it sits inside the repository, it is committed and shared via version control.

That is exactly what you want for rules the whole team relies on: the build command, test framework, architectural conventions, directory layout, and anything a new contributor needs on day one.

Rule of thumb: if a fresh clone would break without it, it belongs in the project-level CLAUDE.md — not in your personal user file.

# ./CLAUDE.md  (repo root — committed, shared by everyone)

## Build & Test
- Build:  yarn build
- Test:   yarn test --runInBand
- Lint must pass before every commit.

## Conventions
- NestJS modules under src/<feature>/.
- All DB access goes through the repository layer, never inline SQL.

Directory Level — Scoped to a Subtree

A CLAUDE.md placed inside a subfolder is directory-scoped: it applies only when Claude is working within that subtree. This keeps narrow, local rules close to the code they govern.

Example: a frontend/CLAUDE.md can hold React/Tailwind conventions that make no sense for the backend, while services/payments/CLAUDE.md can carry rules that only matter for billing code.

Directory-level files are still committed (they live in the repo), so they are shared — but their reach is the folder, not the whole project.

# frontend/CLAUDE.md  (scoped to the frontend subtree)

## UI conventions (apply only under frontend/)
- Components are function components with hooks; no class components.
- Style with Tailwind utility classes; avoid inline style objects.
- Co-locate tests as Component.test.tsx next to the component.

How the Levels Combine

The levels are additive context, not mutually exclusive. When you work in a subfolder, Claude can draw on the user file, the project file, and the directory file together.

Think of it as concentric scopes:

  • User — broadest reach (every project), narrowest audience (just you).
  • Project — whole repo, whole team.
  • Directory — one subtree, whole team.

So the question is never only "how specific is this rule?" but also "who needs to see it — me, or everyone?" Audience decides user vs project; scope decides project vs directory.

The Classic Mistake: Team Rules in the User File

The most common anti-pattern: putting a rule everyone depends on into ~/.claude/CLAUDE.md. It works perfectly for you — so the gap is invisible — but because the user file is never shared via VCS, new teammates miss it entirely.

Symptoms: Claude follows the convention on your machine and ignores it on a colleague's, and nobody can figure out why. The fix is always the same: move shared rules down into the project-level (or directory-level) CLAUDE.md so they ship with the repo.

Modularize with @path Imports

A CLAUDE.md does not have to be one giant file. You can pull in other files with @path imports, which keeps each file focused and readable.

For example, a project file can import a shared standards document instead of inlining hundreds of lines. This makes the hierarchy easier to maintain and lets you reuse the same standards across files.

# ./CLAUDE.md  (project root)

## Engineering standards
@./standards/coding-style.md
@./standards/security.md

## Build
- Build: yarn build

Path-Scoped Rules with .claude/rules/

A monolithic CLAUDE.md loads into context for every task — even when most of it is irrelevant — wasting tokens. A cleaner pattern for narrow rules is .claude/rules/ files with YAML frontmatter.

Each rule file declares a paths pattern, and it loads only when you are editing matching files. This gives you directory-level precision while saving context, because rules that don't match the current file are never pulled in.

# .claude/rules/migrations.md
---
paths:
  - "db/migrations/**"
---

- Every migration must be reversible (provide a down step).
- Never edit a migration that has already shipped; add a new one.

Editing Memory: /memory and /init

You don't have to hand-edit these files in an external editor. Inside Claude Code, the /memory command opens and edits the CLAUDE.md memory, and changes persist across sessions.

For a brand-new repository, /init bootstraps a project-level CLAUDE.md by documenting the codebase, giving you a sensible starting point you can then refine.

Choosing which file /memory writes to still comes back to the same decision: personal (user) versus shared (project or directory).

# In an interactive Claude Code session:
/init      # generate a project-level CLAUDE.md from the codebase
/memory    # open and edit CLAUDE.md; edits persist across sessions

Skills and Commands Follow the Same Split

This user-versus-project split is not unique to CLAUDE.md — it is a consistent Claude Code pattern. Skills and commands use the exact same two scopes:

  • Project scope — .claude/skills/ and .claude/commands/ in the repo are shared via VCS.
  • User scope — ~/.claude/skills/ is personal.

Note that .claude/commands/ is the legacy form and .claude/skills/ is the current one, but the scoping rule is identical: repo = team, home = you. Learn the split once and it applies everywhere.

Keep Secrets Out of Committed Files

Because project-level and directory-level files are committed to version control, treat them like public code: never put secrets in them. The same discipline applies to a project-scoped .mcp.json (shared in VCS) versus the personal ~/.claude.json.

For tokens and keys, reference environment variables — for example ${GITHUB_TOKEN} — instead of pasting the raw value. The shared file says which variable to use; the actual secret stays in the environment, out of the repo and out of CLAUDE.md.

// .mcp.json  (committed — references env vars, never raw secrets)
{
  "mcpServers": {
    "github": {
      "command": "github-mcp",
      "env": { "GITHUB_TOKEN": "${GITHUB_TOKEN}" }
    }
  }
}

Quick Check: Where Does the Rule Go?

Your team agrees on a build command and a test framework that every contributor must use. A new engineer just cloned the repo. Where should this rule live so that Claude Code applies it for the whole team from day one?

Recap: Audience and Scope Decide the Level

Pick the level by answering two questions — who and where:

  • User (~/.claude/CLAUDE.md): personal, every project, NOT shared via VCS — new teammates miss it. Use for personal preferences only.
  • Project (./CLAUDE.md): shared via VCS, whole team, whole repo. The home for build commands and conventions everyone needs.
  • Directory (subfolder CLAUDE.md): shared via VCS but scoped to one subtree.

Keep files lean with @path imports and load narrow rules on demand via .claude/rules/ with paths frontmatter. Never commit secrets — reference env vars like ${GITHUB_TOKEN}. The biggest trap to avoid: putting team rules in your personal user file, where everyone else will silently never see them.

Często zadawane pytania

Czy lekcja „Poziomy użytkownika, projektu i katalogu” jest bezpłatna?

Tak — pełny tekst „Poziomy użytkownika, projektu i katalogu” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Claude Architect, przejdź na CoddyKit PRO. Kurs Claude Architect zawiera 4 lekcji w sumie.

Co nauczysz się w „Poziomy użytkownika, projektu i katalogu”?

Gdzie znajduje się każdy plik CLAUDE.md i kogo dotyczy Ćwiczysz Claude Architect z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.

Czy potrzebuję doświadczenia, aby zacząć Claude Architect?

Nie wymagamy żadnego doświadczenia. Claude Architect w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 1 z 4.

Ile czasu zajmuje lekcja „Poziomy użytkownika, projektu i katalogu”?

Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.

Czy mogę pisać i uruchamiać kod w tej lekcji Claude Architect?

Tak. Każda lekcja Claude Architect zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.

Wszystkie lekcje w tym kursie

  1. Poziomy użytkownika, projektu i katalogu
  2. Składnia importu @path
  3. .claude/rules/ ze ścieżkami w frontmatter
  4. Reguły monolityczne a modułowe
← Powrót do Claude Architect