Agent Self Reflection 1.0.0
by @mrhenghu
Periodic self-reflection on recent sessions. Analyzes what went well, what went wrong, and writes concise, actionable insights to the appropriate workspace f...
clawhub install agent-self-reflection-1-0-0π About This Skill
name: self-reflection slug: agent-self-reflection version: 1.0.0 description: Periodic self-reflection on recent sessions. Analyzes what went well, what went wrong, and writes concise, actionable insights to the appropriate workspace files. Designed to run as a cron job.
Self-Reflection Skill
Reflect on recent sessions and extract actionable insights. Runs hourly via cron.
Step 1: Gather Recent Sessions
# List sessions active in the last 2 hours
openclaw sessions --active 120 --json
Parse the output to get session keys and IDs. Skip subagent sessions (they're task workers, not interesting for reflection). Focus on:
Step 2: Read Session History
For each interesting session from Step 1, read the JSONL transcript:
# Read the last ~50 lines of each session file (keep it bounded!)
tail -50 ~/.openclaw/agents/main/sessions/.jsonl
β οΈ CRITICAL: Never load full session files. Use tail -50 or Read with offset/limit. Sessions can be 100k+ tokens.
Parse the JSONL to understand what happened. Look for:
type: "user" or type: "human" β what was askedtype: "assistant" β what you respondedtype: "tool_use" / type: "tool_result" β what tools were called and resultsStep 3: Analyze & Extract Insights
For each session, ask yourself:
What went well?
What went wrong?
Lessons learned?
Quality bar: Each insight must be:
Step 4: Route Insights to the Right Files
Each insight belongs somewhere specific. Route them:
β AGENTS.md
β TOOLS.md
β memory/YYYY-MM-DD.md (today's date)
β memory/about-user.md
β skills//SKILL.md
β MEMORY.md
Step 5: Write the Insights
For each insight, append or edit the appropriate file. Use the Edit tool for surgical changes to existing content. Use append (write to end) for daily memory files.
Format for daily memory files:
## Self-Reflection β HH:MM ETInsights
[source: session-key] Lesson learned here
[source: session-key] Another insight Tool Notes
Discovered: tool X needs Y configuration User Context
Brenner mentioned interest in Z
Step 6: Summary
After writing all insights, produce a brief summary of what you reflected on and what you wrote. This is your output β keep it to 2-4 sentences max.
If there's nothing interesting to reflect on (quiet period, only heartbeats), just say so. Don't manufacture insights.
Quality Checklist
Before writing any insight: