A Mission Kit recipe. An unattended night of plan ticks across several repos: one fire at a time, in the order you choose, inside a time window and a budget, with a morning report that shows only what is still open when you read it.
<angle-bracket> names in this README are placeholders you fill in for your own setup. Every repo name in
the examples (acme-app, acme-api, acme/*) is fake.
Mission Kit's agent-kit countdown runs one headless plan tick per invocation and exits. That is the
right primitive, but one fire per timer per repo does not make a night. A night of six hours over five
repos wants a loop that keeps a repo going while it does work, moves on when it hits a gate or asks a
question, and stops at the window end or when the money runs out.
Everyone who wants that writes the same glue: the loop, a way to keep an API key out of logs and unit files, a nightly and monthly ceiling, a choice of model per kind of work, and a morning summary that is already stale by the time you read it. Night Shift is that glue, written once, on top of the kit's own exit codes, result line and cost ledger.
23:00 timer starts bin/night-shift window 23:00-06:00, budget 20 USD tonight / 200 this month
23:00 acme-api exit 0 ok 1.85 tick did work, same repo again
23:31 acme-api exit 0 ok 2.10
00:04 acme-api exit 5 needs-operator 0.40 "agent requested stop: which queue backend?" -> next repo
00:07 acme-app exit 2 needs-operator - gate exit pending from yesterday -> next repo
00:08 acme-docs exit 0 ok 0.60
00:21 acme-docs exit 0 ok 0.20 "plan exhausted" -> next repo
00:23 acme-inbox exit 3 broken 0.05 Circuit's Dead: no stream event for 15 min -> next repo
00:39 end: all repos visited; 7 fires
07:30 timer starts bin/night-shift-report re-checks every open item, mails the result
Each line is one agent-kit countdown --cwd <repo> --backend claude ... fire. The kit does the plan
work, the git work and the gate handling, under its own one-tick contract (it never runs /git-prod).
Night Shift only decides which repo fires next and when to stop.
- Linux or macOS.
bash(3.2 or later),git,jq, and the usual coreutils.flockonly for the cron example.ghorglab, authenticated, in the environment the timer runs in: the kit's ticks use them to open pull or merge requests.- The
claudeCLI, logged in (subscription) or with an API key (see Guards). - The Mission Kit CLI, pinned:
npm install -g @dadado/agent-kit-cli@6.25.0, installed in each repo withagent-kit install --claude, and an active plan in each repo (for example from/start-project) so the ticks have work.
git clone https://github.com/mission-kit/night-shift.git ~/night-shift
cd ~/night-shift
bash tests/run.sh # no network, no agent: a fake agent-kit stands in
mkdir -p ~/.config/night-shift
cp config.env.example ~/.config/night-shift/config.env && chmod 600 ~/.config/night-shift/config.env
cp repos.example ~/.config/night-shift/repos # then list your own clones- Give the loop its own clones. For each repo, a dedicated clone that nobody edits by hand
(countdown refuses a dirty tree, and you must not race the agent):
git clone <your-repo-url> <user-home>/night/acme-api, then mark it:git -C <user-home>/night/acme-api config night-shift.owned true. Prefer clones to worktrees: in a worktree, plaingit configwrites the shared repo config, so your own checkout would read as owned too (seedocs/config.mdfor the worktree variant). - Set the window and the budget in
config.env(NS_WINDOW_START,NS_WINDOW_END,NS_NIGHT_BUDGET_USD,NS_MONTH_BUDGET_USD,NS_TICK_BUDGET_USD). Every key:docs/config.md. - Check:
bin/night-shift --checkvalidates the config, the pinned kit version, each repo and the budget left, and fires nothing. - Install the timers from
units/: systemd user units on Linux, launchd agents on macOS, or the cron example. The operating system fires the recipe; neither Night Shift nor the kit schedules anything. - Watch the first night (see
plan-template.md, last step) before you trust it unattended.
The same steps, as a Mission Kit plan with its decision points, are in plan-template.md.
Two files, both outside any repo:
~/.config/night-shift/config.env(fromconfig.env.example,chmod 600): the window, the caps, billing and budgets, the model per task class, the pinned kit version and the report delivery hook. It is sourced as shell; the scripts refuse it when group or others can write it.~/.config/night-shift/repos(fromrepos.example): one owned clone per line, in firing order, with optionalclass=,model=andmax_fires=.
Every key, its default, the files the scripts write and the exit codes are in
docs/config.md.
Status: experimental. One supervised fire has completed a tick on a local model; no full night has run yet. Use it supervised.
Tested on 2026-11-29: Qwen3.8 27B (Q4 quantization, 256k context) on an integrated GPU, behind an
Anthropic-compatible server. The fire took a trivial to-do from pending to completed: 27 turns, 58
minutes, file written, commit merged into the pre-production branch by /git-staging, HANDOFF updated,
correct result line. claude reported 5.10 USD for it; local mode counted 0.
NS_BILLING=local points every fire at a model server on your own machine that speaks the Anthropic
Messages API (Ollama does, at http://127.0.0.1:11434). A night then costs no API spend:
NS_BILLING=local
ANTHROPIC_BASE_URL=http://127.0.0.1:11434
ANTHROPIC_AUTH_TOKEN=local # whatever the server expects; Ollama accepts calls without one
NS_MODEL_CODE=my-local-model # the server's own model names, for each class you use
ANTHROPIC_DEFAULT_HAIKU_MODEL=my-local-model
ANTHROPIC_DEFAULT_SONNET_MODEL=my-local-model
ANTHROPIC_DEFAULT_OPUS_MODEL=my-local-model
CLAUDE_CODE_SUBAGENT_MODEL=my-local-modelWhat local mode changes:
- Fail closed. The loop refuses to start without
ANTHROPIC_BASE_URL, or when it is not on127.0.0.1,localhostor[::1](NS_LOCAL_REMOTE_OK=1allows a model server on another machine that bills nothing). The host must be exactly one of those three, with an optional numeric port: a URL with a user name or@in its host part counts as remote. Fires run withoutANTHROPIC_API_KEY. - No budgets.
claudedoes not know a local model's price, so it prints a made-up one: a one-word reply from an 8B model came back as about 0.017 USD. That figure lands in the kit's cost ledger. Local mode passes no--budget-remaining, sets no per-tick cap, ignores the three budgets, logs no cost per fire, and lists its fires inlocal-fires.tsvso every spend sum (the loop,--check, the morning report) counts them as 0. The caps that still hold are the window, the fire caps and the kill switch. Outside local mode the sums fail closed instead: a fire on a modelclaudecannot price (kit 6.26.0 and later recordcost_usd: nullwithcost_usd_reportedandcost_basis: "unknown") counts at the figureclaudereported. - Model names.
NS_MODEL_TRIAGE,NS_MODEL_SYNTHESIS,NS_MODEL_CODEandmodel=take the names the server lists (ollama list).clauderesolves its own aliases (haiku,sonnet,opus) and subagent model throughANTHROPIC_DEFAULT_*_MODELandCLAUDE_CODE_SUBAGENT_MODEL; set them to a local model so no call asks the server for a Claude model it does not serve.
Coming next: the kit's own local backend (in development, not in a release yet) drives a local model
without claude in between and reports no cost by construction. Early runs of the same tick on the same
model took minutes instead of an hour. Once it ships in a kit version this recipe pins, it should replace
the gateway route described here.
Known limits, from the first tests:
- Small models cannot do a tick. On a real fire (2026-11-28, Ollama,
llama3.1:8bwith a 32k context), the model answered the tick in one turn with no tool call: it described the steps, printedLOOP_TICK_RESULT: continueand changed nothing. The 27B model above did the same to-do with 26 tool calls. - An
okfire is not proof of work. The kit recorded that empty fire asok/completed, so the loop would fire the same repo again up to its cap. On a local model, check in the morning that the to-dos actually moved before trusting the Done section. - Context length. The
claudesystem prompt and tool list are large. Ollama picks a default context from the memory it sees (its runner started at 4096 tokens here, with context shift on, which drops the start of a longer prompt). Raise it withOLLAMA_CONTEXT_LENGTHor a model withPARAMETER num_ctx.claudereported a 1M-token window for the unknown model, so do not count on its own compaction to stay under the server's limit. - Protocol. The server must speak the Anthropic Messages API, tool use included. A server that only offers the OpenAI chat API needs a translating proxy in front of it; Night Shift does not ship one.
- Speed. A local tick is much slower than a hosted one (58 minutes for a one-line file above). Raise
NS_FIRE_WINDOW_MINandNS_STALL_MINso a slow tick is not taken for a stall.
| Piece | What it does |
|---|---|
bin/night-shift |
The linear loop. Started by the timer at the window start. Fires agent-kit countdown in each listed repo, in order; exit 0 fires the same repo again (up to its cap), an exhausted plan, exit 2, 3 or 5 move to the next repo. Ends at the window end, the night cap, an exhausted budget or the kill switch. Before each fire it sums the cost ledgers and passes --budget-remaining. One instance at a time (a lock directory). Writes one run-log line per fire. |
bin/night-shift-key |
Env-only API-key wrapper: reads the key from a mode-600 file (or the existing environment) and execs the fire with ANTHROPIC_API_KEY set for that process only. Honors the kill switch. |
bin/night-shift-report |
The morning report: done, needs you, broken, spend. Collected when it runs, not when the night ended, and drops items you resolved in between. |
units/ |
systemd user service and timer pairs for the loop and the report, an OnFailure= example, launchd agents and a cron example. All templates with placeholders. |
The kit picks a model per role (roles.worker in .cursor/context/config.json) or per plan
(worker_model in the plan front matter), and --model on a fire overrides both. Night Shift adds a
default by kind of work, set per repo in the repos list:
| Class (repos list) | Kind of work | Model | Config key | How it reaches the kit |
|---|---|---|---|---|
class=triage |
triage, classification, inbox sorting | small (for example haiku) |
NS_MODEL_TRIAGE |
countdown --model <value> |
class=synthesis |
reports, summaries, docs | mid (for example sonnet) |
NS_MODEL_SYNTHESIS |
countdown --model <value> |
class=code |
code with tests | top (for example opus) |
NS_MODEL_CODE |
countdown --model <value> |
model=<id> on the line |
anything | the one you name | - | countdown --model <id> |
| no class, no model | per plan | the plan decides | - | no --model: plan worker_model, else roles.worker.model |
Because --model beats the plan's worker_model, a repo whose plans each choose their own model should
have no class=: the loop then passes no --model and the kit's precedence (flag, then plan, then
config) applies. There is no per-plan key in Night Shift; per plan is the plan's own worker_model.
- The kit never schedules, and Night Shift never pushes. The timer you install starts the loop. Every
git action happens inside a kit tick under its contract:
/git-stagingon a diff, never/git-prod. - One fire at a time. A lock directory under
~/.local/state/night-shift/stops a second loop; a lock whose process is gone is taken over. Countdown itself refuses a pending gate exit and a dirty tree. - Only clones the loop owns. A repo must be marked with
git config night-shift.owned true, or it is skipped and reported. Lock, logs and reports live outside every repo, so the loop never dirties a tree. - Budget before every fire. Night and month spend are summed from the kit's cost ledgers across all
listed repos and passed as
--budget-remaining; the kit refuses a fire it cannot cover, and the night ends.NS_TICK_BUDGET_USDcaps each tick (AGENT_KIT_CLAUDE_MAX_BUDGET_USD). With API-key billing the loop refuses to start without a ceiling. - The API key lives in one process.
night-shift-keyreads it from a file that must be yours and mode600(or from the environment a secret manager prepared), exports it only into the process that becomes the fire, and never prints it. It is not in argv, the run log, a unit file or a repo. The kit redacts it from its own logs as well. - Subscription stays subscription. With
NS_BILLING=subscription, fires run withANTHROPIC_API_KEYremoved, so a key left in your shell does not turn a night into API spend. - Local stays local. With
NS_BILLING=local, the loop refuses an endpoint that is not on this machine unless you vouch for it, and fires run without a key (see Local model). - Kill switch.
touch ~/.config/night-shift/STOP: no further fire starts, and the key wrapper runs nothing. Remove the file to resume. - A window that holds. A fire starts only when its whole
--window-minfits before the window end, so the night never kills a tick halfway. - Headless permissions. The kit runs
claude -pticks with permissions bypassed and prompts denied (its documented headless mode). Only list repos whose plans and code you have reviewed.
The morning report (bin/night-shift-report, from its own timer) has four sections:
| Section | What lands there | What to do |
|---|---|---|
| Done | Every fire of the night that exited 0, with plan, to-do and cost. | Review the pull or merge requests the ticks opened. |
| Needs you | Repos whose last fire exited 5 (the agent asked a question) or 2 (a gate exit is pending). | Answer in the plan or HANDOFF, or triage the gate with agent-kit ground-control. A pending gate makes the next night's fire in that repo refuse at once (no agent, no cost). A question leaves no gate behind: until you answer it, the next night's first fire there will likely stop on the same question and cost one tick. |
| Broken | Exit 3 (Circuit's Dead: failure, stall, dirty tree, fetch failed), a fire with no result line, a repo that is not owned or not a repo. | Read the fire output in ~/.local/state/night-shift/fires/ and the kit's .cursor/loop-logs/countdown-*.log. |
| Spend | Tonight and this month from the cost ledgers, against your budgets, per repo; budget refusals. | Compare with your provider's usage page. |
The report re-checks each open item when it runs and drops it when the to-do is now completed or
cancelled, HANDOFF has a DONE/DECIDED line naming it, the gate exit was triaged, or every branch it
cites is merged into your pre-production branch. These checks read local files and local refs only
(NS_REPORT_FETCH=1 adds one git fetch). A squash merge is not visible to git branch --merged; the
to-do and HANDOFF checks usually cover it.
Delivery is yours: NS_REPORT_HOOK runs any command with the report file (mail, a desktop notice, a chat
webhook script). The loop's own unit can also call an OnFailure= unit when a night ends broken (exit 3)
or misconfigured (exit 1); exit 5, a repo waiting for you, is declared a success with SuccessExitStatus=5.
- Written before the kit's recurring-plan contract. Mission Kit has an open design for recurring plans (routines r2). Night Shift predates it and drives plain countdown fires from an OS timer. When that contract lands, the recipe will move onto it.
- Path claims are parked. Two workers in different worktrees of the same repo can still edit overlapping paths. The kit's lease covers one checkout. Night Shift avoids the problem by being linear (one fire at a time across all repos); a claim mechanism waits for the loop pattern to settle.
- Cost comes from the backend. The ledger holds what
claudereports; other backends record no cost, and the budget then counts them as 0. For a model it does not know,claudereports a made-up price; local mode skips those lines, while undersubscriptionorapi-keythey count at that figure, which can be above or below the real bill. - Spend outside the listed repos is invisible. Daytime runs in other clones do not count against the night or month budget unless you list those clones.
- Daylight-saving nights shift the window by an hour.
- A question can cost one tick per night. Exit 5 lands no gate, so a repo whose question you have not answered stops on it again the next night. Answer before the next window, or take the repo off the list.
- Not yet soaked. The scripts are covered by tests against a fake
agent-kit; a run of real nights on the public version is still to come.
Mission Kit is the agent harness this recipe drives: each fire is agent-kit countdown, and the plans,
gates, HANDOFF and cost ledger are the kit's. Install it at the pinned version:
npm install -g @dadado/agent-kit-cli@6.25.0
agent-kit install --claude # in each repo the loop ownsThe version is pinned on purpose; nothing from the kit is vendored or forked here. Mission Kit is installed
under its own license and is not redistributed by this repo. If the recipe hits a gap in the kit, file it
as a kit Backlog item instead of patching the kit. To adopt the recipe with an agent walking you through
the decisions, run /start-project with plan-template.md as the payload.
- The code in this repo is MIT-licensed (see
LICENSE): use it, fork it, ship it. - The Mission Kit name and the Mission Kit logo (
assets/logo.svg) are marks of Mission Kit and are not covered by the MIT license. Forks and redistributions must not use them in a way that suggests endorsement. - The mark in
assets/logo.svgis the Mission Kit mark (a white stroke), not the older Agent Kit / Startup Kit logo. - To use your own image: replace
assets/logo.svgwith any SVG (square works best). Nothing in the scripts reads it; it is shown at the top of this README (the<img>tag under the title). The product name appears in this README and in the report heading (render()inbin/night-shift-report).
bin/ night-shift (loop), night-shift-key (API-key wrapper), night-shift-report (morning report)
lib/common.sh config, repos list, window and ledger helpers shared by the three scripts
units/ systemd/, launchd/, cron/ templates
docs/config.md every config key, the repos list format, files written, exit codes
tests/ shell tests with a fake agent-kit (tests/run.sh)
scripts/ hygiene-scan.sh
assets/logo.svg the Mission Kit logo (see Trademark)
plan-template.md adopting the recipe as a Mission Kit plan for /start-project
Run bash tests/run.sh and bash scripts/hygiene-scan.sh before you push. To also check for your own
host, account and project names without committing them, list them in a file outside the repo and run
HYGIENE_DENYLIST=/path/to/denylist.txt bash scripts/hygiene-scan.sh. See SECURITY.md for how to report
a problem.
MIT, see LICENSE. The Mission Kit name and logo are excluded (see Trademark).