D3 · Claude Code Configuration & Workflows

20% of the exam · ≈12 of 60 questions · plain-language lesson first, full notes at the end

Step 3 of 9~25 min
The big idea Claude Code is Anthropic's AI teammate for software work — and like any teammate, what makes it reliable is the onboarding you write down: standing instructions, reusable playbooks, and non-negotiable rules. This domain is about putting each kind of guidance in the right place — the single most underestimated topic on the exam, even by daily users.

Memory — where the standing instructions live

Claude Code reads instruction files called CLAUDE.md before doing anything. Several can exist at once, and precedence matters:

CLAUDE.md precedence hierarchy with side notes
🏠

The "works on my machine" bug

Team conventions that work for you but not a teammate almost always live in your personal file (~/.claude/CLAUDE.md) — which version control never shares. Move them into the project.

Team-wide rules ⇒ project scope (repo). Personal taste ⇒ user scope. Diagnostic: /memory shows exactly which files are loaded.
📎

Splitting big instruction files

@import lets one memory file pull in others. Two facts people get wrong: imports load eagerly (every session, whether relevant or not — on-demand loading is what skills do), and chains only go 5 levels deep; paths resolve from the file doing the importing.

Always-relevant content → memory/imports. Task-specific content → a skill.
🧩

Rules that follow a file type

"All SQL files use these conventions" across 14 folders? One rules file with a paths filter loads only when a matching file is being edited — no copy-paste into 14 folders.

.claude/rules/ + paths: ["**/*.sql"] beats per-directory duplication.

The right mechanism for the job

Five kinds of guidance, five homes. Most D3 questions reduce to this table:

Decision tree for choosing CLAUDE.md, skill, command, hook, or MCP
The need sounds like…UseWhy
"always our house style"CLAUDE.md / rulesloaded every session
"when doing X, follow this playbook"Skillloads on demand, keeps sessions lean
"devs run it before each release"Slash commandhuman-triggered
"must ALWAYS happen / audit / block"Hookcode — runs 100% of the time
"talk to Jira / GitHub / our database"MCP serverexternal systems

Skills & commands, the fine print

A command invoked as /deploy staging v2.3 receives its arguments as $1/$2 ($ARGUMENTS = the whole string). A skill marked context: fork runs in its own workspace so its noisy exploration never clutters your session — not the same as branching a session. allowed-tools is a hard restriction: a review skill limited to reading physically cannot edit.

Project commands: .claude/commands/ (shared) · personal: ~/.claude/commands/.
🪝

Hooks: before vs after

PreToolUse runs before a tool call and can block it (policy gates). PostToolUse runs after (auto-lint, audit log, format normalization).

An audit requirement written in CLAUDE.md is "usually" — and "usually" fails audits. Hook it.
🗺️

Plan mode is judgment, not ritual

Use it for big multi-file or architectural changes, several valid approaches, or unfamiliar code — explore, plan, get approval, execute. Mandating it for every one-line fix is process theater, and the exam punishes that.

Well-scoped single-file fix ⇒ just do it.

Managing long sessions

CommandDoesUse when
/compactsummarizes the session in place (lossy)mid-task and full — save key findings to a file FIRST
/clearwipes everythingstarting an unrelated task
--resumereopens a past sessionits knowledge is still mostly valid — say what changed
fork_sessionbranches a sessiontrying two approaches from one shared baseline

For noisy codebase exploration, the Explore helper does the digging in its own workspace and returns only summaries — your session's memory survives the investigation.

Claude Code without a human — CI pipelines

In a pipeline (e.g. auto-reviewing every pull request) there's no person to approve or steer, so flags replace the human. This is what it looks like:

Headless claude -p pipeline flow with guardrail flags
claude -p "review this diff" \
  --output-format json \    # machine-readable envelope
  --json-schema out.json \  # ENFORCES the result's structure
  --allowedTools "Read,Grep" \  # least privilege
  --max-turns 8             # bounded; non-zero exit fails the build
Classic trap: --output-format json only wraps the output so it can be parsed — the fields inside still vary run to run until --json-schema pins them down.
🔁

Stop the bot repeating itself

Re-review posts the same comments again? Generated tests duplicate existing ones? Same cause: the bot can only avoid duplicating what it can see.

Give prior findings / existing tests in the input + instruct "only NEW or still-unaddressed."
💬

Getting good work out of Claude

Specs misread differently every run ⇒ show 2–3 concrete input→output examples. Unfamiliar territory ⇒ have Claude interview you first. Building to a standard ⇒ write the tests first, then share the specific failures. Several problems ⇒ related ones in ONE message (they interact), trivia separately.

Examples beat longer prose; questions-first beats guess-first; batch feedback by interaction.
Drill D3 now — quiz filtered to this domainAdaptive: anything you miss comes back in a new disguise until you convert it.

Flash-drill this domain (22 cards)

Tap a card to flip it — the same concepts the quiz drills adaptively.

Full study notes optional deep reading — the original study-kit text, code-free

1. CLAUDE.md hierarchy & precedence

CLAUDE.md files hold persistent instructions Claude Code loads automatically at session start. They exist at multiple levels, and more specific overrides more general on conflict — while all levels are loaded together:

Level Location Scope Typical content
Enterprise / managed policy system-managed path (IT-deployed) whole org mandated policies
User (global) ~/.claude/CLAUDE.md every project for this user personal preferences
Project <repo>/CLAUDE.md (checked in) everyone on this repo build commands, conventions, architecture notes
Local / subdirectory CLAUDE.md deeper in the tree, or CLAUDE.local.md (not committed) that subtree / just you area-specific or personal-only notes

Precedence on conflict (the exam fact): enterprise policy wins over everything; then the more specific file winsproject overrides user for that repo; a subdirectory file refines the project file for its subtree.

Two design rules the exam rewards:

  • Keep CLAUDE.md lean. It's loaded into context every session — every token spent here is spent on every task. Move rarely-needed detail into skills (loaded on demand) or docs.
  • Project CLAUDE.md is a team artifact — check it in. Personal quirks go in the user file or CLAUDE.local.md, not the shared one.

📊 Diagram — “CLAUDE.md precedence hierarchy with side notes” (a version appears earlier on this page)

2. .claude/rules/

Instead of one monolithic CLAUDE.md, .claude/rules/ holds multiple focused rule files (markdown) that are loaded alongside it. Use it to keep instruction sets modular — testing.md, api-conventions.md, security.md — easier to review, own, and update than one growing file.

Exam angle: "the team's CLAUDE.md has grown to thousands of tokens of mixed guidance; what's the best restructure?" → split into .claude/rules/ topic files; push task-specific procedures into skills so they only load when relevant.

3. The mechanism menu — the highest-yield table in this domain

"Which mechanism should the team use?" is the most common question shape in Domain 3. Learn this table:

Mechanism Trigger Best for Key property
CLAUDE.md / rules Loaded automatically every session Always-relevant context: build commands, conventions, architecture Always in context (costs tokens every session)
Skill Loaded on demand when relevant (or invoked) Task-specific procedures & expertise: "how we do releases", document workflows Progressive disclosure — costs ~nothing until needed
Slash command User explicitly types /name Repeatable prompts a human kicks off: /review-pr, /write-tests Deliberate, parameterizable invocation
Hook Lifecycle event fires (PreToolUse, PostToolUse, ...) Guarantees: policy, blocking, logging, auto-format after edit Deterministic — always runs; not up to the model
MCP server Tools become available to the model Connecting external systems (Jira, DB, internal APIs) Extends capability, not instructions

Fast selector:

  • "Claude should always know X about this repo" → CLAUDE.md / rules
  • "Claude should know how to do this kind of task well, when it comes up" → skill
  • "A developer wants to run this workflow on demand" → slash command
  • "This must happen every time, no exceptions" → hook
  • "Claude needs to talk to an external system" → MCP

Distractor alert: options that put policy in CLAUDE.md ("add a rule saying never...") when the scenario demands a guarantee. CLAUDE.md is still prompt-space — probabilistic. Guarantees live in hooks and permissions.

📊 Diagram — “Decision tree for choosing CLAUDE.md, skill, command, hook, or MCP” (a version appears earlier on this page)

4. Hooks in Claude Code

Hooks are shell commands configured in settings (e.g. .claude/settings.json) that run at lifecycle events:

Event Fires Canonical uses
PreToolUse Before a tool call executes Block dangerous commands, require approval, validate inputs
PostToolUse After a tool call completes Auto-run formatter/linter after edits, audit logging
Session / other events (start, stop, notification...) At session lifecycle points Setup, cleanup, notifications

A PreToolUse hook can block the action (non-zero exit / deny decision) — that's what makes it enforcement rather than advice.

{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Edit|Write",
        "hooks": [{ "type": "command", "command": "npx prettier --write \"$FILE\"" }]
      }
    ]
  }
}

Same principle as Domain 1: prompts guide, hooks enforce — here applied to a developer workflow ("code must always be formatted", "never run rm -rf", "log every Bash command").

5. Plan mode

Plan mode makes Claude Code research and propose before touching anything: it explores the codebase read-only, produces a plan, and only executes after you approve.

When it's the exam answer:

  • Large or risky changes (migrations, refactors across many files)
  • Unfamiliar codebases — force understanding before edits
  • Any scenario emphasizing review before execution or stakeholder sign-off

Contrast: for a trivial single-file fix, plan mode is overhead — the exam expects judgment, not "always use plan mode."

6. Sessions: /compact, --resume, /clear

Command Effect Reach for it when
/compact Summarizes the conversation in place, freeing context while preserving key facts Long session, context nearly full, work continues
/clear Wipes the conversation entirely — fresh start Switching to an unrelated task
claude --resume (or --continue) Reopens a previous session with its history Interrupted work; picking up next day

The Domain 5 crossover fact: compaction is summarization — it can lose detail. Decision-critical state (requirements, decisions made, file lists) should also live in durable files (a scratchpad, a TODO.md) so nothing depends on the summary being perfect.

7. Permissions & tool allowlists

Claude Code asks permission before sensitive actions; teams tune this in settings:

  • Allowlists (permissions.allow): pre-approve safe, frequent operations (e.g. Bash(npm test), Read) to reduce prompt fatigue.
  • Denylists (permissions.deny): hard-block specific patterns (e.g. Bash(rm -rf*), reading .env*).
  • --allowedTools (CLI flag): cap the tool surface for a run — essential in CI/headless where nobody is present to approve.
{
  "permissions": {
    "allow": ["Read", "Grep", "Glob", "Bash(npm test:*)"],
    "deny":  ["Bash(rm:*)", "Read(.env*)", "Read(**/secrets/**)"]
  }
}

Exam framing: permissions are the Claude Code face of least privilege — the same principle as allowedTools for subagents (Domain 1) and minimal tool surface (Domain 2).

8. .mcp.json and configuration scopes

MCP servers are configured at three scopes; the file answers "who gets this server?"

Scope Where Shared with Use for
Project .mcp.json at repo root, checked in Everyone who clones the repo Team-standard servers (issue tracker, project DB)
User user-level config (~/.claude…) Just you, across all projects Personal tooling
Local project-local, not committed Just you, this project Experiments, servers with personal credentials
{
  "mcpServers": {
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": { "GITHUB_TOKEN": "${GITHUB_TOKEN}" }
    }
  }
}

Two tested details:

  1. Scoped distribution: "the whole team needs the Jira server" → project-scope .mcp.json, checked in. "Only I need it" → user/local scope. Committing a server that needs personal credentials → reference environment variables, never literal secrets in the file.
  2. .mcp.json is configuration; the server's tools still flow through the same permission system as everything else.

9. Headless mode: claude -p for CI/CD

-p / --print runs Claude Code non-interactively: one prompt in, result out, exit. This is the building block for CI pipelines — and a guaranteed exam topic (Scenario S5 is entirely about it).

# Basic: run a task and print the result
claude -p "Review the diff in this PR for security issues" \
  --output-format json \
  --allowedTools "Read,Grep,Glob" \
  --max-turns 20

# In a GitHub Action step
- name: AI review
  run: |
    claude -p "Summarize risky changes in this PR as markdown bullets" \
      --output-format json > review.json
  env:
ANTHROPIC_API_KEY }}

The flags that matter (and why the exam cares):

Flag Purpose Reliability angle
-p "<prompt>" Non-interactive run No human present — everything must be pre-configured
--output-format json Machine-readable result envelope (incl. result text, cost, session id) Pipelines parse output — never scrape free text
--allowedTools "..." Explicit tool allowlist for the run Nobody can approve prompts in CI → pre-authorize the minimum
--max-turns N Cap agentic iterations Bound cost/time; a stuck run fails fast instead of hanging the pipeline
exit code Non-zero on failure Lets the CI step fail properly

Headless mental model: interactive Claude Code relies on a human as the safety net; in CI the flags replace the human. Options that assume interactive approval prompts inside a pipeline are wrong by construction.

📊 Diagram — “Headless claude -p pipeline flow with guardrail flags” (a version appears earlier on this page)

10. Built-in tools

Claude Code ships with a standard toolset. Knowing which tool fits which job shows up in Scenario S4 (developer productivity) questions:

Tool Does Prefer it over
Read Read a file (incl. images/pages) Bash(cat ...)
Write Create/overwrite a file shell redirection
Edit Targeted string replacement in a file rewriting whole files for small changes
Glob Find files by name pattern Bash(find ...)
Grep Regex search across files Bash(grep ...)
Bash Run shell commands — (use when there's no dedicated tool)

Why dedicated tools beat Bash equivalents (exam rationale): they're individually permissionable (you can allow Read while denying Bash), parallel-safe, and produce structured results the harness can gate and audit. Bash is the escape hatch, not the default.

11½. Official exam-guide addenda (v1.0)

Specifics from the official task statements (Exam Guide v1.0, July 2026):

CLAUDE.md mechanics (TS 3.1). Three tested details beyond the hierarchy table: the @import syntax lets a CLAUDE.md reference external files (each package's file imports just the standards it needs — modularity without duplication); the /memory command shows exactly which memory files are loaded — the diagnostic for "Claude behaves differently for teammate X" (classic root cause: the instruction sits in someone's user-level ~/.claude/CLAUDE.md, which version control never shares); and .claude/rules/ is the modular alternative to a monolithic file.

Path-scoped rules (TS 3.3). Rules files support YAML frontmatter with a paths: field of glob patterns — the rule loads only when editing matching files:

---
paths: ["**/*.test.tsx", "terraform/**/*"]
---

This beats subdirectory CLAUDE.md files when a convention follows a file type scattered across directories (test files, IaC files), and it saves tokens by not loading irrelevant rules.

Skill frontmatter (TS 3.2). SKILL.md supports three tested options: context: fork — run the skill in an isolated sub-agent context so verbose output (codebase analysis, brainstorming) doesn't pollute the main conversation; allowed-tools — restrict tool access during skill execution; argument-hint — prompt the invoker for required parameters. Commands split the same way as everything else: .claude/commands/ = project/shared, ~/.claude/commands/ = personal.

Plan mode's helper (TS 3.4). The Explore subagent isolates verbose discovery output and returns summaries — the context-preserving way to do large read-only investigation phases.

Iterative refinement (TS 3.5) — a topic of its own on the exam. Four techniques: (1) when prose instructions produce inconsistent results, give 2–3 concrete input/output examples — the single most effective clarifier; (2) test-driven iteration — write the test suite first (behavior + edge cases + performance), then iterate by sharing test failures; (3) the interview pattern — have Claude ask questions before implementing in unfamiliar domains (surfaces cache invalidation, failure modes you didn't think of); (4) fixes that interact go in one detailed message; independent fixes iterate sequentially.

CI specifics (TS 3.6). --output-format json pairs with --json-schema to enforce the findings structure, not just request it. Re-running review after new commits? Include the prior findings and instruct "report only new or still-unaddressed issues" — that's the duplicate-comment fix. Test generation in CI? Provide the existing test files so it doesn't regenerate covered scenarios. And the same-session generator is a weak reviewer of its own code — use an independent review instance (cross-ref: page 03 §7).

Built-in tool fallback (TS 2.5). When Edit fails because the anchor text isn't unique, the reliable fallback is Read (full file) + Write — not retrying Edit with more context. Explore codebases incrementally: Grep for entry points → Read to follow imports → trace flows; don't read everything upfront.

Finished this page?Mark it complete — your progress updates everywhere instantly.
Next: D4 · Prompt Engineering & Structured Output →