Put each setting at the right scope, pin the model
Place Claude Code instructions and settings at the scope that matches who must share them and who may override them, and pin model versions so behaviour changes only when you choose.
Scenario
A five-person team shares one repository. Claude Code runs the tests without asking on Priya's laptop but prompts everyone else. It never reads .env for Marco, yet it opened one for the new hire. And the nightly codemod produced different code this week, although nobody touched it.
Every rule exists somewhere. Each one is in the wrong place.
Explanation
Instructions: CLAUDE.md scopes. Claude Code reads these files at the start of a session:
| Scope | File | Shared with |
|---|---|---|
| Managed | set by IT, e.g. /etc/claude-code/CLAUDE.md |
Everyone in the organization |
| User | ~/.claude/CLAUDE.md |
Only you, all projects |
| Project | ./CLAUDE.md or ./.claude/CLAUDE.md |
The team, via git |
| Local | ./CLAUDE.local.md (add it to .gitignore) |
Only you, this project |
They don't override each other: all of them are loaded together, broadest first. A CLAUDE.md in a subdirectory loads when Claude works in that directory. Users can't exclude the managed file.
Settings: settings.json scopes. Permissions, model, hooks and environment live in settings, which Claude Code applies, not just reads:
| Scope | File |
|---|---|
| User | ~/.claude/settings.json |
| Project (commit it) | .claude/settings.json |
| Local (kept out of git) | .claude/settings.local.json |
| Managed | managed-settings.json or another managed source |
When two files set the same key, the higher level wins: managed, then command line, then local, then project, then user. Lists such as permissions.allow merge across files.
Permission rules are checked in the order deny, ask, allow. A deny at any level blocks the call, and nothing below managed settings can override a managed rule.
Guidance or enforcement? CLAUDE.md is delivered as context that Claude tries to follow, with no guarantee. A rule that must never be broken belongs in settings (a deny rule) or a hook, at a scope users can't override if they must not. Know what a deny rule covers: a Read or Edit rule applies to Claude's file tools, the Bash file commands Claude Code recognizes (cat, head, tail, sed, tee) and redirection targets, but not to a command that reads files without naming them (grep -r pattern . from that folder) or a script that opens files itself. For enforcement at the OS level, for every process, add the sandbox.
Pin the model. A model ID names a fixed snapshot: Anthropic doesn't change the weights behind an ID. Aliases are different. In Claude Code, opus, sonnet and haiku resolve to the newest version (on the Anthropic API) and update over time; to pin, set the full model ID in model. On the API, some older models also have aliases that point to their latest dated snapshot. Every ID has its own retirement date, so pinning means planning the next migration, not avoiding it.
Version prompts with the model. Keep each prompt in version control with the model ID it was tested on, so you can always say what ran.
Worked example
Before: Priya's test approval sits in her own local file, the .env rule is a line in her personal ~/.claude/CLAUDE.md, and the shared settings use the alias opus.
After: the team's rules are in the committed .claude/settings.json (the model value is the full ID of the current Opus model, from the models overview):
{
"model": "<full Opus model ID>",
"permissions": {
"allow": ["Bash(npm run test *)"],
"deny": ["Read(./.env)", "Read(./.env.*)"]
}
}
- Everyone gets the test approval and the
.envblock from git. The deny rule is enforced for Claude's file tools and the file commands Claude Code recognizes, not just suggested. - The full model ID replaces the alias, so a new release doesn't change the codemod's output until the team decides to upgrade.
- Priya's sandbox URL stays in her
CLAUDE.local.md; her preference for short answers stays in~/.claude/CLAUDE.md.