memory-insights

Analyze session friction trends, success rates, and satisfaction patterns across sessions using Claude Code facets data. Read-only query tool for on-demand trend analysis.

Memory Insights — Session Trend Analysis

Read-only analytics over Claude Code facets data for friction trends, success patterns, and satisfaction signals.

Data Source

Read all JSON files in ~/.claude/usage-data/facets/ (skip gracefully if directory doesn't exist). Each file is a per-session analysis with fields: session_id, underlying_goal, goal_categories, outcome, session_type, claude_helpfulness, primary_success, friction_counts, friction_detail, user_satisfaction_counts, brief_summary.

Graceful degradation: If ~/.claude/usage-data/facets/ doesn't exist, output: "No facets data available. Facets are generated by Claude Code and may not be present on all installations. Session insights require at least one completed Claude Code session."

Commands

Default (no arguments): Summary Dashboard

Show a summary dashboard:

  • Total sessions analyzed: [N]
  • Outcome breakdown: fully_achieved [N], mostly_achieved [N], etc.
  • Helpfulness: essential [N], very_helpful [N], etc.
  • Top 5 friction types with counts
  • Sessions with friction: [N]/[total] ([%])
  • Satisfaction: [satisfied+likely_satisfied] positive, [dissatisfied+frustrated] negative

/memory-insights friction — Friction Deep Dive

  • All friction types ranked by count
  • Top 5 highest-friction sessions with brief_summary and friction_detail
  • Correlation: which goal_categories have the most friction?
  • Trend: is friction increasing or decreasing over recent sessions?

/memory-insights sessions --worst — Highest-Friction Sessions

  • Sort all sessions by total friction count (descending)
  • Show top 10 with: session_id, brief_summary, friction_counts, outcome
  • Include friction_detail for each

/memory-insights sessions --best — Most Successful Sessions

  • Filter: outcome=fully_achieved AND friction_counts is empty
  • Show with: session_id, brief_summary, primary_success, session_type

/memory-insights patterns — Cross-Session Pattern Analysis

  • Correlate friction types with goal_categories (e.g., "wrong_approach clusters around debugging and configuration_change tasks")
  • Correlate session_type with outcome (e.g., "iterative_refinement has 80% fully_achieved vs multi_task at 50%")
  • Identify which primary_success factors appear in friction-free sessions

Privacy

Facets data contains session summaries and goals but no file contents. No privacy tag filtering is needed. However, do not expose full underlying_goal text if it might contain sensitive project details — summarize instead.

Insight Routing

After presenting analysis results, check if findings represent actionable conventions that should be preserved for future sessions.

Examples of routable insights:

  • "Debugging tasks have 100% friction rate" → friction.md convention
  • "Docker/container tasks fail consistently" → friction.md convention
  • "Iterative refinement sessions spiral after 3 attempts" → friction.md convention

Present proposed additions:

Insights suggest adding to friction.md:

  • "When debugging, verify hypothesis before fix attempts (2-strike limit)" <!-- @category: pattern -->

Route to friction.md? [y/n]

On approval, write to .claude/memory/friction.md. If the file doesn't exist, create it with a # Friction Patterns header and ## Conventions / ## Project-Specific sections (same template as /memory-init).

Cap total entries at ~15-20. If file exceeds cap after adding new entries, drop the least-recurrent entries (those without repeated evidence across multiple sessions).