Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Usage Best Practices  ›  Capstone Project

Verify with Tests

Usage Best Practices 15 minA task is done only when a check passes, so you watch a new test fail for the right reason, make it pass without editing it, and then review and run the checks yourself.

Verify with Tests

"Done! The feature works" is a claim. A test run that passes is evidence. Much of this course comes down to one habit: never accept the claim without the evidence.

The rule

Done means a check passed, not that Claude said so.

Tests turn a fuzzy request into a target the agentic loop can hit. A few habits make them work well with an agent:

  • Test first. Ask for a test that captures the requirement, and watch it fail before any feature code exists. A failing test proves it can tell "missing" from "present".
  • Fail for the right reason. The failure should say the behaviour is missing ("expected 6 deliveries, got 7"), not that the test itself is broken by a typo or a bad import.
  • Say how to run the checks. Put the command, such as pytest -q, in CLAUDE.md, so Claude runs it on its own in every session.
  • Forbid the shortcut. "Don't change or skip the tests" closes the easiest way to fake a pass.
  • Run it yourself. ! pytest -q at the end is your independent confirmation.
  • Go beyond unit tests when it matters: a linter, a type checker, or opening the app and trying the feature the way a customer would.
Write a test: pausing tomorrow removes exactly one delivery.
Run it and show me it fails. Don't write the feature yet.
Now implement it in orders.py. Don't change or skip the test.
Run pytest -q until everything passes.

Sending these as two separate messages matters. Ask for the test and the feature together and you never see the red step, so you cannot tell a test that detects the missing behaviour from one that would have passed anyway.

The shortcut

Red, green, look. Red: see the test fail for the right reason. Green: make it pass without touching the test. Look: read the diff and run the checks yourself.

The pause feature, start to finishStep 1 of 5
  1. Plan

    In plan mode you agree on the rule: customers can pause tomorrow's delivery until 8 p.m. tonight.

The trap hides at both ends. A test that fails for the wrong reason proves nothing, and a test that passes because it was edited proves even less.

Drills

Answer fast — trust the rule.

quick drill

Claude says "All done, the feature works" but ran nothing. What do you do?

quick drill

Why watch a new test fail before writing the feature?

quick drill

The new test fails with NameError: name 'weekly_ordr' is not defined. Is that a good "red"?

quick drill

Where should the command for running the tests be written so Claude uses it every session?

Remember

  • Done means a check passed, not that Claude said so.
  • Shortcut: red, green, look.
  • Trap: a test that fails for the wrong reason, or passes because it was changed.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainRed, green, look

Walk through red, green and look for the tiffin 'pause tomorrow' feature. Explain what each stage proves, and what you would do if the red test failed for the wrong reason.