Claude
Skills
Sign in
Back

regression-learning

Included with Lifetime
$97 forever

Improve regression detection over time through cross-task pattern recognition, test prioritization, and historical analysis

Productivity

What this skill does


# regression-learning

Cross-task learning skill for improving regression detection over time through pattern recognition, test prioritization, and historical analysis.

## Triggers


Alternate expressions and non-obvious activations (primary phrases are matched automatically from the skill description):

- "learn from regressions" → adaptive pattern recognition
- "improve detection accuracy" → regression ML tuning

## Purpose

This skill integrates with Al's cross-task learning system to continuously improve regression detection by:
- Learning from past regression patterns (REG-XXXX records)
- Identifying high-risk code patterns and hot spots
- Prioritizing tests by regression likelihood
- Building a taxonomy of root causes
- Suggesting fixes based on past resolutions
- Adapting test strategies based on effectiveness

Based on REF-013 MetaGPT's executable feedback pattern, this skill creates a persistent memory that accumulates knowledge across iterations and projects.

## Behavior

When triggered, this skill:

1. **Pattern Recognition**:
   - Analyze historical regression records
   - Identify recurring error patterns
   - Map code patterns to failure types
   - Detect hot spots in codebase
   - Build regression taxonomy

2. **Test Prioritization**:
   - Rank tests by regression detection likelihood
   - Prioritize based on:
     - Historical failure correlation
     - Code change patterns
     - Component risk scores
     - Recent regression trends
   - Generate optimal test execution order

3. **Root Cause Memory**:
   - Store root cause analyses from REG-XXXX
   - Link similar regressions across time
   - Build fix template library
   - Track fix effectiveness
   - Enable cross-project learning

4. **Predictive Analysis**:
   - Predict regression probability for code changes
   - Flag high-risk modifications
   - Suggest additional test coverage
   - Recommend preventive actions

5. **Feedback Loop**:
   - Learn from false positives/negatives
   - Adjust confidence thresholds
   - Incorporate human corrections
   - Track prediction accuracy
   - Improve over time

## Learning Schema

### Learning Record

```yaml
# .aiwg/ralph/learning/regression-patterns.yaml

learning_records:
  - pattern_id: "RP-001"
    pattern_name: "null_access_without_check"
    category: null_undefined_access

    occurrences:
      - regression_id: "REG-0023"
        file: "src/auth/validate.ts"
        root_cause: "Missing null check before property access"
        fix: "Added early return for null/undefined"
        effectiveness: 1.0  # 100% success rate

      - regression_id: "REG-0047"
        file: "src/api/users.ts"
        root_cause: "Null user object accessed"
        fix: "Added null guard clause"
        effectiveness: 1.0

      - regression_id: "REG-0091"
        file: "src/payments/process.ts"
        root_cause: "Transaction object null"
        fix: "Added null check with error throw"
        effectiveness: 1.0

    statistics:
      total_occurrences: 3
      avg_fix_time_hours: 1.5
      recurrence_rate: 0.0  # 0% recurrence after fix
      detection_methods:
        automated_test: 3
        production: 0

    fix_template:
      pattern: |
        // Before: obj.property
        // After:
        if (!obj) {
          throw new Error('Object is null or undefined');
        }
        // Or: if (!obj) return defaultValue;

      applicability_rules:
        - language: typescript
        - pattern: "Cannot read property .* of null"
        - context: function_entry

    confidence: 0.95
    last_updated: "2026-01-28T15:30:00Z"
```

### Hot Spot Tracking

```yaml
# .aiwg/ralph/learning/code-hotspots.yaml

hotspots:
  - file: "src/auth/validate.ts"
    risk_score: 8.5  # 0-10 scale

    regression_history:
      - REG-0023: null_access_without_check
      - REG-0056: type_mismatch
      - REG-0112: missing_validation

    total_regressions: 3
    regressions_per_kloc: 2.1  # Per 1000 lines of code

    recent_changes:
      last_30_days: 8
      last_7_days: 2

    contributors: 3

    risk_factors:
      high_complexity: true
      frequent_changes: true
      multiple_regressions: true
      critical_path: true

    recommended_actions:
      - "Increase test coverage (current: 65%, target: 80%)"
      - "Add null checks at function entry"
      - "Refactor complex validation logic"
      - "Add integration tests"

    test_priority: critical  # Run tests for this file first
```

### Test Effectiveness Tracking

```yaml
# .aiwg/ralph/learning/test-effectiveness.yaml

test_effectiveness:
  - test_path: "test/auth/validate.test.ts"

    regression_detection_rate: 0.85  # 85% of regressions caught

    detected_regressions:
      - REG-0023
      - REG-0056
      - REG-0112

    missed_regressions:
      - REG-0089: "Escaped to production"

    false_positive_rate: 0.02  # 2% false alarms

    execution_stats:
      avg_duration_ms: 450
      success_rate: 0.98
      flakiness_score: 0.01  # Very stable

    priority_score: 9.2  # High value test

    recommendations:
      - "Add edge case: empty string input"
      - "Test concurrent validation requests"
```

## Regression Pattern Taxonomy

### Pattern Categories

| Category | Description | Detection | Fix Template | Effectiveness |
|----------|-------------|-----------|--------------|---------------|
| **null_undefined_access** | Accessing properties of null/undefined | `Cannot read property .* of null` | Add null check | 95% |
| **type_mismatch** | Type coercion or wrong type | `Expected .* but got .*` | Add type validation | 90% |
| **off_by_one** | Array bounds or loop conditions | `Index out of bounds` | Fix boundary conditions | 88% |
| **race_condition** | Timing-dependent failures | `Intermittent failures` | Add synchronization | 75% |
| **missing_validation** | Inputs not validated | `Validation error` | Add input checks | 92% |
| **logic_error** | Incorrect business logic | `Wrong behavior` | Fix logic | 85% |
| **resource_leak** | Resources not released | `Memory leak / handles` | Add cleanup | 80% |
| **api_misuse** | Incorrect API usage | `API error` | Fix API call | 90% |
| **configuration_error** | Wrong config values | `Config mismatch` | Update config | 95% |

## Test Prioritization Algorithm

```yaml
test_prioritization:
  algorithm: weighted_risk_score

  factors:
    code_change_correlation: 0.30      # How often this test catches changes
    historical_regression_detection: 0.25  # Past regression detection rate
    code_hotspot_coverage: 0.20        # Tests high-risk code
    recent_failure_trend: 0.15         # Recently failing pattern
    execution_efficiency: 0.10         # Fast tests preferred

  output:
    - test_priority: critical | high | medium | low
    - execution_order: [test1, test2, ...]
    - skip_recommendations: [low-value tests]
    - expand_coverage: [high-risk areas]
```

### Example Prioritization

```yaml
# After code change to src/auth/validate.ts

prioritized_tests:
  critical:  # Run first
    - test/auth/validate.test.ts
    - test/integration/auth-flow.test.ts
    reason: "High regression detection rate for this file"

  high:  # Run next
    - test/api/login.test.ts
    - test/api/register.test.ts
    reason: "Depends on auth module"

  medium:  # Run if time allows
    - test/unit/utils.test.ts
    reason: "Low correlation with auth changes"

  low:  # Skip in fast-feedback mode
    - test/ui/theme.test.ts
    reason: "No historical correlation"

  skip_in_fast_mode:
    - test/e2e/full-flow.test.ts
    reason: "Slow (5 min), low failure rate for auth changes"
```

## Predictive Regression Analysis

### Risk Prediction

```yaml
# On code change: src/payments/process.ts

regression_prediction:
  file: "src/payments/process.ts"
  change_type: modification
  lines_changed: 45

  risk_analysis:
    overall_risk: HIGH  # critical | high | medium | low
    confidence: 0.82

    risk_factors:
      - factor: "Known hotspot (REG-0034, REG-0067)"
        wei

Related in Productivity