t27.aiРусский

One small step per prompt

You will learn

Why a plan of small steps with a check each leaves one suspect when something fails.

A big request is a chain of small ones, and the agent can get any link wrong. In small_step.t27 a plan has five steps, and each ends with a check you run before the next prompt. The list PASSED holds 1 for a step whose check passed and 0 for one that did not: 1, 1, 0, 0, 0. The earliest zero is step 3, so step 3 is the single prompt to fix. One big prompt for all five steps leaves five suspects; one small step leaves one. The lesson plants one bug: say that step 4 was the earliest to fail, and the test that reads the list catches it.

Try it

In the diagram find the earliest step whose check failed; then in the spec change FIRST_FAILED from 3 to 4 and run the tests.

Open the interactive lesson →

Vibecoding: one small step per prompt ↗

A plan of five steps with a check each: the first step that fails is the only prompt to fix. One big prompt leaves five suspects, a small step leaves one. Vibecoding from zero.

specs/vibecoding/small_step.t27

// SPDX-License-Identifier: Apache-2.0
; Vibecoding, module Prompting, lesson 3: one small step per prompt.
; A big request is a chain of small ones. Each step ends with a check you run before the next
; prompt. If a step fails, you know which one: the last. This spec lists a plan of five steps,
; says which steps passed, and finds the first one that did not.

module vibecoding_small_step;

pub const STEP_COUNT : u8 = 5;
; 1 means the step's check passed, 0 means it failed or was not run yet.
pub const PASSED : [5]u8 = [1, 1, 0, 0, 0];

; first_failed walks the plan in order and returns the number of the first step that did not pass.
; It returns STEP_COUNT + 1 when every step passed.
pub fn first_failed(a: u8, b: u8, c: u8, d: u8, e: u8) -> u8 {
    if (a == 0) { return 1; }
    if (b == 0) { return 2; }
    if (c == 0) { return 3; }
    if (d == 0) { return 4; }
    if (e == 0) { return 5; }
    return 6;
}

; The first failed step in the plan above is step 3: that is the only prompt to fix.
pub const FIRST_FAILED : u8 = 3;
; One big prompt for all five steps: when it fails, any of the five could be the cause.
pub const SUSPECTS_ONE_BIG_PROMPT : u8 = 5;
; One small step per prompt: only the step that just ran can be the cause.
pub const SUSPECTS_SMALL_STEP : u8 = 1;

test the_first_two_steps_passed {
    assert PASSED[0] == 1;
    assert PASSED[1] == 1;
}

test step_three_is_the_first_to_fail {
    assert PASSED[FIRST_FAILED - 1] == 0;
    assert PASSED[FIRST_FAILED - 2] == 1;
}

test a_small_step_leaves_one_suspect {
    assert SUSPECTS_SMALL_STEP == 1;
    assert SUSPECTS_ONE_BIG_PROMPT == STEP_COUNT;
    assert SUSPECTS_SMALL_STEP < SUSPECTS_ONE_BIG_PROMPT;
}

test the_last_step_is_read {
    assert PASSED[STEP_COUNT - 1] == 0;
}

Open the lesson's spec in the player ↗

All lessons