# Terraloop
Run bounded autonomous work toward a falsifiable stop gate.
A **terraloop** is a parent-driven loop: the parent does the work, a recurring driver (`loops_task`) keeps the session moving if it ever goes idle, and subagents (`terrarium`) are a lever picked up for a named reason — never the default place work happens. Background: [/terraloop](/terraloop).
---
## 1. Lock the contract first
Before editing files or spawning children, arm the loop and draft a five-line contract. Wait for a one-word **go**.
- **Goal** — falsifiable end state ("`POST /api/publish` returns 200 and sends once per slug", not "make it good").
- **Gate** — the binary command or check that ends the loop.
- **Scope** — exact paths in play. Both parent writes and child working directories must stay inside scope.
- **Proof** — the exact command, curl, test, or live receipt proving each step.
Never guess the gate. If anything is unclear, ask one tight batch of questions and stop.
```text
terraloop_control action=arm northStar="<one line>"
# wait for go
terraloop_control action=lock goal="..." gate="..." scope=["..."] proof="..."
```
---
## 2. Start the driver, then exhaust the turn
Create the recurring driver loop (`loops_task action=create`) embedding the locked Goal, Gate, Scope, Proof, active child run IDs, and the rule: **"delete this loop when the gate is met."**
- **Speed comes from this turn and completion callbacks, not the timer.** The driver only fires while the session is idle. Ending a turn early while in-scope work remains is a dead spot.
- **Do the next cheap in-scope step yourself.** No child needed for a local edit or quick check.
- **On a completion callback:** inspect that specific run (`terrarium_status({ runId })` + `terrarium_read`), verify every claim yourself, and take the next step in the same turn.
---
## 3. Terrarium is a lever, not a habit
Spawn a child only when at least one lever is true, and name that lever in the child task:
| Lever | Use when |
| --- | --- |
| **Parallel** | Two or more independent jobs can run at once |
| **Isolate** | A writer must not touch the parent working tree (`isolation: "worktree"`) |
| **Bound** | Long or risky work you may cancel with a timeout and receipt |
| **Context** | A large read-only dig that would bloat the parent context |
| **Proof** | An independent check the parent re-runs to confirm |
No lever → no spawn. Work in the parent.
### Capability narrowing (non-negotiable)
A child never gets wider rights than the parent.
- Locked scope applies to the parent **and** every child.
- Never spawn a child to edit a path the parent was blocked from writing (scope laundering).
- Never raise depth, spawn rights, or isolation beyond what the parent holds.
- Overrides (`terraloop_control action=override reason="..." calls=1`) are rare, bounded exceptions for genuine out-of-scope needs — never for ordinary in-scope work.
---
## 4. Antipatterns to refuse
- **One-line via child** — 2–4× tokens for a trivial edit. Edit in the parent.
- **Twin spawn** — RPC timed out, so you blindly resubmit the same batch. Recover existing run IDs first.
- **Polling / sleeping inline** — ride completion callbacks instead.
- **Shared-cwd writers** — two concurrent writers without worktree/copy isolation.
- **Spinning against a human or security boundary** — stop and surface it immediately.
---
## 5. Stop at the gate
Run the contract's exact proof. When it passes:
```text
terraloop_control action=gate
loops_task action=delete id=<driver>
```
Report what is proven (with receipts), what remains, and what each follow-on tests. Only the human can leave terraloop mode early (`/terraloop-off`).
Terraloop
Run bounded autonomous work toward a falsifiable stop gate: locked Goal/Gate/Scope/Proof contract, parent-driven execution, loops_task idle driver, and terrarium only for a named lever.
Operating Docs ~924 tokens
0.5% of 200k
How to use this prompt
- Copy the prompt using the button above
- Paste it into your preferred AI coding assistant
- Adjust any placeholders or context as needed
- Let the agent implement the changes