Skip to main content

---

title: Session Retrospective Hook v2.0 component_type: hook version: 2.0.0 audience: contributor status: active summary: Self-improving skill system using v4.0 enhanced export data keywords:

  • retrospective
  • learning
  • skill-improvement
  • self-improving
  • v4.0 tokens: ~4000 created: 2026-01-04 updated: 2026-01-04

Session Retrospective v2.0 - Self-Improving Skill System

Redesigned to leverage v4.0 unified-message-extractor data:

  • Uses tool_result.status for accurate outcome classification
  • Extracts user intent from messages before skill invocations
  • Detects user corrections to learn from mistakes
  • Generates specific, actionable improvement patterns
  • Auto-updates SKILL.md files with learned patterns

Key Improvements over v1.0:

  • Queries database directly instead of regex on transcripts
  • Uses actual tool success/failure status
  • Captures intent -> action -> outcome -> correction chains
  • Produces specific recommendations with examples
  • Implements feedback loop to update skills

Usage: # Analyze recent sessions hooks/session-retrospective-v2.py --analyze

# Generate improvements for specific skill
hooks/session-retrospective-v2.py --improve-skill classify

# Auto-update skills based on learnings
hooks/session-retrospective-v2.py --auto-update

# Show skill health dashboard
hooks/session-retrospective-v2.py --dashboard

File: session-retrospective-v2.py

Classes

ToolOutcome

Individual tool execution outcome.

SkillInvocationChain

Complete chain: user_intent -> skill -> tools -> outcome -> user_reaction.

ImprovementPattern

Specific, actionable improvement pattern.

RetrospectiveV2

Self-improving skill system using v4.0 enhanced data.

Functions

overall_status()

Determine overall outcome based on tool results and user reaction.

success_score()

Calculate success score 0.0 to 1.0.

to_skill_section()

Generate markdown section for SKILL.md.

get_db_connection()

Get database connection with row factory.

extract_skill_invocations(limit)

Extract skill invocations from database with full context.

calculate_skill_scores(chains)

Calculate accurate skill scores based on actual outcomes.

extract_improvement_patterns(chains)

Extract specific, actionable improvement patterns.

generate_skill_updates(skill_name, scores, patterns)

Generate markdown section to add to skill file.

update_skill_file(skill_name, update_content)

Add learned patterns to skill file.

save_learnings(scores, patterns)

Save learnings to JSON file.

Print skill health dashboard.

Usage

python session-retrospective-v2.py