Your codebase improves while you sleep.
Night Shift scans your repositories overnight, finds lint errors, TypeScript issues, security vulnerabilities, and documentation gaps — fixes them automatically, commits each fix to its own branch, and sends you a morning summary. Self-hosted, free, runs with your own LLM.
Night Shift Architecture
┌────────────────────────────────────────────────────────────────────┐
│ COORDINATOR (cron) │
│ Runs nightly · checks RAM · creates run record · orchestrates │
└───────────┬──────────────────────────────────────┬────────────────┘
│ │
▼ ▼
┌─────────────────────┐ ┌─────────────────────────┐
│ SCANNER (per repo) │ │ WORKER POOL (parallel) │
│ │ │ │
│ • ESLint errors │ tasks │ Worker 1: lint-fix │
│ • TypeScript issues │──────────▶ │ Worker 2: security │
│ • npm audit │ (DB) │ Worker 3: type-fix │
│ • Missing tests │ │ │
│ • Thin docs │ │ Each worker: │
└──────────────────────┘ │ 1. Create branch │
│ 2. Apply fix │
│ 3. Verify (tsc) │
│ 4. Commit + push │
│ 5. Rollback on failure │
└───────────┬──────────────┘
│
┌─────────────────────────────────────┘
▼
┌─────────────────────┐ ┌─────────────────────┐
│ LESSON GENERATOR │ │ MORNING SUMMARY │
│ (optional, Pro) │ │ │
│ │ │ • ntfy notification │
│ Explains the WHY │ │ • DB summary record │
│ behind each fix │ │ • Run statistics │
└──────────────────────┘ └──────────────────────┘
| Night Shift | Devin | CodeRabbit | Sweep (dead) | |
|---|---|---|---|---|
| Cost | Free (self-hosted) | $500/mo | $15/mo+ | Shut down |
| Your data | Stays on your server | Sent to cloud | Sent to cloud | — |
| LLM choice | Ollama / Claude / GPT | Proprietary | Proprietary | — |
| Approach | Overnight batch fixes | Interactive agent | PR review only | Issue→PR |
| What it fixes | Lint, types, security, docs | Everything (slowly) | Nothing (reviews only) | Issues |
| Safety | Branch per fix, auto-rollback | Full repo access | Read-only | Full access |
| Setup | 5 minutes | Account + billing | GitHub app | — |
Night Shift is not trying to be Devin. It handles the boring, repetitive maintenance that piles up — the kind of work nobody wants to do but everybody benefits from. It runs when you're asleep, uses your own LLM, and every fix lands on its own branch for you to review.
| Category | Detection | Fix method | Verification |
|---|---|---|---|
| Lint | eslint --quiet |
eslint --fix |
Re-lint |
| Types | tsc --noEmit |
LLM-assisted patch | tsc --noEmit re-check |
| Security | npm audit (high/critical) |
npm audit fix + individual upgrades |
TypeScript + build check |
| Docs | README < 20 lines | LLM-generated expansion | Length check |
| Deps | npm outdated |
npm update (minor/patch only) |
TypeScript + Next.js build |
Every fix runs on its own branch (nightshift/lint-fix-20260801-eslint-no-unused-vars), so you always review before merging.
- Linux with bash 4+, curl, jq, python3
- PostgreSQL 13+ for task tracking
- Ollama (recommended) or Anthropic API key for LLM analysis
- Node.js repos with ESLint / TypeScript
git clone https://github.com/FvdHMBAI/nightshift.git
cd nightshift
# 1. Configure
cp config.sh config.local.sh # keep your settings separate
vim config.local.sh # add repos, DB connection, LLM
# 2. Install (creates tables, cron jobs, checks deps)
./install.sh
# 3. Test run
./coordinator.shEdit config.sh (or create config.local.sh that sources and overrides it):
# Repositories to scan (absolute paths)
REPOS=(
"$HOME/projects/my-frontend"
"$HOME/projects/my-api"
"$HOME/projects/my-backend"
)
# Database
DB_MODE="postgres" # or "docker"
DB_URL="postgresql://user:pass@localhost:5432/nightshift"
# DB_CONTAINER="my-postgres" # if mode=docker
# LLM — Ollama is default (free, local)
OLLAMA_MODEL="qwen3:8b" # any Ollama model
# ANTHROPIC_API_KEY="sk-ant-..." # optional: better type/doc fixes
# Limits
MAX_TASKS=15 # max tasks per run
MAX_WORKERS=3 # parallel workers
MAX_TASK_DURATION=7200 # 2h timeout per task
MIN_FREE_RAM_MB=3072 # abort if < 3GB free
# Notifications (ntfy.sh compatible)
# NTFY_URL="https://ntfy.sh/my-nightshift"22:00 Coordinator starts
├── Check RAM, create run record
├── For each repo:
│ ├── git fetch origin develop
│ ├── ESLint scan → findings
│ ├── TypeScript scan → findings
│ ├── npm audit → findings
│ ├── Test coverage check → findings
│ └── README length check → findings
│
├── Classify findings → tasks (low/medium/high risk)
│
├── Run workers (up to 3 parallel):
│ ├── Create nightshift/* branch
│ ├── Apply fix
│ ├── Verify (tsc --noEmit, build check)
│ ├── If broken → rollback, mark failed
│ ├── If clean → commit, push, mark completed
│ └── Generate lesson (optional)
│
└── Generate summary → DB + ntfy notification
06:00 Morning summary (catches any unfinished runs)
- Branch isolation — every fix gets its own branch. Your main/develop is never touched.
- Backup tags — created before any changes, recoverable with
git tag -l 'nightshift-backup/*'. - Compilation verification — TypeScript check after every npm change. Breaks → automatic rollback.
- Stash protection — uncommitted work is stashed before, restored after.
- RAM monitoring — stops spawning workers if memory drops below threshold.
- Task timeout — 2-hour default prevents runaway processes.
- Lockfile — prevents concurrent coordinator runs.
- Risk classification — high-risk tasks (security) are flagged, complex ones deferred to Claude.
Night Shift uses PostgreSQL to track every run, task, and generated lesson:
-- Recent runs
SELECT started_at, tasks_created, tasks_completed, tasks_failed, summary
FROM nightshift_runs ORDER BY started_at DESC LIMIT 5;
-- Failed tasks (what to investigate)
SELECT repo, category, title, error_message
FROM nightshift_tasks WHERE status = 'failed'
ORDER BY created_at DESC LIMIT 10;
-- Lessons generated
SELECT topic, concept_category, difficulty, created_at
FROM lessons ORDER BY created_at DESC LIMIT 10;Every completed fix generates a learning lesson explaining the programming concept behind the change — not just what was fixed, but why it matters. Stored in the database with topic, difficulty, code before/after, and exercises.
Works best with an Anthropic API key but falls back to Ollama.
| Variable | Default | Description |
|---|---|---|
NIGHTSHIFT_DB_URL |
postgresql://...localhost:5432/nightshift |
PostgreSQL connection |
NIGHTSHIFT_DB_MODE |
postgres |
postgres or docker |
NIGHTSHIFT_DB_CONTAINER |
— | Docker container (if mode=docker) |
NIGHTSHIFT_DB_NAME |
nightshift |
Database name (docker mode) |
NIGHTSHIFT_DB_USER |
postgres |
Database user (docker mode) |
OLLAMA_URL |
http://localhost:11434/api/generate |
Ollama endpoint |
OLLAMA_MODEL |
qwen3:8b |
Local LLM model |
ANTHROPIC_API_KEY |
— | Claude API (optional, Pro features) |
NIGHTSHIFT_CLAUDE_MODEL |
claude-sonnet-4-6 |
Claude model |
NIGHTSHIFT_NTFY_URL |
— | ntfy.sh notification URL |
NIGHTSHIFT_LOG_DIR |
/var/log/nightshift |
Log directory |
NIGHTSHIFT_LESSON_DIR |
./lessons |
Lesson output directory |
Add custom task categories by:
- Adding a scanner in
coordinator.sh→scan_repo()that outputsrepo|category|title|description - Adding a handler in
worker.sh→case "$category" in your-category) execute_your_fix && success=true ;; - That's it. The coordinator/worker/summary pipeline handles the rest.
Can it break my code? Every fix runs on its own branch. If TypeScript compilation fails after a fix, the change is rolled back automatically. Your working branches are never modified.
Does it support monorepos?
Yes. Add the monorepo root to REPOS. The scanner checks for ESLint, TypeScript, and npm audit at the configured paths.
What LLMs does it support? Any Ollama model (local, free) or Anthropic Claude (cloud, paid). The TypeScript fixer and doc generator use the LLM; lint and security fixes are deterministic tools.
How much does it cost to run? With Ollama: $0. With Claude API: typically $0.02-0.10 per run depending on findings. The system logs token usage per task.
Can I run it manually?
Yes: ./coordinator.sh runs a full cycle. ./summary-morning.sh generates/sends the summary.
MIT — see LICENSE
Built by Prompt & Build — running 13+ SaaS products with AI agents.