# Claude Code Automation Research — Best Current Setup for Rocky

> Researched: 2026-03-13
> Purpose: Replace reliance on Chat (1hr limit, 4hr cooldown) with autonomous Claude Code systems
> Save to: RateRight-HQ/05-Skills/Claude-Code-Automation-Guide.md

---

## THE PROBLEM

Rocky gets 1 hour of Chat then 4 hours locked out. During those 4 hours AND during 12-hour site days, nothing should be waiting on him. The system needs to run itself.

---

## THREE SCHEDULING OPTIONS (ranked by durability)

### 1. Desktop Scheduled Tasks (BEST for Rocky)
- **What:** Persistent tasks that survive restarts, run on a cron schedule
- **Where:** Claude Code Desktop app (must be open, computer must be awake)
- **Durability:** Survives restarts, catches up on missed tasks (checks back 7 days)
- **Setup:** Click Schedule tab → New Task → name, prompt, model, folder, frequency
- **Or:** Type /schedule in any Desktop session
- **Best for:** Morning briefs, evening prep, campaign monitoring, daily research
- **Limitation:** Computer must be on and Desktop app open

### 2. /loop Command (SESSION-SCOPED — good for active work)
- **What:** Recurring prompts within a single Claude Code session
- **Where:** Any Claude Code instance (terminal, Desktop, IDE)
- **Durability:** Dies when you exit the session. 3-day auto-expiry.
- **Setup:** `/loop 30m check campaign status and update the daily note`
- **Best for:** Monitoring during active work sessions, polling deployments, babysitting builds
- **Limitation:** Session-scoped only. Exit = all tasks gone. No catch-up for missed fires.
- **Max:** 50 tasks per session

### 3. GitHub Actions (MOST DURABLE — for critical automation)
- **What:** Cloud-hosted cron jobs that run regardless of your machine
- **Where:** GitHub's infrastructure
- **Durability:** Always on, doesn't need your computer
- **Best for:** The hostel email campaign, daily data syncs, anything that MUST run 24/7
- **Limitation:** Needs a GitHub repo and workflow file, more setup

---

## REMOTE CONTROL (control from your phone on site)

### What it does
Start a Claude Code session on your PC, then control it from your phone via the Claude iOS/Android app or claude.ai/code. Your code stays local — phone is just a window.

### Setup
```bash
claude remote-control "RateRight HQ"
# or inside an existing session:
/remote-control
# or shorter:
/rc
```

Shows a QR code — scan with phone. Session appears in Claude app with green dot.

### Make it automatic (every session)
Run `/config` in Claude Code → set "Enable Remote Control for all sessions" to true.

### Key facts
- Pro or Max plan required
- Your files never leave your machine
- Works on phone, tablet, any browser
- Full bidirectional — you can send messages, approve actions, steer work
- 10-minute network timeout — if offline >10 min, session dies (restart with `claude remote-control`)
- One session per remote connection
- Bypass permissions flag doesn't work with Remote Control yet

### Perfect for Rocky
- Start COO session at 6:30am before leaving for site
- Enable remote control
- Check on phone during lunch break
- Approve/reject agent outputs from site
- Come home to completed work

---

## RECOMMENDED SETUP FOR ROCKY

### Daily automation (Desktop Scheduled Tasks):

**Task 1: Morning Brief (6:00 AM)**
```
Read 00-Brain/ROADMAP.md and latest daily note.
Check Google Sheet hostel campaign tracker.
Check for email replies needing attention.
Write brief to 01-Daily/[today].md.
Keep under 20 lines.
```
Model: Sonnet | Folder: RateRight-HQ | Frequency: Daily 6:00 AM

**Task 2: Evening Prep (6:30 PM)**
```
Read ROADMAP.md. Prepare Window brief for Rocky.
What needs approval tonight? What's blocked on him? What completed today?
Write to 01-Daily/[today].md under ## The Window heading.
```
Model: Sonnet | Folder: RateRight-HQ | Frequency: Daily 6:30 PM

**Task 3: Campaign Monitor (every 2 hours)**
```
Run node scripts/hostel-campaign-status.js.
Flag any replies needing manual review.
Append status to 01-Daily/[today].md.
```
Model: Haiku | Folder: RateRight-HQ | Frequency: Every 2 hours

**Task 4: Agent Output Sync (every 4 hours)**
```
Check vault/09-Agent-Output/ for new files from VPS agents.
List any new outputs. Note them in daily log.
```
Model: Haiku | Folder: RateRight-HQ | Frequency: Every 4 hours

### Active session automation (/loop):

When doing a coding session at night:
```
/loop 15m check campaign replies and update sheet
```

When monitoring a deployment:
```
/loop 5m curl rateright.com.au/go and confirm 200
```

### For the email campaign specifically:

The hostel email sender should NOT be a /loop or Desktop scheduled task — it needs to run 24/7 regardless of whether Rocky's computer is on. Options:
1. **Node.js cron on VPS** (current setup via scripts/hostel-campaign.js) — runs on VPS, doesn't need Rocky's PC
2. **GitHub Actions** — runs on GitHub's infrastructure, most reliable
3. **PM2 on VPS** — add the campaign script to PM2 alongside growth-engine

Recommendation: Keep it on the VPS as a PM2 process. It's already there, COO can manage it.

### Remote Control for site days:

```bash
# Before leaving for site (5:30 AM):
cd C:\Users\mclou\RateRight-HQ
claude remote-control "RateRight HQ"
# Scan QR code with phone
# Check from site during breaks
```

Or make it automatic: run /config → Enable Remote Control for all sessions = true

---

## CONTEXT MODE (extend session life)

Install to reduce token waste:
```
claude mcp add-marketplace context-mode
```

What it does:
- Intercepts large tool outputs (web pages, file reads, search results)
- Stores them in a local SQLite database instead of dumping into context
- 99% reduction in some cases (56KB page → 299 bytes)
- Session extends from ~30 min to ~3 hours
- Tracks decisions and errors — won't repeat mistakes after compaction

Install on both HQ and COO.

---

## SELF-IMPROVING LOOP PATTERN

Each scheduled task can improve itself over time:

1. **Before running:** Read a state file from last run
2. **Do the task**
3. **After running:** Write state file with what happened, what worked, what failed
4. **Next run reads the state file** — learns from previous run

Example state file format:
```markdown
# Last Run: 2026-03-13 06:00
## Duration: 45 seconds
## What happened: Generated morning brief, 3 new replies detected
## Issues: Google Sheet API rate limited on first try, retried successfully
## Improvement: Added 2-second delay between Sheet API calls
```

This is the auto-research pattern applied to operational tasks.

---

## SETUP PROMPTS

### For COO — install Context Mode:
```
Install context-mode on both HQ and COO:
claude mcp add-marketplace context-mode
```

### For HQ — set up Desktop scheduled tasks:
```
Open Claude Code Desktop app. Create these scheduled tasks:
[paste the 4 tasks from above]
```

### For COO — set up Remote Control as default:
```
Run /config in Claude Code and set "Enable Remote Control for all sessions" to true.
Test it by running claude remote-control "RateRight HQ" and scanning the QR code with your phone.
```

### For COO — move email campaign to PM2:
```
Set up the hostel campaign sender as a PM2 process on the VPS so it runs 24/7 without needing Rocky's PC:
1. SSH into VPS
2. Create a campaign runner script that sends one email every 30 minutes
3. Register with PM2: pm2 start scripts/hostel-campaign.js --name hostel-campaign
4. pm2 save
5. Confirm it's running: pm2 status
```

---

## PRIORITY ORDER

1. Fix DMARC/SPF/DKIM (emails are bouncing — URGENT)
2. Install Context Mode (extends session life immediately)
3. Set up Remote Control (Rocky can monitor from site tomorrow)
4. Create Desktop scheduled tasks (morning brief, evening prep, campaign monitor)
5. Move email campaign to PM2 on VPS (runs without Rocky's PC)
6. Set up self-improving loop on campaign monitor (auto-learns over time)
