Evaluate past Claude Code sessions and extract reusable knowledge as CLAUDE.md updates or new skills. Triggers: "reflect on sessions", "what did we learn", "save this knowledge", "extract learnings", after completing significant tasks.
which bun 2>/dev/null || echo "NOT INSTALLED"ls -d ~/.claude/plugins/cache/aiocean-plugins/aio-reflect/*/skills/aio-reflect/scripts 2>/dev/null | sort -V | tail -1 || echo "NOT FOUND"[ -d "$HOME/.claude/aio-reflect/memory" ] && echo "$HOME/.claude/aio-reflect/memory" || echo "NOT CREATED (will be created on first run)"Purpose: Turn transient learnings into permanent improvements. What separates growth from stagnation is the ability to learn from experience.
RF="$(ls -d ~/.claude/plugins/cache/aiocean-plugins/aio-reflect/*/skills/aio-reflect/scripts 2>/dev/null | sort -V | tail -1)"
MEMORY="$HOME/.claude/aio-reflect/memory"
mkdir -p "$MEMORY/diary" "$MEMORY/reflections"
Then call scripts as bun run $RF/script-name:
# Extract last 5 sessions with diary summary
bun run $RF/extract-session.ts <project-path> --last 5 --diary
# Full extraction with thinking blocks
bun run $RF/extract-session.ts <project-path> --last 5 --verbose
# Deep extraction with subagent conversations
bun run $RF/extract-session.ts <project-path> --last 5 --full --verbose
# JSON output for further processing
bun run $RF/extract-session.ts <project-path> --last 5 --json
# Stats only (cost, tokens, work mode, tasks)
bun run $RF/extract-session.ts <project-path> --last 10 --stats-only
The extractor deeply understands Claude Code's JSONL format and storage:
Per session:
{uuid}/subagents/agent-*.jsonl~/.claude/tasks/{uuid}/Aggregate (multiple sessions):
bun run $RF/get-project-path.ts <path> --check
3.5. (Optional) List all projects with sessions:
bun run $RF/project-tree.ts --stats
# List sessions with stats to identify unprocessed ones
bun run $RF/extract-session.ts <project-path> --stats-only
# Then compare session IDs against $MEMORY/processed.json
bun run $RF/extract-session.ts <project-folder> --last N --verbose
Output includes:
Read the extracted sessions holistically. Let AI identify what matters - don't use keyword detection or bias towards "corrections".
Core Question: What knowledge from these sessions is reusable and can evolve?
A. Check Rule Violations
Compare session with existing CLAUDE.md rules:
B. Find Friction Points
Detect patterns where user repeatedly has to:
Ask: What would make this friction disappear?
C. Discover Preferences
Patterns the user consistently shows across sessions:
Only worth capturing if it appears multiple times across sessions.
D. Extract Reusable Knowledge
AI should freely identify knowledge that:
Skip:
E. Evaluate Skill Candidates (Selective)
Criteria for extracting a skill:
Types of extractable knowledge:
Present findings in structured format:
## Reflection: [Project Name]
Analyzed [N] sessions from [date range]
### Rule Violations (if any)
- **Rule**: [existing rule text]
- **What happened**: [brief description]
- **Action**: Strengthen → [proposed new text]
### Friction Points
1. **Pattern**: [what user repeatedly has to do]
**Frequency**: [how often across sessions]
**Solution**: [what would eliminate this friction]
### Preferences
1. **Preference**: [what user consistently does/requests]
**Evidence**: [sessions where this appeared]
### Reusable Knowledge
1. **Knowledge**: [what was learned]
**Why reusable**: [how it applies beyond this session]
### Skill Candidates
1. **Problem**: [what problem this solves]
**Trigger**: [when to use]
**Worth creating?**: [Yes/No + reasoning]
### Proposed Changes
#### CLAUDE.md Updates
**Change**: [add/modify/strengthen]
**Text**: [exact text]
**Rationale**: [why this helps future sessions]
#### New Skills
[For each proposed skill]
**Name**: [kebab-case-name]
**Problem**: [one-line description]
**Trigger**: [error messages, symptoms]
**Evidence**: [session quote]
IMPORTANT: Never create or modify files without explicit user approval.
Step 1: Ask which changes to apply
Present all proposed changes and ask: "Which of these should I apply?"
Options:
Step 2: Apply CLAUDE.md updates
For rule violations (strengthen existing):
For new rules:
Step 3: Create skills (if approved)
Step 4: Mark sessions as processed
Update $MEMORY/processed.json:
{
"sessions": {
"session-id": {
"project": "/path/to/project",
"processedAt": "2026-01-18T12:00:00Z",
"learningsApplied": 3
}
}
}
Step 5: Write diary entry (optional)
If user wants, save reflection to $MEMORY/diary/YYYY-MM-DD-reflection.md
---