Rubric
Contents — domains, guide and mocks

Operating Claude Code

CCDV-F 3.114 min read · checked 21 September 2026

Task statementClaude Code Operation (3.1%) — core components (Rules, Skills, Commands, Agents, Agent Memory), session management, built-in and custom slash commands, headless and streaming modes, the CLAUDE.md hierarchy, repository initialization, and settings.json

Where does this instruction belong?

What kind of instruction is it?
  • True in every session
    CLAUDE.mdLoaded at every session start
  • Only for some files
    .claude/rules/Path-scoped, loads on match
  • A whole procedure
    SkillLoads when invoked or relevant
  • Must never happen
    HookCode, not context
Ask how often it is relevant and whether it must be obeyed. Those two answers pick the file for you.

The core components

Five mechanisms extend a Claude Code session, and they differ in one dimension above all: when their content enters the context window.

ComponentLives inWhen it loads
Rules and instructionsCLAUDE.md, ./.claude/CLAUDE.md, .claude/rules/*.mdEvery session; path-scoped rules load when Claude touches matching files
Skills.claude/skills/ and ~/.claude/skills/Descriptions at start; the full content only when invoked or judged relevant
Commands.claude/commands/ and ~/.claude/commands/When you type /name
Agents (subagents).claude/agents/ and ~/.claude/agents/When Claude delegates, or you name one
Auto memory~/.claude/projects/<project>/memory/The MEMORY.md index every session; topic files on demand

The practical rule follows from the right-hand column. Anything that must be true all the time goes in a memory or rules file and costs context on every request. Anything that matters occasionally goes in a skill, so it costs almost nothing until it is needed. Anything that must be obeyed rather than considered goes in a hook, because instruction files are context, not enforced configuration.

The CLAUDE.md hierarchy

Claude Code loads CLAUDE.md and CLAUDE.local.md from the working directory and every directory above it, concatenating them rather than letting one override another. Content is ordered from the filesystem root down to where you launched, so the most specific file is read last. Files in subdirectories below the working directory are not loaded at launch — they load when Claude reads files in those directories.

Memory files, broadest first

loaded in this order, top to bottom

  1. Managed policyorganisation-wide, deployed by IT
  2. User~/.claude/CLAUDE.md, all your projects
  3. Project./CLAUDE.md or ./.claude/CLAUDE.md
  4. Local./CLAUDE.local.md, gitignored
  5. Subdirectoryloads when Claude reads those files
Nothing here overrides anything: it is all concatenated. Later text simply sits closer to the task, and within a directory the local file follows the shared one.

A CLAUDE.md can pull in other files with @path/to/file, expanded at launch, recursively, to a maximum depth of four hops. Wrap a path in backticks to mention it without importing it. The guidance on size is blunt: aim under 200 lines, because longer files consume context and reduce adherence — split by topic into .claude/rules/, where a paths frontmatter field scopes a rule to matching files so it loads only when relevant.

A CLAUDE.md that works

Vague

# Project notes

Format code properly and
keep files organised.

Test your changes before
you commit anything.

Follow our conventions.

Verifiable

# Payments API

- Use 2-space indentation
- Run `npm test` before
  committing
- Handlers live in
  `src/api/handlers/`
- Never edit
  `db/migrations/` by hand
The right-hand version is verifiable. Every line names a command, a path or a rule you could check — which is what makes it worth the tokens it costs on every request.

Slash commands, built-in and custom

A slash command is recognised only at the start of a message, and whatever follows the name becomes its arguments. The built-ins worth knowing by name: /init to bootstrap a project, /clear to start a fresh conversation, /compact to summarise the current one, /context to see what is occupying the window, /memory to view and edit memory files, /resume to return to an earlier conversation, /agents to manage subagents, /permissions and /config for rules and settings, /mcp for server connections, /model and /status.

Custom commands are markdown files: .claude/commands/ for ones the team shares through version control, ~/.claude/commands/ for your own across every project. The body is the prompt; YAML frontmatter can set description, argument-hint, allowed-tools and model. Inside the body, $ARGUMENTS is everything typed after the name, and $1, $2 pick out individual arguments.

`.claude/commands/audit.md`text
---
description: Security audit for a package
argument-hint: "[scope]"
allowed-tools: bash, read
model: opus
---

Run a security audit on $ARGUMENTS. Check for injection,
hardcoded secrets and insecure dependencies. Report each
finding as file:line followed by one line of explanation.

Sessions, headless mode and streaming

A session is the conversation transcript, written to disk automatically. /resume returns to one interactively. From a script, --continue picks up the most recent conversation in the directory and --resume <session-id> returns to a specific one — capture the id from the JSON output when you start it.

Headless mode is the same tool without the terminal interface: claude -p "…". It reads standard input, so you can pipe a diff or a log into it, and it exits non-zero when a run fails so a pipeline can branch on the status. Three output formats: text (the default), json (the result plus session id, usage and cost) and stream-json (newline-delimited events as they happen).

Headless in a pipelinebash
# Pipe a diff in, get plain text out
git diff main | claude -p "list any typos as file:line" --allowedTools "Read"

# Structured output, then reuse the session id
session=$(claude -p "Start a review" --output-format json | jq -r '.session_id')
claude -p "Now focus on the database queries" --resume "$session"

# Event-by-event streaming for a live UI
claude -p "Explain recursion" --output-format stream-json --verbose

A headless run in CI

  1. Pipe inputdiff, log or prompt on stdin
  2. claude -pwith --allowedTools
  3. Read outputtext, json or stream-json
  4. Branch on exitnon-zero fails the job
Each stage is ordinary shell plumbing. The only Claude-specific parts are the flags that decide what the process may do and what shape the output takes.

settings.json and who wins

Settings files hold configuration rather than instructions: permission allow, ask and deny rules, hooks, environment variables, the default model, plugins. Four files, plus managed settings an organisation can deploy.

ScopeFileAffects
Managedmanaged-settings.json and other managed sourcesEveryone the organisation deploys it to; you cannot override it
Command lineclaude --settings <file-or-json>This session only
Project local.claude/settings.local.jsonYou, in this project; kept out of git
Shared project.claude/settings.jsonEveryone who clones the repository
User~/.claude/settings.jsonYou, in every project on this machine

That table is also the precedence order, highest first: managed, then command line, then project local, then shared project, then user. A key set higher wins. There is one important exception to the mental model — list keys such as permissions.allow merge across files rather than overriding, so each file can add entries without erasing another's.

Traps the wrong answers are built from

Tempting but wrongDo this instead
Putting a long procedure in CLAUDE.mdMove it to a skill so it loads only when that kind of work comes up.
Relying on CLAUDE.md to prevent a dangerous actionMemory files are context, not enforcement — use a PreToolUse hook.
Expecting a project CLAUDE.md to override a user oneMemory files concatenate; it is settings files that override.
Running claude -p in CI with broad tool accessPre-approve narrow rules such as Bash(git diff *), and consider --bare for reproducibility.
Treating /init output as the finished configurationAdd the facts the model cannot discover, then keep the file short.

You should now be able to

  • Place an instruction correctly across CLAUDE.md, .claude/rules/, skills, commands and hooks.
  • State the CLAUDE.md load order and explain that files concatenate rather than override.
  • Write a custom slash command with frontmatter and arguments.
  • Run Claude Code headlessly with the right output format and pre-approved tools.
  • Resolve which settings file supplies a value, and recognise where lists merge instead.

Practice questions

Original questions written for this lesson, in the exam’s style. Answer first, then open the reasoning — every option is explained, including why the wrong ones are tempting.

  1. Question 1

    A monorepo has CLAUDE.md at the repository root and another in services/billing/. An engineer launches Claude Code from services/billing/ and asks why the root instructions still seem to apply.

    What is the correct explanation?

    1. AOnly the nearest CLAUDE.md loads; the root file must have been imported with @.
    2. BBoth files load and are concatenated, root first and the nearer file last.
    3. CThe root file wins because broader scope has higher precedence.
    4. DThe nearer file replaces the root file for any heading they share.
    Show answer and reasoning
    1. AIncorrect. Files in the directory hierarchy above the working directory all load; an import is not required.
    2. BCorrect. Memory files accumulate rather than override, ordered from the filesystem root down to the working directory.
    3. CIncorrect. That is settings-file behaviour. Memory files do not have winners.
    4. DIncorrect. There is no section-level merge; the whole of each file enters context.
  2. Question 2

    A team wants a nightly job that reviews the previous day's merged pull requests and writes findings to a file, with no human available to answer prompts.

    Which two choices make that run behave predictably? (Select 2.)

    1. ARun claude -p and pre-approve only the tools the job needs with --allowedTools.
    2. BUse --output-format json so the script can read the result and session id programmatically.
    3. CAdd an instruction to CLAUDE.md telling Claude not to ask for permission.
    4. DRely on the default text output and grep the response for keywords.
    5. EPass --resume with no session id so the job starts clean each night.
    Show answer and reasoning
    1. ACorrect. Headless mode with narrow pre-approval means nothing waits on a prompt and nothing unexpected runs.
    2. BCorrect. Structured output gives the result text plus session metadata and cost, which a script can parse and branch on.
    3. CIncorrect. Permission behaviour is configuration, not something a memory file can grant.
    4. DIncorrect. Parsing prose is brittle compared with reading a structured field.
    5. EIncorrect. --resume requires an id; a fresh run needs no session flag at all.
  3. Question 3

    A security team wants Claude Code sessions across the company never to run a particular family of shell commands, whatever an individual engineer configures locally.

    Where should that rule live?

    1. AIn each engineer's ~/.claude/settings.json, distributed by a setup script.
    2. BIn the repository's .claude/settings.json, committed to version control.
    3. CIn managed settings deployed by the organisation.
    4. DIn the root CLAUDE.md, stated as a prohibition.
    Show answer and reasoning
    1. AIncorrect. User settings sit at the bottom of the precedence stack and any project file can override them.
    2. BIncorrect. Shared project settings are overridden by a developer's own project-local file.
    3. CCorrect. Managed settings sit at the top of the precedence stack and nothing an individual sets overrides them.
    4. DIncorrect. Memory files are context the model considers, not a permission rule it must obey.

Sources

Drafted with AI assistance and checked against the sources above; expert review is in progress. Spotted an error? Tell us and it gets fixed, dated and listed on how this is written.