Night Shift
by @vardhineediganesh877-ui
Queue coding plans during the day, approve them, execute later in isolated worktrees, and inspect reports. Background agentic execution requires an explicitl...
clawhub install night-shift📖 About This Skill
name: night-shift version: 1.0.5 description: "Queue coding plans during the day, approve them, execute later in isolated worktrees, and inspect reports. Background agentic execution requires an explicitly configured non-interactive runner." metadata: { "openclaw": { "requires": { "bins": ["python3", "git"] }, "optional": { "bins": ["agent", "cursor", "claude"], "env": [ "OPENCLAW_WORKSPACE", "NIGHT_SHIFT_DATA_DIR", "NIGHT_SHIFT_MODEL", "CURSOR_CLI", "CURSOR_API_KEY", "TELEGRAM_BOT_TOKEN", "TELEGRAM_CHAT_ID", "NIGHT_SHIFT_CHAT_ID", ], }, "capabilities": [ "filesystem-read-write", "git-worktrees", "subprocess-execution", "optional-cursor-cli", "optional-claude-cli", "optional-telegram-notifications", "optional-model-provider-calls", ], }, }
Night Shift
Night Shift is an autonomous queued-execution skill for engineering work.
Instead of asking the agent to do one large coding task immediately, you build a queue of plans, review or approve them, then run them in a controlled batch window. Each plan is split into phases, executed in isolation, verified, checkpointed, and summarized in a report.
Mental model:
This is useful when you want:
When to Use
Use Night Shift when the user asks for things like:
Prefer Night Shift over immediate execution when:
Do not use Night Shift for:
Core Concepts
1. Plan
A plan is the unit of queued work. It includes:2. Phase
Each plan is split into phases. A phase has:3. Execution Method
Each phase chooses one of several execution methods:shellcursorclaude-codesubagentThis lets the framework mix deterministic shell work with agentic coding work.
4. Worktree Isolation
Each plan runs in its own git worktree underdata/night-shift/worktrees/.That means Night Shift can:
5. Verification
Phases can be checked after execution using one of several verification modes, including:files_existcheck_git_diffrun_testslint_checksmoke_testimport_checkintegration_checksnapshot_diffnone6. Reporting
After execution, Night Shift writes a report so the next interaction starts from evidence instead of guesswork.Typical Workflow
During the day
1. Add one or more plans 2. Review phases 3. Edit prompts or priorities if needed 4. Approve the plans that are safe to runAt execution time
5. Start Night Shift 6. It acquires a lock, checks budgets, creates worktrees, and executes phases 7. It verifies each phase, checkpoints progress, records failures, and logs resultsAfter execution
8. Read the report 9. Inspect worktrees or diffs 10. Merge successful work, retry failed work, or queue follow-up plansUser-Facing Commands
These are the command patterns the skill is designed around.
| Command | Purpose |
|---|---|
| plan add | Create a new plan with generated phases |
| plan steal | Queue work derived from an external repo/project |
| plan list [status] | Show plans in the queue |
| plan show # | Show full details for one plan |
| plan approve # | Approve one plan |
| plan approve all | Approve all queued plans |
| plan remove # | Remove a plan |
| plan priority # | Change priority |
| plan edit # | Refine a phase prompt |
| good night | Start execution of approved plans |
| night shift status | Show current state |
| night shift stop | Request stop / halt execution |
| night shift dry-run | Preview what would execute |
| morning | Show the latest execution report |
| night shift merge # | Merge completed plan results |
| night shift inspect # | Inspect outputs/worktree |
| night shift retry # | Retry a failed or partial plan |
If your host agent uses a different natural-language wrapper, preserve the same intent and lifecycle.
Architecture
Night Shift is split into a few major parts.
Queue and Models
models.py — core plan/phase data models and enumsqueue.py — CRUD, queue index, plan storage, approvals, updatesphase_generator.py — creates initial phases from plan inputExecution Engine
executor.py — main run loop, orchestration, locking, budget checks, reportingphase_runner.py — executes individual phases using the chosen methodsubagent_runner.py — helper for subagent-based executionSafety and Recovery
verifier.py — phase verification logiccheckpoint.py — save/resume progressfailure_memory.py — track known failures and avoid blind repetitionlock.py — prevent overlapping runsbudget.py — per-phase/per-plan/night budget trackingmemory_guard.py — watchdog for memory/process hygieneRepo / Git Operations
git_manager.py — worktree setup, commit/reset helpersVisibility and Operations
reporter.py — morning-style summariesmonitor.py — notifications and health checkswatchdog.py — execution monitoringstatus.py — status helperscron_trigger.sh / ns-control.sh — optional shell wrappersOptional Extensions
Thebmad_*.py files are advanced helpers for richer planning/PRD flows. They are not required for the core Night Shift lifecycle.Execution Flow
A typical run looks like this:
1. Preflight - confirm no conflicting lock - load queue - check for approved plans - initialize budget / logs / monitors
2. Plan selection - choose approved plans in queue order / priority order
3. Per-plan setup - create or prepare isolated worktree - load checkpoint if resuming
4. Per-phase execution - build phase prompt - dispatch via the selected execution method - capture output, status, timing, and any token/cost metadata available
5. Verification - run configured verification step - mark success/failure - record failure memory if relevant
6. Persistence - update plan JSON - update queue index - save checkpoint/logs
7. Completion - finalize plan status - generate report - release lock
Safety Model
Night Shift is designed to be agentic, but not reckless.
Safety features
What this protects against
What it does not guarantee
You still need sensible approval and review.
Trust, permissions, and security scanners
Night Shift may be flagged by automated scanners because it intentionally includes operational automation primitives:
cron_trigger.sh, ns-control.sh, claude-wrapper.sh)These are expected for an unattended coding workflow, but they deserve review before use. Night Shift does not bundle private keys, hidden credentials, miners, persistence malware, or background network beacons. It only uses credentials and CLIs already available in the host environment.
Before running it in a new workspace:
1. Review queued plans and phase prompts before approval.
2. Run night shift dry-run first when available.
3. Start with a disposable test repo or branch.
4. Keep production deploys as explicit manual steps unless you intentionally add deploy phases.
5. Inspect diffs/reports before merging completed work.
For non-interactive ClawHub installs, some registries may require --force after scanner warnings. Treat that as a prompt to review the code, not as a failure signal.
Storage Layout
Night Shift stores runtime state under:
data/night-shift/
├── queue.json
├── plans/
├── worktrees/
├── execution/
├── reports/
├── failure-memory.json
├── budget.json
└── execution.log
Important files
queue.json — lightweight queue indexplans/*.json — full plan recordsworktrees// — isolated git worktree per planfailure-memory.json — prior failed step fingerprintsbudget.json — current budget trackingexecution.log — main execution logEnvironment Variables
Night Shift now supports portable configuration instead of relying on hardcoded local paths.
Core
OPENCLAW_WORKSPACE — override workspace rootNIGHT_SHIFT_MODEL — preferred model hint for model-driven helpersCURSOR_CLI — explicit path to Cursor CLI / agent binaryNotifications
NIGHT_SHIFT_CHAT_ID — target chat for Night Shift notificationsTELEGRAM_CHAT_ID — fallback notification targetTELEGRAM_BOT_TOKEN — Telegram Bot token for notificationsExecution environment
Night Shift also inherits normal environment from the host runtime, including anything needed by:If a specific execution method requires additional auth or binaries, document that at the host level.
Prerequisites
Required
data/night-shift/Optional but useful
cursor executionclaude-code executionStrongly recommended
Examples
Example 1 — queue a feature for later
User intent: > Add OAuth login to the app, but do it overnight.Night Shift flow:
1. plan add add OAuth login to the app
2. inspect generated phases
3. plan approve #
4. later: good night
Example 2 — multiple plans in one batch
User intent: > Queue three fixes now, run them all tonight.Flow: 1. add three plans 2. set priorities as needed 3. approve the safe ones 4. run Night Shift 5. read the morning report
Example 3 — dry run before execution
User intent: > Show me what would run tonight.Flow:
night shift dry-runExample 4 — retry a failed plan
User intent: > Retry the failed parser plan.Flow:
night shift retry #Example 5 — inspect before merge
User intent: > Show me what Night Shift changed before we merge.Flow:
night shift inspect #night shift merge # when satisfiedHow to Operate the Skill Well
Good plan inputs
Night Shift works best when the plan title/description is concrete.Better:
Worse:
Good approval policy
Approve unattended runs when:Avoid approval when:
Good execution method selection
Use:shell for deterministic scripted workcursor / claude-code for coding-heavy phasessubagent for delegated structured workLimitations
Be honest about these.
Troubleshooting
“No approved plans found”
Approve at least one plan before starting execution.“Night Shift already running”
A lock file or active run exists. Inspect status before forcing a restart.“Worktree creation failed”
Check:“Phase keeps failing”
“Notifications are not sent”
Check notification env vars:TELEGRAM_BOT_TOKENNIGHT_SHIFT_CHAT_ID or TELEGRAM_CHAT_ID“Cursor / Claude execution not found”
Set the expected binary path explicitly or install the required tool:CURSOR_CLIclaude-code“Execution stopped midway”
Inspect checkpoints, report output, logs, and plan status. Resume/retry instead of starting from scratch blindly.Publishing Notes
Night Shift is publishable as a power-user engineering skill.
Its strongest differentiators are:
Its biggest adoption caveats are:
That is fine. Don’t oversell it as “plug-and-play for everyone.” Sell it as a serious autonomous coding workflow for advanced users.
Files
Core engine files in scripts/ include:
models.pyqueue.pyphase_generator.pyexecutor.pyphase_runner.pyverifier.pycheckpoint.pyfailure_memory.pybudget.pygit_manager.pylock.pyreporter.pymonitor.pywatchdog.pysubagent_runner.pymemory_guard.pyOptional/advanced helpers:
bmad_batch.pybmad_context.pybmad_guardrails.pybmad_phases.pybmad_prd_evolve.pybmad_queue.pybmad_rollback.pyShell helpers:
cron_trigger.shns-control.shclaude-wrapper.shSee Also
REFERENCE.md — operational reference, setup notes, environment variables, and troubleshootingscripts/test_queue.py — queue behavior checksscripts/test_integration.py — end-to-end integration checks⚡ When to Use
💡 Examples
Example 1 — queue a feature for later
User intent: > Add OAuth login to the app, but do it overnight.Night Shift flow:
1. plan add add OAuth login to the app
2. inspect generated phases
3. plan approve #
4. later: good night
Example 2 — multiple plans in one batch
User intent: > Queue three fixes now, run them all tonight.Flow: 1. add three plans 2. set priorities as needed 3. approve the safe ones 4. run Night Shift 5. read the morning report
Example 3 — dry run before execution
User intent: > Show me what would run tonight.Flow:
night shift dry-runExample 4 — retry a failed plan
User intent: > Retry the failed parser plan.Flow:
night shift retry #Example 5 — inspect before merge
User intent: > Show me what Night Shift changed before we merge.Flow:
night shift inspect #night shift merge # when satisfied⚙️ Configuration
Required
data/night-shift/Optional but useful
cursor executionclaude-code executionStrongly recommended
📋 Tips & Best Practices
“No approved plans found”
Approve at least one plan before starting execution.“Night Shift already running”
A lock file or active run exists. Inspect status before forcing a restart.“Worktree creation failed”
Check:“Phase keeps failing”
“Notifications are not sent”
Check notification env vars:TELEGRAM_BOT_TOKENNIGHT_SHIFT_CHAT_ID or TELEGRAM_CHAT_ID“Cursor / Claude execution not found”
Set the expected binary path explicitly or install the required tool:CURSOR_CLIclaude-code