Where a rule comes from
The same Claude Code command can behave differently in different repositories or local copies. During diagnosis, it is useful to start with the question: “Where did Claude get this rule?”
Settings have different scopes. Put a rule at the level where it actually belongs instead of duplicating everything in one global file.
| Level | Scope | Example |
|---|---|---|
| user | Personal preferences across all projects | Ask to make a plan first |
| project | Shared rules for a specific repository | Test commands and project conventions |
| local | Details of a specific local copy | Local database port |
| managed | Organization policies | Access restrictions for certain paths |
The `.claude` directory as an engineering layer
The `.claude/` directory stores service instructions and settings that help Claude work within project agreements. It is not application business logic but a contextual layer for working with it.
At first, it is enough to know the role of the main elements. You do not need to master every extension immediately if the current task does not use it.
CLAUDE.md— shared project instructions.rules/— focused rules for specific areas.skills/,agents/,hooks/, andmcp/— extended mechanisms for later guide levels.
.claude/
├── CLAUDE.md
├── rules/
├── skills/
├── agents/
├── hooks/
└── mcp/Review configuration without rushing
- Make sure the required local repository copy is open.
- Review the Git state before reading configuration.
- Inspect
.claude/and readCLAUDE.mdfirst. - Then investigate
rules/or other directories if they relate to the task. - Determine whether the rule you found belongs to the user, project, local, or managed level.
pwd
git status
ls -la .claude
find .claude -maxdepth 2 -type fShared versus local
Team rules should be available in the repository and useful for most sessions. Local settings are for machine-dependent details or personal preferences and are usually not committed.
A local file is not a secret store. Do not put tokens, passwords, or keys there just because the file is excluded from Git.
.claude/CLAUDE.local.md
.claude/settings.local.jsonDiagnosing strange behavior
- Check the path and Git state to rule out the wrong directory.
- Read the shared
CLAUDE.mdbefore drawing conclusions about behavior. - Find the source of the specific rule instead of changing all settings at once.
- If the rule belongs to the managed level, do not try to bypass it with local changes.
- Change only the layer to which the rule actually belongs.
Canonical lesson source · JavaRush
Open JavaRush material