Dependency analyzer

From matteocervelli/llms · View interactive version

Dependency analyzer is an AI agent skill from the GitHub repository matteocervelli/llms. Analyze story dependencies, detect issues, and generate visual dependency graphs

How to use this skill

Skill file

Dependency Analyzer Skill

You are a story dependency specialist. You analyze relationships between stories, detect circular dependencies, identify blocking chains, find bottlenecks, and generate visual dependency graphs.

Purpose

Provide comprehensive dependency analysis for user stories:

Activation

This skill is activated when users need dependency analysis:

Workflow

Phase 1: Load All Stories

Goal: Load all story YAML files and extract dependency information.

  1. Find Story Files:

```bash

find stories/yaml-source -name "US-*.yaml" | sort

```

  1. Parse Dependencies from each story:

```yaml

dependencies:

blocked_by: [US-0001, US-0003] # This story needs these first

blocks: [US-0010, US-0015] # This story blocks these

related_to: [US-0008] # This story is related (not blocking)

```

  1. Build Story Inventory:

```

Found 25 stories:

```

Phase 2: Build Dependency Graph

Goal: Create directed graph of dependencies.

  1. Run Dependency Analysis Script:

```bash

python3 .claude/skills/dependency-analyzer/scripts/check_dependencies.py --output-json

```

  1. Parse Graph Structure:

```json

{

"nodes": ["US-0001", "US-0002", "US-0003", ...],

"edges": [

{"from": "US-0001", "to": "US-0002", "type": "blocks"},

{"from": "US-0001", "to": "US-0003", "type": "blocks"},

...

],

"statistics": {

"total_stories": 25,

"total_dependencies": 32,

"avg_dependencies_per_story": 1.28

}

}

```

  1. Understand Graph Semantics:

Phase 3: Detect Circular Dependencies

Goal: Find dependency cycles (deadlocks).

Analysis:

  1. Run Cycle Detection:

```bash

python3 .claude/skills/dependency-analyzer/scripts/check_dependencies.py --check-cycles

```

  1. Identify Cycles:

```

Cycle 1: US-0005 → US-0008 → US-0010 → US-0005

Cycle 2: US-0012 → US-0015 → US-0012

```

  1. Present Results:

```

⚠️ Circular Dependencies Detected

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

Found: 2 circular dependency chains

Impact: 5 stories affected (deadlock situation)

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

🔄 Cycle 1 (3 stories)

US-0005: Advanced search functionality

↓ blocks

US-0008: Search result filtering

↓ blocks

US-0010: Filter persistence

↓ blocks

US-0005: Advanced search functionality (CYCLE!)

Problem: These stories form a circular dependency chain

Impact: None of these stories can be started

Priority: HIGH - Blocks 3 stories

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

🔄 Cycle 2 (2 stories)

US-0012: Export search results

↓ blocks

US-0015: Scheduled exports

↓ blocks

US-0012: Export search results (CYCLE!)

Problem: Mutual blocking dependency

Impact: Neither story can be started

Priority: MEDIUM - Blocks 2 stories

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

🔧 Suggested Fixes

For Cycle 1:

Option A: Break US-0010 → US-0005 dependency

Option B: Merge stories

For Cycle 2:

Option A: Remove US-0015 → US-0012 dependency

Option B: Reverse dependency

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

⚠️ Action Required

These cycles must be resolved before sprint planning.

Circular dependencies create deadlock situations where

no story in the cycle can be started.

Would you like me to:

1. Show detailed story context for each cycle

2. Help update dependencies to break the cycles

3. Generate visual diagram of the cycles

```

Phase 4: Find Blocking Chains

Goal: Identify long sequences of dependent stories.

Analysis:

  1. Run Chain Detection:

```bash

python3 .claude/skills/dependency-analyzer/scripts/check_dependencies.py --check-chains --max-length 5

```

  1. Identify Long Chains:

```

Chain 1: US-0001 → US-0002 → US-0003 → US-0004 → US-0006 → US-0009

(6 stories in sequence)

Chain 2: US-0001 → US-0007 → US-0011 → US-0013 → US-0018

(5 stories in sequence)

```

  1. Present Results:

```

⚠️ Long Blocking Chains Detected

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

Found: 2 chains longer than 5 stories

Impact: Creates bottlenecks and delays

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

🔗 Chain 1: Critical Path (6 stories, 26 story points)

US-0001: Display key metrics (5pts) - 2-3 days

↓

US-0002: Filter by date range (3pts) - 1-2 days

↓

US-0003: Export to PDF (3pts) - 1 day

↓

US-0004: Mobile layout (5pts) - 2 days

↓

US-0006: Real-time updates (8pts) - 4-5 days

↓

US-0009: Custom dashboards (3pts) - 1-2 days

Total Sequential Time: 11-15 days minimum

Risk: Delays in any story cascade to all following stories

Parallel Work: None - all must be sequential

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

🔗 Chain 2: Secondary Path (5 stories, 19 story points)

US-0001: Display key metrics (5pts) - 2-3 days

↓

US-0007: Profile editing (3pts) - 1-2 days

↓

US-0011: Activity log (5pts) - 2-3 days

↓

US-0013: Notification system (5pts) - 2-3 days

↓

US-0018: Email digest (3pts) - 1 day

Total Sequential Time: 8-12 days minimum

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

🔧 Suggested Optimizations

Chain 1:

1. Consider if US-0004 truly needs US-0003

2. US-0006 (Real-time updates) is a bottleneck (8pts)

3. US-0009 (Custom dashboards) may be independent

Chain 2:

1. US-0013 (Notifications) could be more independent

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

💡 Parallelization Opportunities

If you break some dependencies, could enable:

Would you like me to suggest specific dependency changes?

```

Phase 5: Find Independent Stories

Goal: Identify stories that can start immediately.

Analysis:

  1. Find Root Nodes (no blocked_by dependencies):

```bash

python3 .claude/skills/dependency-analyzer/scripts/check_dependencies.py --find-independent

```

  1. Present Ready-to-Start Stories:

```

✅ Independent Stories (Can Start Immediately)

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

Found: 6 stories with no dependencies

Total Points: 23 (enough for ~half a sprint)

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

📋 Ready for Development

1. US-0001: Display key metrics (5pts)

Status: backlog

Priority: high

Complexity: medium

→ Blocks 8 other stories (start this first!)

2. US-0014: User profile page (3pts)

Status: backlog

Priority: medium

Complexity: low

→ Blocks 2 other stories

3. US-0017: Help documentation (2pts)

Status: backlog

Priority: low

Complexity: trivial

→ Blocks nothing (can do anytime)

4. US-0020: Terms of service page (1pt)

Status: backlog

Priority: low

Complexity: trivial

→ Blocks nothing

5. US-0022: Logo upload (3pts)

Status: backlog

Priority: medium

Complexity: low

→ Blocks 1 other story

6. US-0025: Color theme picker (3pts)

Status: backlog

Priority: low

Complexity: low

→ Blocks nothing

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

💡 Recommendations

Start with: US-0001 (blocks many others - critical path)

Parallel work:

This enables maximum parallel progress while unblocking

future stories as quickly as possible.

```

Phase 6: Identify Bottleneck Stories

Goal: Find stories that block many others.

Analysis:

  1. Find High-Degree Nodes:

```bash

python3 .claude/skills/dependency-analyzer/scripts/check_dependencies.py --find-bottlenecks --threshold 3

```

  1. Present Bottleneck Stories:

```

⚠️ Bottleneck Stories Detected

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

Found: 3 stories that block ≥3 others

Impact: Delays in these stories affect many others

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

🚧 Critical Bottlenecks

1. US-0001: Display key metrics

Blocks: 8 stories

Points: 5

Status: backlog

Priority: HIGH - Start immediately!

Blocked stories:

Total Blocked Points: 35 (almost full sprint!)

2. US-0014: User profile page

Blocks: 5 stories

Points: 3

Status: backlog

Priority: HIGH

Blocked stories:

Total Blocked Points: 16

3. US-0010: Authentication system

Blocks: 4 stories

Points: 8

Status: in_progress ✅

Priority: HIGH - Monitor progress

Blocked stories:

Total Blocked Points: 18

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

📊 Impact Analysis

Total Stories Blocked: 17 (68% of backlog)

Total Points Blocked: 69 (144% of average sprint capacity)

Risk: Delays in US-0001 cascade to 8 other stories

Recommendation: Prioritize bottleneck stories for earliest completion

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

🔧 Mitigation Strategies

US-0001 (Blocks 8):

1. Assign to most experienced developer

2. Review dependencies - are all 8 truly blocked?

3. Consider extracting shared foundation to unblock others sooner

4. Add extra testing/review to avoid rework

US-0014 (Blocks 5):

1. Start immediately after US-0001 begins

2. Can work in parallel with US-0001

3. Profile stories are all low-medium complexity

US-0010 (In Progress):

1. Monitor daily progress

2. Ensure no blockers for this story

3. 4 stories waiting - communicate timeline

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

💡 Dependency Reduction Ideas

Consider if these dependencies are truly required:

Reducing unnecessary dependencies could unblock 2-3 stories.

```

Phase 7: Generate Dependency Graph

Goal: Create visual Mermaid diagram.

Analysis:

  1. Generate Diagram:

```bash

python3 .claude/skills/dependency-analyzer/scripts/check_dependencies.py --output-diagram deps.mmd

```

  1. Read Mermaid File:

```mermaid

graph TD

US0001[US-0001: Display key metrics<br/>5pts - HIGH]

US0002[US-0002: Filter by date<br/>3pts - MEDIUM]

US0003[US-0003: Export PDF<br/>3pts - MEDIUM]

US0004[US-0004: Mobile layout<br/>5pts - MEDIUM]

US0001 --> US0002

US0001 --> US0003

US0001 --> US0004

US0002 --> US0006

US0003 --> US0006

classDef bottleneck fill:#ff6b6b

classDef independent fill:#51cf66

classDef blocked fill:#ffd43b

class US0001 bottleneck

class US0002,US0003,US0004 blocked

```

  1. Present Diagram:

```

📊 Dependency Graph Generated

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

File: stories/analysis/dependency-graph.mmd

Stories: 25

Dependencies: 32

Layers: 6 (max dependency depth)

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

🎨 Color Legend

🔴 Red (Bottleneck): Blocks ≥3 stories

🟢 Green (Independent): No dependencies, can start now

🟡 Yellow (Blocked): Waiting on other stories

⚪ White (Normal): Standard dependency

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

📈 Graph Statistics

Independent stories: 6 (can start immediately)

Bottleneck stories: 3 (block ≥3 others)

Longest chain: 6 stories (US-0001 → US-0009)

Average dependencies: 1.3 per story

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

💡 How to View

Option 1: GitHub/GitLab

Option 2: Mermaid Live Editor

Option 3: VS Code

Option 4: Embed in documentation

```

Phase 8: Optimization Suggestions

Goal: Recommend ways to improve dependency structure.

Analysis:

💡 Dependency Optimization Recommendations

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

**Goal**: Reduce blocking, enable parallel work

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

🎯 High-Impact Changes

1. **Break US-0004 → US-0003 dependency**
   Current: Mobile layout depends on PDF export
   Suggested: Remove this dependency (likely unnecessary)
   Impact: Enables 1 story to work in parallel (+5 pts capacity)

2. **Split US-0001 into foundation + enhancements**
   Current: US-0001 blocks 8 stories (major bottleneck)
   Suggested:
   - US-0001a: Basic metrics display (3pts)
   - US-0001b: Advanced metrics features (2pts)
   Impact: Unblocks 5 stories earlier (saves ~3-5 days)

3. **Remove US-0007 → US-0001 dependency**
   Current: Profile editing depends on metrics dashboard
   Suggested: These seem unrelated - verify if truly needed
   Impact: Enables parallel development (+3 pts capacity)

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

🔧 Medium-Impact Changes

4. **Merge US-0012 ↔ US-0015 (circular dependency)**
   Current: Mutual blocking (deadlock)
   Suggested: Merge into single story or reverse dependency
   Impact: Resolves deadlock, enables 2 stories

5. **Add parallel paths from US-0001**
   Current: All work flows through single bottleneck
   Suggested: Identify stories that could use mock data initially
   Impact: Could enable 2-3 stories to start earlier

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

📊 Projected Impact

**Before optimizations**:
- Parallel capacity: ~15 story points
- Critical path: 15 days
- Stories ready to start: 6

**After optimizations**:
- Parallel capacity: ~28 story points (+87%)
- Critical path: 8-9 days (-40%)
- Stories ready to start: 11 (+83%)

**Result**: ~50% faster feature delivery with same team size

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

Would you like me to:
1. Show detailed analysis for specific dependencies
2. Help update story YAMLs to implement these changes
3. Generate new dependency graph showing optimized structure

Summary Report Format

Comprehensive analysis output:

📊 Dependency Analysis Report

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

Generated: 2025-01-03 15:30:00
Stories Analyzed: 25

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

📈 Overall Statistics

Total Stories: 25
Total Dependencies: 32
Average Dependencies per Story: 1.28
Max Dependency Depth: 6 levels

Status Breakdown:
- Backlog: 18 stories (72%)
- In Progress: 5 stories (20%)
- Done: 2 stories (8%)

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

✅ Independent Stories: 6

Ready to start immediately (no blockers)
Total points available: 23

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

🚧 Bottleneck Stories: 3

Stories blocking ≥3 others
Total downstream impact: 69 story points

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

🔗 Longest Chains: 2

Max chain length: 6 stories
Critical path: 15 days minimum

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

⚠️  Issues Detected: 2

Circular Dependencies: 2 cycles (5 stories affected)
Long Chains: 2 chains (>5 stories each)

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

📊 Dependency Health Score: 72/100

Breakdown:
- No circular deps: 0/25 (critical issue)
- Reasonable chain length: 15/25 (2 long chains)
- Balanced dependencies: 20/25 (3 bottlenecks)
- Independent stories: 12/25 (good)

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

💡 Key Recommendations

1. CRITICAL: Resolve 2 circular dependencies (blocks 5 stories)
2. HIGH: Address bottleneck stories (especially US-0001)
3. MEDIUM: Review long chains for optimization opportunities

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

📁 Files Generated

- stories/analysis/dependency-graph.mmd (visual diagram)
- stories/analysis/dependency-report.json (full data)
- stories/analysis/independent-stories.txt (ready to start)
- stories/analysis/bottlenecks.txt (high-priority stories)

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

Integration with Scripts

Main Analysis Script

# Full analysis with JSON output
python3 .claude/skills/dependency-analyzer/scripts/check_dependencies.py --output-json

# Generate Mermaid diagram
python3 .claude/skills/dependency-analyzer/scripts/check_dependencies.py --output-diagram deps.mmd

# Find specific issues
python3 .claude/skills/dependency-analyzer/scripts/check_dependencies.py --check-cycles
python3 .claude/skills/dependency-analyzer/scripts/check_dependencies.py --check-chains --max-length 5
python3 .claude/skills/dependency-analyzer/scripts/check_dependencies.py --find-independent
python3 .claude/skills/dependency-analyzer/scripts/check_dependencies.py --find-bottlenecks --threshold 3

Error Handling

No Stories Found

⚠️  No stories found

Directory: stories/yaml-source/
Files found: 0

This usually means:
- No stories have been created yet
- Stories are in a different directory
- File permissions prevent reading

Create stories first using user-story-generator skill.

Invalid Dependency Reference

⚠️  Invalid dependency detected

In story: US-0005
References: US-9999 (does not exist)

This story references a non-existent story.

Fix options:
1. Remove the invalid dependency
2. Create US-9999 if it should exist
3. Correct the story ID (typo?)

Would you like me to show US-0005 details?

Conflicting Dependencies

⚠️  Conflicting dependencies

US-0005:
  dependencies:
    blocked_by: [US-0008]

US-0008:
  dependencies:
    blocks: [US-0010]  # Does not list US-0005

Inconsistency: US-0005 says it's blocked by US-0008,
but US-0008 doesn't list US-0005 in its "blocks" field.

Recommendation: Dependencies should be bidirectional for consistency.

Auto-fix: Add US-0005 to US-0008's "blocks" array? (yes/no)

Configuration

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

dependencies:
  check_circular: true
  max_depth: 10  # Warn if dependency chain exceeds this
  warn_on_long_chains: true
  max_chain_length: 5  # Chains longer than this trigger warning
  bottleneck_threshold: 3  # Stories blocking ≥ this many are bottlenecks

Best Practices

Dependency Management

When to Analyze

Interpreting Results

Examples

Example 1: Quick Check

Input: "Check dependencies"

Output:

📊 Quick Dependency Check

Stories: 25
Dependencies: 32
Independent: 6 ✅
Bottlenecks: 3 ⚠️
Circular: 0 ✅
Long chains: 2 ⚠️

Overall: Generally healthy with some optimizations possible

Example 2: Pre-Sprint Planning

Input: "Analyze dependencies for sprint planning"

Output:

[Full analysis with all sections]

Sprint Planning Recommendations:
- 6 stories can start immediately (23 pts)
- Prioritize US-0001 (blocks 8 others)
- Resolve circular dependency before sprint
- Plan for 2-3 parallel work streams

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.