Deployed Lab

Module 7 · Scenario labs · Chapter 27

Scenario lab 2: Code Generation with Claude Code

19 min1 clickable picture1 break-it lab1 predict, 2 quick quizzes, 5-question final quiz5-min video review
In 30 seconds

The picture: a relay race. Every runner must hold the same baton, not a private copy.

Exam objective: Scenario 2, Code Generation with Claude Code

One of the six official scenarios, drawn at random on exam day. It mixes domains. You should be able to:

The cold open

Harbor & Pine Outfitters is a made-up company. Owen Brandt owns the harbor-web monorepo and CI. Support wants a returns-reason field, to see why gear comes back.

The code was fine. The setup was private, partial and vague. This lab rebuilds it in the open.

The plan for this chapter
  1. Decision 1: where the conventions live (chapter 13).
  2. Decision 2: how the repeatable work is shared (chapter 14).
  3. Decision 3: plan mode or direct edits (chapter 15).
  4. Decision 4: what the CI reviewer checks (chapters 16 and 17).
  5. Break-it lab: find three planted faults in the team setup.
  6. Worked example, then the final quiz, all in Scenario 2.

Next: where the conventions live.

Step 1: Put conventions where the whole team, and CI, can see them

Why this step: chapter 13 (CLAUDE.md hierarchy and path rules) is the base here. A rule in the wrong file helps one laptop only.

Think of a shop noticeboard versus a note in one worker's pocket. The whole shift reads the board.

Where the picture breaks down:

# .claude/rules/tests.md (illustrative)
---
paths:
  - "src/**/*.test.tsx"
  - "src/**/*.test.ts"
---
Tests sit beside the code they test.
Name the case for the behaviour, not the method.
Cover the empty, invalid and happy path.

Quick check: where does the test convention belong?

Next: package the repeatable part as a command.

Step 2: Share the repeatable part as a command

Why this step: chapter 14 (Commands and skills) covers the repeatable slice of a job. Adding a field follows the same steps every time.

  1. Add the field to the form component.
  2. Add it to the API handler and its validation.
  3. Add it to the repository-pattern data layer.
  4. Add or update tests beside each changed file.
  5. Run the tests and report what changed.

That list becomes a project command in .claude/commands/, checked in like the rules. Anyone gets the same steps, order and checks.

# .claude/commands/add-field.md (illustrative)
---
description: Add one field across form, API, data layer and tests
argument-hint: [field-name] [field-type]
allowed-tools: Read, Edit, Grep, Glob, Bash
---
Add $1 ($2) in this order: React form, API handler,
repository data layer, then tests beside each file.
Run the test suite with Bash and report failures.

Note allowed-tools. The lab will test it: a command that cannot run the test runner cannot finish its own last step.

Next: plan first, because this change touches many files.

Step 3: Use plan mode when the change crosses layers

Why this step: chapter 15 (Plan mode and refinement) gives the rule. Direct edits suit a one-file fix. This change touches four layers.

Do this: predict before you reveal.

Rework across every layer already touched. One line in a plan ("fixed list of six reasons") would have prevented it. Plan mode pays when a wrong early choice multiplies across files.

Next: the picture, from plan to merged pull request.

Step 4: Follow the change from plan to merged pull request

Why this step: the exam tests the whole flow. Press Next to walk it.

A field change flows from plan to merged pull request Plan mode lists the files. The shared command edits the React form, the API handler and the repository data layer, adds tests beside the code, then CI review checks explicit criteria before a human merges. Plan modefiles and order React formreason dropdown API handlervalidate the list Data layerrepository pattern Testsbeside the code CI reviewexplicit criteria Merged PRhuman approves
  1. Plan mode lists every file across the four layers. Owen spots the fixed-list decision before any code exists.
  2. The shared command works in plan order: form, API handler, then the repository data layer. Project rules load throughout.
  3. Each changed file gets its test next door, in the style of the path rule scoped to test files.
  4. The CI reviewer checks the written criteria list, not a general feeling about the code.
  5. CI comments, tests pass, and a human approves. The machine advises, the person decides.
PlanInterfaceAPIData and testsCI check

Next: what the CI reviewer should actually check.

Step 5: Give the CI reviewer criteria, not vibes

Why this step: chapters 16 (Claude Code in CI/CD) and 17 (Explicit criteria and few-shot) meet here. This reviewer once flagged too much, so developers ignored it.

Quick check: which CI instruction is checkable?

Worked example (all numbers made up): what the shared setup saves on this one change.

1. Files touched: 4 form + 3 API + 3 data layer + 4 test files = 14 files.

2. Without the command, a made-up 25 minutes of setup and test-style fixes per file batch, times 4 layers = 100 minutes.

3. With the command and rules loaded, made-up rework drops to 20 minutes total.

4. Saving: 100 - 20 = 80 minutes on one field.

5. The team ships a made-up 6 such changes a month: 6 x 80 = 480 minutes, or 8 hours a month.

The saving comes from shared files, not from anyone typing faster.

Next: the break-it lab, with three planted faults.

Step 6: Break-it lab, debug the team setup

Why this exercise: Scenario 2 rarely hands you a blank repo. It hands you a plausible setup with quiet faults.

Lab: Step 6 hands you a plausible harbor-web setup with three quiet faults. This lab runs in your browser and needs JavaScript enabled.

Field note, November 2026

A habit worth copying: treat Claude Code config like code. Rules, commands and CI prompts go through pull request review, so a bad rule is caught like a bad function. Practice advice, not a measured statistic.

The Deployed Lab jobs page (snapshot 15 Nov 2026) lists 367 open FDE roles, median posted base about $243K, base pay only.

Mix-ups to avoid

Chapter quiz

Five questions. Score 70% or more to mark this chapter complete.

Review this chapter in 5 minutes

Watch the whole chapter recapped: conventions in the repo, a shared add-field command, plan mode, and explicit CI criteria.

Decision rule: for any Scenario 2 setup, ask three questions: can the team and CI load it, can it run every step it promises, and does it load only where it applies?

Independent exam preparation. Not affiliated with or endorsed by Anthropic.

Review

Glossary

Project CLAUDE.md
Checked-in instructions at the repo root that every session and CI run loads. Example: harbor-web layer rules.
User CLAUDE.md
Your personal instruction file, loaded only for you. Example: your own shorthand habits.
Path rule
A file in .claude/rules/ with paths frontmatter, loaded only for matching files. Example: test style for *.test.tsx.
Slash command
A saved, named workflow in .claude/commands/ that anyone on the team can invoke. Example: /add-field.
allowed-tools
The enforced list of tools a command or skill may use. Example: Read, Edit, Grep, Glob, Bash.
Plan mode
A mode where Claude explores and proposes steps before editing. Example: listing 14 files before the field change.
Repository pattern
Data access kept in one layer, so handlers never call the database directly. Example: the harbor-web data layer.
CI reviewer
Claude Code running in the pull request pipeline, commenting against set criteria. Example: flagging a reason outside the fixed list.
Explicit criteria
Review rules written so two runs reach the same verdict. Example: a test file beside every changed file.
Few-shot example
A worked example inside instructions that shows the wanted behaviour. Example: one passing and one failing snippet per criterion.

Next: "Scenario lab 3: Multi-Agent Research System".