$npx -y skills add PaulRBerg/agent-skills --skill night-shiftAutonomous overnight codebase improvement with bounded runtime, evidence-gated changes, and verification.
| 1 | # Night Shift |
| 2 | |
| 3 | Improve a codebase autonomously within a fixed deadline, keeping only safe changes supported by concrete evidence. |
| 4 | |
| 5 | A valid run ends with verified improvements or a verified no-op. Never invoke an ask-user mechanism or end a user-facing |
| 6 | message with a question. Convert every unresolved decision into a deferred-work entry with its evidence, risk, and |
| 7 | required choice while continuing any independent safe work. |
| 8 | |
| 9 | ## Arguments |
| 10 | |
| 11 | - `path`: Optional absolute or relative path. Default to the current Git worktree root. Resolve it canonically and |
| 12 | accept it only when it is inside that worktree. |
| 13 | - `--max-runtime DURATION`: Optional positive integer followed by `m` or `h`, such as `45m` or `3h`. Default to `2h`. |
| 14 | |
| 15 | Treat an invalid path, duration, unknown option, or ambiguous positional input as a blocker. Report it and stop. |
| 16 | |
| 17 | Calculate the deadline before auditing. Reserve the final 15% for aggregate validation and reporting, clamped to 5–30 |
| 18 | minutes and never exceeding the total runtime. |
| 19 | |
| 20 | ## Session Contract |
| 21 | |
| 22 | When the client supports persistent goals, create one containing the resolved outcome, deadline, safety limits, and |
| 23 | verification bar. Keep working inline when goal mode is unavailable. |
| 24 | |
| 25 | Work in the current worktree and preserve changes that this run does not own. Local, reversible edits and |
| 26 | non-destructive validation are authorized. Do not change public contracts, commit, push, sync, deploy, release, write to |
| 27 | external systems, incur paid-service costs, change credentials or permissions, perform destructive migrations, or expand |
| 28 | scope. |
| 29 | |
| 30 | Stop when the deadline arrives, no safe candidates remain, or every remaining candidate requires a prohibited or unclear |
| 31 | decision. Enter final validation when the reserved window begins even if a change wave is unfinished. |
| 32 | |
| 33 | ## Ground the Run |
| 34 | |
| 35 | 1. Read the applicable repository instructions. Record the worktree root, starting commit, starting status, resolved |
| 36 | scope, deadline, and validation window. A dirty worktree is not a blocker; distinguish and preserve pre-existing |
| 37 | changes. |
| 38 | 2. Discover repository-defined build, test, lint, typecheck, format, and task-runner commands. Prefer the repository's |
| 39 | documented commands and inspect wrappers before running commands with unclear side effects. |
| 40 | 3. Establish baseline results for every safe, relevant check. If the baseline is red, prioritize reproducible failures |
| 41 | before discretionary improvements. When a failure needs an unclear or prohibited action, defer it and continue only |
| 42 | with independently verifiable work. |
| 43 | |
| 44 | Completion of this phase requires a recorded baseline and an ownership boundary that prevents this run from overwriting |
| 45 | unrelated edits. |
| 46 | |
| 47 | ## Audit and Rank |
| 48 | |
| 49 | Audit the resolved scope using these lenses: |
| 50 | |
| 51 | - correctness, security, reliability, error handling, and concurrency; |
| 52 | - duplication, inconsistent patterns, deep-module and interface quality, and testability; |
| 53 | - performance, dependencies, data formats and file extensions, configuration, and observability; |
| 54 | - tests, accessibility, documentation, agent context, naming, and directory structure. |
| 55 | |
| 56 | Treat source files over 1000 lines and test files over 2000 lines as discovery candidates only. Split a file only when |
| 57 | cohesion, coupling, change risk, or testability establishes a better seam; line count alone is not evidence. |
| 58 | |
| 59 | Rank candidates by impact, evidence, regression risk, isolation, and verification cost: |
| 60 | |
| 61 | - Apply reversible, behavior-preserving local improvements backed by concrete evidence. |
| 62 | - Apply dependency or framework updates, data-format or extension changes, renames, and reorganizations only when all |
| 63 | affected consumers are controlled, the migration is atomic, compatibility is demonstrable, and repository checks can |
| 64 | prove the result. |
| 65 | - Defer every candidate prohibited by the Session Contract and any work whose intended behavior is unclear. |
| 66 | |
| 67 | Do not retain a performance change without a recorded baseline metric and repeatable benchmark. |
| 68 | |
| 69 | ## Coordinate Work |
| 70 | |
| 71 | Use the smallest effective team when subagents are available, with at most five concurrent children. Otherwise execute |
| 72 | the same workflow inline. |
| 73 | |
| 74 | - Parallelize independent read-only audit lenses. |
| 75 | - Give writing agents stable IDs, dependency waves, exact non-overlapping write scopes, repository constraints, and |
| 76 | required completion evidence. |
| 77 | - Assign shared manifests, lockfiles, exports, and integration files to one sequential owner. |
| 78 | - Tell every worker that it shares the worktree, must preserve others' edits, and must not broaden scope. |
| 79 | - Reconcile each wave before starting dependents. Use a fresh-context verifier after every nontrivial wave. |
| 80 | |
| 81 | ## Execute a |