Claude Code CLAUDE.md, settings.json and Permission Modes

📚 Exam guide v1.1 (exams from 7 Dec 2026)🔄 Checked against official sources: 24 Nov 2026⏱️ 8 min read🎯 D3 Claude Code Operation · D2 Configuration and SDLC Integration

👋 In plain words: Claude Code reads two kinds of project files: CLAUDE.md, which tells Claude how your project works, and settings.json, which controls what Claude is allowed to do. Both exist at several levels, and the levels have a fixed order of priority. This lesson walks through each level with real runs, so you know exactly which rule wins.

Advertisement

“Why did Claude Code ignore our rule?” almost always has a configuration answer: the rule was in the wrong file, overridden by a higher level, or the workspace was not trusted. In this lesson you will build a project’s CLAUDE.md with an import, learn the memory hierarchy, write settings.json permission rules and watch a deny rule protect a secrets file, learn the settings precedence order, compare the permission modes, and see why workspace trust matters.

📖 What You’ll Learn: You will be able to structure CLAUDE.md files across levels, use imports, write allow/ask/deny rules, predict which settings win, choose a permission mode, and explain workspace trust.

🔑 Key terms

  • CLAUDE.md (memory file): Markdown instructions Claude Code loads into context: commands, conventions, project facts.
  • settings.json: JSON configuration for permissions, hooks, environment variables, model and more.
  • Permission rule: an allow, ask or deny entry such as Bash(pytest:*) or Read(./.env).
  • Permission mode: the session’s default behaviour for tool use (for example default, acceptEdits, plan).
  • Workspace trust: your confirmation that a folder is safe; until then, some project settings are not applied.

🪜 Step 1: Learn the CLAUDE.md hierarchy

Claude Code loads memory files from several places and combines them. From broadest to most specific:

Level Location Shared with Use for
Enterprise (managed) A system-wide policy location set by IT Everyone in the organisation Company-wide rules
User ~/.claude/CLAUDE.md Only you, all projects Personal preferences
Project ./CLAUDE.md or ./.claude/CLAUDE.md The team, via Git Commands, conventions, architecture
Project rules ./.claude/rules/*.md (can be limited to paths) The team, via Git Topic- or folder-specific rules
Subfolders CLAUDE.md in subdirectories The team Loaded when Claude works with files in that folder

More specific instructions add to broader ones. Keep each file short and factual: every line is in context on every request.

Advertisement

🪜 Step 2: Write a project CLAUDE.md with an import

@path imports another file, so long reference material can live in its own document:

📄 CLAUDE.md

# Checkout service
- Run unit tests: pytest -q tests/unit
- Never edit files under migrations/
- Test conventions: @docs/testing.md

📄 docs/testing.md

# Testing conventions
- UI tests use Playwright with page objects in tests/pages/
- Test data comes from factories in tests/data/; never hard-code emails
- Mark slow tests with @pytest.mark.slow

⌨️ Terminal

claude -p "Where should test data for a new UI test come from?" --model claude-opus-5-5

🖥️ Output (sample run)

From the factories in tests/data/, per docs/testing.md (imported by CLAUDE.md). Do not hard-code email addresses.

The answer depends on a line that exists only in docs/testing.md, which reached Claude because CLAUDE.md imported it.

🪜 Step 3: Write permission rules

Permissions live in settings.json under allow, ask and deny. Rules name a tool and, optionally, a pattern. When rules overlap, deny wins over ask, and ask wins over allow, and rule lists from different settings files are combined:

📄 .claude/settings.json

{
  "permissions": {
    "allow": ["Bash(pytest:*)", "Bash(git diff:*)", "Read(./src/**)"],
    "ask": ["Bash(git push:*)"],
    "deny": ["Read(./.env)", "Read(./secrets/**)", "Bash(rm -rf:*)"]
  }
}

📄 .env

API_TOKEN=not-a-real-token

Now ask Claude to read the secrets file. The model requests Read(.env); the harness refuses before the file is opened:

⌨️ Terminal

claude -p "What is in the .env file?" --allowedTools Read --model claude-opus-5-5

🖥️ Output (sample run)

I can't read .env: the project's permission settings deny access to that file.
Ignoring 3 permissions.allow entries from .claude/settings.json: this workspace has not been trusted. Run Claude Code interactively here once and accept the trust dialog, or set projects["C:\Users\you\claude-course"].hasTrustDialogAccepted: true in C:\Users\you\claude-course\.claude-config\.claude.json.

Read the output carefully. The deny rule blocked the read and Claude Code printed a warning: the allow rules were ignored because this workspace has not been trusted yet. That is a safety feature: a cloned repository cannot grant itself permissions until you trust it, but deny rules (which only reduce power) still apply.

⚠️ Watch out: Deny rules are for Claude Code’s tools. A deny on Read(./.env) does not stop a Bash command such as cat .env unless you also restrict Bash. For secrets, combine deny rules, a narrow Bash allow-list, hooks (Lesson 40), and keeping real secrets out of the working folder.
Advertisement

🪜 Step 4: Know which settings win

Settings files also exist at several levels. When they conflict, Anthropic documents this precedence, highest first:

  1. Enterprise managed settings: cannot be overridden by users or projects.
  2. Command-line arguments for this session (for example --allowedTools, --model).
  3. Local project settings: .claude/settings.local.json (personal, not committed).
  4. Shared project settings: .claude/settings.json (committed for the team).
  5. User settings: ~/.claude/settings.json.

Two practical rules follow: put team policy in .claude/settings.json; put personal tweaks in .claude/settings.local.json (Git-ignored); and if a rule “does not work”, check whether a higher level overrides it.

🎯 Exam focus: “Configuration and SDLC Integration” items give you several configuration files and ask what happens in an environment. Work through the precedence list: managed policy first, then CLI flags, local project, shared project, user. Also check workspace trust and whether a rule is a deny (always applied) or an allow (needs trust).

🪜 Step 5: Choose a permission mode

Mode Behaviour Use when
default Asks before actions that are not pre-allowed Normal work
acceptEdits Auto-approves file edits; still asks for other risky actions Iterating on code you will review
plan Analyse and plan only; no edits or commands that change things Before large or risky changes
bypassPermissions No permission checks Only inside an isolated container with no secrets
dontAsk, auto Further non-interactive modes in recent versions (see the official docs) Automation with care

Set the default in settings.json ("defaultMode"), switch during a session with Shift+Tab, or pass --permission-mode on the command line.

🪜 Step 6: Pin and separate per environment

Configuration is part of your software lifecycle:

  • Pin the model in settings or CI flags so behaviour does not change silently when defaults move (Lesson 42).
  • Commit .claude/settings.json, CLAUDE.md, .claude/rules/, skills and .mcp.json; Git-ignore .claude/settings.local.json.
  • Review changes to these files like code: a new allow rule is a security change.
  • In CI, pass explicit flags (--allowedTools, --permission-mode, --model) so a run does not depend on a developer’s local files.

🌍 Real-world example: Ravi’s “ignored” rule

A teammate complained that Claude Code kept asking before running pytest, although .claude/settings.json allowed it. The cause was workspace trust: they had cloned the repository into a new folder and never accepted the trust prompt. After trusting the folder, the allow rule applied. Meanwhile the deny rule on .env had protected the folder all along.

Advertisement

🧪 Practice Questions

Question 1. The shared project file .claude/settings.json sets “model” to claude-opus-5-5, the developer’s ~/.claude/settings.json sets it to claude-sonnet-5-5, and the developer’s .claude/settings.local.json does not set a model. No managed policy or CLI flag is used. Which model does a session in that project use?

  • A. claude-sonnet-5-5, because user settings are highest
  • B. claude-opus-5-5, because shared project settings outrank user settings
  • C. Neither; conflicting settings fall back to the default
  • D. Whichever file was edited last
Show answer

Answer: B. For single-value settings, precedence is managed > CLI > local project > shared project > user. Permission rule lists are different: they combine across levels, and a matching deny rule wins.

Question 2. After cloning a repository, a developer sees “Ignoring permissions.allow entry … this workspace has not been trusted”. What does this mean?

  • A. The settings file is invalid JSON
  • B. Project allow rules are not applied until the user trusts the folder; deny rules still apply
  • C. The model ID is wrong
  • D. Hooks are disabled
Show answer

Answer: B. Workspace trust stops a cloned project from granting itself permissions.

Question 3. Where should a team put the command to run its tests so every Claude Code session knows it?

  • A. The project CLAUDE.md committed to the repository
  • B. ~/.claude/CLAUDE.md on each laptop
  • C. .claude/settings.local.json
  • D. The system prompt of the API
Show answer

Answer: A. Project CLAUDE.md is shared through Git and loaded for everyone working in the repository.

Question 4. Which two belong in .claude/settings.json rather than CLAUDE.md? (Choose 2.)

  • A. Deny rules for reading secrets
  • B. An explanation of the architecture
  • C. Hooks that block destructive commands
  • D. Coding style preferences written as sentences
Show answer

Answer: A and C. settings.json enforces permissions and hooks; CLAUDE.md gives instructions and context.

📝 Assignment

  1. Task 1: Write a project CLAUDE.md under 20 lines and move long conventions into a docs/ file imported with @.
    ✅ Done when: /memory shows both files in use.
  2. Task 2: Add .claude/settings.json with allow rules for your test command and deny rules for secrets folders, and check them with /permissions.
    ✅ Done when: reading a secrets file is refused.
  3. Stretch: Add .claude/settings.local.json to .gitignore and use it to set a personal default mode, then confirm the team file is unchanged in Git.
    ✅ Done when: git status shows no change to .claude/settings.json.
Advertisement

❓ Frequently Asked Questions

🤔 Where does Claude Code look for CLAUDE.md?

At the enterprise, user (~/.claude/CLAUDE.md) and project levels (./CLAUDE.md or ./.claude/CLAUDE.md), in .claude/rules/, and in subfolders when Claude works with files there.

🤔 How do I import a file into CLAUDE.md?

Write @path/to/file.md in CLAUDE.md. The referenced file is loaded together with it.

🤔 What is the order of Claude Code settings precedence?

Enterprise managed settings, then command-line arguments, then .claude/settings.local.json, then .claude/settings.json, then ~/.claude/settings.json.

🤔 Why are my project permission rules ignored?

Usually because the workspace has not been trusted yet, or a higher-precedence setting overrides them.

🏁 Summary

  • CLAUDE.md gives instructions; settings.json enforces permissions, hooks and options.
  • Memory files combine from enterprise, user, project, rules and subfolder levels; @ imports keep them short.
  • Permission rules: allow, ask, deny with tool patterns; deny rules apply even before trust.
  • Settings precedence: managed > CLI > local project > shared project > user.
  • Choose permission modes deliberately; never bypass permissions outside an isolated sandbox.
📝 Test yourself: D3 Claude Code practice test (20 random questions, 20 minutes), or browse all CCDV-F mock tests (3 full 70-question exams and 8 domain practice tests, with explanations).

Next, continue with Claude Code Skills, Plugins, Rules Files and Slash Commands.

🎬 Prefer video? Watch QA, automation and AI testing tutorials on the SQA Tools YouTube channel.

Independent study material by SQA Tools. Not affiliated with, endorsed by or sponsored by Anthropic. Claude is a trademark of Anthropic. Practice questions are original, not real exam content. Code outputs marked “sample run” come from running the exact code against a local stand-in for the Claude API, so real replies, IDs and token counts will differ. Exam facts checked against Anthropic’s official CCDV-F exam guide v1.1 on 24 Nov 2026.