To put chains on that beast (the code-developing large model), we need to create a dedicated skill file in the .agents/skills/ directory. By leveraging the 'radar effect' of using-superpowers, we can force the AI to adopt this workflow before writing any business logic.
1. Create the TDD Skill File
In .agents/skills/test-driven-development/SKILL.md, write down this set of rules:
---
name: test-driven-development
description: Triggered upon receiving any instruction to implement a feature or fix a bug. This outline must be read before writing any business logic files.
---
# The Iron Law of TDD: Red-Green-Refactor
**Core Prohibition**: Do not "write business code by guessing and then add tests later." You must strictly follow these steps without skipping any.
1. **Write a Failing Test (Red)**:
- First, create a new `*.spec.ts` file or add to an existing one. Write a test case for the goal you are about to implement.
- Run it using the command. (It must fail and show red text, because the source business file is just an empty shell at this point.)
- **Read the Error!** Confirm that the test failed because the "feature is not implemented," not due to a syntax error.
2. **Make it Pass (Green)**:
- Switch to the `src/` directory and write the minimum viable business code. (The only goal is to make the test pass and turn green; don't worry about elegant architecture yet.)
- Run the terminal tests repeatedly.
- This is one of only **two** stages where you are allowed to enter a code-tweaking loop.
3. **Refactor and Clean Up (Refactor)**:
- When the terminal shows a green `PASS`, now is the time to put on your "architect" hat.
- Extract common methods from the business logic, optimize time complexity, and improve code readability.
- Feel free to make major changes, because the tests are your safety lock. If you break something during refactoring, the tests will turn red!
2. Granting the Toolset Terminal Freedom
When using Agents with advanced terminal sandboxes, like Antigravity/Claude Code, we must ensure that Vitest is installed in the base system.
Issue a task in the terminal or on the task board:
"Please set up the project's Vitest environment and configure the
package.jsonscript fortest:unit."
This action isn't about writing business code. It's about enabling the Agent to delegate its code validation to an objective machine by running simple shell commands (like npm run test:unit), rather than relying on your eyes or its own hallucinations.
The testing infrastructure is now in place. In the next episode, the real, brutal battle begins. We will execute the first coding action from task_plan.md and witness firsthand how the Agent breaks through the ordeal of failing red tests