---
name: Enhanced LLM-Native JIRA Workflows
description: Example workflows demonstrating advanced context management, prompt optimization, and multi-turn reasoning
version: 1.0.0
workflows:
  - id: epic-breakdown-with-reasoning
    name: Intelligent Epic Breakdown
    description: Break down complex epics using multi-turn reasoning and context awareness
    tags: [epic, planning, multi-turn]
    
    context_template: feature_epic_breakdown
    
    phases:
      - name: Analysis
        description: Analyze epic complexity with context awareness
        steps:
          - id: load-context
            task: Execute context-manager
            action: |
              Load or create epic breakdown context
              Check for previous breakdown attempts
              Apply team's preferred patterns
            
          - id: analyze-epic
            task: Execute prompt-optimizer
            action: |
              Select optimal epic analysis prompt based on:
              - Epic size and complexity
              - Team's historical patterns
              - Available context richness
              Execute analysis with enhanced prompt
          
          - id: present-analysis
            task: Execute reasoning-engine
            action: |
              Present epic analysis with progressive disclosure:
              - Summary for quick review
              - Detailed breakdown on request
              - Risk factors highlighted
              - Suggest breakdown approaches
      
      - name: Interactive Planning
        description: Guide user through story generation with checkpoints
        steps:
          - id: breakdown-conversation
            task: Execute interaction-flows
            action: |
              Start epic_breakdown_flow:
              Turn 1: "I've analyzed epic {{epic_key}}. It's {{complexity}} with {{estimate}} potential stories."
              Turn 2: Present breakdown options (vertical, horizontal, risk-based)
              Turn 3: Generate stories based on chosen approach
              Turn 4: Refine with user input
              
          - id: checkpoint-progress
            task: Execute checkpoint-manager
            action: |
              Create checkpoint after each turn
              Allow resume if interrupted
              Track decisions made
      
      - name: Story Creation
        description: Create stories with optimized prompts
        steps:
          - id: optimize-creation
            task: Execute prompt-chains
            action: |
              Chain story creation prompts:
              1. Validate story completeness
              2. Check dependencies
              3. Create in JIRA with proper links
              4. Update BMAD documentation
              
          - id: verify-sync
            task: Execute universal-sync-analysis
            action: |
              Verify three-way sync health
              Update context with created stories
              Generate sync report

  - id: sprint-planning-adaptive
    name: Adaptive Sprint Planning
    description: Plan sprints with intelligent capacity analysis and story selection
    tags: [sprint, planning, adaptive]
    
    context_template: sprint_planning_standard
    
    phases:
      - name: Capacity Intelligence
        description: Smart capacity calculation with pattern learning
        steps:
          - id: analyze-patterns
            task: Execute context-analyzer
            action: |
              Analyze team's sprint patterns:
              - Historical velocity trends
              - Completion rates by story type
              - Common planning mistakes
              Generate insights for current sprint
          
          - id: calculate-capacity
            task: Execute prompt-library
            action: |
              Use optimized capacity calculation prompt
              Factor in:
              - Team availability
              - Historical accuracy
              - Current context (holidays, releases)
              
      - name: Story Selection
        description: Intelligent story selection with multi-criteria optimization
        steps:
          - id: selection-conversation
            task: Execute decision-trees
            action: |
              Navigate sprint_planning_decision_tree:
              - Check capacity vs velocity
              - Evaluate story readiness
              - Consider dependencies
              - Balance priorities
              
          - id: optimize-selection
            task: Execute prompt-optimizer
            action: |
              Use context-aware story selection:
              - Team's skill distribution
              - Epic priorities
              - Technical dependencies
              - Risk balance

  - id: intelligent-sync-recovery
    name: Sync Operation with Recovery
    description: Demonstrate checkpoint recovery for interrupted sync operations
    tags: [sync, recovery, resilience]
    
    phases:
      - name: Sync Preparation
        description: Prepare for sync with checkpoint creation
        steps:
          - id: create-sync-checkpoint
            task: Execute checkpoint-manager
            action: |
              Create checkpoint before sync:
              - Current sync scope
              - Entity states
              - User preferences
              Mark as resumable
              
      - name: Simulated Interruption
        description: Handle sync interruption gracefully
        steps:
          - id: detect-incomplete
            task: Execute reasoning-engine
            action: |
              On next session:
              "I see you have an incomplete sync operation from {{time_ago}}.
              You were syncing {{entity_count}} stories and completed {{completed_count}}.
              Would you like to continue where you left off?"
              
          - id: resume-sync
            task: Execute checkpoint-manager
            action: |
              If user confirms:
              - Restore full context
              - Continue from last successful operation
              - Show what was completed and what remains

  - id: personalized-daily-standup
    name: Context-Aware Daily Standup
    description: Generate standups that learn from team patterns
    tags: [standup, daily, personalized]
    
    phases:
      - name: Pattern Learning
        description: Learn team's standup preferences
        steps:
          - id: analyze-preferences
            task: Execute context-analyzer
            action: |
              Analyze past standup patterns:
              - Preferred format and detail level
              - Common discussion topics
              - Time constraints
              - Team distribution
              
      - name: Intelligent Generation
        description: Create personalized standup agenda
        steps:
          - id: optimize-standup-prompt
            task: Execute prompt-optimizer
            action: |
              Select standup template based on:
              - Day of week (Monday vs Friday)
              - Sprint phase (early, mid, late)
              - Recent team events
              - Detected urgency
              
          - id: progressive-standup
            task: Execute interaction-flows
            action: |
              Use progressive disclosure:
              - Quick summary first
              - Detailed sections on request
              - Focus on anomalies and risks
              - Suggest discussion topics

  - id: bug-investigation-assistant
    name: Intelligent Bug Investigation
    description: Multi-turn bug analysis with context-aware insights
    tags: [bug, investigation, multi-turn]
    
    phases:
      - name: Bug Discovery
        description: Smart bug identification and context gathering
        steps:
          - id: understand-issue
            task: Execute reasoning-engine
            action: |
              Natural conversation:
              User: "The login is broken"
              Assistant: "I'll help investigate the login issue. Let me check a few things..."
              
              Use context to understand:
              - Component affected
              - Recent changes
              - Similar past issues
              
      - name: Guided Investigation
        description: Lead user through systematic investigation
        steps:
          - id: investigation-flow
            task: Execute decision-trees
            action: |
              Use bug_investigation_tree:
              - Check error patterns
              - Review recent deployments
              - Analyze related tickets
              - Generate hypotheses
              
          - id: adaptive-depth
            task: Execute prompt-optimizer
            action: |
              Adjust investigation depth based on:
              - User expertise level
              - Issue complexity
              - Available time
              - Prior investigation success

example_usage:
  epic_breakdown_scenario: |
    User: "Break down the payment processing epic"
    
    Assistant: [Initializes context, loads patterns]
    "I'll help you break down the payment processing epic. Let me analyze it first..."
    
    [Uses optimized prompt for epic analysis]
    "I've analyzed PAYMENT-100: 'Payment Processing System'. Here's what I found:
    
    📊 **Epic Analysis**
    - Estimated size: Large (8-12 stories)
    - Technical complexity: High (external integrations)
    - Risk factors: PCI compliance, third-party dependencies
    - Team experience: Medium (new payment provider)
    
    How would you like to break this down?
    1. **By payment flow** (vertical slices) - Recommended
    2. **By technical layer** (frontend/backend/integration)
    3. **By risk** (tackle unknowns first)
    4. **Custom approach**"
    
    User: "Let's go with payment flow"
    
    Assistant: [Creates checkpoint, continues conversation]
    "Good choice! Breaking down by payment flow will give us complete user journeys. 
    
    Based on the requirements, I suggest these payment flows:
    1. **Credit Card Processing** (3 stories)
    2. **PayPal Integration** (2 stories)  
    3. **Refund Management** (2 stories)
    4. **Payment History** (1 story)
    5. **Error Handling & Recovery** (2 stories)
    
    Would you like me to generate the detailed stories for these flows?"
    
    [Continues with story generation, creating checkpoints at each step]

  sync_recovery_scenario: |
    [Session 1]
    User: "Sync all stories in the current sprint"
    Assistant: "I'll sync all stories in Sprint 42. Found 15 stories to sync..."
    [Creates checkpoint, begins sync]
    [Network interruption after 8 stories]
    
    [Session 2 - Next day]
    Assistant: "Welcome back! I see you have an incomplete sync operation from yesterday.
    You were syncing 15 stories in Sprint 42 and completed 8 successfully.
    
    ✅ Completed: AUTH-101, AUTH-102, PAY-201...
    ⏳ Remaining: PAY-203, UI-301, UI-302...
    
    Would you like to continue syncing the remaining 7 stories?"
    
    User: "Yes, continue"
    
    Assistant: [Restores context, resumes operation]
    "Resuming sync from PAY-203..."

key_benefits:
  - context_awareness: Operations remember previous interactions and learn patterns
  - intelligent_prompting: Prompts are optimized based on context and performance
  - natural_conversations: Complex operations feel like helpful discussions
  - resilient_operations: Interruptions are handled gracefully with checkpoints
  - continuous_improvement: System learns and adapts while preserving privacy