examples / example-05-tdd-state-machine-test.md
examples / example-05-tdd-state-machine-test.md
A developer needs to write a failing test for a React Counter state machine before writing the implementation. The test should cover edge cases: CounterJump, CounterLoop, CounterDeadlock, and CounterTie.
This maps to the TDD skill combined with the Bug Fix playbook (for the "reproduce first" pattern). The real pstack pattern is: write the failing test first, make it pass, then implement.
Step 1: Get the TDD skill
{ "tool": "get_skill", "parameters": { "name": "tdd", "mode": "full" } }
Step 2: Get the Statechart skill for state machine testing
Step 3: Route to a playbook that includes TDD
Step 4: Get the principle about test behavior
Step 5: Use recommend_skills for test-related skills
pstack-mcp returns:
The model writes the failing test first (red), then implements the minimum code to pass (green), then refactors — all guided by the skill's explicit instructions.
A developer needs to write a failing test for a React Counter state machine before writing the implementation. The test should cover edge cases: CounterJump, CounterLoop, CounterDeadlock, and CounterTie.
This maps to the TDD skill combined with the Bug Fix playbook (for the "reproduce first" pattern). The real pstack pattern is: write the failing test first, make it pass, then implement.
Step 1: Get the TDD skill
{ "tool": "get_skill", "parameters": { "name": "tdd", "mode": "full" } }
Step 2: Get the Statechart skill for state machine testing
Step 3: Route to a playbook that includes TDD
Step 4: Get the principle about test behavior
Step 5: Use recommend_skills for test-related skills
pstack-mcp returns:
The model writes the failing test first (red), then implements the minimum code to pass (green), then refactors — all guided by the skill's explicit instructions.
{
"tool": "get_skill",
"parameters": {
"name": "statechart",
"mode": "full"
}
}
{
"tool": "playbook-route",
"parameters": {
"task": "Write a test-first implementation of a React Counter state machine. The counter must support: increment, decrement, reset, jump to value, loop detection, deadlock detection, and tie-breaking.",
"limit": 1
}
}
{
"tool": "get_principles",
"parameters": {
"names": ["test-behavior-not-implementation", "prove-it-works"],
"mode": "full"
}
}
{
"tool": "recommend_skills",
"parameters": {
"task": "write a comprehensive test suite for a finite state machine with edge cases",
"limit": 3
}
}
{
"tool": "get_skill",
"parameters": {
"name": "statechart",
"mode": "full"
}
}
{
"tool": "playbook-route",
"parameters": {
"task": "Write a test-first implementation of a React Counter state machine. The counter must support: increment, decrement, reset, jump to value, loop detection, deadlock detection, and tie-breaking.",
"limit": 1
}
}
{
"tool": "get_principles",
"parameters": {
"names": ["test-behavior-not-implementation", "prove-it-works"],
"mode": "full"
}
}
{
"tool": "recommend_skills",
"parameters": {
"task": "write a comprehensive test suite for a finite state machine with edge cases",
"limit": 3
}
}