Skip to content

Loop until the North Star

loop() composes the runtime:

plan → record → observe → refine → repeat
import { loop } from "unsurf/skills/loop";
const result = await loop({
spec: "open coey.dev and visit the first project",
northStar: "Did the browser land on a project page?",
maxIterations: 3,
});

Or attach to an already-open browser:

Terminal window
unsurf loop "open coey.dev and visit the first project" \
--north-star "Did the browser land on a project page?" \
--max-iter 3 \
--cdp-port 9222

Good North Stars are:

  • yes/no
  • visible in the recording
  • specific enough to stop on

Examples:

  • “Did the authenticated dashboard load?”
  • “Did the page reach a project detail view?”
  • “Did all three form fields contain non-empty values?”
ReasonMeaning
metThe recording satisfied the North Star
abortRefiner gave up
maxIterationsBudget exhausted
errorBudgetToo many consecutive failures

Use loop for browser-native work with a visual success condition. Use worker when a stable API seam has already been discovered and direct HTTP replay is the better interface.