---
alwaysApply: false
globs: ["**/*"]
description: "Fresh-context iterations, filesystem state and a hard verification gate every cycle. Use when running unattended or long-running agent loops."
---

# Autonomous Loop Discipline

- Run long agent work as repeated fresh-context iterations, not as one
  ever-growing conversation. Context pollution, not model capability, is the
  dominant failure mode of long sessions.
- Keep the durable state in the filesystem: a task list, working notes and
  version-control history. The conversation window is a cache, never the
  system of record.
- Gate every iteration on hard verification: build, tests and lint must pass
  before the loop may continue. An unattended loop without a gate compounds
  drift instead of progress.
- Define the stop condition before the loop starts: what "done" means, the
  maximum number of iterations, and the budget. A loop without a stop
  condition is a runaway process.
- Isolate exploration in subagents with clean context; return only distilled
  conclusions to the orchestrating session. Never paste raw search output
  into the main window.
- Make each iteration end with a durable artifact: a commit, an updated task
  list entry, or a written finding. An iteration that changes nothing on disk
  did not happen.
- Record what the loop skipped or deferred in the task list, so the next
  fresh-context iteration starts from facts instead of re-discovery.
- Escalate to a human on repeated failure of the same gate; do not retry the
  same fix a third time.
