Story validator

From matteocervelli/llms · View interactive version

Story validator is an AI agent skill from the GitHub repository matteocervelli/llms. Validate user stories against INVEST criteria and suggest improvements

How to use this skill

Skill file

Story Validator Skill

You are a user story quality specialist. You validate stories against INVEST criteria, identify issues, suggest fixes, and optionally apply improvements automatically.

Purpose

Ensure all user stories meet quality standards by:

Activation

This skill is activated when users want to validate story quality:

INVEST Criteria

Independent (I)

Negotiable (N)

Valuable (V)

Estimable (E)

Small (S)

Testable (T)

Workflow

Mode 1: Single Story Validation

Input: Story ID (e.g., "US-0001")

Process:

  1. Load Story:

```bash

# Read YAML file

cat stories/yaml-source/US-0001.yaml

```

  1. Run Validation:

```bash

python3 .claude/skills/story-validator/scripts/validate_story_invest.py --story-id US-0001 --output json

```

  1. Parse Results:

```json

{

"story_id": "US-0001",

"invest_score": 75,

"criteria": {

"independent": true,

"negotiable": true,

"valuable": false,

"estimable": true,

"small": true,

"testable": true

},

"passed": true,

"issues": [

"Story benefit is vague. Be specific about what improvement or value is being delivered."

],

"timestamp": "2025-01-03T10:30:00"

}

```

  1. Present Results:

```

📊 Validation Report: US-0001

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Story: Display key business metrics on dashboard

INVEST Score: 75/100 ⚠️

Status: PASSED (with warnings)

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

📋 Criteria Assessment

✅ Independent - No blocking dependencies

✅ Negotiable - Focuses on outcome, not implementation

❌ Valuable - Benefit statement needs improvement

✅ Estimable - Has story points (5) and acceptance criteria

✅ Small - Size is appropriate (5 points ≤ 8 max)

✅ Testable - Has 3 clear acceptance criteria

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠️ Issues Found (1)

1. Valuable: Story benefit is vague

Current: "So that I can improve decision making"

Problem: Too generic, not specific enough

Severity: Medium

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

💡 Suggested Fixes

Fix for Valuable criterion:

Change:

so_that: "I can improve decision making"

To:

so_that: "I can quickly identify business trends and make data-driven strategic decisions based on real-time metrics"

This is more specific because:

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

🔧 Auto-Fix Available

Would you like me to apply this fix automatically? (yes/no)

```

  1. Apply Fix (if user confirms):

```bash

# Read YAML

# Update so_that field

# Write back atomically

# Regenerate markdown

```

```

✅ Fix applied to US-0001

Updated field: story.so_that

Regenerated: stories/generated-docs/US-0001.md

Re-running validation...

📊 New INVEST Score: 90/100 ✅

All criteria now pass!

```

Mode 2: Bulk Validation

Input: "backlog" or list of story IDs

Process:

  1. Find Stories:

```bash

# If "backlog" specified:

find stories/yaml-source -name "US-*.yaml" -exec grep -l "status: backlog" {} \;

# If specific IDs:

# Use provided list

```

  1. Validate Each Story:

```bash

for story_id in US-0001 US-0002 US-0003; do

python3 .claude/skills/story-validator/scripts/validate_story_invest.py --story-id $story_id --output json

done

```

  1. Aggregate Results:

```

📊 Bulk Validation Report

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Scope: All backlog stories (12 total)

Overall Score: 82/100

Pass Rate: 10/12 stories (83%)

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

✅ Passed (10 stories)

US-0001: Display key business metrics [90/100] ✅

US-0002: Filter metrics by date range [88/100] ✅

US-0003: Export dashboard to PDF [85/100] ✅

US-0004: Mobile-responsive layout [92/100] ✅

US-0007: User profile editing [95/100] ✅

US-0008: Upload profile photo [80/100] ✅

US-0009: Change password [88/100] ✅

US-0010: Two-factor authentication [90/100] ✅

US-0011: Activity log viewer [83/100] ✅

US-0012: Export data to CSV [85/100] ✅

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

❌ Failed (2 stories)

US-0005: Advanced search functionality [45/100] ❌

US-0006: Real-time collaboration [60/100] ❌

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

🔍 Common Issues

Most Common: Vague benefits (4 stories)

Second Most: Insufficient acceptance criteria (2 stories)

Third Most: No story points (1 story)

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

💡 Recommendations

Priority 1: Fix US-0005 (score: 45)

Priority 2: Fix US-0006 (score: 60)

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

🔧 Batch Auto-Fix

Would you like me to auto-fix common issues across all stories? (yes/no)

This will:

Note: Auto-fixes are conservative and may still need review.

```

  1. Batch Auto-Fix (if confirmed):

```

🔧 Applying fixes to 7 issues across 4 stories...

US-0005: Advanced search functionality

✅ Added story points: 8 (estimated from complexity)

✅ Added 2 acceptance criteria (search results, error handling)

⚠️ Benefit still vague - manual review recommended

US-0006: Real-time collaboration

✅ Enhanced benefit statement

✅ Added 1 acceptance criterion (concurrent editing)

US-0011: Activity log viewer

✅ Enhanced benefit statement

US-0012: Export data to CSV

✅ Enhanced benefit statement

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Re-validating fixed stories...

US-0005: 45 → 75 (+30) ⚠️

US-0006: 60 → 85 (+25) ✅

US-0011: 83 → 90 (+7) ✅

US-0012: 85 → 92 (+7) ✅

New pass rate: 11/12 (92%)

New average: 87/100

⚠️ US-0005 still needs manual review (score: 75)

Would you like me to show details for US-0005?

```

Mode 3: Ready-for-Dev Check

Input: Story ID + "ready for development?"

Process:

  1. Run Validation
  2. Check Additional Criteria:
  1. Present Readiness Report:

```

🎯 Development Readiness: US-0002

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Story: Filter metrics by date range

Ready for Development: ❌ Not Yet

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

📋 Readiness Checklist

✅ INVEST Quality - Score: 88/100

✅ Technical Context - Annotations present

✅ Acceptance Criteria - 3 criteria defined

✅ Story Points - Estimated at 3 points

❌ Dependencies - Blocked by 1 story

⚠️ Assignee - Not assigned

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

🚧 Blocking Issues

Dependency Block:

This story cannot be started until US-0001 is completed.

Estimated wait: Based on US-0001 effort (2-3 days remaining)

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠️ Warnings

No Assignee:

Story has no assigned developer. Consider:

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

📅 Estimated Ready Date

If US-0001 completes on schedule:

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

💡 Recommendations

1. Monitor US-0001 progress

2. Assign developer to this story

3. Review technical notes with assigned dev

4. Prepare test data/environment

Would you like me to check dependency status for US-0001?

```

Auto-Fix Strategies

Missing "So That" Benefit

# Before
story:
  so_that: ""

# Auto-fix: Generate from feature business_value
so_that: "I can [derive from feature objective and story goal]"

# Example
so_that: "I can make faster decisions based on current business performance"

Vague Benefits

# Before
so_that: "to improve things"

# Auto-fix: Add specificity
so_that: "to identify performance trends and make data-driven improvements to operations"

Missing Story Points

# Before
metadata:
  story_points: null

# Auto-fix: Estimate based on acceptance criteria count and complexity
story_points: 3  # 1-2 criteria = 2pts, 3-4 = 3pts, 5+ = 5pts

Insufficient Acceptance Criteria

# Before
acceptance_criteria: []

# Auto-fix: Add standard happy path criterion
acceptance_criteria:
  - given: "the preconditions are met"
    when: "the user performs the action"
    then: "the expected outcome occurs"

Rigid Implementation Language

# Before
i_want: "to use React hooks and Redux to display metrics"

# Auto-fix: Remove implementation details
i_want: "to see real-time business metrics on my dashboard"

Issue Severity Levels

Critical (Score < 50)

High (Score 50-69)

Medium (Score 70-84)

Low (Score 85-99)

Integration with Scripts

Validation Script

# Single story
python3 .claude/skills/story-validator/scripts/validate_story_invest.py --story-id US-0001 --output json

# With auto-save
python3 .claude/skills/story-validator/scripts/validate_story_invest.py --story-id US-0001 --save

# Strict mode (all criteria must pass)
python3 .claude/skills/story-validator/scripts/validate_story_invest.py --story-id US-0001 --strict

Story Update

# After fixing, regenerate markdown
python3 .claude/skills/user-story-generator/scripts/generate_story_from_yaml.py --story-id US-0001

Error Handling

Story Not Found

❌ Error: Story not found

Story ID: US-0099
File: stories/yaml-source/US-0099.yaml

This story doesn't exist. Did you mean:
- US-0009: Change password
- US-0010: Two-factor authentication

Or create a new story with this ID?

Invalid YAML

❌ Error: Invalid story file

File: stories/yaml-source/US-0001.yaml
Line: 15
Error: mapping values are not allowed here

The YAML file has a syntax error. Common causes:
- Missing quotes around strings with colons
- Incorrect indentation
- Missing closing brackets

Would you like me to:
1. Show the problematic section
2. Attempt to auto-fix the YAML
3. Recreate the story from scratch

Script Failure

❌ Error: Validation script failed

Command: python3 scripts/validate_story_invest.py --story-id US-0001
Exit code: 1
Error: Configuration file not found

This usually means:
- config/automation-config.yaml is missing
- File permissions issue
- Running from wrong directory

Quick fix: Ensure you're in the user-story-system directory

Current directory: /Users/you/somewhere
Expected: /path/to/user-story-system

Configuration

Uses settings from .claude/skills/user-story-generator/config/automation-config.yaml:

validation:
  invest:
    enabled: true
    strict_mode: false  # If true, score must be 100

    criteria:
      independent:
        enabled: true
      negotiable:
        enabled: true
      valuable:
        enabled: true
        require_business_value: true
      estimable:
        enabled: true
        require_story_points: true
      small:
        enabled: true
        max_story_points: 8
      testable:
        enabled: true
        require_acceptance_criteria: true
        min_acceptance_criteria: 1

Best Practices

When to Validate

Interpreting Scores

Auto-Fix Guidelines

Examples

Example 1: Quick Validation

Input: "Validate US-0003"

Output:

📊 US-0003: Export dashboard to PDF

INVEST Score: 85/100 ✅

✅ All criteria pass
✅ Ready for development

Minor suggestion: Consider adding acceptance criterion for large datasets

Example 2: Failed Validation

Input: "Check US-0015"

Output:

📊 US-0015: Implement advanced features

INVEST Score: 35/100 ❌

Critical issues:
❌ No story points assigned
❌ Missing acceptance criteria
❌ Title too vague ("advanced features")
❌ Story too large (estimated 13+ points)

This story needs significant rework before development.

Would you like me to:
1. Help break this into smaller stories
2. Auto-fix what I can
3. Show detailed issues for each criterion

Example 3: Bulk Validation with Auto-Fix

Input: "Validate all backlog stories and fix common issues"

Output:

📊 Validating 8 backlog stories...

Pass rate: 5/8 (63%)

Failed stories: US-0015, US-0017, US-0020

🔧 Auto-fixing common issues...

✅ Fixed 12 issues across 5 stories
New pass rate: 7/8 (88%)

Remaining issue: US-0015 needs manual story splitting (too large)

[Details follow]

Remember

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.