plugins/sjawhar/skills/reflect/SKILL.md
Analyze Claude Code and OpenCode sessions for patterns and improvements
npx skillsauth add sjawhar/dotfiles plugins/sjawhar/skills/reflectInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Analyze session transcripts from both Claude Code and OpenCode to identify patterns in corrections and feedback, then generate actionable improvements.
Optional: Number of days to analyze (default: 7)
Example: /reflect 14 to analyze the past 2 weeks.
1.1 Load previous report (if exists):
~/.dotfiles/.claude/session-analysis/1.2 Run indexing (indexes both Claude Code and OpenCode sessions):
python3 ~/.dotfiles/.claude/skills/reflect/index-sessions.py --days {N}
Use --source claude or --source opencode to limit to one source. Default indexes both.
1.3 Query flagged turns from SQLite database at ~/.dotfiles/.claude/sessions.db:
import sqlite3
conn = sqlite3.connect(str(Path.home() / '.dotfiles' / '.claude' / 'sessions.db'))
# Get all flagged turns from the past N days
query = '''
SELECT
s.source, s.project, s.id as session_id, s.source_path, s.initial_prompt_preview,
t.turn_number, t.type, t.line_start, t.line_end, t.source_path as turn_source_path,
f.flag_type
FROM flags f
JOIN turns t ON f.turn_id = t.id
JOIN sessions s ON t.session_id = s.id
WHERE s.timestamp > datetime('now', '-{N} days')
ORDER BY s.timestamp DESC
'''
2.1 Fetch flagged content from source files:
s.source = 'claude-code'): Use line_start/line_end with fetch_turn_content() to read from the source JSONL file.s.source = 'opencode'): Use turn_source_path (the message JSON file path) with fetch_opencode_turn_content() — reads the message file and assembles text from its parts.Both functions are provided by the indexing script.
2.2 Apply secret redaction before agent access:
2.3 Group by session for context preservation:
Launch 5 specialized agents in parallel using the Task tool:
| Agent | Mandate |
|-------|---------|
| Mistake Finder | Find Claude errors that user corrected: wrong file, wrong approach, misunderstood request. Focus on rejection and interrupt flags. |
| Preference Learner | Identify implicit user preferences: formatting, communication style, tool choices, workflow patterns. Look for repeated clarification patterns. |
| Command Repeater | Find repeated slash commands or multi-step workflows that could become skills. Look for patterns in initial prompts. |
| Prompt Repeater | Find similar initial prompts across sessions suggesting a skill opportunity. Use initial_prompt_preview from sessions table. |
| CLAUDE.md Miner | Find project-specific concepts, patterns, or rules that should be documented. Group findings by project. |
Agent prompt template:
You are analyzing Claude Code and OpenCode session transcripts to find {AGENT_FOCUS}.
Context: {PREVIOUS_REPORT_SUMMARY}
Here are the flagged turns from the past {N} days:
{FLAGGED_CONTENT_MARKDOWN}
For each pattern you find:
1. Describe the pattern clearly
2. Provide 2-3 specific examples with session IDs
3. Explain the root cause
4. Suggest a concrete improvement (skill, CLAUDE.md update, alias, etc.)
Focus on actionable patterns that appear at least 2-3 times.
After all agents complete:
4.1 Deduplicate findings:
4.2 Assess previous improvements (if previous report exists):
4.3 Rank by frequency and impact:
Present findings to user for decision:
## Pattern: {PATTERN_NAME}
Frequency: {COUNT} sessions
Type: {IMPROVEMENT_TYPE}
Root cause: {ANALYSIS}
Examples:
- Session abc123: "{example_excerpt}"
- Session def456: "{example_excerpt}"
Suggested improvement:
{DETAILED_SUGGESTION}
Options:
1. Implement now
2. Defer (add to next week's list)
3. Dismiss (not actionable)
For each pattern, ask the user to choose using the AskUserQuestion tool with options.
For each "implement now" decision:
Skills: Create new file in ~/.dotfiles/.claude/commands/{skill-name}.md
CLAUDE.md updates:
~/.dotfiles/.claude/CLAUDE.md~/.dotfiles/.claude/project-instructions/{project}/CLAUDE.mdBash aliases: Add to ~/.dotfiles/bash/aliases.sh
Agents: Create new file in ~/.dotfiles/.claude/agents/{agent-name}.md
Save report to ~/.dotfiles/.claude/session-analysis/YYYY-MM-DD.md:
# Session Analysis Report - {DATE}
## Summary
- Sessions analyzed: {COUNT}
- Date range: {START} to {END}
- Projects covered: {PROJECT_LIST}
- Flags detected: {interrupt: N, rejection: N, clarification: N}
## Previous Improvements Assessment
{For each prior improvement: status (improved/unchanged/regressed), evidence}
## Patterns Observed
{For each pattern: frequency, examples, root cause, suggested improvement}
## Improvements Made
{For each implemented change: type, file, reason, expected result}
## Improvements Deferred
{For each deferred: reason, trigger to revisit}
## Notes for Next Analysis
{Context that future runs should consider}
development
Use when searching flights, hotels, or rental cars; comparing fares across flexible dates; discovering cheap destinations from a fixed origin; or hunting hidden-city ticketing deals. Trigger on multi-city itineraries, fare calendars, "where can I fly cheaply", price-sensitive trip planning, or any time the user wants a sanity-check against Google Flights pricing — Skiplagged surfaces hidden-city deals other engines deliberately hide.
development
Search the web via Ceramic Search (lexical/keyword-based). Use when looking up current events, recent news, time-sensitive facts, specific people/products/companies, technical docs, or any topic requiring fresh web results. Triggers on "search the web", "look up", "find recent", "latest news", "current", or when built-in knowledge is likely stale.
tools
Use when reading WhatsApp messages, searching conversations, sending messages, listing chats, or interacting with WhatsApp workspaces
tools
Watch CI status, fix failures, and merge when green