---
description: Implement user story using TDD workflow
argument-hint: [STORY-ID] [--force] [--fix] [--ignore-debt-threshold]
model: Sonnet
effort: High
allowed-tools: AskUserQuestion, Read, Skill, Bash(git:*)
execution-mode: immediate
---

# /dev - TDD Development Workflow

Execute full Test-Driven Development cycle for a user story. Do not skip any phases nor skip the spec-driven-dev skill.

You MUST execute the spec-driven-dev skill, when called upon: Skill(command="spec-driven-dev")
---

## Phase 0: Parse Arguments and Set Context Markers

```
STORY_ID = null
FORCE_FLAG = false
REMEDIATION_MODE = false
IGNORE_DEBT_FLAG = false

FOR arg in arguments:
    IF arg == "--force": FORCE_FLAG = true
    ELIF arg == "--fix": REMEDIATION_MODE = true
    ELIF arg == "--ignore-debt-threshold": IGNORE_DEBT_FLAG = true
    ELIF arg matches "STORY-[0-9]+": STORY_ID = arg

IF STORY_ID empty:
    Display: "Usage: /dev STORY-NNN [--force] [--fix] [--ignore-debt-threshold]"
    HALT
```

Verify story exists:
```
@devforgeai/specs/Stories/$STORY_ID*.story.md
IF file not found: Display "Story not found: $STORY_ID" and HALT
```

Auto-detect gaps.json for remediation:
```
gaps_result = Glob(pattern="devforgeai/qa/reports/${STORY_ID}-gaps.json")
IF gaps_result not empty AND REMEDIATION_MODE != true:
    REMEDIATION_MODE = true
    Display: "Auto-detected gaps.json - Remediation mode enabled"
```

---

## Phase 1: Invoke Skill

```
Display: ""
Display: "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
Display: "  DevForgeAI Development Workflow"
Display: "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
Display: "**Story ID:** ${STORY_ID}"
Display: "Executing TDD workflow (Red > Green > Refactor > Integration)..."

**Story ID:** ${STORY_ID}
**Force Flag:** ${FORCE_FLAG}
**Remediation Mode:** ${REMEDIATION_MODE}
**Ignore Debt Threshold:** ${IGNORE_DEBT_FLAG}

Skill(command="spec-driven-dev")
```

---

## Phase 2: Display Results

Display skill's formatted result directly. No processing, parsing, or template generation in command. All business logic delegated to skill, all display templates generated by dev-result-interpreter subagent.

---

## Error Handling

| Error | Resolution |
|-------|------------|
| Invalid Story ID | Usage: /dev STORY-NNN |
| Story Not Found | Glob(pattern="devforgeai/specs/Stories/*.story.md") |
| Skill Failed | Check: context files (/create-context), git init, tech-stack.md |
