A multi-agent autonomous framework that lets your AI assistants work while you sleep.
AI Night Shift is an open-source framework for running multiple AI agents (Claude Code, Gemini, and more) in coordinated autonomous sessions during off-hours. Born from 30+ real production night shifts, this isn't theoretical โ it's battle-tested.
Most "autonomous agent" tools run a single agent in isolation. AI Night Shift orchestrates multiple heterogeneous AI agents working together:
| Agent | Engine | Role | Mode |
|---|---|---|---|
| Developer | Claude Code | Coding, debugging, deploying | Continuous (hours) |
| Researcher | Gemini CLI | Research, data gathering, triage | Periodic (minutes) |
| Coordinator | Any LLM | Task routing, monitoring | Heartbeat (30min) |
They communicate through shared protocols โ a file-based message queue, shared chat log, and task board integration.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ AI Night Shift โ
โ โ
โ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โ
โ โ Claude โ โ Gemini โ โHeartbeat โ โ
โ โ Code โ โ CLI โ โ Agent โ โ
โ โ โ โ โ โ โ โ
โ โ night_ โ โ patrol. โ โ heartbeatโ โ
โ โ shift.sh โ โ sh โ โ _config โ โ
โ โโโโโโฌโโโโโโ โโโโโโฌโโโโโโ โโโโโโฌโโโโโโ โ
โ โ โ โ โ
โ โโโโโโโโฌโโโโโโโโดโโโโโโโฌโโโโโโโโ โ
โ โ โ โ
โ โโโโโโโโผโโโโโโโ โโโโโโผโโโโโโ โ
โ โ night_chat โ โ bot_inboxโ โ
โ โ .md โ โ (JSON) โ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโ โ
โ โ
โ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โ
โ โ Plugins โ โDashboard โ โTemplates โ โ
โ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
git clone https://github.com/judyailab/ai-night-shift.git
cd ai-night-shift
bash install.sh# Copy the example config and edit your settings
cp config.env.example config.env
nano config.env
# Customize the night shift prompt
nano claude-code/prompt_template.txt# Run a single round to verify setup
bash claude-code/night_shift.sh --max-rounds 1# The installer adds cron jobs automatically, or set up manually:
crontab -e
# Add: 0 1 * * * cd ~/ai-night-shift && bash claude-code/wrapper.sh| Module | Description | Docs |
|---|---|---|
| Claude Code | Continuous developer sessions | README |
| Gemini | Periodic patrol and research | README |
| OpenClaw | Heartbeat coordinator pattern | README |
| Protocols | Inter-agent communication | README |
| Plugins | Extensible pre/post/task hooks | README |
| Dashboard | Visual monitoring interface | Open dashboard/index.html |
| Templates | Prompt templates by use case | 4 templates included |
| Template | Use Case |
|---|---|
development.txt |
Coding, testing, debugging |
research.txt |
Data gathering, analysis |
content.txt |
Writing, translation, SEO |
maintenance.txt |
System admin, monitoring |
Extend your night shift with pre-built or custom plugins:
# Enable a plugin
ln -s plugins/examples/system_health.sh plugins/enabled/
# List all plugins
bash plugins/plugin_loader.sh --listBuilt-in plugins: System Health, Backup, Git Commit Summary, Morning Report, De-Sloppify
Open dashboard/index.html in a browser. Drag and drop your report files to visualize:
- Agent activity and status
- Round-by-round timeline
- Night chat messages
- System health metrics
The night shift runner is agent-agnostic. Switch agents with one config change:
# In config.env
AGENT_ADAPTER=claude-code # default
# AGENT_ADAPTER=codex-cli # OpenAI Codex CLI
# AGENT_ADAPTER=aider # Aider
# AGENT_ADAPTER=custom # Your own (copy adapters/custom.sh)Or via CLI flag:
bash claude-code/night_shift.sh --adapter codex-cliCreate your own adapter: copy adapters/custom.sh, implement 5 functions, done. See adapters/ for details.
The most common pitfall: your agent stops mid-task and waits for confirmation that never comes.
All included templates have an Autonomy Rules block that prevents this:
- Never ask for confirmation โ decide and execute
- Never wait for user input โ choose the safest option and proceed
- Never use interactive commands
- If stuck 3 times, log and move on
See docs/advanced.md for the full prompt design guide.
- Completion Signal โ agents can say "I'm done" to end the shift early
- Shared Task Notes โ cross-round context memory bridge
- De-Sloppify Pattern โ separate cleanup pass for code quality
- Anti-Pattern Guide โ avoid common autonomous loop pitfalls
- Bash 4+ and Python 3.6+
- At least one AI CLI tool:
- Claude Code (
npm install -g @anthropic-ai/claude-code) - Gemini CLI (
npm install -g @google/gemini-cli)
- Claude Code (
- A Linux/macOS system with
cronandtimeout(GNU coreutils; macOS:brew install coreutils)
- PID locking prevents concurrent runs
- Time windows ensure shifts end on schedule
- Rate limit handling with automatic retry
- No secrets in code โ all credentials via environment variables
- Append-only communication โ agents can't delete each other's messages
- Plugin timeout โ max 5 minutes per plugin execution
See CONTRIBUTING.md for guidelines.
MIT โ Judy AI Lab
Built with real-world experience from 30+ autonomous night shifts. If your AI works harder while you sleep, you're doing it right. ๐