Wake Claude Code only when a shell watcher says overnight jobs are done

A Mac user generated 846 images overnight and had Claude Code build a token-free launchd watcher, so Claude woke once at the end to check the batch; it has since run more than 60 queued jobs.

Done withClaude Code· Nov 15, 2026

What they did

The author, who writes a series under the name HomoFuturus about a Mac kept on around the clock, asked Claude Code to generate about 800 images overnight and report when done. Polling with a one-minute loop woke Claude, and spent tokens, on every check, and a background watch was reaped when memory ran low. So the author had Claude write a plain shell script that counts the output files, logs each count, and drops an alarm file plus a Mac notification at the target. Claude also registered it with launchd to run every minute. Claude then waited on a sleep loop for the alarm file and was told to inspect the images once it appeared. Later Claude built a small windowless Swift supervisor app to get past macOS folder permissions, plus a queue where timed jobs such as post publishing are dropped as files.

How it went

The real run produced 846 images in one night. In a test with a fake generator, Claude woke exactly once and spotted that all six files were the same image. The scheduler has run more than 60 jobs. While debugging slow images Claude listed the memory hogs; closing two apps cut swap from 49 GB to 20 GB and time per image from 739 seconds to 100 to 160.

Worth knowing

On macOS a launchd script cannot read ~/Documents and fails silently, with find returning 0, so the author moved to a tiny app that asks for permission once. Setting CLAUDE_CODE_DISABLE_BG_SHELL_PRESSURE_REAP=1 before starting Claude stops the waiting shell from being cleaned up under memory pressure.

Try it

With Claude Code· 6 parts to fill in

I am starting a long job that writes files into [output folder]. Write a shell-only script at [script path] that counts the files, appends the time and count to a log, and when the count reaches [target number] writes an alarm file at [alarm path] and shows a desktop notification, skipping if the alarm already exists. Register it with [launchd or cron] to run every [interval]. Then wait in the background without checking in until the alarm file exists. When it does, inspect the output, tell me about any files that look wrong, and stop.

Square brackets are the parts to fill in. The prompt is ours; the story is theirs.

Where they said it

Related