All practice tests

Module 2 practice questions: Claude Code setup and workflows

15 questions · Claude Code Configuration & Workflows

Practice questions written by Sanjay Shah. Not exam questions, not affiliated with or endorsed by Anthropic.

  1. Question 1

    A team's root CLAUDE.md says "Never read .env or anything in secrets/." During a debugging session, Claude Code read .env.production anyway. What is the best fix?

    • A) Move the sentence to the top of CLAUDE.md and put it in bold.
    • B) Add a .claudeignore file listing .env* and secrets/.
    • C) Add Read deny rules for .env* and secrets/** to the shared .claude/settings.json, and keep the CLAUDE.md line to explain why.
    • D) Ask each developer to start sessions in plan mode.
    Show answer

    Answer: C

    • A: Wrong: placement and bold make a request more visible, but it is still a request.
    • B: Wrong: the docs say a .claudeignore file has no effect (checked 2026-11-25). Deny rules are the mechanism.
    • C: Right: CLAUDE.md is knowledge, not enforcement. A Read deny rule in shared settings blocks the read for everyone, and the CLAUDE.md line still explains the reason.
    • D: Wrong: plan mode limits editing; it doesn't stop reading, and it isn't a secrets control.
  2. Question 2

    A developer wrote a PreToolUse hook to stop edits to infra/prod/. The script prints "blocked" and exits with code 1. Edits to infra/prod/ still happen. Why, and what is the fix?

    • A) Only exit code 2 blocks; exit 1 is a non-blocking error. Exit 2 and print a reason (with what to do instead) to stderr.
    • B) PreToolUse hooks can't block edits; use a PostToolUse hook to undo them.
    • C) The hook must be in CLAUDE.md, not in settings.
    • D) Exit code 1 blocks only in plan mode; switch the team to plan mode.
    Show answer

    Answer: A

    • A: Right: for command hooks, exit 2 is the blocking signal, and stderr becomes the reason Claude sees. Any other non-zero code is a non-blocking error, and the action goes ahead.
    • B: Wrong: PreToolUse is exactly the event that can block a tool call. Undoing afterwards is worse.
    • C: Wrong: hooks are configured in settings files; CLAUDE.md can't run code.
    • D: Wrong: exit codes don't change meaning by mode.
  3. Question 3

    A lead added team permission rules to .claude/settings.local.json in the repo and told everyone they were "in place". New team members don't get the rules. What is the best fix?

    • A) Copy the file into each person's ~/.claude/settings.json.
    • B) Put the rules in CLAUDE.md so they are loaded for everyone.
    • C) Rename the file to settings.team.json.
    • D) Move the rules to .claude/settings.json, which is committed and shared; keep settings.local.json for personal preferences.
    Show answer

    Answer: D

    • A: Wrong: copying to user settings is manual, drifts, and applies to every project, not just this one.
    • B: Wrong: CLAUDE.md doesn't enforce permissions.
    • C: Wrong: Claude Code doesn't read a file by that name.
    • D: Right: .claude/settings.json is the shared, committed project layer. settings.local.json is personal and normally kept out of git.
  4. Question 4

    A company lets outside contractors use Claude Code on its repos. Security wants some limits (such as never running curl to unknown hosts, never reading credentials folders) that no project file or personal setting can loosen. What is the best mechanism?

    • A) A strongly worded section in every repo's CLAUDE.md.
    • B) Managed settings deployed by the organisation, which sit above every other settings layer.
    • C) Project .claude/settings.json in each repo, reviewed in pull requests.
    • D) A UserPromptSubmit hook in each contractor's user settings.
    Show answer

    Answer: B

    • A: Wrong: CLAUDE.md is advice, not a limit.
    • B: Right: managed settings sit at the top of the settings layers and can't be overridden by project, local or user files.
    • C: Wrong: project settings help, but they live in each repo, can be changed in a PR, and don't cover repos where someone forgot them.
    • D: Wrong: a hook in the contractor's own user settings is under the contractor's control, and prompt checks don't control tool use.
  5. Question 5

    A project's CLAUDE.md has grown to 700 lines, including pasted design documents and old incident notes. Developers say Claude now ignores conventions it used to follow. What is the best change?

    • A) Split it into two 350-line files in the same folder.
    • B) Cut the root file to the essentials (commands, map, key conventions, traps); turn the long guides into skills or plain-text pointers that load only when needed, and move folder-specific rules into folder CLAUDE.md files or path-scoped rules.
    • C) Switch to a model with a larger context window.
    • D) Repeat the most important conventions at the top and bottom of the file.
    Show answer

    Answer: B

    • A: Wrong: memory files add up, so two files in the same place still load the same 700 lines. (Moving the text behind @imports wouldn't help either: imported files load at launch too.)
    • B: Right: every line of CLAUDE.md is loaded each time. Keeping the root short makes the important lines count. Skills, path-scoped rules and folder files load detail only where it's needed.
    • C: Wrong: the problem is signal-to-noise and cost, not running out of room.
    • D: Wrong: repetition adds more lines and doesn't remove the noise.
  6. Question 6

    A "code reviewer" subagent was meant to only review. It sometimes "fixes" the code it reviews, and those edits reach pull requests unreviewed. What is the best fix?

    • A) Add "do not edit files" to the subagent's prompt in capital letters.
    • B) Run the reviewer only in the main session instead of as a subagent.
    • C) Set a lower maxTurns so it has less time to edit.
    • D) Limit the subagent's tools to read-only tools such as Read, Grep and Glob.
    Show answer

    Answer: D

    • A: Wrong: a prompt instruction is a request.
    • B: Wrong: it loses the benefits of a subagent (own context, its own tools) and doesn't stop editing.
    • C: Wrong: fewer turns limit length, not capability. One turn is enough to edit a file.
    • D: Right: the subagent's tools list is enforcement. Without edit tools, it can't edit.
  7. Question 7

    A team committed .mcp.json with their issue tracker's API token written in the headers. What is the best fix (after rotating the token)?

    • A) Replace the token with ${TRACKER_TOKEN} so each person's environment supplies it, and keep the file committed so the team shares the server definition.
    • B) Delete .mcp.json and have each developer add the server at local scope with the shared token.
    • C) Keep the token in the file but make the repository private.
    • D) Move the token into CLAUDE.md, which Claude reads anyway.
    Show answer

    Answer: A

    • A: Right: .mcp.json supports ${VAR} expansion. The committed file shares the server definition; each person's environment holds the secret.
    • B: Wrong: it loses the shared definition and spreads a shared token around.
    • C: Wrong: a private repo still keeps the secret in git history, visible to everyone with access.
    • D: Wrong: CLAUDE.md is committed too, and it puts the secret into the model's context.
  8. Question 8

    Developers keep pasting the same eight-step instructions for "add a new API endpoint the house way" (route, validation, tenant filter, tests). What is the best place for this?

    • A) A PreToolUse hook that blocks any new route file unless all eight steps are followed.
    • B) The root CLAUDE.md, so it is loaded in every session.
    • C) A project skill (.claude/skills/add-endpoint/SKILL.md) with a clear description, which Claude loads when relevant and anyone can run as /add-endpoint.
    • D) An MCP server that returns the instructions.
    Show answer

    Answer: C

    • A: Wrong: a hook can't check "did you follow eight steps", and blocking isn't teaching.
    • B: Wrong: it loads the instructions into every session, even those that never add an endpoint.
    • C: Right: a repeatable multi-step job is what skills are for. The description lets Claude pick it up when relevant, and /add-endpoint runs it on demand. It costs little context until used.
    • D: Wrong: an MCP server is for outside systems; this is local know-how.
  9. Question 9

    A team wants Claude Code to review every pull request in CI. The draft pipeline runs Claude in bypassPermissions mode with all tools and the deploy credentials in the environment. Which two changes give the best design? (Choose TWO.)

    • A) Keep bypassPermissions, but remove the deploy credentials.
    • B) Let the CI run approve and merge PRs that it finds no issues in, to save reviewer time.
    • C) Run headless (claude -p) with --allowedTools limited to read-only tools, and JSON output that the pipeline turns into PR comments.
    • D) Run it interactively on a developer's laptop and paste the results into the PR.
    • E) Give the CI run only the secrets the review needs, and keep merging with a human reviewer.
    Show answer

    Answer: C, E

    • A: Wrong: bypassPermissions with all tools can still edit, push or run anything else available.
    • B: Wrong: the bot reviews and a person merges; "no issues found" isn't approval.
    • C: Right: an explicit allow-list of read-only tools plus structured output is least-privilege automated review.
    • D: Wrong: it isn't automated or consistent.
    • E: Right: minimal secrets limit the damage if something goes wrong, and a human merge keeps the final decision with a person.
  10. Question 10

    Two developers run Claude Code sessions in the same checkout, on different tasks. Files get overwritten, and tests fail for reasons nobody understands. What is the best fix?

    • A) Have both sessions use plan mode only.
    • B) Ask each session to commit after every edit.
    • C) Use a shared CLAUDE.md that lists who is editing which files.
    • D) Give each session its own git worktree and branch (for example claude --worktree <name>).
    Show answer

    Answer: D

    • A: Wrong: plan-only sessions can't do the tasks.
    • B: Wrong: commits don't stop two processes writing the same files at the same time.
    • C: Wrong: a list is advice and goes stale.
    • D: Right: worktrees give each session its own folder and branch, so the sessions can't overwrite each other.
  11. Question 11

    Only the payments/ folder has extra rules: amounts in integer minor units, a fixed rounding rule, and idempotency keys on every write. Where should this knowledge go?

    • A) In payments/CLAUDE.md (or a rule file scoped to payments/**), so it loads when Claude works in that folder.
    • B) In the root CLAUDE.md, so it's always present.
    • C) In each developer's ~/.claude/CLAUDE.md.
    • D) In a PreToolUse hook that prints the rules before every edit anywhere in the repo.
    Show answer

    Answer: A

    • A: Right: knowledge that applies to one folder belongs in that folder's CLAUDE.md or a path-scoped rule, which loads when Claude works there.
    • B: Wrong: it adds context to every task in every folder.
    • C: Wrong: personal files aren't shared, so the team gets inconsistent behaviour.
    • D: Wrong: a hook is for enforcement; printing rules before every edit anywhere is noisy and mis-scoped.
  12. Question 12

    A developer asked Claude Code to "migrate the whole API from callbacks to async/await". It edited 40 files; halfway through, it chose an approach the team didn't want, and most of the diff was thrown away. What would most likely have prevented this?

    • A) A shorter CLAUDE.md.
    • B) Running the task in acceptEdits mode so it finished faster.
    • C) Starting in plan mode, reviewing and correcting the plan, and only then letting it edit.
    • D) Asking Claude to commit after each file.
    Show answer

    Answer: C

    • A: Wrong: unrelated to choosing the approach.
    • B: Wrong: faster editing makes a wrong approach spread faster.
    • C: Right: for big changes, plan mode lets you see and correct the approach before any file changes. Fixing a plan is cheap; fixing 40 files isn't.
    • D: Wrong: commits make undoing easier but don't prevent the wrong approach.
  13. Question 13

    A PreToolUse hook blocks rm -rf commands by exiting 2 with no message. Claude then tried find . -delete to do the same thing. Which two improvements are best? (Choose TWO.)

    • A) Print a clear reason on stderr that says why it's blocked and what to do instead (for example, ask the user, or preview with git clean -n).
    • B) Change the exit code to 1 so Claude gets a softer signal.
    • C) Remove the hook and add "don't delete files" to CLAUDE.md.
    • D) Widen the hook to cover other ways of deleting files, such as find … -delete.
    • E) Block every Bash command.
    Show answer

    Answer: A, D

    • A: Right: Claude adapts to the reason it's given; a safe alternative stops it hunting for workarounds.
    • B: Wrong: exit 1 is a non-blocking error, so it doesn't block at all.
    • C: Wrong: it replaces enforcement with advice.
    • D: Right: the rule is about deleting, not about one command, so the hook should cover the obvious equivalents.
    • E: Wrong: it breaks normal work (tests, builds) to fix one risk.
  14. Question 14

    A team wants the formatter and the tests next to an edited file to run automatically after every edit Claude makes, with the test output fed back to Claude. Which mechanism fits best?

    • A) A line in CLAUDE.md: "Always run the formatter and tests after editing."
    • B) A PreToolUse hook on Edit|Write.
    • C) A PostToolUse hook on Edit|Write that runs the formatter and the nearby tests.
    • D) A nightly CI job.
    Show answer

    Answer: C

    • A: Wrong: advice, not automation; it will be skipped sometimes.
    • B: Wrong: PreToolUse runs before the edit exists.
    • C: Right: PostToolUse runs after the tool succeeds, so it can format and test the edited file, and the output reaches Claude.
    • D: Wrong: nightly is too late for Claude to act on in the session.
  15. Question 15

    To answer "where is tenant filtering done across the codebase?", the main Claude Code session read about 200 files. The session became slow, and later answers in the same session got worse. Which two practices should the team adopt? (Choose TWO.)

    • A) Raise the session's output token limit.
    • B) Delegate large searches to a subagent with read-only tools, which reads the files in its own context and returns a short summary with file paths.
    • C) Ask Claude to "remember only the important parts".
    • D) Turn off CLAUDE.md for the session.
    • E) Use /clear between unrelated tasks, so each one starts with a focused context.
    Show answer

    Answer: B, E

    • A: Wrong: output limits don't affect how full the context is.
    • B: Right: a subagent has its own context window, so the 200 files never enter the main session.
    • C: Wrong: not a mechanism; the files are already in the context.
    • D: Wrong: CLAUDE.md is small; the 200 files are the problem.
    • E: Right: a fresh context per task stops one task's leftovers from crowding out the next.

↑ ↓ navigate · ↵ select · esc close