I've run Claude Code sessions overnight — start a task at 11pm, check the result in the morning. Here's what I've learned about making it work.
What makes overnight sessions succeed
Clear, atomic task definition. "Implement the CSV export feature for the admin dashboard" is a better overnight task than "work on the admin dashboard." Specific scope means Claude knows when it's done.
Concrete done criteria. Add to the task prompt: "Done when: the export button works, the CSV format matches the spec in docs/csv-format.md, and all tests pass." Claude checks itself against these.
No decisions requiring your input. If Claude hits an ambiguous choice and stops to ask, your overnight session halted hours ago. Pre-answer the choices you can predict. "If the library doesn't support X, use Y instead."
A test suite that confirms correctness. In the morning, tests passing is the signal. Without tests, you have no way to know if the output is right.
What breaks overnight sessions
Container restarts. Containers can be killed unexpectedly. A state file in tasks/current-task.md lets a restarted session recover context. Without it, the session restarts from scratch.
Tasks that need browsing or external APIs. If the task hits a rate limit or a blocked URL overnight, it stalls. Keep overnight tasks self-contained within the codebase.
Open-ended tasks. "Improve the codebase" produces something but you won't know what. "Reduce test execution time by at least 20% without changing test coverage" is measurable.
The morning review checklist
- Read the diff end-to-end. Don't skim.
- Run the full test suite yourself.
- Check for any files changed outside the stated scope.
- Verify the done criteria were actually met.
Overnight sessions are high leverage when the task is right. Wrong task, wrong setup — you wake up to nothing useful or something you have to revert.
Top comments (0)