Global autonomy flag with decision log and morning report. While on, sessions never stop on AskUserQuestion or plan approval stalls: they decide with a conservative reversible default, log every choice to decision-log under night-<date> slugs, commit finished work (pushing only plain fast-forwards to the project's night-mode-push-allow list), and surface the whole batch in a morning report the next day.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Cfn Night Mode?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/masharratt-cfn-night-mode)
---
name: cfn-night-mode
description: "Global autonomy flag with decision log and morning report. While on, sessions never stop on AskUserQuestion or plan approval stalls: they decide with a conservative reversible default, log every choice to decision-log under night-<date> slugs, commit finished work (pushing only plain fast-forwards to the project's night-mode-push-allow list), and surface the whole batch in a morning report the next day."
version: 1.0.0
tags: [autonomy, hooks, guard, decisions, morning-report]
status: production
---
# Night Mode
## Contract
While the flag is on, the main chat has full autonomy: it does not stop on AskUserQuestion, EnterPlanMode, or plan approval stalls. This is the same contract as `cfn-megaplan --unattended`, applied globally: take the recorded conservative default instead of stopping; never widen scope, never loosen a boundary, never skip a bar. Night mode only removes the wait. In exchange, every autonomous decision MUST be recorded in the decision log under slug `night-<date>` so the morning report can surface the batch for review and overturn. A session without logging is a violation, not an optimization: the report prints a red flag when denies outnumber records.
## Safety floor
Autonomy NEVER covers these. They are never executed and never "decided" to execute. Each one becomes a deferred blocking decision (`--blocking --status proposed --chosen "DEFERRED: <what>"`) and work continues on a different path:
- Database destruction: DB DELETE, DROP, TRUNCATE (any unscoped destructive SQL)
- Deploys of any kind (Fly, Vercel, Supabase push, production migrations)
- `git push` outside the project's night-mode-push-allow list (plain fast-forward only; never force, delete or rewrite), `git force/reset/clean`
- Credential or secret changes, key rotation
- New Anthropic provider API calls added to project code
## Git policy
Commit finished work as you go (`git commit`). git push only to the project's night-mode-push-allow list (plain fast-forward); never force, delete or rewrite. Any other push is a morning action for a human.
The list is `<project>/.claude/night-mode-push-allow`: one `remote branch` pair per line, `#` comments allowed (example: `vps_personal main`). The guard resolves the project from the push's effective directory (`cd X && git push`, `git -C X push`) and accepts the `tools/dev/with-main-lock.sh <owner> [--] git push ...` wrapper. It blocks `-f`, `--force*`, `+refspec`, `--delete`/`-d`/`:branch`, `--mirror`/`--all`/`--tags`, a refspec writing a different branch, a bare `git push`, and any unlisted pair. A missing or unreadable list blocks every push. Fast-forward-only is enforced by git and the remote: a non-fast-forward push is rejected unless forced. Every allowed push appends a `git-push` line to `.night-mode-events.log` and shows under PUSHES in the morning report.
## Decision logging
```bash
# Normal autonomous decision (pass --status accepted for settled calls;
# the writer default is proposed, which lands the row in review queues):
bash $HOME/.claude/skills/decision-log/record.sh --slug night-$(date +%F) \
--id <D-n> --title "<the question, short>" \
--chosen "<option you picked>" --rationale "<why, one line>" --status accepted
# Safety-floor deferral (then continue on a different path):
bash $HOME/.claude/skills/decision-log/record.sh --slug night-$(date +%F) \
--id <D-n> --title "<the question, short>" \
--chosen "DEFERRED: <what you wanted>" --rationale "<why>" \
--blocking --status proposed
```
The guard hook emits ready-to-run versions of these when it blocks a question. Decision ids use the form `D$(date +%H%M%S)-$$` so same-second concurrent denies cannot overwrite each other via upsert.
**What is NOT a decision:** run summaries and status notes ("backlog run complete: 3 commits", "all workstreams landed", "morning batch answered") do not go in the ledger — they are outcomes, not forks. Put them in the events log (`.night-mode-events.log`) or the session report instead. Every ledger row must name a question that could have gone another way.
## Morning report
`report` and `off` print only a short summary (counts, two file paths, the acknowledge command) and split the overnight window into two files:
- **Important** (`$HOME/.claude/.night-mode-report-important.txt`, the session reads it): NEEDS ACTION (blocking, full cards), OPEN PROPOSALS (proposed, not blocking), auto-decisions Jev scored at or above `CFN_NIGHT_JEV_IMPORTANT_AT` (default 1.0; the session judges which matter), PUSHES, and Accountability (with a red flag when there are denies and zero logged decisions).
- **Routine** (`/tmp/night-mode-routine-<uid>.txt`): auto-decisions Jev scored lower or did not score, and best-effort `git log --since` commit evidence.
`report --full` prints both in the terminal. Jev scores each row (`jev-night-risk.sh`, idempotent per decision id); its status lines never reach stdout. Turning the flag off (`off`) writes `.night-mode-pending-review`; a fresh session then reminds about the report until `report --ack` clears the marker and truncates the events log.
## CLI reference
```bash
bash $HOME/.claude/skills/cfn-night-mode/night-mode.sh on # activate + doctor check
bash $HOME/.claude/skills/cfn-night-mode/night-mode.sh off # unlink flag, summary + report files, mark pending
bash $HOME/.claude/skills/cfn-night-mode/night-mode.sh status # flag, pending, registrations, today count
bash $HOME/.claude/skills/cfn-night-mode/night-mode.sh report [--ack] [--full] [--since YYYY-MM-DD] [--project P]
bash $HOME/.claude/skills/cfn-night-mode/night-mode.sh doctor [--install]
```
Surface night-mode decisions only when `status` says pending review: yes OR a new night's slug has rows. Historical proposed rows are not open asks.
Window precedence for `report`: `--since` > pending marker > flag start timestamp > today. State lives in `$HOME/.claude/` (dotfiles: `.night-mode-active`, `.night-mode-pending-review`, `.night-mode-events.log`) unless overridden. Test/sandbox overrides: `CFN_NIGHT_MODE_DIR`, `CFN_NIGHT_SETTINGS`, `DB_PATH`.
## Hooks
- `.claude/hooks/cfn-night-mode-guard.sh`: PreToolUse, matcher `AskUserQuestion|EnterPlanMode|ExitPlanMode|Bash`. Gates `git push` against the night-mode-push-allow list (see Git policy). Blocks questions and new plan modes with self-contained instructions (a subagent hitting the guard needs nothing else); answers ExitPlanMode with a JSON allow so a session already mid-plan when the flag flips on is not trapped. Fails open (silent exit 0) when the flag is off or jq is missing.
- `.claude/hooks/cfn-night-mode-inject.sh`: registered under SessionStart AND UserPromptSubmit. On, it injects this contract at session start (read live from this file, so no duplicated copy drifts) and a short per-turn reminder. Off with a pending marker, it emits the review reminder in the event-correct shape.
Registrations live in `~/.claude/settings.local.json` (machine-local, never committed). Install or repair with `doctor --install`; verify with plain `doctor`. Exit 1 means something is missing and is named in the output.
## Dependencies
- `bash`, GNU `date` (WSL2/GNU platform assumption)
- `jq` (hooks and settings transforms; guards fail open without it)
- `sqlite3` (decision store, same DB as decision-log)
- `$HOME/.claude/skills/decision-log/record.sh` (single writer for decisions)
## The flag file does not expire
`$HOME/.claude/.night-mode-active` holds only a timestamp and no TTL. It read
`2026-08-27T04:44:42Z` when inspected on 2026-09-02, six days stale, and was still gating
pushes and outward-facing work in every session that saw it. Check its age before treating
night mode as a live instruction rather than a leftover from a previous batch.
Decisions log through `$HOME/.claude/skills/decision-log/record.sh` (listed under
Dependencies above), which exists and works:
```bash
bash $HOME/.claude/skills/decision-log/record.sh --slug night-$(date +%F) --id D-n \
--title "..." --chosen "..." --rationale "..."
```
This skill's own directory holds only `SKILL.md` and `night-mode.sh` and has never held a
`record.sh`. A 2026-09-01 handoff claimed that file was "missing from disk" and treated
decisions as unloggable, which sent a session hunting for a script that was never there.