Claude Code Automation: Let Agents Build While You Sleep

Claude Code automation that runs overnight: an autonomous Stop-hook loop, safe permission bypass, and guardrails so you wake up to progress, not chaos.

TL;DR

Claude Code automation that runs overnight needs three things: an autonomous loop so agents pick up the next task themselves (built on the Stop hook), a permission mode that skips routine approvals so they don't stall waiting for you, and guardrails — a clear escalation policy plus an audit log — so you wake up to progress, not chaos. Autonomy and guardrails are the same project, not opposites.

The dream is simple: describe what you want, close the laptop, and find it built in the morning. The reality is achievable — but only if you build the guardrails with the same care as the autonomy. An agent that never stops to ask is powerful; an agent that never stops to ask and has no boundaries is a liability. This guide shows how to set up overnight Claude Code automation that’s actually safe to leave running.

The two ingredients of autonomy

For an agent to work unattended, it has to clear two hurdles that normally require you:

  1. It can’t stop to ask permission for every action. By default an agent pauses for approval before many operations. Multiply that by a night of work and it’ll be stalled on the first prompt while you sleep.
  2. It can’t stop when a task ends. Finishing one task and going idle is the opposite of overnight progress. The agent needs to reach for the next piece of work on its own.

Solve both and you have automation. Solve them carelessly and you have a runaway. The art is solving them with the brakes already installed.

Ingredient 1 — Skip routine approvals (deliberately)

Claude Code can run in a permission mode that bypasses the approval prompt for routine actions — effectively “don’t ask me before each edit or command.” For an unattended run that’s not optional; it’s the difference between an agent that works and one that waits.

In Munder Difflin this is the auto mode toggle: when it’s on, agents are launched with --permission-mode bypassPermissions so they proceed without pausing on every step. You’ll see the exact command in the spawn dialog, so there’s no mystery about what’s being run.

The important word is deliberately. Bypassing approvals is a real grant of authority, so you pair it with the boundaries below. Turn it off when you want to confirm each action; turn it on when you’ve scoped the work and you trust the guardrails.

Ingredient 2 — The autonomous loop

The second ingredient is the loop that keeps an agent moving from one task to the next without you handing it each one. The elegant way to build it is on Claude Code’s Stop hook — the hook that fires when an agent is about to finish a turn.

The mechanism, in plain terms: when an agent tries to stop, a hook checks whether it has any unread work waiting in its inbox. If it does, the hook returns “don’t stop — here’s what’s next,” and the agent keeps going. If the inbox is empty, the hook lets it finish. Two safeguards keep this from becoming an infinite loop: a flag that prevents blocking a stop twice in a row, and a per-agent cursor so each task is surfaced exactly once. The full mechanics are in Claude Code hooks, explained.

The crucial property for overnight work: the loop is driven by a queue, not a timer. An agent continues only while it has tasks; when the work runs out, it stops cleanly instead of spinning or inventing busywork. You’re not setting a duration — you’re filling a queue and letting the team drain it.

v0.1.6 adds scheduled missions — the harness itself dispatches recurring directives to any agent on a timer you set. A 30-minute floor-check mission pointing at Michael (body: ‘Are all agents making progress? Re-engage anyone idle.’) turns the orchestrator into a self-healing system: even if the floor goes quiet, Michael wakes up, reads the hive state, and re-engages stuck agents without you touching anything.

Ingredient 3 — Guardrails (the part that makes it safe)

This is where most “let it run overnight” experiments go wrong. Autonomy is easy; bounded autonomy is the work. Four guardrails turn an unattended run from reckless to routine.

An explicit escalation policy

Decide, in writing, what the agents are not allowed to do on their own — and have those things escalate to a human queue instead of executing. A good default critical list:

  • destructive operations (anything hard to undo),
  • spending real money,
  • scope changes (work drifting from what you asked), and
  • conflicts the team can’t resolve.

In a hive, the orchestrator enforces this: routine decisions it makes itself, critical ones it routes to an approvals queue — the human-in-the-loop approvals that keep an overnight run safe. You come back in the morning to a short list of “I needed your call on these,” not a pile of irreversible actions.

Bounded scope

Don’t point an unattended team at “improve the codebase.” Give it a concrete, finishable goal: “add validation to these three forms, with tests.” Bounded scope means the queue drains to empty — which, remember, is what makes the agents stop. Unbounded scope is how you get motion without progress.

A full audit log

Every action and message should be recorded so you can reconstruct the night. A single-committer git repo doubles as that log: each coordination step is a commit you can read back in order. When you wake up, “what happened while I was out?” has a precise answer, not a guess.

Start small, then extend the leash

Run a 30-minute unattended session before you run an 8-hour one. Watch what the agents do with the autonomy you’ve granted, tighten the escalation policy where they overstepped, and only then extend the duration. Trust is earned by observation, not assumed.

A realistic overnight setup

Putting it together, a sane overnight automation looks like this:

  1. Scope a finishable goal and break it into tasks.
  2. Turn on auto mode so agents don’t stall on approvals.
  3. Let the orchestrator route the tasks into agents’ inboxes; the autonomous loop keeps them working through the queue.
  4. Keep the escalation policy tight so anything risky lands in the approvals queue instead of happening.
  5. Close the laptop. Agents drain the queue, escalate the few things that need you, and stop when the work is done.
  6. Review the audit log in the morning — and the short approvals list.

That’s automation you can actually sleep through, because the system is built to stop and ask exactly when it should. It’s the practical version of running a coordinated team while you’re away, the same muscle as running multiple Claude Code agents — just with you out of the room.

What’s still not realistic

Honesty matters here. Unattended agents are great at well-specified, bounded work and at grinding through a queue. They’re not a substitute for your judgment on ambiguous design calls, and they shouldn’t be handed open-ended mandates with money or production access. The right mental model is a diligent overnight shift with a clear ticket list and a manager who escalates — not a genie. Keep the goals concrete and the guardrails tight, and the overnight shift earns its keep.


Munder Difflin gives you everything an overnight hive needs: an autonomous Stop-hook loop, an auto mode that skips routine approvals, an orchestrator that escalates only the critical few, and a git audit log of the night. Download Munder Difflin to let a hive of Claude Code agents build while you sleep; it’s free and open source.

FAQ

How do I make Claude Code keep working without me approving every step?

Run it with a permission mode that bypasses approval prompts for routine actions, and pair that with an autonomous loop so the agent picks up the next task on its own. The safety comes from scoping what it can do and escalating the genuinely risky calls, not from approving each keystroke.

Is it safe to run AI coding agents unattended overnight?

It's safe in proportion to your guardrails. Autonomy without guardrails is how you wake up to a mess. With a clear escalation policy (destructive ops, spend, scope changes go to a human queue), bounded scope, and a full audit log, unattended runs become low-risk and productive.

What does an agent do when it runs out of work overnight?

In a well-built loop it simply stops. The autonomous loop only continues an agent while it has unread tasks in its inbox; when the queue is empty, the Stop hook lets it finish instead of spinning.