# Run work while you sleep

This is the payoff for everything before it. An agent you can trust to verify its own work is an agent you can leave alone with a hard task. What makes that safe isn't hope. It's a checkable finish condition, an isolated git worktree, and a decision log you audit in the morning.

![She waves goodnight from the door while robots keep the factory running, one updating a DECISION LOG wall board under a BUILD LOOP ACTIVE sign.](./images/overnight.jpg)

One honest limit first: Selesai has no `/loop` wake mechanism or other unattended re-check scheduler, and Cursor's is explicitly unsupported. A long run drives its iterations while the session is live, and delegated work comes back through native async completion notifications. If nothing can wake the session, the agent tells you it cannot resume unattended instead of polling, sleeping, or pretending. Long runs also never activate Selesai Goal mode without your explicit Goal contract.

## Earn the trust before the long run

A run you don't trust just produces unchecked work faster, and the mess compounds with every iteration. Before you leave one running, check that it has earned it:

- You've done the task once by hand, or watched an agent do it, so you know what good looks like.
- The agent has the tools and signals you'd use yourself: the verification skill, the profiler, the logs.
- Every stage proves its work and can stop the line when the work misses the bar.
- You've read a few transcripts and turned the repeated failures into tools, skills, or checks.

Make the run autonomous only after all four hold. Until then, run it while you watch.

## The overnight contract

A good handoff has the goal, the finish condition, permissions, and an escape hatch. It doesn't need to be long:

```text
$poteto-mode im going to bed. migrate every caller to the new parser in a fresh worktree off <base>.
done means zero old callers, all parser fixtures pass, old api deleted.
keep a decision log. don't ask me before committing.
continue until the stated check passes. if you're truly stuck after a few hours, stop and write up why.
```

Walk through what each line buys you:

- "im going to bed" is a session override. The agent stops asking and keeps going, within the authorized scope.
- "done means..." turns the goal into checks every iteration can run.
- "fresh worktree off `<base>`" keeps the run from colliding with anything else you have open. Worktree isolation requires a clean source checkout.
- "don't ask me before committing" pre-answers the permission the agent would otherwise block on. Without it, commits stay unauthorized and the run reports local results.
- The [Autonomous run playbook](../../skills/poteto-mode/playbooks/autonomous-run.md) drives the iterations and re-checks the finish condition; native async completion notifications wake the parent for delegated work. There is no unattended wake mechanism beyond that, and the run says so.
- The escape hatch lets it stop at a genuine dead end and write up why, which beats eight hours of creative goal reinterpretation.

Because you'll review this work after stepping away, `$poteto-mode` routes it through [`$figure-it-out`](../../skills/figure-it-out/SKILL.md), which designs the run's phases before any code and wires in the decision log.

To stop a run on purpose, tell the agent to pause, or that you're about to go offline or restart Selesai. The [Pause safely playbook](../../skills/poteto-mode/playbooks/pause-safely.md) finishes or backs out of the current step, commits a work-in-progress checkpoint (when commits are authorized), and writes a resume note. A fresh chat picks the work up from that note through the Session pickup playbook. Saying "keep going" never triggers a pause.

## What the run does all night

```mermaid
flowchart TD
    A[Check the finish condition] --> B[Make the smallest justified change]
    B --> C[Verify against the real artifact]
    C --> D{Progress?}
    D -->|Yes| E[Commit]
    D -->|No| F[Discard]
    E --> G[Log one decision row]
    F --> G
    G --> A
```

One change, one check, one log row, every iteration. Changes that didn't help get discarded, not left to ride. A plateau means pivot, not stop, and the finish condition never quietly relaxes to declare victory.

## The morning audit

[`$show-me-your-work`](../../skills/show-me-your-work/SKILL.md) is what makes the run reviewable. Each row records the time, phase, decision, reason, an evidence pointer, and the result, in a TSV at `decisions.tsv` (or `.audit/<task-slug>.tsv` when several runs share a directory). The appender is a helper script, invoked as `bash "<skill dir>/skills/show-me-your-work/scripts/log.sh"` because seeded copies lose the executable bit. It stays local by default. Commit it when the work is ambitious enough that a reviewer needs the trail to trust the result, and when commits are authorized.

When you're back, ask for the run in review form:

```text
$show-me-your-work catch me up on what you did last night
```

Before the skill hands back its summary, it spawns a reviewer on a different model family to read the trail and the run's record, when delegation is authorized and such a model is available. The reply ends with an Attention section listing what deserves your scrutiny, led by the reviewer's model; when no different-vendor reviewer was available, that line reads `reviewed inline, not independent` instead of claiming independence. Read that section first, then the log rows it points at. You're auditing decisions, not re-reading the whole night.

For a quick status instead of an audit, run [`$ketchup`](../../skills/ketchup/SKILL.md) in the chat that ran the work. It reads only, and tells you in plain words what changed since your last message, with the screenshots and small diagrams the work produced. Then it lists each call waiting on you, such as a merge, an approval, or a choice between options, with its pick, the evidence, and the risk, so you can decide from the reply alone.

## When the night holds a queue, not a task

The contract above drives one task to one finish condition. Some nights hold more, a queue of independent changes or a whole program. Two playbooks and one skill scale the same trust up.

[Autopilot-full](../../skills/poteto-mode/playbooks/autopilot-full.md) runs a queue of independent PRs to merged, once you have authorized delegation and each class of remote write for that queue. Each PR gets one owner agent that carries it from build through merge, and no owner merges on its own verdict. A swarm of fresh local verifiers, each in an isolated worktree, checks the owner's code-ready head. A later rebase or minor fix gets one fresh verifier, and only new behavior or a large new diff calls the full swarm again. Only a clean verdict on the patch that merges authorizes the merge:

```text
$poteto-mode full autopilot on this queue. each item is independent. i want them merged by morning.
```

[Autopilot-stack](../../skills/poteto-mode/playbooks/autopilot-stack.md) is Autopilot-full without the merge. You wake up to verified PRs, each with its verdict, and you review and land them yourself. A PR stacks only on a PR it builds on. Pick it over Autopilot-full when you want your own eyes on the work before anything merges:

```text
$poteto-mode autopilot these five changes, but don't merge. i'll land them in the morning.
```

A whole program, such as a migration across many packages, has no playbook of its own. `$poteto-mode` routes large or cross-cutting work to [`$figure-it-out`](../../skills/figure-it-out/SKILL.md), which designs one rigorous run for it:

```text
$poteto-mode migrate every package to the new store. own it until each one is converted and merged. i'll check in twice a day.
```

## Run many bodies of work in parallel

Selesai can coordinate authorized local workers with isolated worktrees and native completion notifications; there are no cloud agents and no persistent project coordinators. Local work does not continue after the machine shuts down. Start each body of work with `$poteto-mode`, and the children it spawns follow the playbooks. Each child reads [`worker.md`](../../skills/poteto-mode/worker.md) first, so workers hold to the kickoff's bar, decide reversible calls instead of asking you, and use the draft status the brief requests for PRs.

A few habits help:

- Give each body of work its own session and worktree, such as a feature, a migration, a perf push, or a tech-debt cleanup. Several can run side by side.
- Keep the decision trail and resume notes where a fresh session can find them; they become the context for the next agent.
- Give each PR a verification swarm before it merges, and let Autopilot-stack or Autopilot-full carry the queue.
- Ask the coordinator for a plan backed by data, and have it answer open questions with prototypes before it asks you.

One prompt can carry a whole program, from research through execution:

```text
$poteto-mode refactor this repo so its architecture is more agent friendly. use $correct and $architect on past commits and review comments to find the mistakes agents make most here. use $recall for context from past sessions. answer open questions with prototypes instead of asking me. come back with a plan backed by real data. once i approve it, run it with autopilot-stack or autopilot-full, and ask me which.
```

## Scheduled and event-driven runs are unsupported

Upstream pstack ships a dormant Benny automation pack for Slack issue reports, built on Cursor Automations. It is not ported to Selesai and is explicitly unsupported; nothing here registers webhooks or wakes itself on a schedule. If you want a staged maintenance line (triage, reproduce, fix, verify), run each stage as its own authorized task, and keep the two rules that make such a line trustworthy:

- Every stage can stop the line. Triage can decide the report is expected behavior, repro can fail to reproduce it, and the fixer can judge the change too risky. Each of those outcomes is useful, because it keeps bad work from reaching the next stage, where it costs more to undo.
- Every stage hands over evidence. Repro attaches screenshots and video of the broken state, and the fix attaches before-and-after proof. A human can then check that the agent fixed the right thing before reading a line of code.

**Pitfall:** a duration is not a finish condition. "work on this for 4 hours" gives the agent nothing to check, and you'll wake up to four hours of motion instead of a result. Give the run a predicate that can pass or fail.

Next: [Steer with principle names](./08-principles.md).
