Skip to main content
ClaudeWave
Slash Command89 repo starsupdated 1mo ago

tasks

Generate TDD task breakdown from plan.md with test-first sequencing and mockup-first mode (--ui-first)

Install in Claude Code
Copy
mkdir -p ~/.claude/commands && curl -fsSL https://raw.githubusercontent.com/marcusgoll/Spec-Flow/HEAD/.claude/commands/phases/tasks.md -o ~/.claude/commands/tasks.md
Then start a new Claude Code session; the slash command loads automatically.

tasks.md

# /tasks — Task Breakdown Generator (Thin Wrapper)

> **v11.0 Architecture**: This command spawns the isolated `tasks-phase-agent` via Task(). All task breakdown logic runs in isolated context.

<context>
**User Input**: $ARGUMENTS

**Active Feature**: !`ls -td specs/[0-9]*-* 2>/dev/null | head -1 || echo "none"`

**Interaction State**: !`cat specs/*/interaction-state.yaml 2>/dev/null | head -10 || echo "none"`
</context>

<objective>
Spawn isolated tasks-phase-agent to generate TDD task breakdown from plan.md.

**Architecture (v11.0 - Phase Isolation):**
```
/tasks → Task(tasks-phase-agent) → tasks.md with TDD structure
```

**Agent responsibilities:**
- Read plan.md and spec.md
- Generate 20-30 tasks with acceptance criteria
- Follow TDD Red-Green-Refactor pattern
- Calculate task sizes (XS/S/M/L)
- Identify dependencies and parallel-safe tasks

**Mode detection:**
- **Epic workflows**: Sprint breakdown with dependency graph
- **Feature workflows**: Tasks organized by user story priority
- **UI-first mode** (--ui-first): Mockup tasks before implementation

**Flags**:
- `--ui-first`: Generate HTML mockup tasks first
- `--standard`: Standard TDD task generation
- `--no-input`: Non-interactive mode for CI/CD

**Workflow position**: `spec → clarify → plan → tasks → implement → optimize → ship`
</objective>

## Legacy Context (for agent reference)

<legacy_context>
Current git status: !`git status --short | head -10`

Current branch: !`git branch --show-current`

Feature spec exists: Auto-detected (epics/_/epic-spec.md OR specs/_/spec.md)

Plan exists: Auto-detected (epics/_/plan.md OR specs/_/plan.md)
</legacy_context>

<process>

### Step 0: WORKFLOW DETECTION

**Detect workflow using centralized skill** (see `.claude/skills/workflow-detection/SKILL.md`):

1. Run detection: `bash .spec-flow/scripts/utils/detect-workflow-paths.sh`
2. Parse JSON: Extract `type`, `base_dir`, `slug` from output
3. If detection fails (exit code != 0): Use AskUserQuestion fallback
4. Set paths:
   - Feature: `SPEC_FILE="${BASE_DIR}/${SLUG}/spec.md"`
   - Epic: `SPEC_FILE="${BASE_DIR}/${SLUG}/epic-spec.md"`
   - Common: `PLAN_FILE="${BASE_DIR}/${SLUG}/plan.md"`, `TASKS_FILE="${BASE_DIR}/${SLUG}/tasks.md"`

**Fallback prompt** (if detection fails):
- Question: "Which workflow are you working on?"
- Options: "Feature" (specs/), "Epic" (epics/)

---

### Step 1: Load User Preferences (3-Tier System)

0. **Load User Preferences (3-Tier System)**:

   **Determine task generation mode using 3-tier preference system:**

   a. **Load configuration file** (Tier 1 - lowest priority):

   ```powershell
   $preferences = & .spec-flow/scripts/utils/load-preferences.ps1 -Command "tasks"
   $configMode = $preferences.commands.tasks.default_mode  # "standard" or "ui-first"
   ```

   b. **Load command history** (Tier 2 - medium priority, overrides config):

   ```powershell
   $history = & .spec-flow/scripts/utils/load-command-history.ps1 -Command "tasks"

   if ($history.last_used_mode -and $history.total_uses -gt 0) {
       $preferredMode = $history.last_used_mode  # Use learned preference
   } else {
       $preferredMode = $configMode  # Fall back to config
   }
   ```

   c. **Check command-line flags** (Tier 3 - highest priority):

   ```javascript
   const args = "$ARGUMENTS".trim();
   const hasUIFirstFlag = args.includes("--ui-first");
   const hasStandardFlag = args.includes("--standard");
   const hasNoInput = args.includes("--no-input");

   let selectedMode;
   let passToScript;

   if (hasNoInput) {
     selectedMode = "standard"; // CI default
     passToScript = ""; // No flag to script
   } else if (hasUIFirstFlag) {
     selectedMode = "ui-first";
     passToScript = "--ui-first";
   } else if (hasStandardFlag) {
     selectedMode = "standard";
     passToScript = ""; // No flag means standard
   } else {
     // No explicit flag - use preference
     selectedMode = preferredMode;
     passToScript = selectedMode === "ui-first" ? "--ui-first" : "";
   }
   ```

   d. **Track usage for learning system**:

   ```powershell
   # Record selection after command completes successfully
   & .spec-flow/scripts/utils/track-command-usage.ps1 -Command "tasks" -Mode $selectedMode
   ```

### Step 1.5: MIGRATION TASK DETECTION (v10.5)

**Detect and generate migration tasks before standard task generation:**

```bash
# Check for migration-plan.md from /plan phase
MIGRATION_PLAN="${BASE_DIR}/${SLUG}/migration-plan.md"

if [ -f "$MIGRATION_PLAN" ]; then
    echo "🗄️  Migration plan detected: $MIGRATION_PLAN"
    HAS_MIGRATIONS=true

    # Parse migration-plan.md for tables/changes
    NEW_TABLES=$(grep -E '#### Table:' "$MIGRATION_PLAN" | wc -l | tr -d ' ')
    MODIFIED_TABLES=$(grep -E '#### Table:.*Modified' "$MIGRATION_PLAN" | wc -l | tr -d ' ')

    echo "   New tables: $NEW_TABLES"
    echo "   Modified tables: $MODIFIED_TABLES"
else
    # Fallback: Check state.yaml for has_migrations flag
    STATE_FILE="${BASE_DIR}/${SLUG}/state.yaml"
    if [ -f "$STATE_FILE" ]; then
        HAS_MIGRATIONS=$(yq eval '.has_migrations // false' "$STATE_FILE" 2>/dev/null || echo "false")
    else
        HAS_MIGRATIONS=false
    fi
fi
```

**If migrations detected, generate Phase 1.5 tasks:**

When `HAS_MIGRATIONS=true`, generate migration tasks BEFORE standard tasks:

```markdown
## Phase 1.5: Database Migrations (BLOCKING)

> Auto-generated from migration-plan.md
> Priority: P0 - Must complete before ORM/API tasks

### T001: [MIGRATION] Create {table_name} table
**Depends On**: T000 (Setup)
**Delegated To**: database-architect
**Priority**: P0 (BLOCKING)
**Framework**: {Alembic | Prisma}
**Source**: migration-plan.md

**Acceptance Criteria**:
- [ ] Migration file created with upgrade()/downgrade()
- [ ] Table schema matches migration-plan.md
- [ ] Foreign keys reference existing tables
- [ ] Indexes created per plan
- [ ] Migration up/down cycle tested
- [ ] Data validation: 0 integrity violations
```

**Task ID Convention:**

| ID