Self-Reflection Skill
name: self-reflection
by brennerspear · published 2026-03-22
$ claw add gh:brennerspear/brennerspear-agent-self-reflection---
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 --jsonParse 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/<sessionId>.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:
Step 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-name>/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 ET
### Insights
- [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 ZStep 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:
Anti-Patterns (Don't Do These)
More tools from the same signal band
Order food/drinks (点餐) on an Android device paired as an OpenClaw node. Uses in-app menu and cart; add goods, view cart, submit order (demo, no real payment).
Sign plugins, rotate agent credentials without losing identity, and publicly attest to plugin behavior with verifiable claims and authenticated transfers.
The philosophical layer for AI agents. Maps behavior to Spinoza's 48 affects, calculates persistence scores, and generates geometric self-reports. Give your...