# Self-correcting draft loop

> A writing harness that drafts, cleans, gates, and reviews until the output passes, then commits. (pattern: Evaluator-optimizer loop)

_Source: https://leovanschaik.xyz/systems/self-correcting-draft-loop/_

---

Most "write with AI" setups stop at the draft. This one treats the draft as the
start of a loop. The model generates, a skill cleans, a hook enforces a hard
rule the model cannot skip, and a separate reviewer decides whether the work
ships. Nothing leaves the loop until it passes.

```mermaid
flowchart TD
  O[Outline] --> D[Draft from outline · prompt]
  D --> H[Humanizer · skill]
  H --> G{No em dash gate · hook}
  G -- fail --> H
  G -- pass --> R[Reviewer · subagent]
  R -- below bar --> D
  R -- passes --> C[commit · command]
  C --> E([Shipped])
```

## How it runs

The outline feeds a draft prompt. The draft passes through the humanizer skill,
which strips AI tells. A `PostToolUse` hook then checks the file for em dashes
and fails the write if it finds any, which feeds a correction straight back to
the model. Only clean text reaches the reviewer subagent, which scores it
against fixed criteria in isolation and returns a verdict. A failing score loops
back to a fresh draft with the reviewer's notes attached. A passing score hands
off to the commit command.

## Why each piece is its own primitive

The skill, hook, subagent, and command are not one big prompt. They are separate
because they fail differently. The hook is deterministic, so it belongs in code,
not in an instruction the model can rationalize past. The reviewer runs in its
own context so its judgment is not anchored by the draft's reasoning. Keeping
them separate is what makes the loop debuggable: when output is wrong, you know
which stage to fix.
