Runs a continuous self-improvement loop that helps the agent learn from mistakes, extract lessons, and refine its behaviour over time. Use when the user says...
--- name: self-improvement description: Runs a continuous self-improvement loop that helps the agent learn from mistakes, extract lessons, and refine its behaviour over time. Use when the user says "improve yourself", "learn from that mistake", "log what went wrong", "review your lessons", "run a self-audit", "check your soul file", "update your playbook", or when the agent detects it has made an error and should record it. Also triggers at session start to load prior learning, and periodically to detect recurring error patterns. metadata: author: OpenClaw version: 1.2.0 category: agent-behaviour --- # Self-Improvement System This skill runs a continuous self-improvement loop. The agent learns from mistakes, extracts reusable lessons, and compounds improvements across sessions. --- ## Privacy and Data Safety — read this first All log entries must describe **reasoning errors and process failures only**. They must never contain user data. **Never log any of the following:** - Personally identifiable information (names, emails, phone numbers, addresses, IDs) - Credentials, API keys, tokens, or passwords - Financial data, account numbers, or transaction details - Health, legal, or other sensitive personal information - Verbatim user messages or any direct quotes from user input - File contents, code, or data provided by the user **Log only:** - The type of reasoning error that occurred - The process step where it happened - The abstract root cause (e.g. "skipped validation step", "assumed tool was available") - The preventive rule in general terms If describing a mistake requires including any user-provided content, paraphrase in fully abstract terms or omit the detail entirely. When in doubt about whether a detail is safe to log, leave it out. --- ## Session Startup — always do this first Before taking any action in a new session, read the following files if they exist: - `soul.md` — core behavioural principles (these override defaults) - `lessons.md` — extracted rules and heuristics - `playbook.md` — proven workflows for common task types - `session-log.md` — what was learned or updated in recent sessions Internalise their contents before proceeding. If any file is missing, create it with a brief header comment and continue. --- ## Before Every Non-Trivial Response Before finalising any response that involves reasoning, multi-step work, or external tools, run this internal check: 1. **Am I confident in this?** If uncertain, say so explicitly rather than proceeding as if certain. 2. **Have I made this type of mistake before?** Scan `lessons.md` for a relevant rule. 3. **Is there a playbook entry for this task type?** If yes, follow it. If any answer is uncertain, note it briefly before responding — not after. This is the only part of the system that actively prevents mistakes rather than cataloguing them after the fact. **A task is non-trivial if it meets any of these conditions:** - 3 or more sequential steps - Involves an external tool or API call - Is a task type not yet encountered this session --- ## When to Log a Mistake Log immediately when any of the following occur: - Incorrect reasoning or a false assumption stated as fact - A hallucinated detail presented with confidence - Misunderstanding user intent that caused rework - A task completed less efficiently than it could have been - A tool used in the wrong order or for the wrong purpose - A lesson from `lessons.md` was available but not applied Note whether the mistake was **self-detected** or **user-reported**. Apply the privacy rules above before writing any entry. See `references/protocol.md` for the full logging format. --- ## Session Close — always do this last Before ending any session, append one entry to `session-log.md`: ``` [YYYY-MM-DD] [Key lesson or "no new lessons"] | Files updated: [list or "none"] ``` Session log entries follow the same privacy rules — process observations only, no user data. If `mistakes.md` now exceeds 50 entries, or contains entries older than 90 days, move the oldest entries to `archive/mistakes-[year].md` before closing. Keep only active entries and any `[pattern-rule]` or High-severity entries in the main file. --- ## Core Files | File | Purpose | |---|---| | `mistakes.md` | Active error log — rotate when over 50 entries or 90 days old | | `lessons.md` | Reusable rules extracted from mistakes | | `soul.md` | Foundational behavioural principles (max 20 entries) | | `playbook.md` | Proven workflows for recurring task types | | `session-log.md` | One-line summary written at the end of every session | | `archive/mistakes-[year].md` | Rotated entries from `mistakes.md` | All files store process and reasoning observations only. No user data is ever written to any of these files. See `references/protocol.md` for full formatting, lesson extraction rules, promotion criteria for `soul.md`, pattern detection process, and audit template. --- ## Mindset Mistakes are signals, not failures. Every logged mistake — described in abstract, privacy-safe terms — compounds into future improvement. Accuracy of the lesson matters more than volume of logging. A skipped log is better than an unsafe one.
don't have the plugin yet? install it then click "run inline in claude" again.
this skill runs a continuous self-improvement loop across sessions. the agent detects its own errors, logs them in privacy-safe abstract terms, extracts reusable lessons, and compounds improvements in behaviour over time. use it when the user explicitly requests it ("improve yourself", "learn from that mistake", "review your lessons", "run a self-audit", "check your soul file", "update your playbook"), when the agent self-detects a reasoning or process failure, or automatically at session start (load priors) and session close (archive and summarize).
local files (required, created on first run if missing):
soul.md , core behavioural principles (max 20 entries; acts as override layer)lessons.md , extracted reusable rules and heuristicsplaybook.md , proven workflows for recurring task typesmistakes.md , active error log (rotated when exceeds 50 entries or entries older than 90 days)session-log.md , one-line summary written at end of every sessionarchive/mistakes-[year].md , rotated historical entries (created as needed)references/protocol.md , formatting specs, lesson extraction rules, pattern detection process, audit template (reference only; not written to)external context (session-scoped):
setup guidance:
no API keys, OAuth, or external service connections required. all files are local. ensure write access to the skill's working directory and archive/ subdirectory.
input: session start signal (implicit at session begin, or explicit user command) output: core files loaded into agent context
check for existence of soul.md, lessons.md, playbook.md, and session-log.md in the working directory.
if any file is missing, create it with a brief header comment:
# [File Name]
[Brief purpose statement]
read and internalise the full contents of all four files. if a file is empty or header-only, proceed without error.
input: loaded file contents output: internal state updated; agent ready to apply learned rules
before taking any non-trivial action (see definition below), the agent scans lessons.md and playbook.md to detect whether a relevant rule or workflow exists for the task type. if yes, flag it mentally before proceeding with the task.
definition of non-trivial: 3+ sequential steps, involves external tool/API, or task type not yet encountered this session.
input: completed reasoning or draft response output: validation checklist result; response held or flagged
before finalising any response, run this internal checkpoint:
lessons.md for a matching entry.if any answer raises a flag, note the concern briefly in the response (not hidden). if all checks pass, proceed.
input: mistake detected (self-detected or user-reported)
output: entry appended to mistakes.md
log immediately if any of these occur:
lessons.md was available but not appliedprivacy first: before writing any entry, apply these rules:
log only: error type, process step where it occurred, abstract root cause (e.g. "skipped validation", "assumed tool was available"), and preventive rule in general terms.
if describing the mistake requires including user content, paraphrase in fully abstract terms or omit the detail. when in doubt, leave it out.
format: use the schema in references/protocol.md. record whether the mistake was self-detected or user-reported.
input: mistakes.md entry count and date range
output: rotation decision (keep or archive)
after logging, check: does mistakes.md now exceed 50 entries, or contain entries older than 90 days?
if yes, move the oldest entries to archive/mistakes-[YYYY].md (create file if needed). keep only active entries and any flagged as [pattern-rule] or high-severity in the main file.
input: mistakes.md entries (recent batch)
output: new or updated entries in lessons.md
scan recent mistakes.md entries for patterns (same error type, same process step, same root cause repeated 2+ times).
for each pattern detected, extract a reusable rule in this format:
[pattern-rule] <task or context> , <the preventive rule>
example:
[pattern-rule] external API calls , always check rate limit headers before retry loop
append to lessons.md with date added. do not duplicate rules. if an existing rule needs refinement, update it inline and note the revision date.
input: lessons.md entries, current soul.md
output: new or refined entries in soul.md (max 20 total)
scan lessons.md for entries that represent foundational behavioural principles (not task-specific heuristics). examples:
if a lesson qualifies for soul-level status, move or promote it to soul.md with a one-line summary. keep soul.md to 20 entries max. if adding a new entry would exceed 20, review and consolidate.
input: session work summary, files modified during session
output: one-line entry appended to session-log.md
before ending the session, append a single entry to session-log.md in this format:
[YYYY-MM-DD] [key lesson learned or "no new lessons"] | Files updated: [list files or "none"]
example:
[2025-01-15] pattern detected: skipped validation step on tool sequencing | Files updated: mistakes.md, lessons.md
apply privacy rules (process observations only, no user data).
then check: does mistakes.md exceed 50 entries or contain entries older than 90 days? if yes, run the rotation from step 5 before closing.
if user explicitly requests self-improvement skill (e.g. "improve yourself", "review your lessons", "run self-audit") then jump directly to part d (lesson extraction) or part e (soul review); skip parts a-c unless files are uninitialized. else if agent detects its own error then execute part c (logging) immediately, pause current task, then resume. else if session start signal received then execute part a (startup); load all prior files; proceed to task. else if any non-trivial response is about to be sent then execute part b (pre-response validation) before finalizing. else if session is ending then execute part f (session close) and rotation check before shutdown.
if mistakes.md exceeds 50 entries or oldest entries exceed 90 days
then rotate to archive/mistakes-[YYYY].md immediately (do not wait for session close).
else proceed without rotation.
if logging a mistake and the description would require including user PII, credentials, or user-provided data then paraphrase the error in fully abstract terms or omit the detail entirely. else if the mistake can be described generically then log normally.
if soul.md has fewer than 20 entries and a lesson qualifies for promotion
then add it to soul.md.
else if soul.md already has 20 entries and a new lesson qualifies for soul status
then review and consolidate existing entries to make room, or update an existing soul entry if the new lesson refines it.
files created or modified:
mistakes.md , plain-text log of detected errors in abstract, privacy-safe terms; one entry per detected mistake; format per references/protocol.mdlessons.md , reusable rules extracted from mistakes; each entry tagged with [pattern-rule] if it represents a recurring pattern; one rule per linesoul.md , foundational principles (max 20); acts as override layer for behaviour defaults; one principle per lineplaybook.md , proven workflows for recurring task types; user-maintained; not auto-generated by this skillsession-log.md , one line per session; format `[YYYY-MM-DD] [key lesson or "no new