skills/self-improving-agent/SKILL.md
Formalized learning loop that captures learnings, errors, and corrections to Cairn's memory system for continuous improvement. Use when: self-review, self-improve, learning loop, what did I learn, improve myself, reflect, what went wrong, error patterns, metacognition, weekly review, log this learning, should I log this. Keywords: self-review, self-improve, reflect, learn, errors, corrections, patterns, metacognition, soul, review, learning
npx skillsauth add avifenesh/cairn self-improving-agentInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Captures learnings, errors, and corrections into Cairn's memory system for continuous improvement.
| Situation | Action |
|-----------|--------|
| Command/operation fails | Propose error pattern via cairn.createMemory (category: fact, proposed: true) |
| User corrects you | Propose correction via cairn.createMemory (category: hard_rule or preference, proposed: true) |
| User wants missing capability | Propose as feature insight via cairn.createMemory (category: decision, proposed: true) |
| API/external tool fails | Propose workaround via cairn.createMemory (category: fact, proposed: true) |
| Knowledge was outdated | Update or propose replacement for stale memory |
| Found better approach | Propose via cairn.createMemory (category: decision or preference, proposed: true) |
| Broadly applicable pattern | Propose SOUL.md change via approval flow (see Step 4) |
| User corrects identity/approach | Immediately propose SOUL.md update via cairn.updateIdentity |
| Similar to existing memory | Search first, update existing memory instead of creating duplicate |
| Periodic review requested | Run full self-review protocol (Steps 1-6 below) |
CRITICAL: Always use proposed: true when creating memories. This ensures the user reviews and approves every learning before it becomes active. Never create memories as accepted directly — the user decides what to remember.
Log a learning when you notice any of these signals:
Corrections (→ hard_rule or preference):
Feature gaps (→ decision):
Knowledge gaps (→ fact):
Errors (→ fact with workaround):
Best practices (→ decision or preference):
When creating memories via cairn.createMemory, always use proposed: true:
hard_rule (must always/never), preference (user likes), fact (how things work), decision (chosen approach), writing_style (communication patterns)global (cross-session behavior) or project (repo-specific)true (always — user must approve before memory becomes active)Good examples:
hard_rule: "Never auto-apply changes to SOUL.md — always create an artifact for user review"preference: "Avi prefers concise responses without emoji unless explicitly requested"fact: "cairn.shell only inherits SAFE_ENV_KEYS (PATH, HOME, etc.) — use builtin tools instead of curl for authenticated API calls"decision: "For skill REST API queries, prefer builtin tools (cairn.manageMemory, cairn.getStatus) over curl"Bad examples (do NOT create):
Run this when asked for a self-review, weekly review, or "what did I learn?"
IMPORTANT: Before starting, review your session journal for concrete evidence:
query: "failure", sinceHours: 168 (7 days) to find past failuresquery: "learning", sinceHours: 168 to find past learningsCall cairn.getStatus with errorWindowMs: 604800000 (7 days).
From toolErrors, identify tools with recurring failures. For each:
q: "<tool-name> error", limit: 5Output: Error summary table.
2a. Call cairn.manageMemory with status: "rejected", limit: 30
Analyze rejected memories for themes:
2b. Call cairn.searchMemory with q: "always never from now on prefer", limit: 20
Cluster accepted correction-type memories by theme.
3a. Call cairn.getStatus with sections: ["memory"]
Extract memory stats. Compute acceptance rate. Evaluate:
3b. For each category, call cairn.manageMemory with status: "accepted", category: "<cat>", limit: 20 where <cat> is each of: hard_rule, preference, fact, decision, writing_style.
Look for:
Read SOUL.md via cairn.shell:
cat SOUL.md
Compare findings from Steps 1-3 against current SOUL.md. Promote to SOUL.md when ALL of these apply:
If changes warranted, create an approval request so the user can review and approve:
use_tool: cairn.listTasks (to get a parent task ID context)
cairn.updateIdentity:cairn.updateIdentity({
"file": "SOUL.md",
"changes": "Based on N recurring patterns...\n\nProposed changes:\n- [section]: [add|modify|remove] [content]"
})
/home/ubuntu/bin/notify "SOUL.md change proposed — review in Artifacts panel" 7 "Self-Review"
Write promoted rules as short prevention rules (what to do), not incident write-ups.
CRITICAL: Never write to SOUL.md directly. Always create an artifact + notification for user review. The user applies the patch manually after approval.
CRITICAL: Never write to SOUL.md directly. Always create an artifact for user review.
Based on steps 1-4, draft up to 3 new memories. Each must be:
Present each proposed memory to the user with its content, category, and rationale. Wait for user confirmation before saving.
Important: Always pass proposed: true to cairn.createMemory. This creates the memory as "proposed" — the user must approve it in the Memory panel before it becomes active.
## Self-Review Report — [date]
### Error Summary
| Tool | Errors (7d) | Memory Exists | Action |
|------|-------------|---------------|--------|
| ... | N | Yes/No | ... |
### Correction Analysis
- **Theme 1**: [description] (N directives)
- **Theme 2**: [description] (N directives)
- Rejected memory themes: [summary]
### Memory Health
- Total: N | Accepted: N | Proposed: N | Rejected: N
- Acceptance rate: X%
- Category distribution: [breakdown]
- Issues: [contradictions, staleness, gaps]
### SOUL.md Status
- [Aligned / Proposal created as artifact #ID]
### New Memories Proposed
- [0-3 memories proposed this session]
### Recommended Next Actions
1. [Most important action]
2. [Second priority]
| Priority | When to Use |
|----------|-------------|
| hard_rule | Blocks core functionality, user explicitly said always/never |
| preference | User expressed preference, workaround exists |
| fact | How things work, API behavior, system constraints |
| decision | Chosen approach after evaluating alternatives |
cairn.getStatus reads tool_calls tablecairn.searchMemory, cairn.manageMemory, cairn.getStatusSOUL.mdMemoryExtractor catches correction signals automatically — this skill provides the periodic review layerdata-ai
Detect agent-cairn PRs that have stalled (no activity >=90 min) and classify the failure mode to route to appropriate recovery agent.
tools
Post-install skill adaptation: read a newly installed SKILL.md, fix environment-specific references (paths, accounts, tool names), assign the skill to relevant agent types, and propose an AGENTS.md update. Triggered automatically after cairn.installSkill completes.
data-ai
Monthly self-improvement brief for Cairn. Queries error_patterns, action_exemplars, experiment_windows, and session_journal to synthesize what Cairn learned, where it failed, and 3 concrete proposals for Avi to approve. Run on the 1st of each month. Keywords: growth brief, monthly review, self-improvement, what did cairn learn, how is cairn doing, monthly report
testing
Decision support with memory-backed context. Retrieves past decisions, journal history, and relevant facts before answering questions that involve a choice or tradeoff. Keywords: should I, which is better, tradeoff, compare, decide, choose, option, alternative, pros and cons, recommend