All practice tests

Module 7 practice questions: Fleets of coding agents

15 questions · Agent Fleet Operations for Software Delivery

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

  1. Question 1

    Two agents, one fixing pagination and one adding CSV export, both edit src/tickets/list.ts in the same checkout, and one overwrites the other's half-finished change. What is the best setup?

    • A) Give each task its own worktree and branch, and split or sequence the tasks so that no two touch the same files.
    • B) Let them keep running in one checkout and resolve the conflicts at the end.
    • C) Add "don't edit files another agent is editing" to CLAUDE.md.
    • D) Keep one checkout but use a faster model, so each agent finishes before the other starts.
    Show answer

    Answer: A

    • A: Right. Separate worktrees stop working files colliding, and splitting tasks by files avoids merge conflicts later.
    • B: Wrong. In one checkout they overwrite each other's work as they go, not just at the end.
    • C: Wrong. CLAUDE.md is guidance, and an agent can't see what another agent is editing.
    • D: Wrong. Speed doesn't isolate anything; it only makes the race shorter.
  2. Question 2

    A PreToolUse hook on Bash prints "push not allowed" and exits with code 1 when it sees git push. The agent still pushed. Why?

    • A) Hooks don't run for the Bash tool.
    • B) The matcher has to be a regular expression such as .*Bash.*.
    • C) PreToolUse hooks run after the tool call, not before it.
    • D) Exit code 1 is a non-blocking error; to block, the hook must exit 2 (stderr becomes the reason) or return a JSON deny decision.
    Show answer

    Answer: D

    • A: Wrong. PreToolUse hooks with a Bash matcher run for Bash calls.
    • B: Wrong. An exact tool name like Bash is a valid matcher.
    • C: Wrong. PreToolUse runs before the tool; that's what lets it block.
    • D: Right. Only exit 2 (or a JSON deny decision) blocks; exit 1 is a non-blocking error and the call goes ahead.
  3. Question 3

    A hook script starts with set -euo pipefail and then reads the command with jq. On unexpected input, jq fails and the script exits with jq's own error code. What happens, and what is the best fix?

    • A) Claude Code blocks the call on any non-zero exit, so the script is safe as it is.
    • B) The call goes ahead, because that exit code is a non-blocking error, so the hook fails open; handle the parse error explicitly and exit 2.
    • C) Claude Code retries the hook until it exits cleanly.
    • D) jq can't fail on input from Claude Code, so nothing needs to change.
    Show answer

    Answer: B

    • A: Wrong. Only exit 2 blocks; other non-zero codes are non-blocking errors.
    • B: Right. With set -e a parse failure exits with jq's code, which lets the call through; catch the error and exit 2 to fail closed.
    • C: Wrong. Hooks aren't retried until they succeed.
    • D: Wrong. Unexpected or changed input is exactly what policy code must handle safely.
  4. Question 4

    A PreToolUse hook on Read blocks .env. A teammate types "@.env what's the database URL?" in a session, and the file's contents are included anyway. What is the best fix?

    • A) Change the hook's matcher to Read|@.
    • B) Rename .env to something agents are unlikely to guess.
    • C) Add Read deny rules for the .env paths and keep the hook; @ references don't make a tool call, so the hook never runs for them.
    • D) Add "never read .env" to CLAUDE.md.
    Show answer

    Answer: C

    • A: Wrong. @ isn't a tool, so there's nothing for the matcher to match.
    • B: Wrong. Obscurity isn't protection, and a person can still @ the new name.
    • C: Right. @ references add the file without a tool call, so hooks don't run; Read deny rules are respected for them.
    • D: Wrong. CLAUDE.md guides the model; it doesn't stop a person's @ reference from including the file.
  5. Question 5

    The pagination agent made a failing test pass by changing it(...) to it.skip(...), and every gate was green. Which two gate changes best stop this? (Choose TWO.)

    • A) Tell the reviewer agent to look harder at test files.
    • B) Fail the build when the total test count is below main's baseline or the number of skipped tests rises.
    • C) Ban the word "skip" in CLAUDE.md.
    • D) Fail the build when the diff adds a .skip( or .only( call.
    • E) Require 100% line coverage on every branch.
    Show answer

    Answer: B, D

    • A: Wrong. A reviewer is useful, but this is a mechanical check that code does exactly and every time.
    • B: Right. Comparing counts with main's baseline catches skipped and deleted tests.
    • C: Wrong. Prose rules don't enforce anything, and loosened assertions don't use the word.
    • D: Right. The diff check catches a new .skip or .only at the line that adds it.
    • E: Wrong. Coverage can stay high with a skipped test, and 100% is costly and still checks the wrong thing.
  6. Question 6

    An agent lowered the numbers in test-baseline.json on its own branch, so the test-count guard passed. What is the best fix?

    • A) In CI, read the baseline from main's copy (git show origin/main:test-baseline.json), and protect the file with code owners and the scope guard.
    • B) Remove the test-count guard, since agents can game it.
    • C) Move the baseline into a CI environment variable that agents can also read.
    • D) Accept the change whenever the reviewer agent approves it.
    Show answer

    Answer: A

    • A: Right. A baseline read from main can't be changed by a branch, and protecting the file stops the edit in the first place.
    • B: Wrong. The guard is valuable; the fix is to put its reference point out of the agent's reach.
    • C: Wrong. If the agent can read it and the pipeline config holds it, it isn't any safer than the file.
    • D: Wrong. A reviewer agent can miss it; gates must not depend on it.
  7. Question 7

    An agent runs headless in CI. It must never stop to wait for approval, and it may only run npm test, npm run lint and npx tsc --noEmit. Which permission setup fits best?

    • A) bypassPermissions.
    • B) dontAsk, with allow rules for exactly those three commands.
    • C) acceptEdits.
    • D) plan.
    Show answer

    Answer: B

    • A: Wrong. Bypass skips safety checks and is meant only for isolated containers; it also ignores allow rules.
    • B: Right. dontAsk auto-denies anything that would prompt, so only the allowed commands run, with no hanging.
    • C: Wrong. acceptEdits approves edits but still prompts for other commands, which hangs a headless run.
    • D: Wrong. Plan mode doesn't make changes until a plan is approved.
  8. Question 8

    A teammate commits "defaultMode": "bypassPermissions" to the repo's .claude/settings.json so agents run without prompts. Nothing changes. Why, and what should they do instead?

    • A) The value is misspelled; it should be "bypass".
    • B) Settings files only load after the machine restarts.
    • C) Project-level settings ignore bypassPermissions (and auto) as the default mode. Use allow rules or dontAsk instead, and keep bypass mode for isolated containers, set outside the repo.
    • D) bypassPermissions only works on Linux.
    Show answer

    Answer: C

    • A: Wrong. bypassPermissions is the correct value.
    • B: Wrong. Settings don't need a restart of the machine.
    • C: Right. A repo can't grant itself bypass or auto as the default mode; use rules or dontAsk, and keep bypass for isolated environments.
    • D: Wrong. It isn't platform-specific.
  9. Question 9

    The settings contain the deny rule Bash(git push *). An agent runs in bypassPermissions mode inside a disposable container and tries git push origin agent/csv-export. What happens?

    • A) It runs, because bypass mode skips every rule.
    • B) It runs, because deny rules only apply in default mode.
    • C) It's blocked only if a PreToolUse hook is installed as well.
    • D) It's blocked: deny rules apply in every mode, including bypassPermissions.
    Show answer

    Answer: D

    • A: Wrong. Bypass skips prompts, but deny rules still block.
    • B: Wrong. Deny rules apply in every mode.
    • C: Wrong. The deny rule blocks on its own.
    • D: Right. Deny rules always block, even in bypassPermissions (and git push * matches this command).
  10. Question 10

    Who should review an agent's pull request, and who decides?

    • A) The authoring agent, in the same session, asked to double-check its own work.
    • B) Nobody needs to review it if all the gates pass.
    • C) A reviewer agent, which approves and merges the PR if it finds nothing.
    • D) A separate reviewer agent with fresh context reports findings, the findings are checked, and then a person reads the diff and decides; agents never merge.
    Show answer

    Answer: D

    • A: Wrong. The author mostly re-reads its own reasoning, which is the weakest review.
    • B: Wrong. Gates check what code can check; correctness, design and security need review.
    • C: Wrong. Agents must not merge; the decision stays with a person.
    • D: Right. Fresh context finds what the author missed, findings are verified, and a person decides.
  11. Question 11

    Three agent PRs turn green at the same time. How should they be merged?

    • A) One at a time: after each merge the others rebase on the new main and re-run their gates, and any conflict goes back to the owning agent.
    • B) Merge all three at once, since each one is green.
    • C) Combine all three branches in a single merge commit.
    • D) Have the coordinator session resolve every conflict itself.
    Show answer

    Answer: A

    • A: Right. Each PR is only green against the main it started from; rebasing and re-gating after each merge keeps main green, and the owner knows the branch's intent.
    • B: Wrong. Branches that were green separately can break together.
    • C: Wrong. One combined merge mixes three changes, making failures hard to attribute and revert.
    • D: Wrong. The coordinator doesn't know each branch's intent as well as the agent that wrote it.
  12. Question 12

    An agent has spent 40 turns on a flaky test, and its spend keeps climbing. What is the best action?

    • A) Keep nudging it with more hints until it gets there.
    • B) Switch it to bypassPermissions so it can try more things.
    • C) Stop it at its budget, rewrite the brief with what you've learned (the known flake, a narrower done criterion), and restart it fresh.
    • D) Start three more agents on the same task and keep whichever finishes first.
    Show answer

    Answer: C

    • A: Wrong. After a long struggle the context is full of failed attempts, and more hints rarely help.
    • B: Wrong. More autonomy for a stuck agent raises risk without fixing the brief.
    • C: Right. A fresh start with a sharper brief usually beats nudging, and the budget caps the waste.
    • D: Wrong. It multiplies cost on a task that's failing because of the brief.
  13. Question 13

    The coordinator is writing a brief for "fix the page-2 bug". Besides the goal and the files in scope, which two sections matter most? (Choose TWO.)

    • A) Done criteria, including a new test that fails on the old code.
    • B) The full transcript of the planning chat.
    • C) A personality description for the agent.
    • D) A list of every file in the repository.
    • E) An explicit out-of-scope list (for example src/auth/, dependencies, CI config).
    Show answer

    Answer: A, E

    • A: Right. Done criteria decide when the agent stops, and a test that fails on old code stops tests that pass either way.
    • B: Wrong. A long transcript buries the instructions; the brief should be distilled.
    • C: Wrong. Personality doesn't help an agent finish or stay in scope.
    • D: Wrong. The agent can list files itself; listing everything says nothing about scope.
    • E: Right. An explicit out-of-scope list prevents scope creep and gives the scope guard its rules.
  14. Question 14

    The CI secret scan flags a real API key for a test environment in a fixture on an agent's branch. What is the best response?

    • A) Delete the file in a new commit and merge.
    • B) Treat the key as exposed: revoke and rotate it, remove it from the branch history before merging, and keep the gate blocking.
    • C) Mark the finding as a false positive, since it's only a test key.
    • D) Add "never commit secrets" to CLAUDE.md and merge.
    Show answer

    Answer: B

    • A: Wrong. The key is still in the branch history and has been exposed.
    • B: Right. An exposed key is compromised whatever environment it's for: rotate it, clean the history, keep the gate.
    • C: Wrong. Test-environment keys still give access to something, and the scan was right.
    • D: Wrong. A note in CLAUDE.md doesn't fix the exposure that already happened.
  15. Question 15

    You want a hard guarantee that no agent can change main without a person, even if a hook is missing or a command slips past a rule. Which two controls give that guarantee? (Choose TWO.)

    • A) A line in CLAUDE.md: "Never push to main."
    • B) A Bash deny rule for git push.
    • C) Agent credentials that have no right to push to main or to approve PRs.
    • D) A reviewer-agent prompt that rejects direct pushes.
    • E) Branch protection on main that requires passing checks and an approving human review.
    Show answer

    Answer: C, E

    • A: Wrong. CLAUDE.md is guidance the model usually follows, not a guarantee.
    • B: Wrong. A Bash rule matches command text, so other ways of running the program can slip past it; it's a guardrail, not a boundary.
    • C: Right. If the credentials can't push or approve, no command the agent writes can change main.
    • D: Wrong. A reviewer agent is advisory and can be wrong or skipped.
    • E: Right. Branch protection is enforced by the Git host, outside the agent's environment, and requires a person.

↑ ↓ सार्नुहोस् · ↵ छान्नुहोस् · esc बन्द