Overview
TaskMaster provides a complete TDD workflow orchestration system that enables AI agents to autonomously implement features following strict Test-Driven Development practices. The system manages workflow state, git operations, test validation, and progress tracking.Key Features
- TDD State Machine: Enforces RED → GREEN → COMMIT cycle
- Git Integration: Automated branch creation, commits with metadata
- Test Validation: Ensures RED phase has failures, GREEN phase passes
- Progress Tracking: Subtask completion, attempt counting, error logging
- State Persistence: Automatic workflow state management
- Dual Interface: CLI commands and MCP tools for flexibility
Architecture
Component Responsibilities
WorkflowOrchestrator- Manages TDD state machine transitions
- Tracks current subtask and progress
- Enforces workflow rules and validations
- Emits events for state changes
- Creates and manages workflow branches
- Stages files and creates commits
- Validates git repository state
- Provides safety checks (clean working tree, etc.)
- Validates RED phase has test failures
- Validates GREEN phase has all tests passing
- Parses test results from various formats
- Generates conventional commit messages
- Embeds workflow metadata (subtask ID, phase, etc.)
- Follows project commit conventions
Getting Started
Prerequisites
- TaskMaster initialized project with subtasks
- Git repository with clean working tree
- Test framework configured (vitest, jest, etc.)
Quick Start
CLI Commands
All commands support--json
flag for machine-readable output.
tm autopilot start <taskId>
Initialize a new TDD workflow for a task.
Options:
--max-attempts <number>
: Maximum attempts per subtask (default: 3)--force
: Force start even if workflow exists--project-root <path>
: Project root directory--json
: Output JSON
tm autopilot resume
Resume a previously started workflow from saved state.
Example:
tm autopilot next
Get the next action to perform with detailed context.
JSON Output:
tm autopilot status
Get comprehensive workflow progress and state information.
Example:
tm autopilot complete
Complete the current TDD phase with test result validation.
Options:
--results <json>
: Test results JSON string
- RED Phase: Must have at least one failing test
- GREEN Phase: All tests must pass (failed === 0)
tm autopilot commit
Create a git commit with enhanced message generation.
Options:
--message <text>
: Custom commit message (optional)--files <paths...>
: Specific files to stage (optional)
tm autopilot abort
Abort the workflow and clean up state (preserves git branch and code).
Example:
MCP Tools
MCP tools provide the same functionality as CLI commands for programmatic integration.autopilot_start
Parameters:
autopilot_resume
Parameters:
autopilot_next
Parameters:
autopilot_status
Parameters:
autopilot_complete_phase
Parameters:
autopilot_commit
Parameters:
autopilot_abort
Parameters:
Workflow Phases
Phase Diagram
Phase Descriptions
PREFLIGHT- Validate task has subtasks
- Check git repository state
- Verify preconditions
- Create workflow branch:
task-{taskId}
- Checkout new branch
- Initialize workflow context
-
RED Phase: Write failing tests
- Action:
generate_test
- Validation: At least one test must fail
- Files: Test files
- Action:
-
GREEN Phase: Implement code
- Action:
implement_code
- Validation: All tests must pass
- Files: Implementation files
- Action:
-
COMMIT Phase: Create commit
- Action:
commit_changes
- Auto-generates commit message
- Advances to next subtask
- Action:
- All subtasks complete
- Workflow ready for review/merge
- Workflow finished
- State can be cleaned up
Responsibility Matrix
Clear division of responsibilities between AI Agent and TaskMaster.Responsibility | AI Agent | TaskMaster |
---|---|---|
Workflow Orchestration | ✓ | |
Start/resume workflow | Call CLI/MCP | Execute & validate |
Track workflow state | Read state | Persist state |
Manage TDD phases | Request transitions | Enforce transitions |
Validate phase completion | ✓ (RED must fail, GREEN must pass) | |
Test Management | ||
Write test code | ✓ | |
Run tests | ✓ | |
Parse test output | ✓ | |
Report test results | Provide JSON | Validate results |
Implementation | ||
Write implementation code | ✓ | |
Ensure tests pass | ✓ | |
Follow TDD cycle | ✓ (guided by TaskMaster) | Enforce rules |
Git Operations | ||
Create workflow branch | Request | ✓ Execute |
Stage files | Request (optional) | ✓ Execute |
Generate commit messages | ✓ | |
Create commits | Request | ✓ Execute |
Progress Tracking | ||
Query progress | Call status | ✓ Provide data |
Advance subtasks | ✓ (automatic on commit) | |
Count attempts | ✓ | |
Log activity | ✓ |
AI Agent Responsibilities
- Read and understand subtask requirements
- Write test code that validates the requirement
- Run test suite using project’s test command
- Parse test output into JSON format
- Report results to TaskMaster for validation
- Write implementation to satisfy tests
- Request commits when GREEN phase complete
- Handle errors and retry within attempt limits
TaskMaster Responsibilities
- Manage workflow state machine
- Enforce TDD rules (RED must fail, GREEN must pass)
- Track progress (completed, current, attempts)
- Create git commits with enhanced messages
- Manage git branches and repository safety
- Validate transitions between phases
- Persist state for resumability
- Generate reports and activity logs
Examples
Complete TDD Cycle Example
1. Start Workflow
2. Get Next Action
3. Write Failing Test
AI Agent createstests/start.test.ts
:
4. Run Tests (Should Fail)
5. Complete RED Phase
6. Implement Code
AI Agent createssrc/commands/start.ts
:
7. Run Tests (Should Pass)
8. Complete GREEN Phase
9. Commit Changes
MCP Integration Example
Error Handling
Common Errors and Solutions
Workflow Already Exists
Error:RED Phase Validation Failed
Error:GREEN Phase Validation Failed
Error:No Staged Changes
Error:Git Working Tree Not Clean
Error:Error Recovery Patterns
Retry Pattern
Graceful Degradation
Troubleshooting
Workflow State Issues
Problem: State file corrupted or inconsistent Solution:Test Results Parsing
Problem: Test output format not recognized Solution: Ensure test results JSON has required fields:Branch Conflicts
Problem: Workflow branch already exists Solution:Permission Issues
Problem: Cannot write to .taskmaster directory Solution:State Persistence Failures
Problem: State not saving between commands Solution:Working with AI Agents
Example prompts for AI agents (Claude Code, Cursor, etc.) to use the TDD workflow.Starting a Task
RED Phase - Writing Failing Tests
GREEN Phase - Implementing
Handling Errors
Checking Progress
Resuming Work
Additional Resources
- Command Reference - Complete CLI command documentation
- MCP Provider Guide - MCP integration details
- Task Structure - Understanding TaskMaster’s task system
- Configuration - Project configuration options