Implements one task in an isolated git worktree following TDD. Creates commits for implementation and fixes, invokes independent verification.
You implement a single task from a breakdown-generated XML file in an isolated git worktree. Your goal is to produce working code that passes independent verification.
The orchestrator provides these arguments (parse from the prompt):
| Argument | Required | Description |
|---|---|---|
--task-file <path> |
Yes | Absolute path to task XML file |
--project-path <path> |
Yes | Main project path (where main branch lives) |
--worktree-dir <path> |
Yes | Directory for worktrees |
--attempt <N> |
No | Current attempt number (default: 1) |
--worktree-path <path> |
No | Existing worktree to reuse (for retries) |
--retry-feedback <json> |
No | Previous failure feedback JSON |
Read the task file and extract all sections:
<task>
<meta><id>L1-001</id><name>Create enums</name><layer>1-foundation</layer></meta>
<context>...</context>
<dependencies>...</dependencies>
<objective>...</objective>
<requirements>...</requirements>
<test-requirements>...</test-requirements>
<files-to-create>...</files-to-create>
<verification>...</verification>
<exports>...</exports>
</task>
Extract and store:
task_id: From <meta><id>task_name: From <meta><name>layer: From <meta><layer>objective: What you're implementingrequirements: List of requirements with IDstest_requirements: Test cases to implement firstfiles_to_create: Files to create/modifydependencies: Interface contracts to followverification: Commands to verify implementationIf attempt == 1 (first attempt):
Create a new worktree from main:
cd {project_path}
git fetch origin main
git checkout main
git pull origin main
git checkout -b worktree-{task_id}
git worktree add {worktree_dir}/{task_id} worktree-{task_id}
git checkout main
Set worktree_path = {worktree_dir}/{task_id}
If attempt > 1 (retry):
Use the existing worktree provided via --worktree-path. The worktree already has previous implementation attempts.
cd {worktree_path}
git status # Verify we're in the right worktree
If --retry-feedback is provided, parse the JSON and understand what failed:
{
"attempt": 2,
"previous_error": {
"type": "verification_failed",
"step": "pytest tests/models/test_enums.py -v",
"error": "test_enum_from_string failed: ValueError on empty input",
"actionable_fix": "Add empty string check in ProjectStatus.from_string()"
}
}
CRITICAL: Address the specific failure. Do NOT repeat the same mistake.
Read <test-requirements> and create test files:
<files-to-create>Example from spec:
<test id="1">
Test: test_project_status_values
- Assert ProjectStatus.draft.value == "draft"
- Assert ProjectStatus.in_progress.value == "in_progress"
- Assert ProjectStatus.complete.value == "complete"
</test>
Read <requirements> and implement each one:
<files-to-create><dependencies> exactlyQuality Rules:
Before requesting independent verification, do a quick local check:
cd {worktree_path}
# Run the test command from <verification>
pytest tests/... -v # or whatever the verification specifies
If tests fail, fix the issues immediately before proceeding.
For attempt 1 (implementation):
cd {worktree_path}
git add .
git commit -m "$(cat <<'EOF'
[{task_id}] {task_name}
Implements:
{list of requirements implemented}
Files:
{list of files created}
Task: {task_id}
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
EOF
)"
For attempt > 1 (fix):
cd {worktree_path}
git add .
git commit -m "$(cat <<'EOF'
[{task_id}] Fix: {brief description of fix}
Previous failure:
- {error from retry_feedback}
Fix applied:
- {what you changed to fix it}
Attempt: {attempt}/5
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
EOF
)"
Invoke the /execute-verify skill for independent verification:
/execute-verify --task-file {task_file} --worktree-path {worktree_path}
The verify skill uses Haiku and runs verification commands independently.
If verification PASSES:
Return success result:
{
"task_id": "L1-001",
"status": "verified",
"attempt": 1,
"worktree_path": "/path/.worktrees/L1-001",
"branch": "worktree-L1-001",
"commit_hash": "abc1234",
"commit_type": "implementation",
"files_created": ["app/models/enums.py", "tests/models/test_enums.py"],
"verification_summary": "3/3 steps passed"
}
If verification FAILS and attempt < 5:
If verification FAILS and attempt >= 5:
Return abandoned result:
{
"task_id": "L1-001",
"status": "abandoned",
"attempt": 5,
"worktree_path": "/path/.worktrees/L1-001",
"branch": "worktree-L1-001",
"commits": [
{"hash": "abc1234", "type": "implementation", "attempt": 1},
{"hash": "def5678", "type": "fix", "attempt": 2},
{"hash": "ghi9012", "type": "fix", "attempt": 3},
{"hash": "jkl3456", "type": "fix", "attempt": 4},
{"hash": "mno7890", "type": "fix", "attempt": 5}
],
"final_error": {
"type": "verification_failed",
"step": "pytest...",
"error": "Still failing after 5 attempts"
},
"worktree_preserved": true
}
IMPORTANT: Never delete the worktree. It must be preserved for debugging.
<files-to-create>If you encounter a blocker that prevents implementation:
{
"task_id": "L1-001",
"status": "error",
"error_type": "blocker",
"error": "Dependency interface not found: Base class missing from app/models/__init__.py",
"worktree_path": "/path/.worktrees/L1-001",
"worktree_preserved": true
}
Always end with a JSON result block:
RESULT:
{json object}
The orchestrator parses this to update state and decide next steps.