feat: Overnight Autonomous Research Agent
Overnight Autonomous Research Agent
Overview
Claude Code skill that runs autonomously overnight on a dedicated second computer (Intel i7 MacBook Pro). Takes a research direction, explores broadly, never blocks on questions (logs with best guesses), produces a morning report. Claude Code’s built-in --continue handles crash recovery. A cron wrapper + tmux keeps it running.
Implementation
Phase 1: MVP — 5 files, run it tonight
| File | Purpose |
|---|---|
.claude/skills/overnight/SKILL.md | Agent behavior and exploration loop |
scripts/overnight-launch.sh | Create workspace, start Claude Code in tmux |
scripts/overnight-restart.sh | Detect dead session, resume via --continue |
scripts/overnight-stop.sh | Graceful shutdown |
scripts/overnight-status.sh | One-screen status check |
How it works:
- Launch script starts Claude Code in a tmux session with
--dangerously-skip-permissions - Agent explores the topic, writes findings to
findings/, appends questions toquestions.md - If the session dies (rate limit, crash, network), cron detects the dead tmux session and restarts via
claude --continue - When the agent has explored all branches or time is up, it writes
report.mdand aDONEsentinel file - Restart wrapper sees
DONEorFAILEDand stops restarting
Crash recovery: claude --continue resumes the most recent session in the working directory. No custom checkpoint system needed — Claude Code persists sessions to disk natively.
Workspace structure:
~/overnight-runs/2026-03-07-2230/
CLAUDE.md ← task briefing + end time (written once at launch, auto-read by Claude)
questions.md ← append-only question log
report.md ← morning report (written during synthesis = DONE signal)
FAILED ← sentinel file if circuit breaker trips
findings/ ← one .md per exploration branch
run.log ← stdout/stderr capture
restart.log ← cron restart history
Phase 2: After first successful overnight run
Decide what to build based on what actually broke. Likely candidates:
- Iteration mode (answer questions, launch next run)
- ntfy.sh phone notifications
- Web UI behind Tailscale
- Cleanup script for old runs
Second Computer Setup (one-time, ~20 min)
1. Create dedicated user account
sudo dscl . -create /Users/overnight
sudo dscl . -create /Users/overnight UserShell /bin/zsh
sudo dscl . -create /Users/overnight RealName "Overnight Agent"
sudo dscl . -create /Users/overnight UniqueID 550
sudo dscl . -create /Users/overnight PrimaryGroupID 20
sudo dscl . -create /Users/overnight NFSHomeDirectory /Users/overnight
sudo createhomedir -c -u overnight
sudo dscl . -passwd /Users/overnight <password>
2. Prevent sleep + auto-restart after power failure
sudo pmset -c sleep 0 displaysleep 0 disksleep 0
sudo pmset -a disablesleep 1
sudo pmset -c autorestart 1 womp 1
Keep lid open, brightness at zero (clamshell is unreliable without external display).
3. Auto-login + disable FileVault
System Settings > Users & Groups > Login Options > Automatic Login > overnight
Disable FileVault (required for auto-login after power failure).
4. Disable auto-updates
sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate AutomaticallyInstallMacOSUpdates -bool false
5. SSH + Tailscale
# Enable SSH: System Settings > General > Sharing > Remote Login > ON
# On your primary computer:
ssh-copy-id overnight@<mac-ip>
# Tailscale for phone access
brew install --cask tailscale
# Install Termius on phone, add Mac's Tailscale IP
6. Install prerequisites (as overnight user)
brew install tmux jq
npm install -g @anthropic-ai/claude-code
claude # authenticate
mkdir -p ~/overnight-runs ~/scripts
7. Set up cron
crontab -e
# Add:
*/20 * * * * /Users/overnight/scripts/overnight-restart.sh >> /Users/overnight/overnight-cron.log 2>&1