Overview
Refrain automates browser workflows through a three-phase pipeline:- Generate — AI explores your web app and builds a runbook.
- Execute — The runbook replays deterministically with zero AI cost.
- Self-heal — When UIs change, AI diagnoses failures and suggests fixes.
Phase 1: Generate
Thegenerate command takes a URL and a goal, then lets AI explore your web app to build a runbook.
AI explores the page
Decides which actions to take (click, input, navigate, etc.) based on the goal and page state. Each action is recorded as a step.
Stall detection
If AI gets stuck in a loop or makes no progress, it asks for human guidance. You can also intervene at any time during exploration.
AI reviews the steps
After reaching the goal, AI reviews all recorded steps — removing unnecessary ones and flagging risky actions that may need approval.
Phase 2: Execute
Theexecute command replays a generated runbook. Selectors are resolved deterministically — no AI tokens are consumed on reruns (except when fallback features are triggered).
Load runbook and resolve variables
Variables are resolved from secrets, context, environment, or interactive prompts.
Execute each step
For each step, the executor resolves the selector using multi-layered resolution, then performs the action (click, input, navigate, etc.).
Handle approvals
Steps marked as requiring approval pause execution and wait for human confirmation via CLI, Slack, Teams, or Discord.
Phase 3: Self-heal
When the target app’s UI changes and steps start failing,--self-heal enables AI-powered diagnostics.
Enhanced execution
Self-heal mode enables aggressive retry strategies, selector caching, Agent Fallback, and Vision Fallback automatically.
Error classification
Each failure is classified into one of 6 categories to guide the repair strategy.
AI repair suggestions
AI analyzes failed steps and generates two types of suggestions: runbook fixes (selector changes, step additions) and context fixes (updated page structure notes).
Key design principles
- Reproducibility — The same runbook produces the same result every time.
- Zero rerun cost — Deterministic execution means no AI tokens on reruns.
- Human-in-the-loop — Approval workflows keep humans in control of risky actions.
- Self-maintaining — AI auto-maintains runbooks when UIs change.