Agent-Driven TDD Workflow
Enforce Test-Driven Development for AI agents working with Elixium. This workflow ensures tests are written before implementation, with human checkpoints for review.
π§ͺ TDD with Human Checkpoints
Traditional TDD is "Red β Green β Refactor". With AI agents, we add human approval gates to ensure quality. Agents can't skip testsβthe API enforces it.
π The 6-Step Workflow
- Prepare β Agent reads story context via
prepare_implementation - Start β Agent creates branch via
start_story - Write Tests β Agent writes tests and calls
propose_test_plan - Human Review β Approve test plan (UI or API)
- Implement β Agent writes code to make tests pass
- Human Review β Review diff, move to Done
π Workflow Diagram
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β 1. Agent: prepare_implementation(storyId) β β β Gets acceptance criteria, context, epic β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€ β 2. Agent: start_story(storyId) β β β Creates branch, workflow_stage = tdd_start β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€ β 3. Agent: Write tests, then call propose_test_plan() β β β workflow_stage = tests_proposed β β π BLOCKED until human approves β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€ β 4. Human: Approve test plan (UI or API) β β β workflow_stage = tests_approved β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€ β 5. Agent: Implement code, run tests until green β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€ β 6. Agent: submit_for_review(storyId, commitHash) β β β workflow_stage = review, state = finished β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€ β 7. Human: Review diff, run tests, move to Done β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π οΈ MCP Tools Reference
start_story
Entry point for TDD workflow. Creates a git branch and sets workflow_stage.
Parameters:
{ storyId: string, branchPrefix?: "feat" | "fix" | "chore" }Returns:
{
"branch": "feat/abc123-my-feature",
"workflow_stage": "tdd_start",
"acceptance_criteria": "...",
"workflow_reminder": "Write tests first..."
}propose_test_plan
Submit test plan for human review. Blocks implementation until approved.
Parameters:
{ storyId: string, testPlan: string, testFilePaths?: string[] }Returns:
{
"workflow_stage": "tests_proposed",
"message": "Test plan submitted. Awaiting human approval."
}π BLOCKED: Agent cannot call submit_for_review until tests are approved.
submit_for_review
Submit implementation for human review. Only works if tests are approved.
Parameters:
{ storyId: string, commitHash?: string, implementationNotes?: string }Returns:
{
"status": "ready_for_review",
"workflow_stage": "review",
"state": "finished",
"next_step": "Human reviews diff and moves to Done"
}π Workflow Stages
| Stage | Description | Who Acts |
|---|---|---|
tdd_start | Branch created, ready to write tests | Agent |
tests_proposed | Tests written, awaiting approval | Human |
tests_approved | Tests approved, implementation unlocked | Agent |
implementing | Agent is writing code | Agent |
review | Implementation complete, awaiting review | Human |
π Human Checkpoints
1. Test Plan Review
When workflow_stage = tests_proposed, review the test plan:
- Are the tests comprehensive enough?
- Do they cover the acceptance criteria?
- Are edge cases considered?
To approve: Click "Approve Test Plan" in the story card, or call the API:
2. Implementation Review
When workflow_stage = review, review the implementation:
- Review the git diff
- Run tests locally
- Check code quality and style
To complete: Move the story to the Done lane
π‘ Best Practices
Writing Good Test Plans
- Be specific: Name the test file paths and describe what each test covers
- Reference AC: Map tests to acceptance criteria (Given/When/Then)
- Include edge cases: Mention error handling, boundary conditions
- Keep it readable: Use markdown formatting for clarity
Example Test Plan
## Test Plan: User Authentication ### Unit Tests (`tests/auth.spec.ts`) - should hash password before storing - should validate email format - should reject weak passwords ### Integration Tests (`tests/auth-api.spec.ts`) - POST /login should return 200 with valid credentials - POST /login should return 401 with invalid password - POST /login should rate-limit after 5 failures ### Edge Cases - Empty email field - SQL injection attempt - Unicode characters in password
π¦ Story Fields Reference
| Field | Type | Description |
|---|---|---|
workflow_stage | enum | Current TDD stage |
branch_name | string | Git branch created for this story |
test_plan | string | Markdown test plan proposed by agent |
test_file_paths | string[] | Paths to created test files |
commit_hashes | string[] | Commits linked to this story |
π§ Troubleshooting
"Cannot submit for review - tests must be approved first"
The agent tried to call submit_for_review before tests were approved. A human must approve the test plan first by clicking "Approve" in the story card or calling the API endpoint.
"Cannot start completed story"
The story is already in the Done lane. Create a new story or move it back to Current/Backlog first.
Agent keeps implementing without writing tests
The agent instructions may need updating. Add to your system prompt: "Always call start_story first, then write tests and call propose_test_plan before implementing."
