The complete guide to ship code while you sleep
A loop is an agent that works, checks, and retries by itselfโwithout you prompting each step.
Reproduce the bug, write a failing test, fix the code, rerun the suite, repeat until itโs green. You write the cycle once and walk away.
A task is loop-ready when:
Key Takeaway: The closed loop focuses on what matters most. It improves with each pass, sharpening the result over time.
A loopโs anatomy is six parts you wire once:
The hardware, runtimes, and agents.
Parallel agents, safe collisions.
Project knowledge, active recall, every loop.
APIs, PRs, tickets, Slack.
Split the builder and reviewer into two agents.
Links the conversation; the loop never forgets.
A loop is implemented as:
# Example of loop implementation
rule = load("RULES.md")
for review in reviews:
if not maker.run(goal, rule):
checker.run(goal, review, tests)
gate.append(review.reason)
Automate the reproduce-fix-verify grind, but keep the merge yours. A good loop proposes the fix and pings you. It never ships on its own.
A loop without a gate produces slop faster. The gate is the check your work must pass before it ships and is the only thing keeping the loop well-functioning.
A loop only improves if it can carry its lessons forward and be held to them.
Your job is not only designing loops that prompt your agents. Itโs designing loops that learn from experience.
Imagine Alice, a software engineer, debugging a recurring issue in her teamโs CI pipeline. She sets up a closed loop:
Over time, Aliceโs loop evolves into a self-learning loop, reducing repetitive failures and freeing her team to focus on new features.
Aliceโs loop becomes the backbone of her teamโs productivity, shipping reliable code while they sleep.