3.1 · 3.1% of the exam · Topic 1 of 1
Claude Code Operation
Claude Code is configured with rules, skills, commands, agents, and memory, then operated through sessions, slash commands, and print mode. CLAUDE.md guides the model. settings.json and hooks enforce what the model is allowed to do.
Learning objectives
- Place a convention in CLAUDE.md or a path-scoped rule, a procedure in a skill, and a hard stop in settings or a hook.
- Keep team instructions in the repository and personal notes, auto memory, and local settings on one machine.
- Resume, compact, or clear a session without confusing conversation history with project memory.
- Start an unattended job with print mode, an output format, and an explicit permission mode.
- Read the settings stack: managed, then flags for this session, then local, shared project, then user.
Detailed theory
What this skill covers
Domain 3 is Claude Code, and it is 3.1% of the CCDV-F exam. The single task statement is Claude Code Operation: rules, skills, commands, agents, agent memory, session management, slash commands, headless and streaming and auto mode, the CLAUDE.md hierarchy, repository initialization, and settings.json.
The exam is asking where a behavior lives. Guidance that the model reads is a different file from configuration the client enforces. A session is a different store from memory that survives the session. A skill that loads on demand is a different budget from a file that loads on every turn.
Rules, skills, and commands
Rules are markdown under .claude/rules/. A file with no paths frontmatter loads at session start, the same way project CLAUDE.md does. A paths list of globs loads when Claude reads a matching file, so test conventions stay out of a session that is editing API handlers. A matching rule is added to the other instructions. It does not erase the root file. paths is the field the client reads from rule frontmatter.
A skill is a directory with SKILL.md, under .claude/skills/ for the team or ~/.claude/skills/ for you. Typing the skill name after / runs it. The body enters context when the skill is invoked or when the model decides it applies, so a long deploy procedure does not sit in every turn. A flat markdown file dropped into the skills directory is not that skill. The older .claude/commands/ layout still creates a slash command from a single markdown file.
Built-in slash commands control the session: /help, /init, /memory, /context, /clear, /compact, /resume, /plan, /permissions, /config, /status, /doctor, /cost, /agents, and /hooks. Custom names come from skills and commands the project or your user directory defines. / on an empty prompt lists what this session can run.
- Always-on convention: CLAUDE.md or an unscoped rule.
- Convention for one file type: a rule with paths.
- Procedure you invoke: a skill or a command.
- Verbose procedure that should not fill the main transcript: a skill with context set to fork.
Agents and agent memory
A subagent is its own Claude session for one subtask. Project agents live as markdown under .claude/agents/. Personal agents live under ~/.claude/agents/. /agents lists and edits them. The file names the agent, describes when to use it, and can limit tools, pick a model, set a permission mode, or isolate the work in a git worktree. The main session receives the result the subagent returns. The subagent's tool chatter stays in its own window.
By default a subagent starts with a fresh context. It does not already know the parent conversation. A fork is the exception: it branches with the parent transcript. If the parent has spent an hour discovering which files matter, the spawn prompt has to carry those facts, or the parent should fork.
Agent memory here means auto memory, the notes Claude writes for itself. They live under ~/.claude/projects/ for that git repository, shared across worktrees on this machine and not copied by git. MEMORY.md is an index. The first 200 lines, or the first 25KB, load at the start of a conversation. Topic files load when Claude opens them. The parent auto memory is not handed to a subagent unless that subagent is a fork. A subagent can keep a separate memory directory of its own.
Auto memory is still context. Claude Code loads it so the model can see a preference you corrected last week. It does not block a tool. /memory opens the instruction files and the auto-memory toggle. /context shows which memory files this session actually loaded.
Sessions and the slash commands that move them
A session is one conversation, from launch until you exit or the process ends. It has a transcript. Project instructions persist across sessions. The transcript does not, unless you resume it.
/clear, also /reset and /new, drops the conversation and keeps CLAUDE.md and auto memory. /compact summarizes the conversation so far so the window has room. /resume and claude --resume reopen a named or numbered session. claude --continue, or -c, reopens the latest conversation in this directory. --fork-session with a resume creates a new session id and leaves the original transcript alone. /rewind rolls the conversation, and optionally the files, back to a checkpoint.
Use a fresh session when the next task has nothing to do with the last one. Resume when the unfinished work is still in that transcript. Compact when the work is the same but the middle of the transcript is noise. Clear when the history itself is the problem and the files on disk already hold the project facts.
CLAUDE.md and starting a repository
CLAUDE.md is instructions you write. Claude reads applicable files at the start of a session, and nested files when it reads a file in that directory. The locations, from broad to narrow, are the managed organization file, ~/.claude/CLAUDE.md, the project file at CLAUDE.md or .claude/CLAUDE.md, and CLAUDE.local.md beside it. All of the files that apply are concatenated. Content closer to the directory where you launched is read later. CLAUDE.local.md is appended after CLAUDE.md in the same directory. Later does not mean it wins. If two instructions contradict, the model may follow either one.
The project file is what a clone receives. The user file and CLAUDE.local.md stay on your machine when they are gitignored. @path imports are inlined when the file loads, so splitting a long file does not shrink the context. A managed CLAUDE.md is still guidance. Blocking a command is a permissions.deny entry or a hook.
/init explores the codebase and writes a starter CLAUDE.md with the build, test, and layout it finds. If a CLAUDE.md already exists, /init proposes edits instead of replacing the file. Set CLAUDE_CODE_NEW_INIT=1 when you want that flow to also offer skills and hooks and to wait for a review before it writes. That is repository initialization: the first session records facts so later sessions do not rediscover them.
settings.json
settings.json is enforced by the client: permissions, hooks, model, and other keys. When the same key is set in more than one place, the higher level replaces the lower one. Highest first: managed settings from the organization, then command-line flags and --settings for this session, then .claude/settings.local.json, then the shared .claude/settings.json, then ~/.claude/settings.json. A flag does not outrank a managed key.
List keys such as permissions.allow are combined across files, so a user allow-list does not erase a project deny. A few keys ignore project and local files. permissions.defaultMode set to auto or bypassPermissions is one of them: those values are read from user or managed settings, or from --permission-mode for a single launch. A committed defaultMode of auto does not turn auto on for the team.
Commit .claude/settings.json for the permissions and hooks the clone should start with. Keep personal exceptions in settings.local.json, which is meant to stay out of git. Check what loaded with /status. Check which instruction files loaded with /context.
{
"permissions": {
"allow": ["Bash(npm test)"],
"deny": ["Read(./.env)", "Read(./.env.*)"]
},
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [{ "type": "command", "command": ".claude/hooks/block-force-push.sh" }]
}
]
}
}Headless, streaming, and auto mode
Headless work is print mode: claude -p "prompt" runs the query and exits, so a script or a CI job can call it. Nobody is sitting at the keyboard, so a permission prompt is a failure. Pair the invocation with an explicit --permission-mode, an allow-list such as --allowedTools, and deny rules for anything the job must not touch. --output-format is text, json, or stream-json. stream-json with --include-partial-messages and --verbose is the streaming form: the caller sees tokens as they are produced instead of one blob at the end.
--bare skips auto-discovery of hooks, skills, plugins, MCP servers, auto memory, and CLAUDE.md so a script starts from a known surface. It is the opposite of a normal interactive session. --no-session-persistence, print mode only, leaves nothing to resume.
Auto is a permission mode in the Shift+Tab cycle, alongside manual, accept-edits, and plan. A classifier lets low-risk actions through and escalates the rest. accept-edits auto-approves file edits and still asks for shell commands. Plan mode researches and proposes and does not edit until you leave it. bypassPermissions skips the checks and belongs in an isolated environment, not on a workstation that holds credentials. Auto is not that skip. Start a session in a chosen mode with --permission-mode. The old --enable-auto-mode flag is gone.
claude -p "Run npm test and report failures" \ --output-format stream-json --include-partial-messages --verbose \ --permission-mode dontAsk \ --allowedTools "Bash(npm test)"
Core concepts
Path-scoped rule
- What
- A markdown file in .claude/rules/ whose paths globs decide when it loads.
- Why
- A convention for one kind of file should not occupy every turn.
- When
- Tests, Terraform, or another subtree has rules the rest of the repo does not.
- When not
- The fact is true for every edit. Put that in project CLAUDE.md.
Skill
- What
- A directory with SKILL.md that becomes a slash command and loads when used.
- Why
- The body is a metered context cost, not a permanent one.
- When
- A multi-step procedure the team runs sometimes.
- When not
- A one-line naming rule, or a tool ban that must be enforced.
Slash command
- What
- Input that starts with /. Built-ins manage the session. Custom ones are skills or .claude/commands/ files.
- Why
- Repeating the same prompt by hand drifts, and the session controls already exist.
- When
- You need /init, /compact, /memory, or a team procedure.
- When not
- You are looking for a permission gate. A command is still a prompt.
Subagent
- What
- A focused Claude instance defined under .claude/agents/ or the user agents directory.
- Why
- Its transcript does not fill the parent window, and its tools can be narrower.
- When
- A subtask is self-contained and would dump pages of tool output.
- When not
- The worker needs the whole parent conversation. Fork, or put the facts in the spawn prompt.
Auto memory
- What
- Notes Claude writes under the user projects directory. The MEMORY.md index loads first, within 200 lines or 25KB.
- Why
- Corrections survive the next launch without a commit.
- When
- A preference is yours and should not become the team's file.
- When not
- A clone must see the instruction. That is project CLAUDE.md.
Session
- What
- One conversation transcript, resumable by id or name unless persistence is off.
- Why
- History and project memory answer different questions.
- When
- Continue unfinished work, or isolate a new task with /clear.
- When not
- You wanted a shared convention. Clearing the session does not edit CLAUDE.md.
CLAUDE.md hierarchy
- What
- Managed, user, project, and local instruction files concatenated into context.
- Why
- There is a load order and no override chain. Conflicts are not resolved by scope.
- When
- You are deciding who sees an instruction after clone, and what loads together.
- When not
- You need the client to refuse a tool. Use settings or a hook.
settings.json
- What
- JSON configuration with a real precedence stack: managed, session flags, local, shared project, user.
- Why
- The client applies it whether or not the model agrees.
- When
- Permissions, hooks, and other keys that must hold.
- When not
- You are explaining coding style. That can stay in CLAUDE.md.
Print mode
- What
- claude -p runs one prompt and exits. text, json, and stream-json choose how the caller reads the result.
- Why
- CI has no terminal prompt to approve.
- When
- A script or pipeline should run Claude Code and parse the output.
- When not
- A person is reviewing a plan interactively. Use a normal session and plan mode.
Auto mode
- What
- A permission mode where a classifier approves routine actions and escalates the rest.
- Why
- It is hands-off without being the same as skipping every check.
- When
- You want fewer prompts and still want risky actions reviewed.
- When not
- The job runs unattended in CI. Use an allow-list and dontAsk or a sandboxed bypass, not a classifier waiting on a person.
Practical examples
The test style that rode along on every turn
A team pasted fifty lines of test conventions into the root CLAUDE.md. Editing a migration paid for those tokens. Moving them to .claude/rules/testing.md with a paths glob for test files keeps them out until a test file is read. The root file still loads. The rule adds to it. A /review skill holds the long checklist that should appear only when someone types the command.
The CI job that waited for a keyboard
A pipeline called claude with a prompt and no -p. The process opened an interactive session and stalled on a permission prompt. The job that works is print mode, stream-json if the runner wants incremental output, dontAsk or an allow-list that names npm test, and a deny for force-push. --bare is appropriate when the runner must not inherit a developer's auto memory and extra skills.
The preference that never cloned
One engineer says "remember we use pnpm." Claude writes auto memory on that machine. A teammate's clone still runs npm. Auto memory is not in git. The instruction that the team shares is a line in project CLAUDE.md, or a hook if the wrong package manager must be refused rather than discouraged.
Claude-specific considerations
- CLAUDE.md concatenation is not settings precedence. More specific does not replace a broader file.
- permissions.allow lists merge. Most scalar keys do not. The highest level that sets a scalar wins.
- auto and bypassPermissions as permissions.defaultMode are ignored in project and local settings.
- A subagent's fresh context is not a bug. The spawn prompt is the briefing.
- /clear keeps project memory. --bare skips it.
- The Messages API does not load CLAUDE.md or settings.json. Those files belong to Claude Code.
Architecture decisions
Tradeoffs
Resident instructions are always available and always cost tokens. On-demand skills and path rules are cheaper and easier to forget when the trigger does not match. Enforcement is narrower than guidance and is the only option when a miss is unacceptable.
Quick reference
- Rules with paths load for matching files. Unscoped rules and CLAUDE.md load with the session.
- A skill is SKILL.md in a directory. It becomes a slash command and loads on demand. .claude/commands/*.md still works.
- A subagent starts fresh unless it is a fork. Brief it, or fork.
- Auto memory is local notes. The MEMORY.md index loads, within 200 lines or 25KB. It is not the team standard.
- /clear drops the transcript and keeps project memory. /compact summarizes. --resume and --continue reopen a session.
- CLAUDE.md files are concatenated. Later in the load order is not a winner.
- /init drafts project CLAUDE.md and does not overwrite an existing file.
- Settings precedence, highest first: managed, session flags, local, shared project, user. Allow-lists merge.
- Print mode is claude -p. stream-json plus --include-partial-messages is streaming output.
- Auto mode classifies actions. bypassPermissions skips checks. defaultMode auto in a project file does not apply.
Decision rules for the exam
Common exam traps
Exam tips
- The domain is small. The marks come from picking the mechanism, not from reciting every flag.
- If the stem says the rule failed even though the model was told, look for a hook or a deny rule.
- If the stem says a clone is missing a convention, the convention was in user scope or auto memory.
- Do not import architect mock items as if they were this task. Answer from the operation of Claude Code.
Common mistakes
Treating CLAUDE.md like settings.json.
Instructions concatenate and can be ignored. Enforcement is settings or a hook.
Putting a personal brainstorm skill in the repository.
Team procedures go under .claude/. A personal skill stays in ~/.claude/skills/.
Calling claude without -p from CI and hoping it finishes.
Print mode exits. An interactive session waits.
Committing defaultMode auto in .claude/settings.json and expecting every clone to start there.
That value is not taken from project or local settings. Use user settings, managed settings, or --permission-mode.
Practice questions
Original questions for this topic. They are study items, not questions from the live exam.
Test naming rules should apply only while a test file is being edited. Where do they belong?
A 400-line deploy procedure is currently pasted into CLAUDE.md and costs tokens on unrelated tasks. What keeps it out of those turns?
Two CLAUDE.md files disagree about the indentation size. What does Claude Code guarantee?
A hook must reject force-push, and a personal theme preference must not affect teammates. Where does each one go?
A CI job must run Claude Code, print structured output as it is produced, and must not wait for approval. Which launch matches that?
You ask Claude to remember that you prefer pnpm in this repo. A teammate clones the repo. What do they get?
Scenario questions
The specialist that missed the bug
A parent session has already read the failing test and the recent commit. The parent asks a review subagent to explain the failure. The subagent reports that it cannot see a failing test.
What is the operational mistake?
The shared file that did not change the mode
A repository commits .claude/settings.json with permissions.defaultMode set to auto. Teammates still start in the mode their own settings and plan choose. A managed policy on the company laptops sets a different model and cannot be loosened from the repo.
Which statement matches Claude Code settings?
Build exercise
Lay out one repo's Claude Code surface
Intermediate · 40 minutes
What you will learn
- Which facts belong in CLAUDE.md, a path rule, or a skill.
- Where a hook goes versus a sentence of guidance.
- How a print-mode command differs from an interactive session.
- What auto memory will not share with a clone.
Step 1
Write a six-line inventory
For a small service, list the package-manager command, a test naming rule, a deploy runbook, a personal editor preference, a force-push ban, and a note Claude learned last week about a flaky test.
Why: The skill is placement. Six facts want different homes.
You should see: Six labeled lines.
Step 2
Assign a home to each line
Use project CLAUDE.md, .claude/rules with a paths glob, a project skill directory, user or local config, shared settings or a hook, and auto memory.
Why: Putting all six in CLAUDE.md is the common miss.
You should see: The ban is not a markdown paragraph. The runbook is not always-on.
Step 3
Write the settings object
Draft a shared .claude/settings.json that allows npm test and denies a force-push bash pattern. Add one PreToolUse hook command for the same ban. Leave defaultMode unset.
Why: The deny and the hook are the enforcement. A project defaultMode of auto would not turn auto on.
You should see: JSON with allow, deny, and a hooks entry.
Step 4
Write the unattended launch
Write a claude -p line that runs the test command, streams JSON, and does not wait for a person. Mention what --bare would drop.
Why: CI is print mode plus an output format plus a permission mode.
You should see: A command that includes -p, stream-json, and a mode that does not prompt.
Step 5
State the session move
The next task is unrelated, but the team's CLAUDE.md must stay. Name the slash command and what it does not delete. Then name the command that would reopen this transcript tomorrow.
Why: Session controls and memory files are different stores.
You should see: /clear, and a resume flag or /resume.
Review checklist
Checks are saved in this browser.
Key takeaways
- Rules, CLAUDE.md, and auto memory shape what the model reads. settings.json and hooks shape what the client allows.
- Skills and path rules are how you stop unused instructions from filling every turn.
- A session is a transcript. /clear does not clear project memory. A subagent does not inherit the transcript unless it is a fork.
- Settings precedence is managed, then flags for this launch, then local, shared project, and user. Allow-lists merge.
- Unattended Claude Code is print mode with an explicit output format and a permission mode that does not wait.
Sources
- Claude Code CLI reference — Interactive session, print mode, resume, and permission-mode flags.
- Claude Code cheatsheet — Session vocabulary, built-in slash commands, and the permission-mode cycle.
- How Claude remembers your project — CLAUDE.md load order, rules, /init, and auto memory limits.
- Settings files and precedence — Managed, flags, local, project, and user, and which defaultMode values a project file cannot set.
- CCDV-F blueprint notes — Domain 3 task statement and weight. Study notes, not exam items.