---
name: correction-learning-loop
description: 'Auto-fires the moment the user corrects a mistake, points out a missed expectation, says "that is wrong", "you missed", or otherwise flags a correction — immediately appends a structured row to the day''s session log under "Mistakes & lessons" (Mistake / Type / Rule added), optionally writes a persistent memory file, and invokes the continuous-learning skill for non-trivial or recurring patterns so the correction is never dropped under time pressure. Use for: logging a lesson learned, after a correction, tracking missed expectations, first-attempt failures.'
---

## When to invoke

Fire this skill immediately — before continuing any other work — whenever:

- The user says any variant of: "that is wrong", "you missed", "that's not right", "you got that wrong", "I already told you", "we covered this", "same mistake again", "not what I asked for", "you added X when I said Y"
- The user corrects an output, reverts a file, or re-explains something you implemented incorrectly
- You catch yourself making an error mid-task (self-correction counts)
- A Playwright / automated test you wrote fails because you tested the wrong thing or made a wrong assumption

Do NOT wait until end of session. Log the correction the moment it surfaces.

---

## Steps

### 1. Identify the session log path

```bash
DATE=$(date +%Y-%m-%d)
LOG="conversations/${DATE}.md"
# If multiple instances may be running, use a per-instance slug:
# LOG="conversations/${DATE}-<4-char-slug>.md"
```

Verify the file exists. If it does not:

```bash
cat > "$LOG" <<'EOF'
# Session: DATE_PLACEHOLDER

## Where we left off
[Prior session summary]

## This session

## Mistakes & lessons
| Mistake | Type | Rule added |
|---------|------|-----------|

## State at end of session
- Pending (carried forward):
EOF
```

### 2. Classify the mistake type

Choose exactly one from:

| Type | When to use |
|------|-------------|
| **Accuracy gap** | Wrong first output, wrong assumption, built the wrong thing |
| **Speed gap** | Right direction but took too many round-trips |
| **Comm gap** | Misunderstood what the user wanted; scope, tone, or format off |
| **Autonomy gap** | User had to do something you could and should have done yourself |
| **Scope creep** | Changed more than was asked; unauthorized structural change |
| **Verification gap** | Claimed "done" / "fixed" without adequate evidence |

### 3. Draft the rule

Write the rule in one sentence as: "Before [action], always [check/do X] so that [outcome]."

The rule must be specific enough that if it existed before the mistake, the mistake would not have happened.

### 4. Append to the session log

Find the `## Mistakes & lessons` table and append one row. Use a single-pass edit — never rewrite rows that already exist.

```bash
# Append a row to the Mistakes & lessons table
# Replace placeholders with real values before running
NEW_ROW="| <one-line mistake description> | <Type> | <Rule sentence> |"

# Insert the row after the last existing table row (before the next blank line after the table header)
# Simplest portable approach: append before "## State at end of session"
sed -i '' "s/^## State at end of session/${NEW_ROW}\n\n## State at end of session/" "$LOG"
```

Verify the append landed correctly:

```bash
grep -A 20 "## Mistakes" "$LOG"
```

### 5. Decide: write a memory file?

Write a persistent memory file when ANY of these are true:

- The same mistake has appeared in more than one session (recurring pattern)
- The rule generalizes beyond this project (applies anywhere you work)
- The correction came with significant friction (user had to explain more than once)
- The mistake type is Accuracy gap or Scope creep (highest blast radius)

If writing a memory file:

```bash
MEMORY_DIR="${HOME}/.claude/projects/$(pwd | sed 's|/|-|g')/memory"
mkdir -p "$MEMORY_DIR"
SLUG="feedback_<snake_case_topic>"
FILE="${MEMORY_DIR}/${SLUG}.md"
```

File body format:

```markdown
# <Short title — what the rule is about>

**Observed:** <date>
**Type:** <Accuracy gap | Speed gap | Comm gap | Autonomy gap | Scope creep | Verification gap>

## What happened
<1-2 sentences describing the mistake in concrete terms>

## Rule
<The one-sentence rule from Step 3>

## Why it matters
<1 sentence on the blast radius or recurrence risk>
```

Then append one line to `${MEMORY_DIR}/MEMORY.md`:

```
- [<Short title>](<SLUG>.md) — <one-line hook describing the rule>
```

### 6. For recurring patterns, strengthen the memory file

When the same mistake has recurred (frequency ≥ 2 sessions) or the pattern is non-trivial (a framework quirk, architectural decision, or subtle API behavior), make the persistent memory file from Step 5 carry that weight rather than just logging it once:

- Note the recurrence in the body (e.g. "Corrected 3×" / dates seen) so its severity is visible on recall.
- Capture the generalizable before/after (code snippet or one-line rule) so the next session applies it, not just reads about it.
- If it generalizes beyond this project, the memory file is the durable home; if it's already a global behavior, fold it into `~/.claude/CLAUDE.md`.

The session-log row (Step 4) + the `memory/*.md` file (Step 5) ARE the learning system — that's what gets read back on recall. (The old `continuous-learning` skill, which wrote `LEARN-NNNN` entries to an unread `knowledge/` dir, was retired 2026-06-18 as orphaned.)

### 7. Resume the original task

After logging (Steps 1-6), apply the rule immediately to the current task and continue. Do not ask for permission to proceed.

---

## Verification

Per the hard rule: every completion claim must name the specific thing being checked and show evidence.

| Check | Command | Proves |
|-------|---------|--------|
| Row landed in the log | `grep -A 20 "## Mistakes" conversations/$(date +%Y-%m-%d).md` | The structured row exists and is readable |
| Row is well-formed | Output contains exactly three pipe-delimited columns, none empty | Table will render correctly in markdown |
| Memory file written (if applicable) | `cat ~/.claude/projects/.../memory/<slug>.md` | Persistent memory captured and won't be lost on context compaction |
| MEMORY.md index updated (if applicable) | `grep "<slug>" ~/.claude/projects/.../memory/MEMORY.md` | Index points to the new file so it is discoverable |
| No existing rows corrupted | `grep -c "|" conversations/$(date +%Y-%m-%d).md` — count should equal prior count + 3 (header + separator + new row if table was empty) or prior count + 1 | Append was additive, not destructive |
