Maintenance Loop
A standing janitor: finishes in-progress work, tends the open PR, and runs cleanup passes when idle
Keep the current branch healthy and moving without you assigning each next step.
continuous
activity-based; idles longer when nothing is pending · Semi-autonomous
How one iteration works
discover → plan → execute → verify → escalate
- 1Discover
Scan the conversation/branch for unfinished work, then the open PR (comments, CI, conflicts).
- 2Plan
Prioritize: finish in-progress work first, then tend the PR, then opportunistic cleanup.
- 3Execute
Do exactly one bounded unit — complete a half-done change, fix a red job, or run one cleanup pass.
- 4Verify
Run tests/build for the area touched; confirm the unit is actually complete before moving on.
- 5Escalate
Don't start new initiatives or take irreversible action the transcript didn't already authorize — surface those instead.
The prompt
The tool-agnostic spec the loop runs each pass — copy it, then wire it to your tool below.
On each pass, in order: (1) continue any unfinished work from our session and finish exactly one bounded piece of it; (2) if that's done, tend the current branch's PR — review comments, failed CI, merge conflicts; (3) if everything is green and quiet, run one small cleanup pass (a focused bug hunt or a simplification) and stop if it's clean. Do not start new initiatives. Only push or delete if it directly continues work already authorized here. If there is genuinely nothing to do, say so in one line.
/loop
Continue any unfinished work from this session and finish one bounded piece. If nothing is in progress, tend the current branch's PR: review comments, failed CI, merge conflicts. If everything is green and quiet, run one small cleanup pass (focused bug hunt or simplification). Do not start new initiatives. Only push/delete to continue already-authorized work. If there's nothing to do, say so in one line.Memory contract
Working tree + open PR are the state. Reads what's uncommitted/in-progress; writes commits. No new external store.
Verification & guardrails
How it checks itself. Builds/tests the touched area each cycle and treats a unit as done only when it's green; cleanup passes are reverted if they break anything.
- Never starts new initiatives outside the in-progress scope
- Irreversible actions (push, delete) only proceed if they continue something already authorized in the transcript
- One bounded unit of work per cycle — no sprawling changes
Failure modes
- Scope creep into a refactor nobody asked for — bound it tightly
- Endless 'cleanup' churn on a quiet repo — let it idle and say 'nothing to do' instead of inventing work
Variations
- Release-branch keeper. Point loop.md at a specific release/next branch and have it keep that branch green and conflict-free.
- Cleanup-only. Strip phases 1-2 and run it purely as an idle-time simplification/bug-hunt loop.
Example run
Finished the half-written pagination handler and added its test (green). PR had no new comments, CI green. Ran a simplification pass: removed one dead helper. Nothing else pending.