# Clawdbot Ops Cheatsheet

## Quick Reference

| Item | Value |
|------|-------|
| **VPS IP** | `134.199.153.159` |
| **SSH** | `ssh root@134.199.153.159` |
| **Binary** | `/usr/bin/clawdbot` |
| **Config** | `/root/.clawdbot/clawdbot.json` |
| **Env** | `/root/.clawdbot/.env` |
| **Credentials** | `/root/.clawdbot/credentials/` |
| **Logs** | `/tmp/clawdbot/clawdbot-YYYY-MM-DD.log` |
| **Cron** | `/etc/cron.d/clawdbot` |
| **Systemd** | `/etc/systemd/system/clawdbot.service` |

---

## SSH Access

```bash
# From Windows/Mac
ssh root@134.199.153.159

# Phone (Termius)
Host: 134.199.153.159
User: root
Password: (stored in Termius)
```

---

## Start / Stop / Restart

**NOTE:** No pm2 on this server. Clawdbot runs as a binary with systemd + cron.

```bash
# Stop clawdbot
systemctl stop clawdbot
rm /etc/cron.d/clawdbot      # Remove cron or it respawns
pkill -9 -f clawdbot

# Start clawdbot
systemctl start clawdbot

# Restart clawdbot
systemctl restart clawdbot

# Check status
systemctl status clawdbot
ps aux | grep claw
```

### Full Kill (when it keeps respawning)

```bash
# 1. Disable systemd service
systemctl stop clawdbot
systemctl disable clawdbot

# 2. Remove cron (this is what keeps respawning it)
rm /etc/cron.d/clawdbot

# 3. Kill all processes
pkill -9 -f clawdbot

# 4. Verify dead
ps aux | grep claw
```

---

## Config Files

### Main Config: `/root/.clawdbot/clawdbot.json`

```bash
cat /root/.clawdbot/clawdbot.json
nano /root/.clawdbot/clawdbot.json
```

**Required sections for working config:**
```json
{
  "auth": {
    "profiles": {
      "anthropic:default": {
        "provider": "anthropic",
        "mode": "oauth"
      }
    }
  },
  "agents": {
    "defaults": {
      "models": {
        "anthropic/claude-sonnet-4-20250514": {
          "alias": "default"
        }
      }
    }
  },
  "channels": {
    "telegram": { "enabled": true },
    "slack": { "enabled": true }
  }
}
```

### Environment: `/root/.clawdbot/.env`

```bash
cat /root/.clawdbot/.env
nano /root/.clawdbot/.env
```

Contains API keys for: Slack, Growth Engine, Twilio, Notion, etc.
(See `docs/clawdbot-env-template.md` for full list - keys stored separately)

### Credentials: `/root/.clawdbot/credentials/`

```bash
ls -la /root/.clawdbot/credentials/
```

Contains:
- `telegram-allowFrom.json` - Allowed Telegram users
- `telegram-pairing.json` - Pairing requests

### Backups

```bash
ls -la /root/.clawdbot/clawdbot.json.bak*
cat /root/.clawdbot/clawdbot.json.bak.1   # Most recent backup
```

---

## Logs

```bash
# Today's log
cat /tmp/clawdbot/clawdbot-$(date +%Y-%m-%d).log

# Follow logs live
tail -f /tmp/clawdbot/clawdbot-$(date +%Y-%m-%d).log

# All logs
ls -la /tmp/clawdbot/
```

---

## Fix OAuth Expired (Anthropic)

**Error:** `OAuth token refresh failed for anthropic`

### Step 1: Stop everything

```bash
systemctl stop clawdbot
systemctl disable clawdbot
rm /etc/cron.d/clawdbot
pkill -9 -f clawdbot

# Verify stopped
ps aux | grep claw
```

### Step 2: Restore config from backup (if broken)

```bash
# Check if current config has auth section
cat /root/.clawdbot/clawdbot.json | grep -A5 '"auth"'

# If missing, restore from backup
cp /root/.clawdbot/clawdbot.json.bak.1 /root/.clawdbot/clawdbot.json
```

### Step 3: Re-authenticate with OAuth

```bash
# Start clawdbot in foreground to authenticate
clawdbot

# Or use the onboard wizard
clawdbot onboard

# Follow the URL to login with Anthropic
# Complete OAuth flow in browser
```

### Step 4: Restart service

```bash
systemctl enable clawdbot
systemctl start clawdbot

# Verify running
ps aux | grep claw
systemctl status clawdbot
```

---

## Model Selection

Available models during `clawdbot onboard`:

| Model | Context | Notes |
|-------|---------|-------|
| `anthropic/claude-opus-4-5` | 195k | Latest Opus, reasoning, most capable |
| `anthropic/claude-sonnet-4-20250514` | 200k | Fast, cheaper |
| `deepseek/deepseek-chat` | - | Requires DeepSeek provider setup |
| `deepseek/deepseek-reasoner` | - | Reasoning enabled |

---

## Adding DeepSeek Provider

1. Add API key to env:
```bash
echo 'DEEPSEEK_API_KEY=your-key' >> /root/.clawdbot/.env
```

2. Add provider to `/root/.clawdbot/clawdbot.json`:
```json
"models": {
  "providers": {
    "deepseek": {
      "baseUrl": "https://api.deepseek.com",
      "apiKey": "${DEEPSEEK_API_KEY}",
      "api": "openai-completions",
      "models": [
        { "id": "deepseek-chat", "name": "DeepSeek Chat" },
        { "id": "deepseek-reasoner", "name": "DeepSeek Reasoner" }
      ]
    }
  }
}
```

3. Restart: `systemctl restart clawdbot`

---

## Config Structure (Working Example)

A working `clawdbot.json` needs these sections:

```json
{
  "meta": { ... },
  "wizard": { ... },
  "browser": {
    "enabled": true,
    "executablePath": "/usr/bin/google-chrome-stable",
    "headless": true,
    "noSandbox": true
  },
  "auth": {
    "profiles": {
      "anthropic:default": {
        "provider": "anthropic",
        "mode": "oauth"
      }
    }
  },
  "agents": {
    "defaults": {
      "models": {
        "anthropic/claude-sonnet-4-20250514": { "alias": "default" }
      },
      "workspace": "/home/ccuser/rateright-growth",
      "maxConcurrent": 4
    }
  },
  "channels": {
    "telegram": { "enabled": true, "botToken": "..." },
    "slack": { "enabled": true, "botToken": "..." }
  },
  "gateway": {
    "port": 18789,
    "mode": "local"
  },
  "plugins": {
    "entries": {
      "telegram": { "enabled": true },
      "slack": { "enabled": true }
    }
  }
}
```

If any of these sections are missing, restore from `.bak.1`.

---

## Directory Structure

```
/root/.clawdbot/
├── clawdbot.json           # Main config
├── clawdbot.json.bak.*     # Backups (restore from .bak.1 if broken)
├── .env                    # Environment variables (API keys)
├── credentials/            # OAuth tokens, Telegram allowlist
├── agents/                 # Agent configs
├── telegram/               # Telegram state
├── memory/                 # Memory storage
├── logs/                   # Internal logs
├── cron/                   # Cron job state
├── browser/                # Browser automation state
├── google/                 # Google auth state
├── identity/               # Identity config
├── subagents/              # Subagent configs
└── devices/                # Device info

/etc/cron.d/clawdbot        # Cron job (respawns clawdbot)
/etc/systemd/system/clawdbot.service  # Systemd service
/usr/bin/clawdbot           # Binary
/tmp/clawdbot/              # Runtime logs
```

---

## Troubleshooting

### Context limit error (HTTP 400)

**Error:** `input length and max_tokens exceed context limit`

This means conversation history is too long. Fix by clearing session memory:

```bash
# Stop clawdbot
systemctl stop clawdbot

# Clear conversation memory (keeps config, credentials, .env)
rm -rf /root/.clawdbot/memory/*

# Restart
systemctl start clawdbot
```

### Clawdbot keeps respawning after kill

```bash
# Remove cron job (this is usually the culprit)
rm /etc/cron.d/clawdbot

# Disable systemd
systemctl disable clawdbot

# Then kill
pkill -9 -f clawdbot
```

### Config got corrupted/stripped

```bash
# Check if auth section exists
cat /root/.clawdbot/clawdbot.json | grep -A5 '"auth"'

# If missing, restore from backup
cp /root/.clawdbot/clawdbot.json.bak.1 /root/.clawdbot/clawdbot.json
```

### "Command not found" errors

| Command | Status |
|---------|--------|
| `pm2` | NOT installed |
| `clawd` | NOT installed (use `clawdbot`) |
| `clawdbot` | Installed at `/usr/bin/clawdbot` |
| `supervisorctl` | NOT installed |

### Check running processes

```bash
ps aux | grep claw
```

### Check what's auto-restarting it

```bash
cat /etc/cron.d/clawdbot
systemctl status clawdbot
crontab -l
```

---

## DEV vs Clawdbot (Both on same VPS)

| Item | DEV (Claude Code) | Clawdbot |
|------|-------------------|----------|
| **User** | `ccuser` | `root` |
| **Directory** | `/home/ccuser/rateright-growth` | `/root/.clawdbot/` |
| **Config** | `~/.claude/` | `/root/.clawdbot/` |
| **Command** | `claude` | `clawdbot` |
| **Process manager** | None (interactive) | systemd + cron |
| **Start** | `su - ccuser && claude` | `systemctl start clawdbot` |
| **Auth** | `/login` command | `clawdbot onboard` |

---

## Useful Commands

```bash
# SSH in
ssh root@134.199.153.159

# Check status
ps aux | grep claw
systemctl status clawdbot

# View logs
tail -f /tmp/clawdbot/clawdbot-$(date +%Y-%m-%d).log

# View config
cat /root/.clawdbot/clawdbot.json

# Check if auth section exists
cat /root/.clawdbot/clawdbot.json | grep -A5 '"auth"'

# View backups
ls -la /root/.clawdbot/clawdbot.json.bak*

# Restore from backup
cp /root/.clawdbot/clawdbot.json.bak.1 /root/.clawdbot/clawdbot.json

# Full stop (won't respawn)
systemctl stop clawdbot && systemctl disable clawdbot && rm -f /etc/cron.d/clawdbot && pkill -9 -f clawdbot

# Full start
systemctl enable clawdbot && systemctl start clawdbot

# Re-authenticate (run in foreground)
clawdbot onboard
```

---

## Related Docs

- `docs/CLAWDBOT-INTEGRATION.md` - API integration guide
- `docs/clawdbot-env-template.md` - Environment variables reference
- `docs/clawdbot-notion-skill.md` - Notion commands
- `docs/VPS-CC-CHEATSHEET.md` - DEV (Claude Code) cheatsheet

---

## Notion Integration

Clawdbot may look for `NOTION_TOKEN` but env has `NOTION_API_KEY`. Add both if needed:

```bash
# If Clawdbot can't find Notion token
echo 'NOTION_TOKEN=ntn_your-key' >> /root/.clawdbot/.env
```

Or tell Clawdbot: "Notion key is in env as NOTION_API_KEY"

---

*Last updated: 2026-02-01*
