Skip to content
Français
Sync not enabled: your progress stays in this browser My learning
Select theme
Français

Claude Code: CLAUDE.md, rules, settings, hooks, skills, which one to use?

11 min read
Improve this page

Logo Claude

Six building blocks can carry a rule: you need a method to know which one to pick. You have just set up CLAUDE.md, targeted rules and a settings.json; hooks and skills come in the next module. This page is the map of the whole set: one simple rule per building block, with examples on lab-claude, so you know what goes where before you have practiced everything. The goal: stop hesitating, and above all stop duplicating the same rule in three files.

What you will learn

  • Tell a fact, a rule, a procedure, an automation and a permission apart
  • Choose between CLAUDE.md, CLAUDE.local.md, rules, settings.json, hooks and skills
  • Put a rule at the right level (project, personal, code area)
  • Recognize the common bad mixes

When should you use this guide?

  • You are adding a new rule to your project and you hesitate
  • Your CLAUDE.md is starting to overflow with procedures and permissions
  • You find the same rule in two different places
  • A contributor asks "why is this rule here and not there?"

The 6 building blocks in one line

Building blockRoleExample on lab-claude
CLAUDE.mdGlobal fact about the project, shared with the team"We use FastAPI, uv, ruff, pytest"
CLAUDE.local.mdPersonal preference, not shared"I edit with Helix, formatting is forced to ruff format"
.claude/rules/*.mdTargeted rule for a code area"Tests use TestClient"
.claude/settings.jsonPermission on tools and commandsallow: Bash(uv run pytest *)
hooks in .claude/settings.jsonAutomation around eventsRun ruff after every Edit
.claude/skills/<name>/SKILL.mdProcedure you invoke with /name/valider chains ruff + pytest and summarizes
.mcp.json / MCP serversExternal tools outside the repositoryfetch for the FastAPI docs, github for issues

The last row does not file any rule: MCP servers plug in external tools. The six building blocks above it carry the rules and settings of your project.

Remember this distinction in five words: fact, rule, permission, automation, procedure. Each building block has one main role, even though settings.json carries two (permissions and the declaration of hooks).

The decision tree in 4 questions

Four questions are enough to file a new instruction, asked in this order. In the tree, each question has its "yes" exit on the same line, naming the building block; only a "no" sends you down. The fourth question is split in two, because it separates the two building blocks that are most often confused: the hook, which triggers on its own, and the skill, which you invoke.

Decision tree: a fact that is always true for the project goes in CLAUDE.md, or in CLAUDE.local.md if it only concerns you; otherwise, a rule valid in a single area goes in .claude/rules with paths:; otherwise, a command to allow, deny or confirm goes in .claude/settings.json with allow, deny or ask; otherwise, an action triggered on its own by an event becomes a hook; otherwise, an action invoked on demand with /name becomes a skill.A rule or an actionto hand to Claude CodeA fact that is alwaystrue for this project?A rule that only appliesin one area (tests, API)? no CLAUDE.md(CLAUDE.local.md if personal) yes A command to allow,deny or confirm? no .claude/rules/‹area›.mdwith paths: yes An action triggeredby an event on its own? no .claude/settings.jsonallow / deny / ask yes An action invokedon demand (/name)? no Hook(after Edit, before Stop) yes Skill(/valider, /prep-pr) yes question to askbuilding block to use
Source · SVG
Esc to close, + and − to zoom, scroll to move around. 100 %

The same questions, with the detail of each answer:

  1. Is it a fact that is always true for this project? → CLAUDE.md (or CLAUDE.local.md if it only concerns you)

  2. Is it a rule that only applies in one area (tests, API, infra)? → .claude/rules/<area>.md with paths: in the frontmatter

  3. Is it a command to allow, deny or put behind a confirmation? → .claude/settings.json via allow / deny / ask

  4. Is it an action triggered by an event or invoked on demand?

    • Automatic (after Edit, before Stop...) → hook
    • On demand (/valider, /prep-pr...) → skill

If a single instruction earns a yes to several questions (a command to allow and a procedure to chain, for example), it mixes two things. Split it.

Block by block

CLAUDE.md, the stable facts of the project

What to put in:

  • Stack, role of the project
  • Useful commands (uv run ruff check ., uv run pytest -q)
  • Major conventions (type annotations, test style)
  • Simple guardrails ("do not modify pyproject.toml without confirmation")

What not to put in:

  • Numbered procedures ("step 1, step 2, step 3") → skill
  • Rules that only concern a subfolder → rule
  • Shell permissions → settings.json
  • Personal preferences → CLAUDE.local.md

Size rule: fewer than ~80 active lines. Details in configure CLAUDE.md (in French).

CLAUDE.local.md, your own preferences

What to put in:

  • Your preferred summary style
  • Reminders tied to your machine or to your current branch
  • Conventions being tested before they are promoted to CLAUDE.md

What not to put in:

  • Team rules (→ CLAUDE.md)
  • Secrets (→ environment variables)

Add it to .gitignore.

.claude/rules/*.md, rules by area

What to put in:

  • A rule that only applies to tests/**/*.py or app/routes/**/*.py
  • A paths: frontmatter so the rule is loaded only when Claude touches the area

Example on lab-claude (.claude/rules/tests.md):

---
paths:
- tests/**/*.py
---
# Rules specific to tests
- Use `fastapi.testclient.TestClient`
- One test = one main assertion
- No mock on the project's own functions

Details in targeted rules.

.claude/settings.json, permissions and environment

What to put in:

  • allow, deny, ask on tools (Bash, Read, Edit, WebFetch)
  • Injected environment variables (env)
  • Attribution (attribution)

What not to put in:

  • Behavior rules ("always summarize in 5 points") → CLAUDE.md
  • Procedures → skill

Rule: deny protects, allow speeds things up, ask keeps you in control. Details in advanced settings.json.

Hooks, automating events

A hook is declared under the hooks key of .claude/settings.json. The .claude/hooks/ folder holds the scripts it runs.

What to put in:

  • Systematic validation after Edit|Write (e.g. ruff check)
  • Blocking destructive commands before Bash
  • A command reminder on Stop

Typical example: run uv run ruff check . after every modification of a Python file.

What not to put in:

  • Actions that you must be able to trigger on demand → skill
  • Permissions → the permissions key of settings.json (with ask or deny)

Details in Claude Code hooks (in French).

.claude/skills/<name>/SKILL.md, invocable procedures

What to put in:

  • A procedure you often type by hand (validation, PR preparation, review)
  • A SKILL.md with steps in the imperative
  • disable-model-invocation: true if the skill changes the state of the project

What not to put in:

  • A general rule (→ CLAUDE.md or rule)
  • An action that must trigger on its own on an event (→ hook)

Details in Claude Code skills.

The same intent, filed in the right place

To build the reflex, here are 7 common intents on lab-claude, each in its right place:

IntentRight building block
"We use FastAPI, pytest, ruff"CLAUDE.md
"Tests use TestClient".claude/rules/tests.md (paths: tests/**/*.py)
"I prefer summaries in 3 points"CLAUDE.local.md
"Allow uv run pytest * without a prompt".claude/settings.json (allow)
"Always refuse rm -rf *".claude/settings.json (deny)
"Run ruff after every Edit"PostToolUse hook on Edit|Write
"A /valider command that chains ruff + pytest"skill .claude/skills/valider/SKILL.md

Keep in mind the trickiest distinction: hook vs skill. A hook triggers on its own on an event. A skill waits for you to type /name.

What not to mix

The common mistakes all follow the same pattern: one building block takes the role of another.

Mix to avoidSymptomFix
Procedure in CLAUDE.mdThe file bloats, Claude skims itExtract it to a skill (/valider, /prep-pr)
Area rule in CLAUDE.mdContradictory rules depending on the folderMove it to .claude/rules/<area>.md with paths:
Permissions in natural language in CLAUDE.mdClaude asks again every timeTurn them into allow/deny in settings.json
Automation inside a skillClaude forgets to run itTurn it into a hook (PostToolUse)
Personal preference in the shared CLAUDE.mdOther contributors have to live with itMove it to CLAUDE.local.md (gitignored)
Skill triggered automatically on a risky actionUnexpected deployment or commitAdd disable-model-invocation: true

An example of a good split on lab-claude

Here is what a well-organized project looks like:

lab-claude/
├── CLAUDE.md # Stack, commands, global conventions
├── CLAUDE.local.md # Personal preferences (gitignored)
├── .claude/
│ ├── settings.json # Team permissions (allow, deny, ask) and hooks
│ ├── settings.local.json # Personal permissions (gitignored)
│ ├── rules/
│ │ ├── tests.md # Rules for tests/**
│ │ └── routes.md # Rules for app/routes/**
│ ├── hooks/
│ │ └── ruff-apres-edit.sh # Script run by a hook after Edit|Write
│ └── skills/
│ ├── valider/SKILL.md # /valider: ruff + pytest + summary
│ └── prep-pr/SKILL.md # /prep-pr: diff, commits, PR title

Each building block has a single role, even when two of them share a file: settings.json carries the permissions and the declaration of hooks. No rule is duplicated. If you add a rule tomorrow, you know exactly where to put it.

Orientation checklist

  • I can tell a fact, a rule, a permission, an automation and a procedure apart
  • No numbered procedure is left in my CLAUDE.md
  • Rules specific to an area are in .claude/rules/ with paths:
  • Permissions are in settings.json, not in natural language elsewhere
  • Automations are in hooks, not in skills
  • Procedures to invoke are in skills, not in CLAUDE.md
  • My personal preferences are in CLAUDE.local.md (gitignored)

Key takeaways

  • One building block = one role. As soon as you have a doubt, split.
  • CLAUDE.md for facts, rules for targeted rules, skills for procedures, hooks for automations, settings.json for permissions.
  • CLAUDE.local.md and settings.local.json absorb everything that is personal.
  • A well-organized project makes every new rule trivial to place.

Knowledge check

Check that the essentials of this guide are mastered. The questions cover only what has just been explained here.

Knowledge check

Check what you have learned with this interactive quiz

6 questions
6 min
70% to pass

How it works

  • The timer starts when you click Start
  • Multiple choice, true/false and short answer questions
  • You can move between questions
  • Detailed results are shown at the end

Starts the quiz and the timer