In Phase 2, we saved our first core logic development task in docs/task_plan.md:
[ ](TDD) Implement the logic for splitting a local Task's duration into TimeBlocks (block_allocator.spec.ts).
This is the core of the entire T-Block system: if a user creates a 2-hour "Write weekly report" Task that overlaps with their 12:00 PM lunch break, it must automatically split into a "1-hour morning block" and a "1-hour afternoon block."
1. Unleash the Hounds: Triggering the Task
Enter this simple sentence into your command prompt:
"Sequentially execute the 'Implement the logic for splitting a local Task's duration into TimeBlocks' task from
task_plan.md."
See? We didn't even specify which algorithm to use or how to split the time. The Agent will first read task_plan.md to get the context, then consult PRD_System_Design.md to confirm the rules, and finally bounce off the test-driven-development skill guardrail we just created.
2. The Agent's One-Man Show (A Record of Fully Automated Background Operations)
Behind the scenes, the Agent now begins a frantic series of internal negotiations:
[Round 1: Red Light]
- It reads the TDD rules.
- It obediently creates
block_allocator.spec.tsundertests/. - In the test, it mocks a 12:00-13:00 lunch break and inserts a two-hour Task.
- It runs the test! The terminal explodes in a sea of red, because the main business logic file,
src/allocator.ts, doesn't even have a function body.
[Round 2: Fighting for Green]
- The AI dives into
src/allocator.tsand rapidly codes fifty lines of an interval merge algorithm. - The AI then autonomously calls the
run_commandtool to run the tests again. - Error! The algorithm was wrong about a specific edge case (like a boundary falling exactly on a one-minute mark), and Vitest throws an AssertionError.
- The AI reads the detailed error stack trace from the terminal, immediately modifies the code, and automatically enters a cycle of debugging!
[Round 3: Refactor and Archive]
After its fully automated, non-stop debugging session, it completes the fix. Finally! The terminal prints green: ✓ Task chunks correctly split.
Then, the AI relaxes a bit. It applies the refactoring rules to clean up the messy logic and reduce its cyclomatic complexity. It records this success in progress.md and checks off the corresponding item in task_plan.md by changing [ ] to [x].
3. The Human Experience
The entire process might have taken 3 minutes, during which you probably just took a sip of coffee. You did nothing. But this isn't because the AI is some kind of miracle worker. Without the framework we built in the previous chapters to constrain it, it would have run to you after the very first error and asked, "Master, this code has an error. What should I do?"
Test guardrails are the only container that allows the AI to achieve a self-contained feedback loop.
The algorithm works, and everyone is happy. But what if, one day, the algorithm required is simply beyond the AI's capabilities? What if it retries a dozen times without success, burning through a lot of tokens on your bill? In the next lesson, we'll introduce the ultimate system backstop: the three-strikes-and-you're-out defense mechanism.