Return to the slide lesson

AI series · Class 4 of 4

Building with AI

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

75–90 minutes facilitated · Work at your own pace

Start practicing
Workshop agenda and audience

Builders and technical founders

Define · Architect · Generate · Review · Iterate

Bring work from Class 3

Exercise 1 of 3

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 example

Build 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.

Your turn

Use the low-stock feature for the test bench. Sketch how it would fit into your own project or the requirements from Class 3.

Your build brief

Your notes will appear here.

Exercise 2 of 3

Build and run the feature

Generate a small implementation, then test the boundary and bad inputs. The test bench below runs a real JavaScript function assembled from your choices. Try an incorrect version first, inspect the failed test, and change one choice at a time.

Worked example

A 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.

Your turn

Choose the input rule and comparison. Run the suite until each case matches the specification. Review the function that ran.

Low-stock test bench

    Your test finding

    Your notes will appear here.

    Exercise 3 of 3

    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 example

    A 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.”

    Your turn

    Add your own test with the custom test controls below. Explain what you verified. For a larger build, use the library’s architecture, code review, debugging, schema, and test prompts in your own development environment.

    Add a test case

    Your review record

    Your notes will appear here.

    Knowledge check

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

    Build brief, test results, and review notes

    Keep a copy of your exercises or bring them to your next class.

    Return to AI series