A free Claude Code plugin · MIT
You sleep. It works.
Claude Code stops mid-task. You ask for eight things and step away, and you come back to the four easy ones shipped, the four hard ones deferred to “a focused session” — and a question that has been waiting since 02:40. nightshift is the harness around that run: it keeps the agent working overnight until every item on the list is actually ticked.
/plugin marketplace add orwa-mahmoud/claude-nightshift
/plugin install nightshift GitHub Two commands inside Claude Code. No servers, no tokens, nothing to download.
The three nights every developer knows
Terminates prematurely
It stops after five of ten todos. The four easy items ship, wrapped in a proud little table; the hard ones “deserve a focused session.” This was the focused session.
Waiting for user input
Ten hours planned. At 02:40 it stops to ask a question. At 08:00 it is still sitting there waiting. The window is gone and the work is not done.
The review loop
“Review this” returns twenty findings. You fix them, ask again, and get twenty new ones. You spend the evening as a mailman between the model and itself.
These are filed, repeatedly: stops mid-task and fails to complete its own plan, terminates without completing all todos, no notification when it is waiting for input.
What it actually does
- Completion lives in a file, not a phrase
-
The shift ends when every
- [ ]in the punch list is ticked — per item, persistent, greppable. A Stop hook refuses to end the session while any remain, and re-states the contract each time it blocks. A crashed session resumes from the file. - Questions get parked, not asked
- Mid-shift the ask-the-user tool is denied. The question lands in a parking lot with a sensible default already chosen, and the work continues. Watching live? Answer any time and it is applied. Asleep? Review the parked calls over coffee.
- Your rules are laws, not suggestions
-
Nothing is blocked out of the box. Whatever you forbid, hooks deny
mechanically for the length of the shift:
git pushfor the night,rm -rf, commits touching a protected folder, diffs that smell like secrets, commits under the wrong identity. The agent can’t, not shouldn’t. - A stuck run is held, not sent home
- No-progress stop attempts are red-flagged in the shift log while the gate keeps the shift open — you wake to a flagged stall, not an early clock-out. Prefer a hard cap? One environment variable, and the deadline bounds the night regardless.
- Receipts, not vibes
- Timestamps, per-item commits and cycle logs, versioned in a local receipts repo that never touches your project history — ignored by default, no remote, never pushed.
When to call in the night shift
- Two days left in the cycle, most of your credit unspent. It does not roll over. Put the backlog on the punch list and let the night eat it.
- Your prototype demos well and is held together with tape. Every shortcut and mock becomes an item; you wake to the product version.
- The wall of warnings everyone scrolls past. Existing lint and type debt becomes punch-list items — accept the ones you care about, decline the rest.
- Test coverage, or a review loop that actually converges. Both ship as ready-made overnight jobs.
If you can write it as a checklist, you can hand it to the night. Build the list at your desk; arm the shift when you are leaving.
Questions
Why does Claude Code stop mid-task without completing all the todos?
The agent decides for itself when the work is done, and that judgement drifts on a long run — the easy items ship and the hard ones get deferred to "a focused session", which is the session it was already in. Instructions not to stop are just more tokens competing with everything else in context, which is why the behaviour comes back. nightshift moves the decision out of the model entirely: a Stop hook refuses to end the session while any "- [ ]" remains in the punch list, and re-states the contract every time it blocks.
How do I stop Claude Code terminating prematurely on a long task?
Put the work in a file rather than a prompt. nightshift's punch list lives at .nightshift/punch-list.md, one checkbox per task, and the clock-out gate blocks the session's exit while any box is open. Because the list is on disk and not in the context window, it survives compaction and a crash — a resumed session picks up exactly where the previous one stopped.
Can I run Claude Code overnight, unattended, while I sleep?
Yes, that is what it is built for. You write the punch list before bed; the gate holds the session open until every box is ticked, a stop-work order lands, or the deadline you set passes. A stuck run is red-flagged in the shift log and held rather than quietly clocked out, so you wake to a flagged stall instead of an early exit.
Isn't this what --dangerously-skip-permissions or auto mode already do?
No — those solve a different half of the problem, and they compose with this rather than replace it. Permission modes stop Claude Code pausing to ask you to approve a tool call. They do nothing about the agent deciding, on its own, that the work is finished when four of eight items are done, and nothing about the agent invoking the ask-the-user tool to raise a genuine design question. nightshift covers those two: the Stop hook for early exits, and denying the ask-tool mid-shift so a question at 02:40 is parked with a default instead of waiting until morning.
How do I stop Claude asking a question in the middle of the night?
During a shift the ask-the-user tool is denied outright. Instead of a session sitting idle for eight hours, the agent chooses the most sensible production-grade default, records the decision and its reasoning in a parking-lot file, and keeps working. You review the parked calls in the morning — and if you are watching live, you can answer at any time and it is applied.
Claude marks tasks complete without verifying the implementation — does this fix that?
Not on its own, and the documentation says so plainly rather than claiming otherwise. The gate checks boxes, not work: it guarantees the agent cannot quietly stop with items outstanding, not that a ticked box is truly done. What raises that bar is the item gate — your own lint, type and test commands, which must run green immediately before each item's commit — plus one conventional commit per item, so the diff behind every tick is there to review in the morning.
Is it safe to let an agent commit while I am asleep?
Nothing is blocked out of the box, and nothing is pushed on your behalf. You opt into the rules you want for the night — deny git push, fence rm -rf or terraform, protect a directory, require a commit identity, refuse a diff that matches a secret pattern — and the hooks deny them mechanically. They are pattern matches, not a sandbox: they keep a well-meaning agent from drifting, not a determined adversary out.
Does the agent verify its own work?
It certifies its own ticks, and the documentation says so plainly. The gate guarantees the agent cannot quietly stop with work outstanding; it does not guarantee that a ticked box is truly done. Item gates — your own lint, type and test commands, run green before each commit — are what raise that bar, and no-lint-no-tests is a first-class path rather than a degraded one.
Is nightshift an agent harness?
Yes — that is the category it belongs to. A harness is the layer around the model that decides when the loop ends, what the agent may touch, and what it leaves behind; harness defects, not model quality, are what most long-run failures trace back to. nightshift is the accountability half of one: the stop condition is a file rather than a phrase the model emits, permissions are denied mechanically instead of asked for, decisions are parked with a default rather than blocking on a human, and every run leaves timestamped receipts. It composes with the rest of a harness — your own gates, evals and sandboxing — rather than replacing them.
Does it work with agents other than Claude Code?
The method is plain markdown and git, so any agent can follow it. The mechanical enforcement is Claude Code-native, because hooks are. For every other agent CLI there is foreman, an outer loop that keeps re-invoking the agent until the list is clear or the deadline passes — enforcement outside the agent instead of inside it.
Wake up to finished work
Your first look in the morning is at a serious product — not a half-done prototype full of shortcuts, and not a question that waited eight hours for an answer.
Read the README on GitHub · nightshift built nightshift · More of my work