Skip to content
story-tree logo

Story Tree

story-tree

Use when user says "update story tree", "show story tree", "show me a map", "story map", "tree diagram", "show stories", "view stories", "list stories", or asks for story visualization or tree status - autonomously maintains hierarchical story backlog by analyzing git commits, identifying under-c...

mattnigh/skills_collection0installs24stars

SKILL.md

Full skill instructions

Story Tree - Autonomous Hierarchical Backlog Manager

Self-managing tree of user stories with capacity-based story generation.

Database: .claude/​data/​story-tree.db Schema: references/​schema.sql

Design rationale: If instructions seem counter-intuitive, consult references/​rationales.md.

Story ID Format

Critical: IDs follow a strict hierarchical format:

LevelParentID FormatExamples
RootNonerootroot
Level 1 (Primary Epics)rootPlain integer1, 2, 15, 16
Level 2+Any non-root[parent].[N]1.1, 8.4, 15.2.1

Common mistake: Creating root children with decimal IDs like 8.6 or root.1. Primary epics MUST have plain integer IDs.

Environment Requirements

Critical: The sqlite3 CLI is NOT available. Always use Python's sqlite3 module:

python -c "
import sqlite3
conn = sqlite3.connect('.claude/​data/​story-tree.db')
cursor = conn.cursor()
cursor.execute('YOUR SQL HERE')
print(cursor.fetchall())
conn.close()
"

Script path: .claude/​skills/​story-tree/​scripts/​tree-view.py (NOT project root scripts/)

Autonomous Operation

On "update story tree": Run Steps 1-7 without permission, invoke story-writing for priority target, output report. Ask clarification ONLY for: over-capacity, multiple equal priorities, or ambiguous git history.

On "generate stories": Delegate to story-writing skill.

Auto-update: On ANY invocation, if lastUpdated metadata >3 days old, run full update first.

Workflow

Step 1: Initialize Database

If .claude/​data/​story-tree.db doesn't exist, create directory and execute references/​schema.sql via Python sqlite3, then insert root node and metadata.

Step 2: Analyze Git Commits

Use incremental analysis from lastAnalyzedCommit checkpoint:

python -c "
import sqlite3, subprocess
conn = sqlite3.connect('.claude/​data/​story-tree.db')
row = conn.execute(\"SELECT value FROM metadata WHERE key = 'lastAnalyzedCommit'\").fetchone()
last_commit = row[0] if row else None
conn.close()

if last_commit:
    result = subprocess.run(['git', 'cat-file', '-t', last_commit], capture_output=True)
    if result.returncode != 0: last_commit = None

cmd = ['git', 'log', f'{last_commit}..HEAD' if last_commit else '--since=30 days ago',
       '--pretty=format:%h|%ai|%s', '--no-merges']
print(subprocess.run(cmd, capture_output=True, text=True).stdout)
"

Step 3: Identify Priority Target

Excluded from generation: Stories where:

  • stage = 'concept' (not yet approved)
  • hold_reason IS NOT NULL (queued/​pending/​blocked/​etc)
  • terminus IS NOT NULL (rejected/​archived/​etc)

Priority algorithm (shallower under-capacity nodes first):

SELECT s.*,
    (SELECT COUNT(*) FROM story_paths WHERE ancestor_id = s.id AND depth = 1) as child_count,
    (SELECT MIN(depth) FROM story_paths WHERE descendant_id = s.id) as node_depth,
    COALESCE(s.capacity, 3 + (SELECT COUNT(*) FROM story_paths sp
         JOIN story_nodes child ON sp.descendant_id = child.id
         WHERE sp.ancestor_id = s.id AND sp.depth = 1
         AND child.stage IN ('implemented', 'ready', 'released')
         AND child.terminus IS NULL)) as effective_capacity
FROM story_nodes s
WHERE s.stage != 'concept'
  AND s.hold_reason IS NULL
  AND s.terminus IS NULL
  AND (SELECT COUNT(*) FROM story_paths WHERE ancestor_id = s.id AND depth = 1) <
      COALESCE(s.capacity, 3 + (...))
ORDER BY node_depth ASC
LIMIT 1;

Dynamic capacity: effective_capacity = capacity_override OR (3 + implemented/​ready children)

Step 4: Generate Stories

Invoke story-writing skill for priority target node. New stories get stage: 'concept' (unless user explicitly requested approved).

Step 5: Update Metadata

INSERT OR REPLACE INTO metadata (key, value) VALUES ('lastUpdated', datetime('now'));
INSERT OR REPLACE INTO metadata (key, value) VALUES ('lastAnalyzedCommit', :newest_commit);

Step 6: Output Report

Include: tree status metrics, analyzed commits, priority target, generated stories, tree visualization.

Tree Visualization

python .claude/​skills/​story-tree/​scripts/​tree-view.py --show-capacity

Use --force-ascii only if Unicode fails.

Three-Field Workflow System (v4.0)

Stories use three orthogonal dimensions instead of a single status:

Stage (10 values) - Linear workflow position

StageDescription
conceptInitial idea, not yet approved
approvedReady to plan
plannedImplementation plan exists, dependencies verified
activeCurrently being worked on
reviewingUnder review/​testing
verifyingAwaiting post-implementation verification
implementedCode complete, verified, not released
readyTested, ready for release
polishMinor refinements
releasedDeployed to production

Hold Reason (8 values + NULL) - Why work is stopped

HoldDescription
NULLNot held, work can proceed
⏳ queuedWaiting for automated processing (algorithm hasn't run yet)
❓ pendingAwaiting human decision (algorithm ran but can't decide)
⊗ blockedExternal dependency
⏸ pausedExecution blocked by critical issue
⚠ brokenSomething wrong with story definition
◇ polishNeeds refinement before proceeding
⚡ conflictInconsistent with another story, needs human resolution
? wishlistIndefinite hold, maybe someday (can be revived when priorities change)

Disposition (6 values + NULL) - Terminal state

DispositionDescriptionStage Required
NULLActive in pipelineAny
rejectedHuman decided not to implement (indicates non-goal)Any (preserved)
infeasibleCannot implementAny (preserved)
duplicativeAlgorithm detected duplicate/​overlap with existing (not a goal signal)Any (preserved)
legacyOld but functionalreleased
deprecatedBeing phased outreleased
archivedNo longer relevantAny (preserved)

Human Review Flag

  • human_review = 1 when story needs human attention
  • Typically TRUE when hold_reason IS NOT NULL

Key Rules

  • Cannot have both hold_reason AND terminus (mutually exclusive)
  • Stage is preserved when held or disposed (know where to resume)
  • Query by dimension for clearer intent

Shared Database Utilities

Python scripts that interact with the story-tree database should import from the shared utility module:

import sys, os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'story-tree', 'utility'))
from story_db_common import (
    DB_PATH,                    # '.claude/​data/​story-tree.db'
    MERGEABLE_STATUSES,         # {'concept', 'wishlisted', 'polish'} - concept=stage, others=hold_reason
    BLOCK_STATUSES,             # {'rejected', 'infeasible', 'duplicative', 'broken', ...}
    get_connection,             # Get SQLite connection
    make_pair_key,              # Canonical pair key for caching
    get_story_version,          # Get story version number
    compute_effective_status,   # COALESCE(terminus, hold_reason, stage)
    delete_story,               # Cascade delete from story_nodes + story_paths
    reject_concept,             # Human rejection (terminus='rejected', goal signal)
    duplicative_concept,        # Algorithm duplicate (terminus='duplicative', no signal)
    conflict_concept,           # Inconsistent stories (hold_reason='conflicted', needs resolution)
    block_concept,              # Set hold_reason='blocked' with note
    defer_concept,              # Set hold_reason='escalated' with note
    merge_concepts,             # Merge two stories into one
    # Tree reorganization functions
    validate_tree_structure,    # Find structural issues in tree
    rename_story,               # Rename story and all descendants
    rebuild_paths,              # Recompute paths for a node
    rebuild_paths_recursive,    # Recompute paths for node and descendants
    move_story,                 # Move story to new parent
    get_next_child_id,          # Get next available child ID
    get_expected_parent_id,     # Determine expected parent from ID format
)

Location: .claude/​skills/​story-tree/​utility/​story_db_common.py

This ensures DRY principles - all story-related skills use the same database operations.

Tree Maintenance

For tree structure validation, reorganization, and repairs, use the story-arborist skill: .claude/​skills/​story-arborist/​SKILL.md

Quick commands:

python .claude/​skills/​story-arborist/​scripts/​tree_health.py   # Full health report
python .claude/​skills/​story-arborist/​scripts/​validate_tree.py # Structural validation
python .claude/​skills/​story-arborist/​scripts/​fix_orphans.py   # Fix orphaned nodes

References

  • references/​schema.sql - Database schema
  • references/​sql-queries.md - Query patterns
  • references/​rationales.md - Design decisions
  • utility/​story_db_common.py - Shared database utilities
  • .claude/​skills/​story-writing/​SKILL.md - Story generation

More skills from mattnigh

spring-framework-patterns logo
mattnigh/skills_collection

spring-framework-patterns

Comprehensive Spring Framework and Spring Boot best practices including dependency injection patterns, bean lifecycle and scopes, REST API development, Spring Data JPA, service layer design, Spring Security, testing strategies, caching, AOP, async processing, error handling, and common anti-patte...

24 0
View

TypeScript厳格モードによる型安全性設計を専門とするスキル。 📖 参照書籍: - 『Effective TypeScript』(Dan Vanderkam): 型設計 📚 リソース参照: - `resources/Level1_basics.md`: レベル1の基礎ガイド - `resources/Level2_intermediate.md`: レベル2の実務ガイド - `resources/Level3_advanced.md`: レベル3の応用ガイド - `resources/Level4_expert.md`: レベル4の専門ガイド - `resources/di...

24 0
View
deploying-cloud-k8s logo
mattnigh/skills_collection

deploying-cloud-k8s

Deploys applications to cloud Kubernetes (AKS/GKE/DOKS) with CI/CD pipelines. Use when deploying to production, setting up GitHub Actions, troubleshooting deployments. Covers build-time vs runtime vars, architecture matching, and battle-tested debugging.

24 0
View
moai-alfred-agent-guide logo
mattnigh/skills_collection

moai-alfred-agent-guide

19-agent team structure, decision trees for agent selection, Haiku vs Sonnet model selection, and agent collaboration principles. Use when deciding which sub-agent to invoke, understanding team responsibilities, or learning multi-agent orchestration.

24 0
View
mermaid-diagram-generator logo
mattnigh/skills_collection

mermaid-diagram-generator

Converts architecture descriptions, module specs, or workflow docs into Mermaid diagrams. Use when visualizing brick module relationships, workflows (DDD, investigation), or system architecture. Supports: flowcharts, sequence diagrams, class diagrams, state machines, entity relationship diagrams,...

24 0
View
pre-flight-check logo
mattnigh/skills_collection

pre-flight-check

INVOKE FIRST before any code work. Validates git workflow (branch, issue, worklog) and checks approach. Use at START of every task and END before completing. Prevents skipped steps.

24 0
View
browser-dev-tools logo
mattnigh/skills_collection

browser-dev-tools

This skill should be used when working with browser-rendered artifacts (i.e. Bun, React/React Native) to proactively validate that development work on localhost is being built appropriately and to support debugging browser-rendered content. Use this skill after making frontend changes to verify t...

24 0
View
lead-dev logo
mattnigh/skills_collection

lead-dev

Lead Développeur - Coordination technique opérationnelle, code review, mentoring et livraison. Pair de web-dev-process au niveau OPÉRATIONS.

24 0
View
worker-monitor logo
mattnigh/skills_collection

worker-monitor

Monitor Docker workers, RQ queue health, and auto-scale workers (max 4). Use when: checking job progress, monitoring queue depth, scaling workers up/down, diagnosing slow processing, or waiting for jobs to complete. Referenced by data-quality skill during reprocessing.

24 0
View
quality-advisor logo
mattnigh/skills_collection

quality-advisor

Proactive quality guidance system that monitors artifact creation and provides real-time feedback on documentation quality

24 0
View
bump-version logo
mattnigh/skills_collection

bump-version

This skill should be used when the user wants to bump the version number in the workspace. It updates versions across all pyproject.toml files (root, tde, and tda packages) and the CHANGELOG.md to keep them synchronized.

24 0
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View