# VPS Claude Code Cheatsheet

## Quick Start (PowerShell)

```powershell
# SSH to VPS
ssh root@<VPS_IP>

# Switch to CC user
su - ccuser

# Start Claude Code interactively
claude

# Or run a one-liner
claude -p "your prompt here" --dangerously-skip-permissions --model sonnet
```

### Re-authenticate (when token expires)
```powershell
ssh root@<VPS_IP>
su - ccuser
claude
/login
```

### Check MCP status
```powershell
ssh root@<VPS_IP> "su - ccuser -c 'claude mcp list'"
```

### Persistent Session (keeps auth alive longer)
```powershell
# Start persistent CC session
ssh root@<VPS_IP> "~/clawd/scripts/start-cc-session.sh"

# Attach to see CC live
ssh -t root@<VPS_IP> "screen -r claude-code"
# (Ctrl+A, D to detach)

# Send command to CC without attaching
ssh root@<VPS_IP> "screen -S claude-code -X stuff 'your command here\n'"

# Check if session running
ssh root@<VPS_IP> "screen -list"
```

---

## MCP Status

| MCP | Status | Notes |
|-----|--------|-------|
| notion | ✅ Connected | Full Notion API access |
| context7 | ✅ Connected | Context management |
| supabase | ⚠️ Needs auth | Add token if needed |
| github | ❌ Not configured | Needs GitHub Copilot |
| slack | ❌ Not configured | Needs Slack OAuth |

---

## Telegram Commands (Clawdbot)

| Command | Action |
|---------|--------|
| `/brief` | COO morning brief (tasks, health, priorities) |
| `/tasks` | List pending Work Tracker tasks |
| `/run` | CC works on highest priority task |
| `/run all` | CC works through all tasks |
| `/run <id>` | CC works on specific task |
| `/cc <msg>` | Talk to CC directly |
| `/status` | Check if CC is running |
| `/stop` | Kill stuck CC process |
| `/health` | System health check |

**Automated:** Morning brief sent at 6:30am Sydney time daily.

---

## CC Slash Commands (use with `/cc`)

| Command | What it does |
|---------|--------------|
| `/cc /commit` | Auto commit with smart message |
| `/cc /commit-push-pr` | Commit + push + create PR |
| `/cc /code-review` | Multi-agent PR review |
| `/cc /clean_gone` | Delete stale branches |

---

## Ralph Loop (Autonomous Work)

```
/cc /ralph-loop "your task here" --max-iterations 10
```

CC keeps working until task complete or iteration limit hit.
Good for: fixing tests, implementing features, refactoring.

---

## Natural Language (just ask CC)

| Ask this... | What happens |
|-------------|--------------|
| "Review this PR" | Code review agents run |
| "Check test coverage" | Test analyzer runs |
| "Check for security issues" | Security scan |
| "Simplify this code" | Code simplifier |
| "Check for bugs in X" | Bug scanner |
| "Review the comments" | Comment accuracy check |

---

## Installed Plugins

| Plugin | Purpose |
|--------|---------|
| supabase | Database ops |
| github | Git/PR tools |
| slack | Slack messaging |
| commit-commands | Smart commits |
| security-guidance | Security checks |
| code-review | PR review |
| context7 | Context mgmt |
| pr-review-toolkit | Review agents |
| ralph-loop | Autonomous loops |
| frontend-design | UI patterns |

---

## Quick Examples

```bash
# Simple question
/cc what's in src/routes/calls.js?

# Code task
/cc add error handling to the SMS webhook

# Commit work
/cc /commit

# Full PR flow
/cc /commit-push-pr

# Autonomous fix
/cc /ralph-loop "fix all TypeScript errors" --max-iterations 5

# Security check
/cc check the auth middleware for vulnerabilities

# Review changes
/cc review changes in the last commit
```

---

## VPS Direct Access

```bash
# SSH to VPS
ssh root@<VPS_IP>

# Run CC as ccuser
su - ccuser
cd ~/rateright-growth
claude

# Re-auth if token expires
claude
/login
```

### Phone Access (Termius)
```
Host: <VPS_IP>
User: root
Password: (stored in Termius)
```

Quick re-auth from phone:
1. Connect via Termius
2. `su - ccuser`
3. `claude`
4. `/login`
5. Copy URL to browser on phone

---

## Troubleshooting

| Issue | Fix |
|-------|-----|
| CC not responding | `/status` then `/stop` if stuck |
| Auth expired | SSH in (or phone), run `claude` then `/login` |
| Plugin not working | Check with `/cc /plugin list` |
| Brief not working | Check cron: `crontab -l` on VPS |

### Auth Expiry Note
OAuth tokens expire after ~1 hour. Hourly cron checks and alerts via Telegram when expired. Use phone SSH for quick re-auth when you get the alert.
