
10. Work That Keeps Running After You Close the Laptop
transcript
show notes
Compares remote control, hosted cloud sessions and headless runs for what happens when the laptop closes, then walks through finishing the shared-list app's issue thirteen as a cloud job and as a headless run. It covers recovering a run that stops partway and checking background work from a phone.
This episode is narrated by AI-generated synthetic voices.
What happens when the laptop closes
Three setups behave differently. With remote control, the session keeps running on your laptop and the phone or browser only connects to it, so it stops when the laptop sleeps or goes offline. A Claude Code on the web session runs on a machine Anthropic starts with a copy of your GitHub repository, so it continues. A headless run (claude -p) lasts as long as the machine it was started on. Plan eligibility and the exact remote-control command name change between releases, so check Anthropic's documentation and your installed version.
Preparing a hosted run
The job is the shared-list app's issue thirteen, the item count in the list header. Last chapter's fix, regression test and commit were only described, so this run does them. A cloud session needs these in place:
- GitHub access through the Claude GitHub app, limited to the one repository. The session works on a new branch cloned from main.
- An environment whose setup script installs packages, installs and starts PostgreSQL, creates a test database and runs migrations. Without a database, a run can report success with nothing tested. A SessionStart hook in the repository is an alternative.
- Committed files such as CLAUDE.md, the settings, the hook, the skill and the reviewer subagent load as usual. The GitHub token does not, so the issue text goes into the request. Production secrets stay out.
- Small commits at each step, since only the branch and the conversation log outlast the session.
- A final report with test output, reviewer verdicts and open items.
The run and its checks
The request asks for a failing regression test first, then the fix, then a review against the criteria. In the illustrative result the header uses the displayed list's length. The reviewer only read code, so you still run the suite and try the app by hand. Common problems are a failed database setup and a session waiting on an approval; repeated routine approvals can become allow rules.
Headless runs and permission mode
The same job can run from a script or CI with a stated permission mode, a turn limit, an optional budget cap and JSON output. The chapter recalls an earlier news item: headless and Agent SDK runs may start in default mode under some conditions, where nobody is there to approve actions. Save the JSON, especially the session id.
When a run stops partway
After a timeout or usage limit, resume by session id on the same machine, or start a fresh session from the committed branch. Both work because of the commit after each step. Automatic retries should check for an existing branch first.
Choosing, and checking from your phone
Use remote control to watch a job, a cloud session for self-contained repository work, and headless for scripted or CI jobs. On the phone, read the last message: the named test and its result, the reviewer verdicts, then the diff for unexpected files. Add a report-format line to CLAUDE.md's definition of done.