About self-reflection
self-reflection helps an agent improve over time by recording mistakes, lessons, and changes, with periodic checks to prompt reflection. It provides command-line operations and can be added to an OpenClaw heartbeat workflow.
Key features
- 01Check whether reflection is due
- 02Log and read reflections
- 03View statistics and reset the timer
- 04Integrate with OpenClaw heartbeat
Use cases
- 01Regularly check whether an agent should reflect
- 02Record API-call errors and lessons
- 03Review recent lessons before later tasks
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ hopyky/ self-reflection --skill self-reflectionAfter installing, type/self-reflectionin Claude Code to confirm it loaded.
Bundled files
References and scripts installed along with SKILL.md.
.gitignoreLICENSEREADME.mdself-reflection.example.jsonbin/self-reflectionDetails
From the project README🪞 Self-Reflection
A skill for continuous self-improvement. The agent tracks mistakes, lessons learned, and improvements over time through regular heartbeat-triggered reflections.
Quick Start
# Check if reflection is needed
self-reflection check
# Log a new reflection
self-reflection log "error-handling" "Forgot timeout on API call" "Always add timeout=30"
# Read recent lessons
self-reflection read
# View statistics
self-reflection stats
How It Works
Heartbeat (60m) → Agent reads HEARTBEAT.md → Runs self-reflection check
│
┌─────────┴─────────┐
▼ ▼
OK ALERT
│ │
Continue Reflect
│
┌─────────┴─────────┐
▼ ▼
read log
(past lessons) (new insights)
Commands
| Command | Description |
|---|---|
check [--quiet] | Check if reflection is due (OK or ALERT) |
log <tag> <miss> <fix> | Log a new reflection |
read [n] | Read last n reflections (default: 5) |
stats | Show reflection statistics |
reset | Reset the timer |
OpenClaw Integration
Enable heartbeat in ~/.openclaw/openclaw.json:
{
"agents": {
"defaults": {
"heartbeat": {
"every": "60m",
"activeHours": { "start": "08:00", "end": "22:00" }
}
}
}
}
Add to your workspace HEARTBEAT.md:
## Self-Reflection Check (required)
Run `self-reflection check` at each heartbeat.
If ALERT: read past lessons, reflect, then log insights.
Configuration
Create ~/.openclaw/self-reflection.json:
{
"threshold_minutes": 60,
"memory_file": "~/workspace/memory/self-review.md",
"state_file": "~/.openclaw/self-review-state.json",
"max_entries_context": 5
}
Author
Created by hopyky
License
MIT
Comments
Markdown supported