Implementation Katas
Four focused drills that exercise the habits from this module. Each targets a specific skill. Repeat each until the technique is automatic.
Kata 1: Write a Regression Test for a Fictional Bug
Time limit: 20 minutes Skill: Regression-first fixing (Concept 11)
Setup: you maintain the fictional task-manager capstone. The following triage entry arrived this morning:
id: BUG-2026-04-21-07
title: DELETE /tasks/{id} returns 204 for tasks the caller does not own
sev: Sev-1
impact: cross-tenant data deletion; security
root-cause suspected: authorization
Instructions:
- Write the smallest test that reproduces the bug. Pick the cheapest level (unit, integration, or E2E) that can reliably show it.
- Confirm the test fails for the right reason, not just any reason.
- Describe in one sentence the smallest fix that would make the test pass.
- Explain why a test written after the fix would be less valuable here.
Repeat until: you can go from triage entry -> failing test in under 10 minutes, and you can name which test level you picked and why.
Kata 2: Refactor a Smelly Function Using a Named Fowler Move
Time limit: 20 minutes Skill: Refactoring cadence with named moves (Concept 13)
Setup: you are given this function in the task-manager service:
def notify(task, user, settings):
if settings.email_enabled:
if user.email and user.verified:
if task.priority in ("high", "urgent"):
send_email(user.email, f"Urgent: {task.title}")
else:
send_email(user.email, f"Update: {task.title}")
if settings.sms_enabled:
if user.phone and user.phone_verified:
if task.priority in ("high", "urgent"):
send_sms(user.phone, f"Urgent: {task.title}")
else:
send_sms(user.phone, f"Update: {task.title}")
Instructions:
- Name the smells present in one sentence each.
- Pick a Fowler refactor from the catalog (e.g., Decompose Conditional, Extract Function, Replace Conditional with Polymorphism, Introduce Parameter Object). Name it explicitly.
- Describe the characterization tests you would add before refactoring.
- Sketch the refactored shape in ~15 lines.
- Defend the move in one sentence: what specific pressure is it absorbing?
Repeat until: you can name the smell, the move, and the target shape inside 5 minutes.
Kata 3: Diagnose a Flaky Test Given Its Trace
Time limit: 15 minutes Skill: Flaky-test diagnosis (Concept 12)
Setup: an E2E test fails about once every 15 runs with:
AssertionError: expected Task.status == "done", got "in_progress"
traceback:
test_task_finalize.py:44: client.post("/tasks/{id}/finalize")
task_svc.py:88: enqueue_status_update(task_id)
test_task_finalize.py:48: client.get("/tasks/{id}") # assertion here
Instructions:
- Walk the five common causes in order. For each, state whether it is likely or unlikely here, with reasoning.
- Pick the most likely cause.
- Name the diagnostic step that would confirm it.
- Name the fix that addresses the cause, not the symptom.
- Explain why auto-retry would be the wrong response here.
Repeat until: you can walk the five-cause checklist from memory and assign a diagnostic step to each.
Kata 4: Write a Technical-Debt Ledger Entry
Time limit: 15 minutes Skill: Debt accounting (Concept 15)
Setup: during a 24-hour read-through you noticed this:
The
auth_middleware.pyin the capstone has three places where it constructs an error response inline instead of using a shared helper. The strings drift. One place returns{"error": "unauthorized"}, another returns{"message": "auth failed"}, and a third returns a plain string"nope". You do not have time to fix it this week -- sync feature takes priority.
Instructions:
Write a ledger entry containing, at minimum:
- a unique id and short title
- precise location (file and approximate line range)
- severity on the Sev-1..Sev-4 scale with rationale
- impact in one or two sentences
- why-deferred (specific, not generic)
- a trigger that would cause you to act on it
- owner
- date and source (e.g., "24-hour read-through on 2026-04-21")
Repeat until: you can write a defensible entry in under 10 minutes and defend each field if challenged.
Completion Standard
- Each kata completed within its time limit at least twice
- You can explain the technique practiced in each kata in one sentence
- You do not need to look up the five flaky-test causes, the Fowler catalog names, or the triage Sev rubric mid-kata
- The artifacts (regression test idea, refactor sketch, diagnosis, ledger entry) are written down somewhere you can reuse them in the capstone