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

  1. Prepare β€” Agent reads story context via prepare_implementation
  2. Start β€” Agent creates branch via start_story
  3. Write Tests β€” Agent writes tests and calls propose_test_plan
  4. Human Review β€” Approve test plan (UI or API)
  5. Implement β€” Agent writes code to make tests pass
  6. 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

StageDescriptionWho Acts
tdd_startBranch created, ready to write testsAgent
tests_proposedTests written, awaiting approvalHuman
tests_approvedTests approved, implementation unlockedAgent
implementingAgent is writing codeAgent
reviewImplementation complete, awaiting reviewHuman

πŸ›‘ 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:

curl -X POST "https://elixium.ai/api/stories/:id/approve-tests" \ -H "x-api-key: YOUR_API_KEY" \ -H "x-board-slug: main" \ -H "Content-Type: application/json"

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

FieldTypeDescription
workflow_stageenumCurrent TDD stage
branch_namestringGit branch created for this story
test_planstringMarkdown test plan proposed by agent
test_file_pathsstring[]Paths to created test files
commit_hashesstring[]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."