---
description: Execute a conductor track — follow TDD workflow, delegate to Tier 3/4 workers
---

# /conductor-implement

Execute a track's implementation plan. This is a Tier 2 (Tech Lead) operation.
You maintain PERSISTENT context throughout the track — do NOT lose state.

## Startup

1. Read `conductor/workflow.md` for the full task lifecycle protocol
2. Read `conductor/tech-stack.md` for technology constraints
3. Read the target track's `spec.md` and `plan.md`
4. Identify the current task: first `[ ]` or `[~]` in `plan.md`

If no track name is provided, run `/conductor-status` first and ask which track to implement.

## Task Lifecycle (per task)

Follow this EXACTLY per `conductor/workflow.md`:

### 1. Mark In Progress
Edit `plan.md`: change `[ ]` → `[~]` for the current task.

### 2. Research Phase (High-Signal)
Before touching code, use context-efficient tools IN THIS ORDER:
1. `py_get_code_outline` — FIRST call on any Python file. Maps functions/classes with line ranges.
2. `py_get_skeleton` — signatures + docstrings only, no bodies
3. `get_git_diff` — understand recent changes before modifying touched files
4. `Grep`/`Glob` — cross-file symbol search
5. `Read` (targeted, offset+limit only) — ONLY after outline identifies specific ranges

**NEVER** call `Read` on a full Python file >50 lines without a prior `py_get_code_outline` call.

### 3. Write Failing Tests (Red Phase — TDD)
**DELEGATE to Tier 3 Worker** — do NOT write tests yourself:
```powershell
uv run python scripts\claude_mma_exec.py --role tier3-worker "Write failing tests for: {TASK_DESCRIPTION}. Focus files: {FILE_LIST}. Spec: {RELEVANT_SPEC_EXCERPT}"
```
Run the tests. Confirm they FAIL. This is the Red phase.

### 4. Implement to Pass (Green Phase)
**DELEGATE to Tier 3 Worker**:
```powershell
uv run python scripts\claude_mma_exec.py --role tier3-worker "Implement minimum code to pass these tests: {TEST_FILE}. Focus files: {FILE_LIST}"
```
Run tests. Confirm they PASS. This is the Green phase.

### 5. Refactor (Optional)
With passing tests as safety net, refactor if needed. Rerun tests.

### 6. Verify Coverage
Use `run_powershell` MCP tool (not Bash — Bash is a mingw sandbox on Windows):
```powershell
uv run pytest --cov=. --cov-report=term-missing {TEST_FILE}
```
Target: >80% for new code.

### 7. Commit
Stage changes. Message format:
```
feat({scope}): {description}
```

### 8. Attach Git Notes
```powershell
$sha = git log -1 --format="%H"
git notes add -m "Task: {TASK_NAME}`nSummary: {CHANGES}`nFiles: {FILE_LIST}" $sha
```

### 9. Update plan.md
Change `[~]` → `[x]` and append first 7 chars of commit SHA:
```
[x] Task description. abc1234
```
Commit: `conductor(plan): Mark task '{TASK_NAME}' as complete`

### 10. Next Task or Phase Completion
- If more tasks in current phase: loop to step 1 with next task
- If phase complete: run `/conductor-verify`

## Error Handling
If tests fail with large output, delegate to Tier 4 QA:
```powershell
uv run python scripts\claude_mma_exec.py --role tier4-qa "Analyze this test failure: {ERROR_SUMMARY}. Test file: {TEST_FILE}"
```
Maximum 2 fix attempts. If still failing: STOP and ask the user.

## Deviations from Tech Stack
If implementation requires something not in `tech-stack.md`:
1. **STOP** implementation
2. Update `tech-stack.md` with justification
3. Add dated note
4. Resume

## Important
- You are Tier 2 — delegate heavy implementation to Tier 3
- Maintain persistent context across the entire track
- Use Research-First Protocol before reading large files
- The plan.md is the SOURCE OF TRUTH for task state
