CLAUDE.md, settings.json and Plugins: Which Claude Code File Advises, Which Enforces, Which Packages
Three needs in one repo: a test command, a rule that Claude must never read .env, and a shared deploy skill. See which file each belongs in, how the settings layers merge, and what a plugin manifest carries.
What you will learn
- Tell advice (CLAUDE.md) from enforced rules (settings.json) and packaged tools (plugins)
- Predict the effective settings when user, project and local files disagree
- Explain why permission lists combine and deny rules are checked first
- Read a plugin manifest and know what enabling a plugin does and doesn't do
Before you start
- A first session in Claude Code
- Basic JSON
Meet bookshop-bot, a small project with a small team. Three files shape how Claude Code behaves in it, and each one has a different job: one advises, one enforces, and one packages. Put a rule in the wrong file and it won't hold when it matters.
Three needs, three homes
The team has three needs:
- Run
pytest -qbefore calling a job done. That's a request, so it goes inCLAUDE.md. - Never read the
.envfile, whatever Claude decides. That has to hold, so it's a deny rule insettings.json. - Everyone gets the same deploy skill. That's a package, so it becomes a plugin.
Think of an office. The staff handbook says "please lock up at night": it's written down and staff are trusted to follow it. That's CLAUDE.md. The safe needs a keycard, and nobody opens it without one, even if they never read the handbook. That's settings.json. The starter kit, a toolbox handed to every new hire, is the plugin. Advice can be ignored. A lock cannot.
CLAUDE.md is advice
Here is the project's CLAUDE.md:
# bookshop-bot
## Tests
- Run the tests with: pytest -q
## Code style
- Python 3.12, with type hints on every function.
- Format with: ruff format
- Never read the .env file.
The test command and the style rules are exactly what this file is for. The last line sounds strict, but it's still only advice. Claude Code loads CLAUDE.md as context, not as enforced configuration. A rule that must never be broken needs the lock.
Settings stack by scope
Settings files stack. From lowest to highest precedence:
Two rules come out of that stack:
- For a plain value, the highest layer wins. The project says Sonnet, the local file says Opus, so Opus wins, for you only.
- For a permission list, every layer adds. Nothing gets dropped.
.claude/settings.json: the shared file
{
"$schema": "https://json.schemastore.org/claude-code-settings.json",
"model": "claude-sonnet-5",
"permissions": {
"allow": ["Bash(pytest *)", "Bash(ruff check *)"],
"deny": ["Read(./.env)", "Read(./.env.*)"]
},
"enabledPlugins": {
"deploy-tools@bookshop-plugins": true
}
}
modelis a plain value: the team's model.allowlets pytest and ruff check run without asking.denyblocks reads of.env. Deny rules are checked before allow rules.enabledPluginsturns a plugin on by its id,name@marketplace.
Commit this file so everyone who clones gets it. It must be strict JSON: no comments, no trailing commas.
.claude/settings.local.json: yours only
{
"model": "claude-opus-5-5",
"permissions": {
"allow": ["Bash(git status)"]
}
}
Same model key, higher layer, so this value wins, but only on your machine. It adds an allow rule for git status without losing anything from the other files. When Claude Code creates this file it keeps it out of git; if you make it by hand, add it to .gitignore yourself.
The sample user file, ~/.claude/settings.json, sets "spinnerTipsEnabled": false and allows Bash(git diff *).
A model of the merge: resolve.py
The project includes a small Python model of these rules. It's a simplified model of the documented behaviour, not Claude Code itself:
LAYERS = [("user", "user-settings.json"),
("project", ".claude/settings.json"),
("local", ".claude/settings.local.json")]
LISTS = ("permissions.allow", "permissions.deny")
def resolve():
value, source = {}, {}
for name, rel in LAYERS:
for key, val in flatten(read(rel)).items():
if key in LISTS:
old = value.get(key, [])
value[key] = old + [v for v in val if v not in old]
source[key] = source.get(key, []) + [name]
else:
value[key], source[key] = val, [name]
return value, source
def decide(call, value):
for rule in value["permissions.deny"]:
if fnmatch.fnmatch(call, rule):
return f"denied by {rule}"
for rule in value["permissions.allow"]:
if fnmatch.fnmatch(call, rule):
return f"allowed by {rule}"
return "no rule matches"
The layers are listed lowest first. A list key combines and skips duplicates; any other key is simply replaced by the later layer. decide() checks deny before allow.
Running run_all.py (plain Python reading the sample files, no model call) printed:
effective settings
model claude-opus-5-5 <- local
spinnerTipsEnabled false <- user
permissions.allow 4 rules <- user+project+local
Bash(git diff *) Bash(pytest *) Bash(ruff check *) Bash(git status)
permissions.deny 2 rules <- project
enabledPlugins deploy-tools@bookshop-plugins: true <- project
permission checks
Read(./.env) denied by Read(./.env)
Bash(pytest -q) allowed by Bash(pytest *)
Bash(git status) allowed by Bash(git status)
Bash(rm -rf build) no rule matches
plugin deploy-tools
version 1.2.0 | needs secrets-vault | /deploy-tools:deploy
- The model comes from local: local beat project, as the stack says.
- Four allow rules from three files, none dropped.
- Reading
.envis denied by the project's deny rule. rm -rf buildmatches no rule at all. No rule means no free pass: it isn't pre-approved.- The plugin brings one skill,
/deploy-tools:deploy.
The plugin manifest: plugin.json
A plugin keeps its manifest in a .claude-plugin folder, with its skills beside it:
{
"name": "deploy-tools",
"version": "1.2.0",
"description": "Staging deploy skill for the bookshop team",
"author": { "name": "Bookshop Team" },
"dependencies": ["secrets-vault"]
}
namebecomes the prefix of every skill in the plugin, so the deploy skill runs as/deploy-tools:deploy.versionis the version users are on until the string changes.dependencieslists other plugins that must be enabled for this one to work.
Enabled is not installed. enabledPlugins in the shared settings turns the plugin on for the project, but each teammate still installs it once on their machine.
Common mistakes
| Placement | Why it fails for "never read .env, for everyone" |
|---|---|
A line in CLAUDE.md | Advice, not a lock |
| A deny rule in each developer's user settings | Not shared; a new teammate won't have it |
A deny rule in settings.local.json | Personal and kept out of git |
A deny rule in the committed .claude/settings.json | The right home: enforced, and everyone gets it |
For the wider choice between skills, hooks, rules files, subagents, slash commands and plugins, see Choosing a Claude Code Extension. To write the skill a plugin carries, see Authoring a Skill.
Quick recap
| File | Job | Shared? |
|---|---|---|
CLAUDE.md | Advise: loaded as context | Yes, committed |
.claude/settings.json | Enforce: permissions, model, enabled plugins | Yes, committed |
.claude/settings.local.json | Your overrides for this project | No, kept out of git |
~/.claude/settings.json | Your defaults for every project | No |
Plugin (.claude-plugin/plugin.json) | Package: skills as one unit | Installed on each machine |
Try it yourself
Add "deny": ["Bash(rm *)"] to the user settings file. Which layer does permissions.deny now come from, and what does decide() say about Bash(rm -rf build)? Then remove model from the local file: which model wins?
Related course on Udemy
Claude Certified Developer - Foundations (CCDV-F) Exam Prep
Build and ship Claude apps: the API, agents, tools and MCP, prompts, evals, security and model choice.View on Udemy ↗: Claude Certified Developer - Foundations (CCDV-F) Exam Prep (paid course, opens in a new tab)Related posts
Authoring a Claude Skill: SKILL.md, Frontmatter, Progressive Disclosure and the Description That Triggers It
Pack a support team's ticket-triage routine into one skill folder, then watch three requests load one, two or all three levels: the catalog, the SKILL.md body, and a script whose code never enters the context.
One Change, Four Environments: Where a Claude Config Edit Lands in Dev, Staging, Prod and CI
Change one line in a repo and ask where it lands. A small resolver for bookshop-bot shows that a new model id in settings.json reaches only CI, a prompt bump reaches dev and CI, and a prod block edit reaches only prod.
Claude in the SDLC: Prompts in Git, a Change Gate by Path, a Claude Review That Advises and a Person Who Merges
Follow one prompt edit from a branch to a merge: version prompts and the model pin like code, keep the API key in GitHub Secrets, gate changes by path, let Claude review the diff, and leave the merge to a person.
Hooks That Block Destructive Actions: a PreToolUse Gate That Allows, Asks or Denies
A coding agent is told to clean up the data folder and picks rm -rf data/. A PreToolUse hook sees the call before the tool runs: tests and single-file deletes pass, a force push asks a person, and rm -rf, DROP TABLE and a write to .env are denied with a reason.