Let your AI work while you sleep
Free.
Before bed I give Claude Code a list of what I want built for my coding and side projects, and in the morning I wake up to new tools to test. Last night it built me a whole CRM. The trick is the permissions. Bypass everything and it can do whatever it wants. Lock it down too much and it gets stuck at 2am waiting for you to approve something, and you wake up to nothing. So I give it exact rules: it can edit files, run tests, and save its work to its own branch, and it can't delete anything, push to my main code, or touch my passwords.
What you need
- Claude Code, either the desktop app or the terminal.
- A project in git. The branches are your undo button.
- A list of things you actually want built.
Heads up: a long overnight session uses a good chunk of your usage. Start with two or three tasks.
Set the rules
Don't turn on bypass permissions. Instead, paste this into .claude/settings.json in your project folder (make the file if it isn't there):
{
"permissions": {
"defaultMode": "dontAsk",
"allow": [
"Edit",
"Write",
"Bash(npm test)",
"Bash(npm run test:*)",
"Bash(npm run build)",
"Bash(git status)",
"Bash(git diff:*)",
"Bash(git log:*)",
"Bash(git add:*)",
"Bash(git commit:*)",
"Bash(git switch:*)",
"Bash(git checkout -b:*)"
],
"deny": [
"Bash(rm:*)",
"Bash(git push:*)",
"Bash(git reset --hard:*)",
"Read(./.env)",
"Read(./.env.*)",
"Read(./secrets/**)"
]
}
}What this does:
- It can: edit files, run your tests and build, and commit to its own branches.
- It can't: delete files, push anything, wipe your work with a hard reset, or read your
.envand secrets files. - It never asks.
dontAskmeans anything not on the list gets turned down automatically, so it can't get stuck at 2am waiting on you.
If your project uses a different test command (like pytest or pnpm test), swap it in. If it needs to install packages, add "Bash(npm install:*)" to the allow list.
These rules are guardrails, not a vault, so keep real passwords and API keys out of the project folder too.
Run it somewhere that stays on
If your laptop goes to sleep, the session stops. Two ways around that:
- A desktop: run it on a computer that stays plugged in. On a Mac, run
caffeinate -iin a terminal tab so it doesn't fall asleep. - The cloud: start the session from claude.ai/code. It runs on Anthropic's machines, so you can close your laptop. Two changes for the cloud: pick Auto as the mode, since the cloud doesn't support
dontAsk, and take"Bash(git push:*)"out of the deny list, since pushing its branch to GitHub is how the work gets back to you. Commit the settings file to your repo so the cloud session can see it.
Give it the list before bed
Paste this in and swap in your tasks:
Tonight, work through these in order: 1. [first thing to build or fix] 2. [second thing] 3. [third thing] For each one, make a new branch called night/[short-name] off main. Build it, run the tests, fix what fails, and commit to that branch. Never touch main. If something gets blocked, don't keep trying. Skip that part, write down what you needed, and move on to the next task. When you're done, write MORNING.md in the project folder with what you finished, what's half done, what you skipped and why, and exactly how I should test each one.
The "skip it and move on" line is the important one. Without it, one blocked task can eat the whole night.
Test it in the morning
Paste this into the same session:
Read MORNING.md. For each branch from last night, show me what changed, start it up, and walk me through testing it step by step. Don't merge anything into main until I say so.
If you like what it built, merge the branch. If you don't, delete the branch and it's like it never happened.
Stuck?
DM me on Instagram (StilesAI). It's free, I got you.
DM @StilesAI