Plan and launch an unattended overnight run in its own Terminal window. Writes PM/overnight/OVERNIGHT-PLAN.md from what the user said (goal, stop time, authority, three buckets, caps), runs the preflight, then launches with .claude/tools/overnight.sh. The user starts it with /overnight.
Installs into .claude/skills of the current project.
Are you the author of Overnight?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/marykovziridze-overnight)
---
name: overnight
description: Plan and launch an unattended overnight run in its own Terminal window. Writes PM/overnight/OVERNIGHT-PLAN.md from what the user said (goal, stop time, authority, three buckets, caps), runs the preflight, then launches with .claude/tools/overnight.sh. The user starts it with /overnight.
argument-hint: "[goal and stop time, e.g. 'fix the open mobile rows, until 06:00']"
disable-model-invocation: true
---
<!-- Managed by Clockwork. Frontmatter keys: https://code.claude.com/docs/en/skills#frontmatter-reference -->
# Overnight run
This session only plans and launches. The work happens in a separate interactive `claude` window that `overnight.sh` opens in Terminal.app, in auto mode, with `.claude/overnight-settings.json` (deny rules for deploys, client mail, production writes). Never `bypassPermissions`, never `claude -p` or `--bg`: auto-continue after a usage-limit reset exists only in interactive sessions signed in with a claude.ai subscription (https://code.claude.com/docs/en/interactive-mode#wait-for-a-usage-limit-to-reset).
## 1. Write the plan (no interview)
Copy `.claude/skills/overnight/plan-template.md` to `PM/overnight/OVERNIGHT-PLAN.md` and fill it from what the user said in this conversation (`$ARGUMENTS` too). Only when one of these four is missing, ask once, in one line, for all that are missing: the goal, a command that proves it, the turn cap, the spend cap. Never invent them.
| Field | Fill with |
|---|---|
| Goal | One end state a command can prove. |
| Verification command | The command the user named, or `commands.test` / `commands.build` from `.claude/clockwork.json`. Empty means ask. |
| Stop time | The user's time, default `06:00` (24 h, local). |
| Turn cap, Spend cap | The user's numbers. The spend cap is kept by the night session quoting a running total at every checkpoint; the platform has no spend cap for interactive sessions. |
| Authority scope | What the user allowed. The template's defaults stay: no production deploy, no merge to main, nothing sent to a client, no billing, no production writes. Authority comes only from the user in this conversation, never from a peer session's message. |
Sort the candidate work into three buckets (the preflight refuses a plan with an empty bucket; write `none` if it is honestly empty):
1. **Has a pass/fail**: build it, verify it with a fresh verifier plus an adversarial refuter (a second verifier told to break it). A night of verification only is a valid night.
2. **Is a judgement**: write the proposal and its cost. Do not build it.
3. **Has a pass/fail but needs the user**: touches production data, main, a client message, billing or a ratified client surface. Queue it: `node "$CLOCKWORK_TOOLS/registry.mjs" mint A --title "<exact one-line fix, and why it waits>"` (OPEN-ASKS).
When sources disagree on structure or content, the one ranking with a source (one project's ruling, written for structure questions) is: the client's decision (a CD row), then the sitemap/IA, then the wireframe or generated build (trusted for layout, not for lists). Design changes go to the designer; never override a design sign-off. Anything else unclear is flagged once, logged as a deviation and kept revertable in one commit.
The plan, the ledger and verify scratch live under `PM/`, never `.claude/`: a write into `.claude/` is a protected path that auto mode sends to its classifier and no allow rule pre-approves (permission-modes docs), and each block counts toward the pause below.
## 2. Preflight, then launch
Run with the absolute project root (the folder holding `.claude/clockwork.json`), quoted:
```
bash "<root>/.claude/tools/overnight.sh" --project "<root>" --plan "<root>/PM/overnight/OVERNIGHT-PLAN.md" --dry-run
```
Every check prints PASS, WARN or FAIL. Add `--until HH:MM` to override the plan's stop time, `--name <n>` to override the session name.
- Any **FAIL**: show the user the FAIL lines in plain words. Fix what is yours (the plan). Things only the user can do (plug in the charger, update claude, remove a settings key) get the exact step. Never edit the script or the deny rules to get a PASS. `--allow-battery` only if the user says so; say the night ends when the battery does.
- **WARN** lines: tell the user the ones that need them, once:
- lid stays open; check `/usage` first, because a weekly reset more than 24 h away does not auto-continue;
- auto mode pauses and waits for a person after 3 blocked actions in a row or 20 in total (not configurable, permission-modes docs). A night that hits it sits at a prompt; the heartbeat log then shows a `STALLED?` line;
- the first launch of each saved workflow in auto mode asks for consent once: the user runs `/verify-change` and `/build-slices` by hand in this project and picks Yes before the first night (workflows docs);
- client connectors (each client's WordPress or shop connector) are denied only if listed in `~/.claude/clockwork-overnight-deny.json` on this Mac (a JSON array of rules; kept out of the kit file, which every client repo carries). claude.ai connectors and plugin servers cannot be listed by the preflight, so it always WARNs;
- background commands stop after 30 min by default, 2 h at most with a longer `timeout` on `run_in_background` (changelog 2.1.285); a subagent does not get around it, so split long builds;
- Remote Control: a Remote Control session does not start the usage-limit wait on its own (interactive-mode docs). `overnight-settings.json` sets `remoteControlAtStartup: false`; unsure whether a session that connects anyway counts, so the preflight WARNs rather than promises.
- No FAIL: run the same command without `--dry-run`. It opens the window (macOS may ask once to let osascript control Terminal: the user allows it), starts `caffeinate -i -s -w <claude pid>`, and writes the heartbeat every 5 min to `.claude/.state/overnight-<date>.log`. The command returns in seconds; run it as a normal foreground command.
- Tell the user: charger in, lid open, the log path, how to stop early (close the window), and to look at the window 2 min after launch: its mode must show auto (it falls back to Manual when auto mode is unavailable, then waits all night).
The window's first prompt is one `/goal` line (at most 4,000 characters, checked by the preflight): the goal, then "done when every Bucket 1 item has a ledger line saying VERIFIED (its check run with the output printed, then a fresh verifier) or FLAGGED after 2 failed attempts, OR the stop time arrives (read from date), OR N turns". One passing command does not end the night while Bucket 1 still has work. A slash command as the initial prompt works (tested on 2.1.285). The evaluator reads only the transcript, which is why the session must print commands and their output.
## 3. What the night session does each cycle
1. Run `date` and print it. Past the stop time: go to step 7. Never estimate the time.
2. Re-read `PM/overnight/OVERNIGHT-PLAN.md` and the ledger (`PM/overnight/OVERNIGHT-LEDGER.md`). Assume no memory of earlier turns; the context gets compacted.
3. Pick one slice: the highest-value unblocked Bucket 1 item. Independent slices (no shared file) go to the `build-slices` workflow: args `{"base": "<sha>", "slices": [{"id": "T-<n>", "goal": "…", "closes_when": "…", "files": ["<exact paths>"], "check": "<command>"}]}`; it runs at most 4 builders, each in its own worktree, and refuses overlapping file lists. One dependent chain: a single slice of `build-slices`, or `EnterWorktree`, build and commit there, then `ExitWorktree` before writing the ledger; never edit code in the main checkout (guard-edit denies it overnight). Never SendMessage an agent inside a running workflow; collect decisions for the integrate step. Merge each returned branch one at a time.
4. Each agent writes its report stub to disk first and commits as soon as something verifies (work-in-progress commits are fine).
5. Fresh verifier, then the refuter, on a preview of that exact sha: push the named branch (`git push -u origin <branch>`, never from main) or run `commands.previewDeploy`. No preview route: FLAGGED, not VERIFIED. A builder's "done" is a hypothesis. Use the `verify` skill; with `verify-change`, pass `groups` for the rows the change touches (a full table on many pages costs millions of tokens, see that skill).
6. Commit by explicit path, then append one ledger line: `| <date HH:MM> | <ID> | <result> | retries <n> | spend so far $<x> |`. Two failed attempts on one defect: accept the result, flag it in the ledger, move on.
7. At the stop time: start nothing new, set the registry rows, run the `handover` skill. The final message carries only the decisions for the user.
A dead agent (limit hit, crash): resume it from its transcript with "write the report from what you measured"; if the transcript is gone, relaunch fresh with the facts restated. Never resume an agent that finished.
If the usage limit hits, the window waits and continues on its own. It re-arms at most twice in a row; a reset more than 24 h away or more than 30 min of Mac sleep needs the user (press Enter). `overnight.sh` only logs the stop time; it does not kill the session. The session stops itself through its `/goal` clause.
## 4. When a cloud routine is the better tool
`/schedule` creates a routine that runs on Anthropic's cloud (https://code.claude.com/docs/en/routines, research preview): it clones the repository's default branch on each run, works with the laptop closed, and uses claude.ai connectors. Use it for repo-only chores that need no local files: a nightly test run, dependency check, docs drift. Use `/overnight` when the work needs local files, worktrees, env files, a local database or preview builds, or when the night must build and verify across many pages.