# backlog-grooming-intelligence

Intelligent backlog grooming and refinement workflows that bridge BMAD planning with JIRA execution, ensuring stories are development-ready through continuous assessment, prioritization, and quality improvement.

## TODO TOOL INTEGRATION - MANDATORY FOR COMPLEX BACKLOG GROOMING

[[LLM: CRITICAL - This is a complex multi-step task requiring todo tool usage:

MANDATORY TODO TOOL ACTIVATION:
Before starting backlog grooming, MUST use todo_tool to break down the complex workflow:

1. ALWAYS say "use todo_tool" or "break down this task step by step" first
2. Create specific, actionable subtasks for:
   - Project mapping validation and configuration loading
   - Story readiness assessment across multiple dimensions
   - Comprehensive quality gates evaluation
   - Prioritization analysis and dependency mapping
   - Collaborative refinement workflow execution
   - Results documentation and team communication
3. Execute tasks one by one, updating status as you progress
4. Only mark tasks complete when fully accomplished with all validation steps done

Keywords that trigger planning mode:

- "use todo_tool"
- "break down this task step by step"
- "create a step-by-step plan"
- "use planning tool"
- "decompose this complex task"

This ensures systematic execution and prevents incomplete backlog refinement.
]]

## Project Mapping Validation

[[LLM: MANDATORY - Before ANY backlog operations:

1. Check if `.bmad-workspace/ck-jira-integration/config/jira-expansion-config.yaml` exists
2. If NOT exists, check legacy `.bmad-workspace/config/jira-expansion-config.yaml`
3. If NOT exists:
   - ERROR: "❌ JIRA expansion config not configured. Please run 'setup' first."
   - Guide user to run setup task
   - DO NOT proceed with operations
4. If exists:
   - Load project key and repository configurations
   - Use project key for all JIRA queries
   - Analyze stories from ALL configured repositories
     ]]

## Core Philosophy

Transform backlog grooming from reactive maintenance to proactive story optimization through intelligent analysis and continuous refinement. The LLM should:

1. **Assess story readiness** for development with comprehensive quality gates
2. **Optimize backlog health** through continuous analysis and improvement
3. **Enable intelligent prioritization** based on value, effort, and dependencies
4. **Facilitate collaborative refinement** with data-driven insights
5. **Learn from execution** to improve future story quality and estimation

## Story Readiness Intelligence

### Comprehensive Readiness Assessment

Analyze BMAD stories and JIRA issues for development readiness across multiple dimensions:

**Acceptance Criteria Analysis:**

- **Completeness Check**: Verify all user scenarios are covered
- **Testability Assessment**: Ensure criteria are measurable and verifiable
- **Clarity Evaluation**: Check for ambiguous or unclear requirements
- **Edge Case Coverage**: Identify missing boundary conditions and error scenarios

**Technical Readiness Evaluation:**

- **Architecture Decisions**: Verify technical approach is defined
- **Dependency Identification**: Map all technical and story dependencies
- **API Contract Clarity**: Ensure interfaces and data models are specified
- **Performance Requirements**: Check for scalability and performance criteria

**Business Value Clarity:**

- **User Impact Assessment**: Verify clear user benefit articulation
- **Success Metrics Definition**: Ensure measurable business outcomes
- **Priority Justification**: Validate business case and urgency
- **Stakeholder Alignment**: Confirm requirements approval and sign-off

**Estimation Quality:**

- **Complexity Assessment**: Evaluate story size appropriateness
- **Effort Estimation**: Compare with historical similar stories
- **Risk Factor Analysis**: Identify estimation uncertainty areas
- **Splitting Recommendations**: Suggest breakdown for oversized stories

### Readiness Scoring System

**Story Readiness Score (0-100):**

```
Readiness = (Acceptance_Criteria * 0.3) +
           (Technical_Clarity * 0.25) +
           (Business_Value * 0.2) +
           (Estimation_Quality * 0.15) +
           (Dependency_Resolution * 0.1)
```

**Readiness Categories:**

- **Ready for Development (85-100)**: Can be picked up immediately
- **Needs Minor Refinement (70-84)**: Small gaps to address
- **Requires Grooming (50-69)**: Significant refinement needed
- **Not Ready (0-49)**: Major work required before development

### Story Quality Gates

**Development Entry Criteria:**

1. **"Definition of Ready" Compliance**: All required fields completed
2. **Acceptance Criteria Completeness**: Minimum 3 testable criteria
3. **Technical Approach Clarity**: Architecture decisions documented
4. **Dependency Resolution**: All blockers identified and planned
5. **Size Appropriateness**: Story fits within sprint capacity

**Quality Improvement Triggers:**

- Stories below readiness threshold get automatic improvement suggestions
- Historical variance analysis influences readiness criteria
- Team velocity patterns inform optimal story sizing
- Risk patterns from reconciliation data enhance quality gates

## Backlog Health Intelligence

### Comprehensive Backlog Analysis

**Distribution Analysis:**

- **Story Size Distribution**: Optimal mix of small, medium, large stories
- **Readiness Pipeline**: Stories at each readiness level
- **Priority vs Effort Mapping**: Value delivery efficiency analysis
- **Theme and Epic Alignment**: Strategic goal coverage assessment

**Flow Optimization:**

- **Throughput Analysis**: Story completion rates by size and type
- **Bottleneck Identification**: Where stories get stuck in refinement
- **Lead Time Assessment**: Time from creation to development readiness
- **Work-in-Progress Limits**: Optimal grooming capacity planning

**Quality Trends:**

- **Readiness Score Trends**: Improving or declining story quality
- **Refinement Velocity**: How quickly stories become ready
- **Estimation Accuracy**: Historical sizing effectiveness
- **Defect Injection**: Quality issues introduced during grooming

### Backlog Health Metrics

**Core Health Indicators:**

- **Ready Story Ratio**: Percentage of stories ready for development
- **Backlog Debt**: Stories requiring significant rework or refinement
- **Dependency Complexity**: Cross-story and external dependency density
- **Value Flow Rate**: Business value delivery per sprint capacity

**Early Warning Signals:**

- **Readiness Decline**: Decreasing quality of new stories
- **Grooming Bottlenecks**: Stories stuck in refinement too long
- **Estimation Drift**: Growing variance between estimates and actuals
- **Priority Thrashing**: Frequent priority changes indicating unclear strategy

## Intelligent Prioritization

### Multi-Dimensional Priority Analysis

**Value-Effort Matrix Intelligence:**

- **Business Impact Scoring**: Quantified user and business value
- **Technical Effort Assessment**: Development complexity and time
- **Risk-Adjusted Prioritization**: Uncertainty and dependency factors
- **Strategic Alignment**: Contribution to long-term goals and OKRs

**Dependency-Aware Ordering:**

- **Critical Path Analysis**: Stories blocking multiple downstream work
- **Dependency Chain Optimization**: Minimize waiting and handoffs
- **Parallel Work Identification**: Stories that can be developed concurrently
- **External Dependency Management**: Third-party and integration constraints

**Capacity-Based Planning:**

- **Team Velocity Alignment**: Stories sized for team capacity
- **Skill-Based Assignment**: Matching story requirements to team expertise
- **Learning Curve Factors**: Accounting for new technology or domain knowledge
- **Sprint Goal Coherence**: Stories that work together toward sprint objectives

### Dynamic Priority Adjustment

**Real-Time Priority Factors:**

- **Market Timing**: Customer demand and competitive pressure changes
- **Technical Discoveries**: New information affecting effort or approach
- **Resource Availability**: Team capacity and skill changes
- **Stakeholder Feedback**: Customer and business stakeholder input

**Priority Recommendation Engine:**

- **Weighted Scoring**: Multi-factor priority calculation with customizable weights
- **Scenario Analysis**: What-if priority changes and their impact
- **Optimization Algorithms**: Mathematical priority ordering for maximum value
- **Constraint Satisfaction**: Priority ordering respecting dependencies and capacity

## Grooming Session Intelligence

### Session Preparation Automation

**Agenda Generation:**

- **Story Selection**: Optimal stories for grooming based on priority and readiness
- **Preparation Materials**: Background information and context for each story
- **Question Identification**: Known gaps and clarification needs
- **Time Allocation**: Estimated discussion time based on story complexity

**Stakeholder Coordination:**

- **Required Attendees**: Identify necessary subject matter experts
- **Preparation Assignments**: Pre-work for efficient session usage
- **Decision Points**: Critical choices that need group consensus
- **Follow-up Planning**: Action items and next steps preparation

### Session Facilitation Support

**Discussion Structure:**

- **Story Walkthrough**: Systematic review process for each story
- **Gap Identification**: Interactive checklist for readiness assessment
- **Estimation Activities**: Collaborative sizing with historical context
- **Decision Documentation**: Capture requirements clarifications and decisions

**Time Management:**

- **Discussion Timers**: Keep sessions focused and productive
- **Priority Queuing**: Address most important items first
- **Parking Lot Management**: Capture side discussions for later follow-up
- **Action Item Tracking**: Ensure all decisions and next steps are recorded

### Post-Session Intelligence

**Grooming Outcome Analysis:**

- **Stories Refined**: Readiness improvement measurement
- **Decisions Made**: Requirements clarifications and technical choices
- **New Stories Created**: Story splitting and new requirement identification
- **Backlog Updates**: Priority changes and story movements

**Continuous Improvement:**

- **Session Effectiveness**: Time usage and outcome quality analysis
- **Team Engagement**: Participation patterns and collaboration quality
- **Decision Quality**: Tracking how grooming decisions affect development
- **Process Optimization**: Recommendations for improving future sessions

## Story Lifecycle Intelligence

### From Concept to Ready

**Story Maturation Pipeline:**

1. **Concept Stage**: Initial idea with basic value proposition
2. **Analysis Stage**: Detailed requirements and acceptance criteria
3. **Design Stage**: Technical approach and architecture decisions
4. **Readiness Stage**: All development prerequisites complete
5. **Sprint Ready**: Queued for development team pickup

**Progression Triggers:**

- **Automatic Advancement**: Stories meeting criteria move forward automatically
- **Quality Gates**: Required checkpoints before stage progression
- **Stakeholder Approvals**: Business and technical sign-offs where needed
- **Risk Mitigation**: Issue resolution before advancement

### Story Evolution Tracking

**Change Management:**

- **Scope Evolution**: Track how requirements change during grooming
- **Priority Changes**: Monitor and analyze priority adjustments
- **Estimation Updates**: Size changes based on better understanding
- **Dependency Discoveries**: New relationships identified during refinement

**Learning Integration:**

- **Pattern Recognition**: Common story evolution patterns
- **Predictive Modeling**: Anticipate likely changes based on story characteristics
- **Risk Mitigation**: Early identification of stories likely to change significantly
- **Process Improvement**: Reduce unnecessary story churn through better initial analysis

## Integration with BMAD-JIRA Ecosystem

### Reconciliation Integration

**Learning from Execution:**

- **Estimation Calibration**: Use actual development time to improve future estimates
- **Readiness Validation**: Correlate readiness scores with development success
- **Quality Prediction**: Identify story characteristics that lead to quality issues
- **Risk Pattern Recognition**: Historical risk materialization to improve assessment

**Feedback Loops:**

- **Developer Feedback**: Post-development story quality assessment
- **Customer Feedback**: User acceptance and value realization measurement
- **Technical Debt Creation**: Stories that introduce maintenance burden
- **Process Effectiveness**: Grooming decisions that prove beneficial or problematic

### Sprint Planning Integration

**Sprint Planning Preparation:**

- **Ready Story Pipeline**: Ensure sufficient groomed stories for sprint planning
- **Capacity Matching**: Stories sized appropriately for team velocity
- **Goal Alignment**: Stories that work together toward sprint objectives
- **Risk Mitigation**: Balanced portfolio of high and low risk stories

**Cross-Sprint Coordination:**

- **Epic Progression**: Ensure epic stories are groomed in logical sequence
- **Dependency Planning**: Multi-sprint dependency resolution
- **Release Planning**: Groomed stories align with release goals and timelines
- **Team Coordination**: Cross-team dependencies identified and planned

### Continuous Improvement

**Process Metrics:**

- **Grooming Efficiency**: Time from concept to ready
- **Quality Improvement**: Readiness score trends over time
- **Estimation Accuracy**: Grooming decisions impact on development estimates
- **Value Delivery**: Business outcomes from groomed stories

**Optimization Recommendations:**

- **Process Improvements**: Better practices based on data analysis
- **Tool Enhancements**: JIRA configuration optimizations
- **Team Training**: Skill development needs identification
- **Stakeholder Engagement**: Improved collaboration patterns

## Advanced Grooming Techniques

### Story Decomposition Intelligence

**Intelligent Story Splitting:**

- **Natural Boundaries**: Identify logical story split points
- **Value Preservation**: Ensure each split delivers user value
- **Dependency Minimization**: Reduce coupling between split stories
- **Testing Considerations**: Maintain testability after splitting

**Splitting Strategies:**

- **User Journey Splits**: Break along user workflow boundaries
- **Technical Layer Splits**: Separate UI, business logic, and data layers
- **Risk-Based Splits**: Isolate high-risk elements for early validation
- **Capability Splits**: Separate basic functionality from advanced features

### Story Enhancement

**Automated Story Improvement:**

- **Template Application**: Apply story templates for consistency
- **Best Practice Integration**: Incorporate team and industry standards
- **Historical Learning**: Apply lessons from similar stories
- **Quality Checklist Application**: Systematic quality improvement

**Story Enrichment:**

- **Context Addition**: Link to related documentation and decisions
- **Example Generation**: Create concrete examples for abstract requirements
- **Test Case Suggestions**: Propose test scenarios based on acceptance criteria
- **Risk Assessment**: Identify and document potential implementation risks

## Natural Language Processing

### Grooming Request Recognition

Understand diverse grooming needs through natural language:

**Session Preparation:**

- "prepare backlog grooming for next week" → Generate grooming agenda with ready stories
- "analyze backlog health" → Comprehensive backlog analysis and health metrics
- "identify stories needing refinement" → Find stories below readiness threshold
- "recommend grooming priorities" → Suggest optimal story ordering for grooming

**Story Assessment:**

- "check story readiness for sprint 5" → Evaluate stories for development readiness
- "analyze story quality trends" → Show readiness score evolution over time
- "find dependencies blocking development" → Identify dependency bottlenecks
- "suggest story improvements" → Recommend specific enhancement actions

**Prioritization Support:**

- "recommend backlog prioritization" → Multi-factor priority analysis
- "show value vs effort analysis" → Value-effort matrix with recommendations
- "identify quick wins" → High-value, low-effort story identification
- "analyze sprint capacity alignment" → Stories sized for team velocity

### Context-Aware Responses

**Intelligent Workflow Selection:**

- **Grooming Stage Detection**: Identify where stories are in refinement pipeline
- **Team Context**: Understand team capacity, skills, and velocity patterns
- **Sprint Timing**: Adjust recommendations based on sprint planning proximity
- **Strategic Context**: Align grooming recommendations with business priorities

**Adaptive Communication:**

- **Stakeholder Audience**: Tailor language and detail level appropriately
- **Urgency Recognition**: Prioritize critical grooming needs
- **Confidence Indicators**: Express uncertainty when recommendations need validation
- **Action Orientation**: Provide specific, actionable improvement suggestions

## Configuration and Customization

### Team-Specific Grooming

**Grooming Process Customization:**

```yaml
grooming_config:
  readiness_criteria:
    acceptance_criteria_minimum: 3
    technical_approach_required: true
    dependency_analysis_depth: "detailed"
    estimation_confidence_threshold: 0.8

  session_optimization:
    max_stories_per_session: 8
    discussion_time_per_point: "15_minutes"
    decision_documentation_level: "comprehensive"
    follow_up_automation: true

  quality_gates:
    definition_of_ready_enforcement: "strict"
    story_size_limits: [1, 2, 3, 5, 8, 13]
    complexity_assessment_required: true
    risk_evaluation_mandatory: true
```

### Integration Settings

**BMAD-JIRA Synchronization:**

```yaml
sync_settings:
  grooming_status_sync: true
  readiness_score_field: "customfield_12345"
  grooming_comments_sync: true
  refinement_history_tracking: true

  automation_triggers:
    auto_ready_flag: true
    grooming_reminder_threshold: 7 # days
    quality_gate_enforcement: true
    estimation_confidence_alerts: true
```

## Natural Language Examples

### Grooming Session Management

- "prepare grooming session for sprint 15 planning"
- "generate backlog grooming agenda"
- "analyze stories ready for refinement"
- "schedule grooming session with stakeholders"
- "review last grooming session outcomes"

### Story Readiness Assessment

- "check story readiness for upcoming sprint"
- "analyze story quality trends"
- "identify stories needing technical clarity"
- "show acceptance criteria completeness"
- "evaluate estimation confidence levels"

### Backlog Health Analysis

- "show backlog health dashboard"
- "analyze story distribution patterns"
- "identify grooming bottlenecks"
- "recommend backlog optimization"
- "track grooming process metrics"

### Prioritization Intelligence

- "recommend story prioritization"
- "show value vs effort analysis"
- "identify dependencies blocking progress"
- "optimize sprint planning readiness"
- "analyze capacity vs backlog alignment"

## Universal Sync Integration for Grooming

### Enhanced Grooming Intelligence with Three-Way Sync

All grooming activities should include comprehensive sync health analysis:

**Automatic Sync Health Integration:**

- Include three-way sync dashboard in grooming sessions
- Show story readiness based on actual development patterns from git history
- Correlate story estimation with historical development velocity
- Identify alignment gaps between planned work and development reality

**Evidence-Based Story Assessment:**

- Validate story estimates using git commit analysis from similar work
- Check story completion feasibility against actual development patterns
- Correlate acceptance criteria with testing patterns from git history
- Generate confidence scores for story readiness based on team velocity data

**Development-Informed Grooming:**

- Prioritize grooming for stories with active development correlation
- Identify stories with unexpected complexity based on similar git patterns
- Recommend story splitting based on component change patterns
- Ground estimation in actual development evidence from git velocity

**Context-Aware Sync Analysis:**

- Grooming sessions: Focus on development readiness and capacity alignment
- Story assessment: Emphasize correlation with actual development patterns
- Backlog health: Show alignment between planned work and team capabilities
- Prioritization: Balance business value with development reality evidence

This intelligence system transforms backlog grooming from a manual, reactive process into an intelligent, proactive practice that continuously improves story quality, team effectiveness, and delivery predictability through systematic analysis and automation while maintaining continuous three-way synchronization awareness.
