---
description: Parse requirements, create branch, setup tasks with research-enhanced analysis
argument-hint: [.prd.TICKET-ID.md] [--branch=name] [--num-tasks=N] [--no-research] [--skip-branch]
allowed-tools: Bash(git *), mcp__task_master_ai__*, Read, Grep, Glob
---

# Task Plan: $ARGUMENTS

Comprehensive workflow to parse PRD documents from multiple requirement management systems (Jira, GitHub Issues, Linear, Workday, Slack), create feature branches, and establish Task Master workflow with research-enhanced task generation.

**Reference:** See [~/.claude/guides/agents.task-master.md](../../guides/agents.task-master.md) for Task Master integration details.

## Workflow Summary

This command automates the complete setup workflow:

1. **DISCOVER PRD** - Auto-detect `.prd.*.md` files in repo root
2. **VALIDATE BRANCH** - Check if on protected branch, create feature branch if needed
3. **SETUP TASK MASTER** - Initialize if needed, create tag matching ticket ID
4. **ANALYZE & PLAN** - Present task count estimate and overview for confirmation
5. **PARSE & GENERATE** - Parse PRD with research mode, generate tasks
6. **VALIDATE & EXPAND** - Run complexity analysis, auto-expand complex tasks

**Supported Systems:**

- Jira (`.prd.PROJ-44.md` - any project key like PLATSD, GRC, etc.)
- GitHub Issues (`.prd.GH-12345.md`)
- Linear (`.prd.LIN-123.md`)
- Workday (`.prd.WD-456.md`)
- Slack (`.prd.SLACK-789.md`)

## Phase 0: Parse Arguments

Extract from `$ARGUMENTS`:

- **PRD File**: Optional explicit path (e.g., `.prd.PROJ-44.md`)
- **--branch=name**: Override suggested branch name
- **--num-tasks=N**: Override task count estimate
- **--no-research**: Skip research mode (faster but less comprehensive)
- **--skip-branch**: Skip branch creation check (use when already on correct branch)

### Argument Examples

````bash
# Auto-detect everything (recommended)
/task:plan

# Specify PRD file explicitly
/task:plan .prd.PROJ-44.md

# Override branch name
/task:plan --branch=feature/custom-name

# Skip research mode for speed
/task:plan .prd.GH-123.md --no-research

# Skip branch validation
/task:plan --skip-branch
```text

### 0.5 Verify API Keys

**CRITICAL: Task Master MCP requires valid API keys for research mode.**

Check if API keys are protected by 1Password:

```bash
# Check for 1Password-protected keys
if echo "$PERPLEXITY_API_KEY" | grep -q "op://"; then
  echo "🔑 Detected 1Password-protected API keys"
  echo "Exporting credentials..."

  # Export 1Password secrets
  source $(task op:export:force)

  # Verify export succeeded
  if echo "$PERPLEXITY_API_KEY" | grep -q "op://"; then
    echo "❌ Failed to export API keys from 1Password"
    echo ""
    echo "**Troubleshooting:**"
    echo "1. Ensure 1Password CLI is installed and authenticated"
    echo "2. Run 'task op' for more details"
    echo "3. Manually export keys or skip research mode (--no-research)"
    exit 1
  fi

  echo "✓ API keys exported successfully"
fi

# Verify at least one API key is available
if [ -z "$ANTHROPIC_API_KEY" ] && [ -z "$PERPLEXITY_API_KEY" ] && [ -z "$OPENAI_API_KEY" ]; then
  echo "⚠️ No AI API keys detected"
  echo ""
  echo "**Options:**"
  echo "1. Set ANTHROPIC_API_KEY for Task Master"
  echo "2. Set PERPLEXITY_API_KEY for research mode"
  echo "3. Run with --no-research flag"
  echo ""
  echo "See: task op (for 1Password integration)"
fi
```text

**Why this matters:**

- MCP connections may fail silently with invalid keys
- Research mode requires Perplexity or similar API access
- 1Password references (`op://...`) must be resolved before MCP usage

## Phase 1: Discover PRD File

### 1.1 Check for Explicit PRD Argument

**If PRD file path provided in $ARGUMENTS:**

```bash
# Verify file exists
PRD_FILE="$ARGUMENTS"
test -f "$PRD_FILE"
```text

**If file doesn't exist:**

```bash
## ❌ PRD File Not Found

Specified file does not exist: $ARGUMENTS

**Check:**
- File path is correct
- File exists in repository root
- File follows naming convention: .prd.TICKET-ID.md

**Available PRD files:**
```bash
ls -la .prd.*.md 2>/dev/null
```text

```text

**Exit if not found.**

### 1.2 Auto-Detect PRD Files

**If no PRD argument provided, search repo root:**

```bash
# Find all .prd.*.md files in repo root
PRD_FILES=$(ls -t .prd.*.md 2>/dev/null)
PRD_COUNT=$(echo "$PRD_FILES" | wc -l | tr -d ' ')
```text

**If no PRD files found:**

```bash
## ⚠️ No PRD Files Found

No `.prd.*.md` files detected in repository root.

**Expected Format:**
- Jira: `.prd.PROJ-44.md` (PROJ can be any project key)
- GitHub Issues: `.prd.GH-12345.md`
- Linear: `.prd.LIN-123.md`
- Workday: `.prd.WD-456.md`
- Slack: `.prd.SLACK-789.md`

**Options:**
1. Download requirements from your tracking system
2. Create PRD file manually in repo root
3. Use different command: `/task:parse-prd <file>`

**Exit** - Cannot proceed without PRD.
```text

**If one PRD file found:**

```bash
PRD_FILE=$(ls -t .prd.*.md 2>/dev/null | head -1)
```text

**If multiple PRD files found:**

```bash
## 🔍 Multiple PRD Files Detected

Found ${PRD_COUNT} PRD files in repository root:

$(ls -lt .prd.*.md | awk '{print "- " $9 " (modified: " $6 " " $7 " " $8 ")"}')

**Current Branch:** $(git branch --show-current)

**Auto-selecting most recent:** $PRD_FILE

**To use a different file:**
- Specify explicitly: `/task:plan .prd.TICKET-ID.md`
- Or continue with auto-selected file
```text

**Ask for confirmation before proceeding.**

### 1.3 Extract Ticket ID from PRD Filename

```bash
# Extract ticket ID from filename
# Pattern: .prd.TICKET-ID.md → TICKET-ID
PRD_FILE_BASENAME=$(basename "$PRD_FILE")
TICKET_ID=$(echo "$PRD_FILE_BASENAME" | sed 's/^\.prd\.//' | sed 's/\.md$//')
```text

**Validate ticket ID format:**

```bash
# Check if ticket ID follows expected pattern
# Should contain at least one letter and one number
if ! echo "$TICKET_ID" | grep -qE '[A-Z]+-[0-9]+|[A-Z]+[0-9]+'; then
  echo "⚠️ Warning: Ticket ID '$TICKET_ID' doesn't follow standard format"
  echo "Expected: ABC-123 or ABC123"
  echo "Continuing anyway..."
fi
```text

## Phase 2: Validate Branch State

**Skip this phase if --skip-branch flag present.**

### 2.1 Check Current Branch

```bash
# Get current branch name
CURRENT_BRANCH=$(git branch --show-current)

# Get default branch name
DEFAULT_BRANCH=$(git config --get init.defaultBranch || echo "main")

# Check if current branch is in remote
git fetch origin --quiet 2>/dev/null
REMOTE_DEFAULT=$(git rev-parse --abbrev-ref origin/HEAD 2>/dev/null | sed 's/origin\///')
if [ -n "$REMOTE_DEFAULT" ]; then
  DEFAULT_BRANCH="$REMOTE_DEFAULT"
fi
```text

**Protected branches list:**

```bash
PROTECTED_BRANCHES="main master develop development release"
```text

### 2.2 Check if Branch is Protected

```bash
# Check if current branch is protected
IS_PROTECTED=false
for PROTECTED in $PROTECTED_BRANCHES; do
  if [ "$CURRENT_BRANCH" = "$PROTECTED" ]; then
    IS_PROTECTED=true
    break
  fi
  # Also check for release branches (release/*, release-*)
  if echo "$CURRENT_BRANCH" | grep -qE "^release[/-]"; then
    IS_PROTECTED=true
    break
  fi
done
```text

**If not on protected branch and branch matches ticket ID:**

```bash
## ✅ Branch Validation

**Current Branch:** $CURRENT_BRANCH
**Ticket ID:** $TICKET_ID

Branch appears appropriate for this work. Proceeding...
```text

**Continue to Phase 3.**

### 2.3 Create Feature Branch (if protected)

**If on protected branch:**

```bash
## 🔄 Protected Branch Detected

**Current Branch:** $CURRENT_BRANCH (protected)
**Ticket ID:** $TICKET_ID from PRD file

Cannot work directly on protected branch. Creating feature branch...
```text

**Suggest branch name:**

```bash
# Generate suggested branch name from ticket ID and PRD content
# Read PRD title/summary (first non-empty line after any markdown headers)
PRD_TITLE=$(grep -v '^#' "$PRD_FILE" | grep -v '^$' | head -1 | \
  tr '[:upper:]' '[:lower:]' | \
  sed 's/[^a-z0-9 -]//g' | \
  sed 's/  */ /g' | \
  sed 's/ /-/g' | \
  cut -c1-50)

# Build suggested branch name
SUGGESTED_BRANCH="feature/${TICKET_ID}-${PRD_TITLE}"
```text

**Present suggestion:**

```text
**Suggested Branch Name:**
$SUGGESTED_BRANCH

**Confirm or modify branch name:**
- Use suggested: Continue
- Modify: Provide new name
- Skip: Use --skip-branch flag
```text

**Wait for user response.**

**If --branch argument provided:**

```bash
SUGGESTED_BRANCH="$BRANCH_ARG"
```text

### 2.4 Create and Checkout Branch

```bash
# Ensure we're on latest default branch
git checkout "$DEFAULT_BRANCH"
git pull origin "$DEFAULT_BRANCH" 2>/dev/null || true

# Create and checkout feature branch
git checkout -b "$SUGGESTED_BRANCH"
```text

**Confirmation:**

```bash
## ✅ Feature Branch Created

**Branch:** $SUGGESTED_BRANCH
**Base:** $DEFAULT_BRANCH
**Ticket:** $TICKET_ID

Ready to proceed with Task Master setup.
```text

## Phase 3: Setup Task Master

### 3.1 Check Task Master Initialization

```javascript
// Check if Task Master is initialized
const fs = require('fs')
const isInitialized = fs.existsSync('.taskmaster/tasks/tasks.json')
```text

**If not initialized:**

```bash
## 🔧 Initializing Task Master

Task Master not yet set up in this project. Initializing...
```text

**Initialize with MCP:**

```javascript
mcp__task_master_ai__initialize_project({
  projectRoot: process.cwd(),
  initGit: true,
  storeTasksInGit: true,
  skipInstall: false,
  yes: true  // Auto-confirm
})
```text

**If already initialized:**

```bash
## ✅ Task Master Ready

Task Master already initialized in this project.
```text

### 3.2 Create or Switch to Ticket Tag

```javascript
// List existing tags
const tags = mcp__task_master_ai__list_tags({
  projectRoot: process.cwd()
})

// Check if ticket tag exists
const ticketTag = tags.find(tag => tag.name === TICKET_ID)
```text

**If tag doesn't exist:**

```bash
## 🏷️ Creating Task Master Tag

**Tag:** $TICKET_ID
**Description:** Tasks for $TICKET_ID from PRD

This ensures all tasks are organized by ticket.
```text

**Create tag:**

```javascript
mcp__task_master_ai__add_tag({
  projectRoot: process.cwd(),
  name: TICKET_ID,
  description: `Tasks for ${TICKET_ID} from PRD file`
})
```text

**Switch to tag:**

```javascript
mcp__task_master_ai__use_tag({
  projectRoot: process.cwd(),
  name: TICKET_ID
})
```text

**If tag already exists:**

```bash
## 🏷️ Switching to Existing Tag

**Tag:** $TICKET_ID

Found existing tag for this ticket. Switching context...

**Warning:** Tasks may already exist for this ticket.
**Options:**
- Continue: Append new tasks to existing
- Cancel: Review existing tasks first with `/task:status`
```text

**Ask for confirmation to continue.**

## Phase 4: Analyze PRD and Present Plan

### 4.1 Read and Analyze PRD

**Use Read tool to load PRD:**

```javascript
// Read PRD file
const prdContent = await read(PRD_FILE)
```text

**Analyze content for complexity:**

```bash
# Basic analysis
WORD_COUNT=$(wc -w < "$PRD_FILE" | tr -d ' ')
LINE_COUNT=$(wc -l < "$PRD_FILE" | tr -d ' ')
SECTION_COUNT=$(grep -c '^#' "$PRD_FILE" || echo "0")
```text

**Parse for key indicators:**

- Feature count (look for lists, numbered items)
- Technical keywords (API, database, integration, auth, etc.)
- Acceptance criteria sections
- Test requirements
- SDLC phases mentioned

### 4.2 Estimate Task Count

**Complexity-based estimation:**

```javascript
// Estimate task count based on PRD analysis
let estimatedTasks = 10  // Default

// Simple heuristics
if (WORD_COUNT < 500) {
  estimatedTasks = 5  // Simple: 3-5 tasks
} else if (WORD_COUNT < 1500) {
  estimatedTasks = 8  // Medium: 5-10 tasks
} else if (WORD_COUNT < 3000) {
  estimatedTasks = 12  // Complex: 10-15 tasks
} else {
  estimatedTasks = 15  // Major: 15+ tasks
}

// Adjust based on sections
if (SECTION_COUNT > 10) {
  estimatedTasks = Math.min(estimatedTasks + 3, 20)
}

// Override if --num-tasks provided
if (NUM_TASKS_ARG) {
  estimatedTasks = NUM_TASKS_ARG
}
```text

### 4.3 Present Plan to Operator

**Show comprehensive plan overview:**

```bash
## 📋 Task Generation Plan

**PRD File:** $PRD_FILE
**Ticket ID:** $TICKET_ID
**Branch:** $CURRENT_BRANCH
**Tag:** $TICKET_ID

### PRD Analysis

**Content:**
- Lines: $LINE_COUNT
- Words: $WORD_COUNT
- Sections: $SECTION_COUNT

**Complexity:** $(determineComplexity)

### Proposed Task Structure

**Estimated Tasks:** $estimatedTasks main tasks

**Task Breakdown (estimated):**
- Planning & Design: 1-2 tasks
- Core Implementation: $(Math.floor(estimatedTasks * 0.6)) tasks
- Testing & QA: $(Math.floor(estimatedTasks * 0.2)) tasks
- Documentation: 1-2 tasks
- DevOps/Deploy: 0-1 tasks

**Features Identified:**
$(extractKeyFeatures from PRD)

### Next Steps

1. Parse PRD with research mode (30-60 seconds)
2. Generate $estimatedTasks tasks with AI
3. Run complexity analysis
4. Auto-expand high-complexity tasks
5. Ready to start: `/task:next`

**Options:**
- Continue: Proceed with plan
- Adjust: Specify different task count (--num-tasks=N)
- Review: Read PRD first (`cat $PRD_FILE`)
- Cancel: Abort planning

**Research Mode:** $(if --no-research then "Disabled (faster)" else "Enabled (recommended)")
```text

**Wait for operator confirmation or adjustment.**

**If operator requests different task count:**

```bash
# Update estimated tasks
estimatedTasks=$NEW_COUNT
```text

**Re-present plan with updated numbers.**

## Phase 5: Parse PRD with Research

### 5.1 Determine Research Mode

```bash
# Check for --no-research flag
USE_RESEARCH=true
if [[ "$ARGUMENTS" == *"--no-research"* ]]; then
  USE_RESEARCH=false
fi
```text

**If research mode disabled:**

```bash
## ⚡ Fast Parsing Mode

Research mode disabled. Task generation will be faster but less comprehensive.

**Trade-offs:**
- ✅ Faster (10-15 seconds vs 30-60 seconds)
- ❌ Less detailed task descriptions
- ❌ May miss edge cases and best practices
- ❌ No industry standards integration
```text

### 5.2 Parse PRD with Task Master

```bash
## 🔄 Parsing PRD

**File:** $PRD_FILE
**Mode:** $(if research then "Research-Enhanced" else "Standard")
**Target Tasks:** $estimatedTasks

$(if research then "Using Perplexity AI for comprehensive analysis..." else "Using standard parsing...")

**This will take:** $(if research then "30-60 seconds" else "10-15 seconds")
```text

**Execute parsing:**

```javascript
mcp__task_master_ai__parse_prd({
  projectRoot: process.cwd(),
  input: PRD_FILE,
  numTasks: estimatedTasks.toString(),
  research: USE_RESEARCH,
  tag: TICKET_ID  // Context already switched in Phase 3.2
})
```text

**Show progress indicator during parsing.**

### 5.3 Verify Task Generation

```javascript
// Get generated tasks
const generatedTasks = mcp__task_master_ai__get_tasks({
  projectRoot: process.cwd(),
  withSubtasks: true
})
```text

**If parsing failed:**

```bash
## ❌ Parsing Failed

Task generation encountered an error.

**Possible Issues:**
- API key missing (check ANTHROPIC_API_KEY or PERPLEXITY_API_KEY)
- PRD format issues
- Network connectivity
- Task Master configuration

**Retry Options:**
- Try without research: `/task:plan --no-research`
- Check API keys: `task-master models`
- Review PRD format: `cat $PRD_FILE`

**Error Details:**
$(show error message)
```text

**If parsing succeeded:**

```bash
## ✅ Tasks Generated Successfully

**Created:** ${generatedTasks.length} tasks
**Tag:** $TICKET_ID
**Status:** All tasks set to 'pending'

**Sample Tasks:**
1. ${generatedTasks[0].title}
2. ${generatedTasks[1].title}
3. ${generatedTasks[2].title}
$(if generatedTasks.length > 3 then "... and " + (generatedTasks.length - 3) + " more")

**View all tasks:** `/task:status`
```text

### 5.4 Post-Parse Cleanup

```bash
# Remove any generated .env.example files
rm -f .env.example 2>/dev/null

# Check for other temporary files
rm -f .taskmaster/.env.example 2>/dev/null
```text

## Phase 6: Validate Dependencies and Complexity

### 6.1 Validate Task Dependencies

```bash
## 🔍 Validating Dependencies

Checking for circular dependencies and invalid references...
```text

**Run validation:**

```javascript
const validation = mcp__task_master_ai__validate_dependencies({
  projectRoot: process.cwd()
})
```text

**If issues found:**

```bash
## ⚠️ Dependency Issues Detected

Found problems with task dependencies.

**Issues:**
$(list validation errors)

**Auto-fixing dependencies...**
```text

**Auto-fix:**

```javascript
mcp__task_master_ai__fix_dependencies({
  projectRoot: process.cwd()
})
```text

**If validation passed:**

```bash
## ✅ Dependencies Valid

All task dependencies are properly configured.
```text

### 6.2 Run Complexity Analysis

```bash
## 📊 Analyzing Task Complexity

Running AI-powered complexity analysis to identify tasks that need subtask breakdown...

**This will take:** 30-60 seconds with research mode
```text

**Execute analysis:**

```javascript
mcp__task_master_ai__analyze_project_complexity({
  projectRoot: process.cwd(),
  research: USE_RESEARCH,
  threshold: 5  // Recommend expansion for complexity >5
})
```text

**Review report:**

```javascript
const complexityReport = mcp__task_master_ai__complexity_report({
  projectRoot: process.cwd()
})
```text

### 6.3 Present Complexity Results

```bash
## 📊 Complexity Analysis Complete

**Tasks Analyzed:** ${generatedTasks.length}

**Complexity Distribution:**
- Low (1-3): ${countByComplexity(1,3)} tasks - Ready to start
- Medium (4-6): ${countByComplexity(4,6)} tasks - May need subtasks
- High (7-10): ${countByComplexity(7,10)} tasks - Recommended for expansion

**High-Complexity Tasks Detected:**
$(list tasks with complexity > 5)

**Recommendation:** Auto-expand high-complexity tasks (≤3 at a time)
```text

### 6.4 Auto-Expand High-Complexity Tasks

**Check for expansion candidates:**

```javascript
// Get high-complexity tasks without subtasks
const needsExpansion = generatedTasks.filter(task => {
  const hasNoSubtasks = !task.subtasks || task.subtasks.length === 0
  const complexity = getComplexityScore(task)
  return hasNoSubtasks && complexity > 5
})

// Limit to first 3 to avoid overwhelming
const toExpand = needsExpansion.slice(0, 3)
```text

**If tasks need expansion:**

```bash
## 🔄 Auto-Expanding Complex Tasks

Expanding ${toExpand.length} high-complexity tasks into subtasks...

**Expanding:**
$(toExpand.map(t => `- Task ${t.id}: ${t.title} (complexity: ${t.complexity})`).join('\n'))

**This will take:** $(toExpand.length * 20-30) seconds
```text

**Expand each task:**

```javascript
for (const task of toExpand) {
  // Determine subtask count based on complexity
  const numSubtasks = Math.min(Math.max(task.complexity, 5), 12)

  mcp__task_master_ai__expand_task({
    projectRoot: process.cwd(),
    id: task.id,
    num: numSubtasks.toString(),
    research: USE_RESEARCH,
    prompt: "Break down based on complexity analysis and industry best practices"
  })
}
```text

**If no expansion needed:**

```bash
## ✅ Task Structure Optimal

All tasks are appropriately sized. No automatic expansion needed.

**Note:** You can still expand individual tasks later with `/task:expand <id>`
```text

## Phase 7: Present Final Summary

### 7.1 Show Complete Setup Status

```bash
## 🎉 Task Master Setup Complete

**Project Setup:**
- ✅ PRD File: $PRD_FILE
- ✅ Ticket ID: $TICKET_ID
- ✅ Branch: $CURRENT_BRANCH
- ✅ Tag: $TICKET_ID (active)

**Task Generation:**
- ✅ Main Tasks: ${generatedTasks.length}
- ✅ Expanded Tasks: ${toExpand.length}
- ✅ Total Subtasks: ${countSubtasks()}
- ✅ Dependencies: Validated
- ✅ Complexity: Analyzed

**Task Status:**
- Pending: ${countByStatus('pending')}
- Ready to Start: ${countReadyTasks()}

**Next Actions:**
1. Review tasks: `/task:status`
2. Start first task: `/task:next`
3. View specific task: `/task:show <id>`
```text

### 7.2 Show Quick Start Guide

```bash
## ⚡ Quick Start

**Get next task:**
```text

/task:next

```text

**Start working:**
```text

/task:next --refine  # For complex tasks, refine before starting

```text

**Track progress:**
```text

/task:status         # View all tasks
/task:show 1         # View task details

```text

**Complete tasks:**
```text

/task:complete <id>  # Mark task as done

```text

### 7.3 Show Project Context

```text

## 📚 Project Context

**PRD Summary:**
$(show first 200 words of PRD)

**Key Features:**
$(extract bullet list of main features)

**Technical Stack:**
$(extract mentioned technologies)

**Full PRD:** `cat $PRD_FILE`

```text

### 7.4 Save Setup Metadata

**Create setup record:**

```bash
# Save metadata for reference
mkdir -p .taskmaster/logs
cat > .taskmaster/logs/setup-${TICKET_ID}.log <<EOF
Setup Date: $(date -u +"%Y-%m-%dT%H:%M:%SZ")
Ticket ID: $TICKET_ID
PRD File: $PRD_FILE
Branch: $CURRENT_BRANCH
Tag: $TICKET_ID
Tasks Generated: ${generatedTasks.length}
Research Mode: $USE_RESEARCH
Operator: $(git config user.name) <$(git config user.email)>
EOF
```text

## Phase 8: Error Handling

### PRD File Not Found

```bash
## ❌ PRD File Not Found

Cannot proceed without a PRD file.

**Expected Location:** Repository root
**Expected Format:** `.prd.TICKET-ID.md`

**Examples:**
- `.prd.PROJ-44.md` (Jira - any project key)
- `.prd.GH-12345.md` (GitHub Issues)
- `.prd.LIN-123.md` (Linear)

**Create PRD:**
1. Download from your tracking system
2. Save as `.prd.TICKET-ID.md` in repo root
3. Run `/task:plan` again
```text

### Task Master Initialization Failed

```bash
## ❌ Task Master Initialization Failed

Could not initialize Task Master in this project.

**Possible Issues:**
- Missing dependencies (run: `npm install` or `bun install`)
- Permission issues
- Corrupted .taskmaster directory

**Fixes:**
1. Install dependencies
2. Remove `.taskmaster` directory and retry
3. Check file permissions

**Error:** $(show error details)
```text

### API Key Missing

```bash
## ❌ API Key Required

Task Master requires an API key for AI-powered task generation.

**Required:** At least one of:
- ANTHROPIC_API_KEY (Claude)
- PERPLEXITY_API_KEY (Research)
- OPENAI_API_KEY (GPT)

**Configure:**
```bash
# Option 1: Environment variable
export ANTHROPIC_API_KEY="your-key"

# Option 2: .env file
echo "ANTHROPIC_API_KEY=your-key" >> .env

# Option 3: Task Master config
task-master models --setup
```text

**After configuring, run:**

```text
/task:plan --no-research  # Fast mode
# OR
/task:plan                # Full research mode
```text

```text

### Branch Creation Failed

```text

## ❌ Branch Creation Failed

Could not create feature branch.

**Possible Issues:**

- Uncommitted changes on current branch
- Branch name conflicts
- Git configuration issues

**Fixes:**

1. Commit or stash changes: `git stash`
2. Use different branch name: `/task:plan --branch=custom-name`
3. Skip branch creation: `/task:plan --skip-branch`

**Error:** $(show git error)

```text

### Parsing Timeout

```text

## ⏱️ Parsing Timeout

Task generation took longer than expected.

**Possible Issues:**

- Network connectivity
- Large PRD file
- API rate limits

**Retry Options:**

1. Try without research (faster): `/task:plan --no-research`
2. Reduce task count: `/task:plan --num-tasks=5`
3. Check network connection
4. Wait and retry

**Partial Results:**
$(if any tasks generated, show them)

```text

## Additional Context

### Supported PRD Formats

**All systems follow the same pattern:**

```text

.prd.TICKET-ID.md

```text

**Examples:**

| System | Format | Example |
|--------|--------|---------|
| Jira | `.prd.PROJECTKEY-NUMBER.md` | `.prd.PROJ-44.md` |
| GitHub Issues | `.prd.GH-NUMBER.md` | `.prd.GH-12345.md` |
| Linear | `.prd.PROJECT-NUMBER.md` | `.prd.LIN-123.md` |
| Workday | `.prd.WD-NUMBER.md` | `.prd.WD-456.md` |
| Slack | `.prd.SLACK-NUMBER.md` | `.prd.SLACK-789.md` |

**Note:** For Jira, PROJECTKEY can be any project key (e.g., PLATSD, GRC, PROJ1, etc.)

**Ticket ID Extraction:**
- Filename `.prd.PROJ-44.md` → Tag `PROJ-44`
- Filename `.prd.GH-12345.md` → Tag `GH-12345`

### Branch Naming Conventions

**Auto-generated format:**

```text

feature/TICKET-ID-description

```text

**Examples:**
- `feature/PROJ-44-implement-auth`
- `feature/GH-12345-add-user-mgmt`
- `bugfix/LIN-123-fix-validation`

**Protected branches requiring new branch:**
- `main`, `master`
- `develop`, `development`
- `release/*`, `release-*`

**Always branches off:** Default branch (usually `main` or `master`)

### Research Mode Benefits

**Enabled (default):**
- ✅ Latest framework patterns
- ✅ Security best practices
- ✅ Performance optimizations
- ✅ Industry standards
- ✅ Compliance considerations
- ✅ Modern tooling suggestions
- ⏱️ Slower (30-60 seconds per operation)

**Disabled (--no-research):**
- ✅ Faster (10-15 seconds per operation)
- ❌ Basic task generation
- ❌ May miss best practices
- ❌ Less comprehensive

**Recommendation:** Use research mode for production work, disable for experimentation.

### Task Count Guidelines

**By PRD Size:**
- **<500 words**: 3-5 tasks (Simple)
- **500-1500 words**: 5-10 tasks (Medium)
- **1500-3000 words**: 10-15 tasks (Complex)
- **>3000 words**: 15-20 tasks (Major)

**By Feature Count:**
- **1-2 features**: 5 tasks
- **3-5 features**: 10 tasks
- **6-10 features**: 15 tasks
- **>10 features**: 20 tasks

**Override with:** `--num-tasks=N` argument

### Automation Level

This command provides **one-click ease of use** with **operator control:**

**Automated:**
- ✅ PRD discovery
- ✅ Ticket ID extraction
- ✅ Branch name suggestion
- ✅ Task count estimation
- ✅ Tag creation/switching
- ✅ Dependency validation
- ✅ Complexity analysis
- ✅ High-complexity expansion

**Operator Confirms:**
- PRD selection (if multiple found)
- Branch name (can modify)
- Task count estimate (can adjust)
- Parsing execution
- Complex task expansion

**Override Available:**
- All suggestions can be overridden with arguments
- Skip steps with flags (--skip-branch, --no-research)
- Full control when needed

### Integration with Other Commands

**Complete workflow:**

```bash
# 1. Setup from PRD
/task:plan

# 2. Get next task
/task:next

# 3. Refine if complex
/task:next --refine

# 4. Start work
/task:start <id>

# 5. Complete task
/task:complete <id>

# 6. Commit work
/commit --all

# 7. Repeat
/task:next
```text

**Quick reference:**

- `/task:plan` - This command (setup)
- `/task:next` - Find next task
- `/task:status` - View all tasks
- `/task:show <id>` - Task details
- `/task:complete <id>` - Mark done

---

**For comprehensive Task Master documentation:**

See [~/.claude/guides/agents.task-master.md](../../guides/agents.task-master.md)
````
