AI · 5 slides · 3 questions

Building with AI

Define a small feature, test its behavior, review the implementation, and document one improvement.

Define the smallest feature

Start with one observable behavior from your requirements. Sketch the inputs, outputs, and failure paths before asking for code. Keep data handling, permissions, and external inputs explicit when you plan a larger system.

Worked exampleBuild a low-stock flag for a shift checklist. Inputs are whole numbers for stock on hand and a reorder threshold. Return “Reorder” at or below the threshold, “OK” above it, and “Invalid” for missing, negative, or fractional counts.

Write example inputs and expected results

Use a normal case, a boundary and a missing value. Decide the behavior before you ask for an implementation. A concrete example settles disagreements about words like “low.”

Worked exampleRule: flag stock below three trays. Two trays shows “Reorder.” Three shows “In stock.” A blank count shows “Count needed.” The blank count requires a different action from an actual count of zero.

Build and run the feature

Test three kinds of input: an ordinary count, a count exactly at the threshold, and an invalid count. Change one rule at a time and rerun all three tests. The optional workbook includes a working test bench.

Worked exampleA test with stock 8 and threshold 5 can pass even if your boundary logic is wrong. Stock 5 and threshold 5 exposes the difference between < and <=. An empty count needs its own test.

Make the first run easy to inspect

Start with sample data and compare the results one row at a time. When something fails, change one part of the requirement or implementation, then rerun the original cases.

Worked exampleThe app flags three trays for reorder. Recheck the agreed threshold, correct the comparison, and retry two, three and blank. The same examples tell the next shift exactly what behavior was tested.

Review and iterate

Read the implementation yourself, then ask a second assistant to critique it against the brief. Add an independent test, rerun the suite, and write down the design decision. For your own feature, commit the smallest verified change and include a short usage example.

Worked exampleA reviewer notices the tests only use a threshold of 5. Add stock 0, threshold 0. Expect “Reorder.” Then test a negative threshold and expect “Invalid.”

Check what you learned

1. The agreed rule says reorder at or below five. What should a count of exactly five return?

2. The stock field is blank. Why test it separately from zero?

3. The AI-generated function passes its own happy-path tests. What would you do before using it?

Open the optional practice workbook to apply the lesson or return to earlier notes.