Skip to content

Instantly share code, notes, and snippets.

@weisisheng
Last active March 27, 2026 12:03
Show Gist options
  • Select an option

  • Save weisisheng/9528d4bf3548fcb4f2c747acfd93a32a to your computer and use it in GitHub Desktop.

Select an option

Save weisisheng/9528d4bf3548fcb4f2c747acfd93a32a to your computer and use it in GitHub Desktop.
claude skill for working overnight when you don't have 24/7 agents, reviews code and does maintenance work.
---
name: night-shift
description: End-of-day review + autonomous overnight improvement plan. Analyzes day/week progress, identifies safe refactors, tech debt removal, and code quality improvements that can be executed while the developer sleeps.
---
Night Shift is the end-of-day handoff ritual. It reviews what shipped today and this week, then identifies and executes safe, high-confidence improvements that make the codebase materially better overnight. The goal: wake up to a codebase that's measurably closer to a 1000x product.
## Arguments
- `/night-shift` — full review + execute improvements
- `/night-shift review` — review only, no changes (dry run)
- `/night-shift status` — show what the last night shift accomplished
## Phase 1: End-of-Day Review (5 min)
### Step 1: Gather Today's + This Week's Progress (ALL in parallel)
```bash
# 1. What shipped today
git log origin/master --oneline --since="today 00:00"
# 2. What shipped this week
git log origin/master --oneline --since="last monday"
# 3. Current state — any WIP left behind?
git branch --show-current
git status --short
git stash list
# 4. Open PRs (anything waiting?)
gh pr list --author @me --state open --limit 10
# 5. CI health
gh run list --limit 5 --json status,conclusion,name,headBranch --jq '.[] | "\(.headBranch): \(.name) — \(.conclusion)"'
# 6. Open issues by priority
gh issue list --state open --limit 20 --json number,title,labels --jq '.[] | "#\(.number) \(.title) [\(.labels | map(.name) | join(","))]"'
```
### Step 2: Read Sprint Context
Read these files to understand current priorities:
- `docs/roadmap/post-launch-sprint-plan.md`
- `lib/feature-flags.ts` (what's in-progress vs shipped)
### Step 3: Output the Day/Week Review
```
## Night Shift Report: [Day, Month Date]
### Today's Shipments
- [list of commits merged to master today, grouped by feature]
### This Week's Progress
- [summary of the week's commits, PRs merged, features shipped]
- **Velocity:** [X commits, Y PRs merged, Z issues closed]
### Outstanding
- **Open PRs:** [list]
- **WIP branches:** [list or "none — clean"]
- **CI status:** [green/red]
- **Blockers for tomorrow:** [any issues that need human decision]
```
## Phase 2: System-Wide Improvement Scan (10 min)
Run these analyses in parallel using subagents:
### Agent 1: Type Safety & Lint Health
```bash
pnpm type-check 2>&1 | tail -50
pnpm lint 2>&1 | tail -50
```
Identify: type errors, lint violations, `any` types that crept in, missing return types on exported functions.
### Agent 2: Dead Code & Unused Exports
Search for:
- Unused imports (biome reports these)
- Exported functions/components with zero importers
- Files not imported anywhere
- Commented-out code blocks (>5 lines)
- `console.log` statements left in production code
### Agent 3: TODO/FIXME/HACK Audit
```bash
# Find all debt markers, excluding node_modules/.next/generated
grep -rn "TODO\|FIXME\|HACK\|XXX\|WORKAROUND" --include="*.ts" --include="*.tsx" . \
--exclude-dir=node_modules --exclude-dir=.next --exclude-dir=.claude
```
Cross-reference with `docs/tech-debt-review-*.md` to identify NEW items since last review.
### Agent 4: Dependency & Security Check
```bash
pnpm audit --prod 2>&1 | tail -30
pnpm outdated 2>&1 | head -30
```
Flag: production CVEs (not dev-only promptfoo issues per project memory), major version bumps available.
### Agent 5: Test Coverage Gaps
```bash
pnpm test --reporter=verbose 2>&1 | tail -30
```
Identify: recently changed files with no test coverage, failing tests, flaky test patterns.
### Agent 6: Performance & Bundle Analysis
```bash
pnpm build 2>&1 | grep -E "(Route|Size|First Load)" | head -30
```
Flag: routes over 200KB first load, new routes without static optimization, unnecessary client components.
## Phase 3: Prioritize & Categorize Improvements
Sort all findings into three categories:
### Safe to Auto-Fix (execute tonight)
These are changes with near-zero risk that improve code quality:
- Remove unused imports
- Remove dead/unreachable code
- Fix lint violations (formatting, naming)
- Remove `console.log` from production code
- Update simple type annotations (`any` → proper type)
- Remove commented-out code blocks
- Fix typos in comments/strings
- Update deprecated API usage (when drop-in replacement exists)
### Needs Human Review (present tomorrow)
- Refactors that change behavior (even slightly)
- Dependency major version bumps
- Dead code removal where usage is ambiguous
- TODO items that reference business decisions
- Test additions for untested critical paths
- Performance optimizations requiring architectural changes
### Strategic Improvements (add to backlog)
- Larger refactors that would take >1 hour
- New abstractions or pattern changes
- Infrastructure changes (CI, deployment, monitoring)
- Feature-level improvements
## Phase 4: Execute Safe Improvements
**STOP HERE if the user ran `/night-shift review`** — present the categorized findings and exit.
For full mode, proceed:
1. **Create a branch**: `chore/night-shift-YYYY-MM-DD`
2. **Execute safe auto-fixes** using subagents (6-10 in parallel, each in worktree isolation):
- Each agent handles one category of fixes
- Each agent runs `pnpm type-check` and `pnpm lint` after its changes
- If type-check or lint fails, the agent reverts its changes
3. **Run full quality gate**:
```bash
pnpm type-check && pnpm lint && pnpm test
```
4. **If quality gate passes**: commit with conventional commit message:
```
chore: night-shift improvements [YYYY-MM-DD]
- [list of changes made]
```
5. **Create PR** targeting master with the night shift report as the PR body
6. **Save the full report** to `docs/night-shift/YYYY-MM-DD.md`
## Phase 5: Tomorrow's Briefing
End with a concise briefing for the morning:
```
## Morning Briefing
### What Night Shift Did
- [X] [list of auto-fixes applied]
- PR: #NNN ready for review
### What Needs Your Decision
1. [Item requiring human judgment]
2. [Item requiring human judgment]
### Recommended First Task Tomorrow
**[Task name]** — [why this is highest leverage]
### Strategic Items Added to Backlog
- [item] → [suggested GitHub issue title]
```
## Constraints
- **NEVER touch feature code** — night shift only improves code quality, never changes behavior
- **NEVER modify .env files, migrations, or config** — infrastructure is off-limits
- **NEVER remove feature flags or flip them** — that's a human decision
- **NEVER modify marketing copy** — per project memory, copy changes need approval
- **NEVER add new dependencies** — only update existing ones if safe
- **Always verify with quality gates** — if `type-check`, `lint`, or `test` fails after changes, revert
- **Respect project memory** — check known accepted tech debt items before flagging them as new
- **One PR per night shift** — bundle all safe fixes into a single, reviewable PR
- **Save reports to `docs/night-shift/`** — never to `.claude/`
- **Use worktree isolation** — per project memory, NEVER share working trees between agents
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment