Skip to content

Instantly share code, notes, and snippets.

@bunlongheng
Created April 10, 2026 15:46
Show Gist options
  • Select an option

  • Save bunlongheng/3a4418acf8d63e2ea26647753913da15 to your computer and use it in GitHub Desktop.

Select an option

Save bunlongheng/3a4418acf8d63e2ea26647753913da15 to your computer and use it in GitHub Desktop.
24-Hour Cron Schedule - Claude Code automation pipeline

Local Apps - 24-Hour Automation Schedule

Fully autonomous infrastructure that monitors, tests, screenshots, audits, and self-heals 12+ applications around the clock. Claude Code AI agents are deployed automatically to fix crashes and flag security/performance issues.


Always Running

Frequency Job Script What It Does
Every 30s Auto-Restart server.js (built-in) Detects any down app, restarts via launchctl instantly
Every 5 min Health Check + Fix health-check-fix.sh Quick fixes first (kill stale, clear locks), then deploys one Claude Code agent per broken app to diagnose and repair

Nightly Pipeline (12 AM - 6 AM)

Time Job Script What It Does Auto-Fix?
12:00 AM Git Pull git-pull-all.sh Pulls latest code from GitHub across all 12 repos before nightly jobs begin N/A
1:00 AM Test Suite nightly-tests.sh Runs 877+ unit/integration/e2e tests across 11 repos. Any failure triggers a Claude Code agent to fix, verify, commit, and push Yes
2:00 AM Screenshots nightly-screenshots.sh Retakes all app screenshots (desktop 1920x1080 @2x, mobile 390x844 @3x) with MacBook Air and iPhone frames N/A
3:00 AM GIF Recordings nightly-gifs.sh Records 30s of real page activity per page, compresses to 5s looping HD GIF. 25 pages for 3pi via LAN, 5 parallel batches N/A
4:00 AM Deep Audit deep-audit.sh Scans for Turbopack cache corruption, native module mismatches, port conflicts, stale lock files, disk space. Fixes automatically and restarts affected apps Yes
5:00 AM Security + Performance Scan nightly-scan.sh Deploys one Claude Code agent per app to audit for hardcoded secrets, XSS/SQL injection risks, large bundle imports, missing optimizations. Flags to stickies, does NOT auto-fix No (flags only)
6:00 AM Summary Report nightly-summary.sh Aggregates results from all nightly jobs and posts a combined report to stickies N/A

Idle Hours (7 AM - 11:59 PM)

No scheduled jobs run during work hours. Only the always-running monitors (30s restart + 5 min health check) remain active.


Claude Code Agent Deployment

Trigger Budget What the Agent Does Auto-Commit?
App down after quick fix fails (5 min check) $1.00/agent Reads crash logs, checks deps/ports/modules, fixes and restarts Yes, if code changed
Test failure (1 AM) $1.00/agent Reads test output + source, fixes code or tests, verifies, pushes Yes
Security/performance scan (5 AM) $0.50/agent Scans source for vulnerabilities and performance issues, reports flags No (read-only)

Agent Guardrails

  • Maximum 3 fix attempts per agent
  • Cannot delete tests or add .skip
  • Cannot change application functionality
  • Must verify fix with npm test before committing
  • Restricted tools: Bash, Edit, Read, Write, Glob, Grep only
  • Security/performance agents are read-only (no writes)

Monitored Applications

App Port Path Test Count
bheng 3000 /Users/bheng/Sites/bheng 172 (153 unit + 19 e2e)
tools 3001 /Users/bheng/Sites/tools 16
diagrams 3002 /Users/bheng/Sites/diagrams 10
claude 3003 /Users/bheng/Sites/claude 11
3pi 3333 /Users/bheng/Sites/3pi 10
3pi-poc 3334 /Users/bheng/Sites/3pi-poc 9
stickies 4444 /Users/bheng/Sites/stickies 266
vault 4445 /Users/bheng/Sites/vault 183
mindmaps 5173 /Users/bheng/Sites/mindmaps 82
safe 6100 /Users/bheng/Sites/safe 10
drop-web 3010 /Users/bheng/Sites/drop 9
drop (Electron) 4111 /Users/bheng/Sites/drop/electron Process check
drop-menu (Electron) N/A /Users/bheng/Sites/drop/electron Process check
ai-spinner (Electron) N/A /Users/bheng/Sites/streamdeck Process check
local-apps 9876 /Users/bheng/Sites/local-apps API health check

Total: 877+ tests across 11 repos


Log Files

Log Source Contents
/tmp/git-pull-all.log 12 AM Git pull results per repo
/tmp/nightly-tests.log 1 AM Test results + agent fix details
/tmp/nightly-fix-{app}.log 1 AM Per-app agent output (only on failures)
/tmp/nightly-screenshots.log 2 AM Screenshot bot output
/tmp/nightly-gifs.log 3 AM GIF recording output
/tmp/deep-audit.log 4 AM Infrastructure audit results
/tmp/nightly-scan.log 5 AM Security/performance flags
/tmp/scan-{app}.log 5 AM Per-app scan agent output
/tmp/nightly-summary.log 6 AM Aggregated summary
/tmp/health-check-fix.log Every 5 min Health check + fix results
/tmp/health-fix-{app}.log Every 5 min Per-app fix agent output (only on failures)

JSON Summaries (for dashboard integration)

File Updated Fields
/tmp/nightly-tests-summary.json 1 AM total, passed, failed, fixed
/tmp/deep-audit-summary.json 4 AM fixed, issues
/tmp/nightly-scan-summary.json 5 AM securityFlags, performanceFlags, total
/tmp/health-check-summary.json Every 5 min total, up, down, fixed

Managing Crons

# List all scheduled jobs
launchctl list | grep com.bheng

# Disable a specific job
launchctl unload ~/Library/LaunchAgents/com.bheng.{job-name}.plist

# Re-enable a specific job
launchctl load -w ~/Library/LaunchAgents/com.bheng.{job-name}.plist

# Run any job manually right now
bash ~/Sites/local-apps/scripts/{script-name}.sh

# Check latest results
cat /tmp/{log-name}.log | tail -50
cat /tmp/{summary-name}.json

Hub/Agent Roles

All nightly jobs and health check agents only run on the hub machine (Mac Mini). Agent machines (MacBook Pro) skip all scheduled jobs silently.

Configured in local-apps/machine-role.json:

{"role": "hub"}   // Mac Mini - all bots enabled
{"role": "agent"} // MacBook Pro - status reporting only
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment