> ## Documentation Index
> Fetch the complete documentation index at: https://elrolio.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Making the System Learn from Itself

> A structured loop that captures session decisions, extracts patterns, compiles standing knowledge, and feeds it back — so the AI system gets better at marketing work the more it does.

# Making the System Learn from Itself

> [!NOTE]
>
> **What this solves**: AI sessions are stateless by default. Every conversation starts from zero. This system makes each session's decisions, failures, and discoveries compound into the next one.

## The Problem

I kept watching the AI make the same mistakes I'd already corrected. A positioning decision from March would get relitigated in April because the system had no memory of why we chose that direction. Corrections — "don't frame it that way, here's why" — evaporated when the session ended.

The manual workaround was pasting context at the start of each session. That worked for a week. It didn't scale past a dozen sessions, and it put the entire burden of institutional memory on me.

## How It Works

The system runs a four-stage loop after every substantive work session. The first two stages happen in the foreground (30-60 seconds), the last two run as background agents so they don't block the next task.

```mermaid theme={null}
flowchart TD
    A[Work Session Ends] --> B[Stage 1: Session Capture]
    B --> C{Triage Judgment}
    C -->|Decisions, pivots, corrections| D[Write Session Doc]
    C -->|Routine execution| E[Skip — re-derivable]
    D --> F[Stage 2: Compound Extraction]
    F --> G[Extract Patterns to Insight Files]
    F --> H[Extract Failures & Corrections]
    F --> I[Memory Promotion Check]
    I --> J{Durable learning?}
    J -->|Yes| K[Promote to Synced Location]
    J -->|No| L[Leave as Local Memory]
    K --> M[Stage 3: Wiki Compile — Background Agent]
    L --> M
    M --> N[Detect Concepts from Session]
    N --> O[Compare Against Standing Knowledge]
    O --> P[Update Wiki Articles with Deltas]
    P --> Q[Stage 4: Decision Log Entry]
    Q --> R[Structured Log with Memory Types]
    R --> S[Ingest to Persistent Memory]
    S --> T[Available to Future Sessions]

    style A fill:#f0f0f0,stroke:#333
    style T fill:#e8f5e9,stroke:#2e7d32
    style M fill:#fff3e0,stroke:#e65100
```

**Stage 1 — Session Capture** is a triage exercise. It distinguishes between what a future session can reconstruct (routine searches, tool usage) and what it can't (why we rejected an alternative, what the user corrected, where thinking pivoted). Output is a structured session document filed by date.

**Stage 2 — Compound Extraction** pulls atomic learnings out of the session as standalone insight files. Failures and corrections are prioritized over successes — they prevent the system from repeating mistakes. A memory promotion check catches learnings that need to sync across machines.

**Stage 3 — Wiki Compile** runs as a background agent. It reads the session document, identifies standing knowledge concepts ("pricing strategy," "competitive landscape"), and compares findings against existing wiki articles. New claims get added. Contradicted claims get flagged. The freshness index rebuilds automatically.

**Stage 4 — Decision Logging** captures strategic decisions with ten structured memory types: decisions with rejected alternatives, pattern seeds, confidence levels, corrections, gaps, and cross-initiative connections. These feed monthly synthesis and pattern detection.

## In Practice

A typical week generates 8-12 session captures. Maybe 4-5 produce compound extractions worth keeping. The wiki compile agent updates 2-3 standing knowledge articles per session, capped at 5 to prevent noisy rewrites.

The payoff showed up about six weeks in. I was working on a competitive positioning brief and the system already knew — from three prior sessions — that we'd tried and rejected a feature-parity framing, why we'd rejected it, and what the stakeholder feedback had been. That context would have taken me 20 minutes to reconstruct manually. It surfaced in the first response.

The monthly synthesis has caught two recurring patterns I hadn't consciously noticed: a tendency to over-index on competitor features when the real differentiation was workflow, and a pattern where stakeholder feedback consistently redirected positioning toward outcomes over capabilities.

## What I Learned Building This

The hardest design problem wasn't capture — it was triage. Early versions logged everything, which made the knowledge base noisy and the wiki articles bloated. Treating the capture skill as a judgment call rather than a recording is what cut the noise. "Would a future agent need this, or could it re-derive it in 30 seconds?" dropped it by roughly 60%.

Failures and corrections compound faster than successes. A logged correction — "the user said don't frame it that way, here's why" — prevents a class of mistakes across future sessions. A logged success mostly just confirms what was already working. I redesigned the extraction priorities around this.

The cross-machine sync problem caught me off guard. Auto-memory writes are local to the machine they're written on. A learning captured on my laptop doesn't reach my desktop unless it gets promoted to a synced location. The memory promotion check in Stage 2 exists because I spent two weeks watching the desktop agent repeat mistakes the laptop agent had already learned from. The system now has two loops: a tight per-session loop that catches things immediately, and a monthly triage that sweeps for stranded local memories.

## Grab the skill

The capture-and-extract core of this loop — Stages 1 and 2 — is packaged as a self-contained, runnable Claude Code skill. It writes plain Markdown and works in any project; no memory services or knowledge base required (those are the optional Stage 3–4 extensions). Drop it into `.claude/skills/`, run it at session end, and you get a resumable session doc plus atomic insight files.

> [card] [compounding-capture](https://github.com/elrolio/skills/tree/main/compounding-capture)
>
> The runnable skill on GitHub — session capture + insight extraction, MIT-licensed.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.