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

# Optimize

> Stage ⑤ — apply an approved remedy and re-run the loop until it converges. One approval, at the point it matters.

<Note>Stage ⑤ of the loop · owned by the **Optimize** skill.</Note>

**Optimize** closes the loop. It takes a remedy that [Diagnose](/helix/lifecycle/diagnose) proposed,
applies it, and re-runs build → evaluate → diagnose to confirm whether the change helped, then
repeats until it converges.

It **conducts the loop itself**: it dispatches each stage in turn, feeds one stage's output to the
next, and stops when there's no better change to make or the moment you decline a remedy.

```mermaid theme={null}
flowchart LR
  B["Build"] --> E["Evaluate"] --> D["Diagnose"] --> O["Optimize"] -. "↻" .-> B
  classDef s fill:#140d22,stroke:#7E47D7,color:#ede7f8;
  class B,E,D,O s;
```

## Run it

Tell Helix what to improve and when to stop:

```text theme={null}
Optimize the Refund Processing agent's policy-check prompt and keep iterating until the
partial-refund criterion passes.
```

Other ways people ask:

* *Apply the top remedy from diagnosis to the Deep Research agent and re-run the eval loop until the agent holds.*
* *Tighten the Refund Processing agent's escalation rule so large disputes stop getting auto-approved.*

## One approval, where it counts

Optimize is a bounded loop, not an open-ended one. You confirm once at the start, and there's a
single approval at convergence — the point where a change is about to be written. Nothing lands on
your code without that approval.

## What you get

* An agent that measurably improved against your criteria, or a clear result that it didn't.
* A change history you approved, each step re-checked.

<Card title="Back to the start" icon="rotate" href="/helix/how-the-loop-works">
  See how the five stages connect.
</Card>
