You start a big job, go to bed, and wake up to one of two things. Either the session stopped at 1am to ask a question, or Claude made a mess because nothing told it where to stop.
Five small pieces of text prevent both. This guide gives you all five as copy-paste text, in the order you set them up. Nothing here makes an unattended run risk-free. It lowers the risk, so start with a small job first.
Download the ZIP to get the three files as plain text, or copy the text from this page.
01 / 10
Before you start
Pick a small job for your first overnight run, one where a mistake costs you nothing. You can go bigger once you have read the morning files and trusted them.
The setup takes about ten minutes. In the order you do it:
Paste the CLAUDE.md block (never list, stuck rule, manager rule, evidence rule).
Add a hard block for anything that must never run.
Start
Claude Code in auto mode.
Set the goal.
Set the loop.
Leave the computer on.
02 / 10
1. Set a goal with proof
The /goal command tells the session what "done" looks like. After every turn, a separate small model checks whether the condition is true. If it is not, Claude keeps going. So the session starts the work and also knows when to end it.
That checker reads only what Claude has shown in the chat. So demand evidence of completion. Without it, the checker can only take Claude's word. The official page is the /goal docs.
Fill in the angle brackets and paste this into Claude Code:
Why each part is there:
- One finished result. One measurable end state beats a list of wishes.
- Proof required.
Claude has to show a file and a line, not just say "done".
- DONE.md and QUESTIONS.md. Two files you read in the morning: what is finished, and what
Claude decided for you.
- Stop after N turns. A cap so a stuck run ends instead of running all night.
Type /goal alone to see the status. Type /goal clear to remove it.
03 / 10
2. Add a loop
The /loop command reruns your prompt on a timer, and you decide what it does each round. Use it for a heartbeat that shows progress, not to do the work. As of November 2026, the details are in the scheduled tasks docs.
Good to know about loops:
- The interval can be seconds, minutes, hours or days, such as
20mor2h. - A loop runs only while the session is open and idle. If the computer sleeps or you close the window, it stops.
- Moving the session to the background keeps
/looprunning. Type/background(or/bg) and your loop tasks carry over to a background session that runs without a terminal window. The computer still has to stay on. This comes from the Limitations section of the scheduled tasks docs. - A recurring loop expires after 7 days.
- A loop with a fixed interval is cancelled by asking
Claude to cancel it. Pressing Esc stops only a loop where Claude picks its own timing.
04 / 10
3. Write a never list
A never list is a short set of things Claude must not do while you sleep. Write down whatever your no-nos are, so it knows them.
A good starting list: no posting, no DMs, no spending money, no pushing code to live projects. Add anything else that would hurt if it happened at 3am.
The best home for it is your CLAUDE.md file, the instructions file Claude Code reads at the start of a session (how it works). This block holds the never list, the stuck rule and two more rules. Copy it into the bottom of your project's CLAUDE.md and edit the never list to fit your job.
## Overnight rules (nobody is watching, so follow these exactly) ### Never, under any circumstances - Post, publish, send or schedule anything outside this folder (no social posts, no emails, no messages, no DMs). - Spend money or start anything that costs money. - Push code to a remote, deploy, or change a live system. - Delete anything you did not create in this run. - Sign in anywhere, change passwords, or read or write secrets files. If a step would need one of these, do NOT do it. Prepare the result as a file in this folder and write the step down in QUESTIONS.md for me. ### When you are stuck or need a decision Do not stop and wait. I am asleep. Instead: 1. Write the question in QUESTIONS.md: what you needed to decide, the options, and which option you chose. 2. Choose the safest option (the one that is easiest to undo and touches the least). 3. Keep going with the rest of the work. Never guess about anything on the NEVER list. Skip it and note it. ### How to work You are the manager, not the writer. Do not write the deliverable files yourself, even small ones. For each separate deliverable, start its own sub agent (one job each, clear instructions, the result saved to a file), run independent ones at the same time, then check what comes back. You only plan, hand out the work, check it and write DONE.md and QUESTIONS.md. ### Evidence Do not say a piece of work is done without showing proof: the file path and one line from it, or the output of the command that checks it. At the end, write DONE.md listing each deliverable with its proof.
Add a lock for the things that must never run
Instructions are advice. A permission rule is a lock. For anything that must never run, add a deny rule.
Open .claude/settings.json in your project and add this line:
{ "permissions": { "deny": [ "Bash(git push *)" ] } }
A rule like this blocks matching commands before they run. It matches commands that begin with git push. A push written another way, such as git -C <folder> push, is not matched. For a firm lock, also use a hook. See Claude Code hooks that block pushes, deletes and secrets. The rules are in the permissions docs.
05 / 10
4. Say what to do when it is stuck
You want progress, but sometimes Claude needs your decision. If you are asleep, a question that waits until morning wastes the whole night.
So tell it ahead of time: pick the safest option, write the question down, and keep going. The block above does exactly that. Claude writes what it needed to decide, the options, and the one it chose into QUESTIONS.md. Safest means the option that is easiest to undo and touches the least.
The one exception is the never list. Claude never guesses about anything on it. It skips that step and notes it.
06 / 10
5. Let sub agents do the work
Claude's short-term memory is limited. That memory is called the context window. In a long job it fills up, and the session gets worse at remembering what it was doing.
The fix is to make the main session the manager. Sub agents do the work, and the main session checks the work. Each sub agent gets one job and its own fresh memory. The manager block above sets this up. See Anthropic's sub agents docs for how sub agents work.
07 / 10
Start the run
Open
Claude Code in your project folder in auto mode, so it does not stop to ask for approval at 2am. Run
claude --permission-mode auto, or press Shift+Tab to switch. It needs a supported model, and an organization can turn it off. See the permission modes docs. If you cannot use auto mode, pre-approve the commands the job needs instead.Paste your filled-in
/goal.Claude starts working at once.
Paste the
/loopline.Leave the computer on, awake and plugged in, with
Claude Code running. Background the session if you want to close the window.
08 / 10
Test it safely
Do a dry run before the real one. Pick a small job, such as writing three short files, and run the full setup.
- Check that QUESTIONS.md exists after the run, even if it is empty.
- Check that DONE.md lists each deliverable with a file path and one line from it.
- Check that PROGRESS.md has timed lines from the loop.
- Ask
Claude to try something on the never list and check that it refuses and writes it down.
- As of November 2026 the pieces were checked against the official pages and run on a small job. A full overnight run and the
/looptiming were not tested, so watch your first night closely.
09 / 10
In the morning
Read three files, in this order:
DONE.md: what is finished, with proof.QUESTIONS.md: whatClaude decided for you.
PROGRESS.md: the timeline.
Then check the proof lines yourself before you trust "done". Open the file, read the line.
Common mistakes
A vague goal. "Improve the site" gives the checker nothing to test. Write one finished result you can prove.
No turn cap. A stuck run keeps going. Add "stop after 20 turns".
A never list only in the chat. Put it in CLAUDE.md, and back it with a deny rule for the worst cases.
Letting the computer sleep. The loop stops when the computer sleeps.
Trusting "done". Read the proof lines.
Does this make an overnight run safe?
No. It lowers the risk. Start with a small job, read the morning files, then go bigger.
Will a long run use a lot of my plan?
Yes, it can. Put a turn cap in the goal and watch your usage after the first night.
Does the loop keep running if I close the window?
Not if the session closes. If you move the session to the background with /background, the loop carries over. The computer still has to be on and awake.
Why not just put the never list in the prompt?
A prompt rule is a request. A deny rule in settings is a lock. Use the CLAUDE.md block for the whole picture and a deny rule for the worst cases.
Finish line
What to do next
Paste the CLAUDE.md block and edit the never list.
Run a small job through the full setup tonight.
Read DONE.md and QUESTIONS.md in the morning.
More on routines that run without you: Plan your day with two scheduled Claude tasks and Catch a Claude routine that fails silently. All the guides are on the guides hub.
You reached the end of the guide