---
name: close-server
description: "End-of-day server close protocol. Compresses sessions, kills sub-agents, resets floating channels, moves all agents to Sonnet, and logs the day. Trigger: 'close server', 'close for the day', 'end of day', 'wrap it up', 'goodnight', 'shutdown'."
---

# Close Server Protocol

Execute ALL steps in order. Do not skip. This is a cost-control + hygiene protocol.

---

## Step 1: Kill Sub-Agents
```
subagents action=list
```
Kill any active sub-agents. They cost money idling.

---

## Step 2: Compress Sessions
```bash
python3 scripts/core/auto-compact-sessions.py
```
Then run the session cleanup:
```bash
openclaw sessions cleanup --all-agents --enforce
```

---

## Step 3: Audit Sessions & Move to Sonnet
Run `sessions_list` with `activeMinutes=1440, messageLimit=0, limit=50`.

For any session running on Opus that shouldn't be:
```bash
session_status model="anthropic/claude-sonnet-4-6" sessionKey="<key>"
```

**Overnight model policy:** ALL agents → Sonnet 4.6. No Opus overnight. Cost too high.

---

## Step 4: Channel Scan & Reset
Run `message action=channel-list guildId=<guild_id>`.

**Check for:**
1. **Floating channels** (no `parent_id`) → move to correct category
2. **Stale project channels** (no activity >14 days) → move to 🗄️ Archive (1478350980872409212)
3. **Active work channels** → verify they're in 📍 Active Work

**Category map:**
| Category | ID | Purpose |
|----------|-----|---------|
| 📍 Active Work | 1478350974862229606 | Current projects + tasks |
| 📌 HQ | 1478350975927451808 | Management, admin, finance |
| 🏢 Curious Endeavor | 1478350976820707359 | CE brand + social |
| 📋 Projects | 1478350978221740185 | Client + internal projects |
| 🛠️ Workspace | 1478350979425505332 | Tools, dev workspace |
| 🗄️ Archive | 1478350980872409212 | Completed/dead projects |
| 🧠 Methodology | 1478406740495306825 | Skills, radar, methodology |
| CE Products | 1484222479433076957 | CE product channels |

**Floating channel destinations:**
- Agent-specific channels (gerri, etc.) → 📌 HQ
- Client/project channels → 📋 Projects
- Dead/empty channels → 🗄️ Archive

---

## Step 5: Log the Day
Write/update `memory/YYYY-MM-DD.md`:
- Work done today
- Active project state
- Decisions made
- What's blocked / waiting
- Handover for next session

---

## Step 6: Update QMD
Run: `python3 scripts/core/qmd-compact.py`

Move completed tasks to daily log. Keep QMD lean — active context only.

---

## Step 7: Confirm Close

Post to #management:
```
🌙 Server Closed — [DATE]
━━━━━━━━━━━━━━━━━━━━━━
Sub-agents killed: X
Sessions compacted: ✅
Channels tidied: X moved
All agents: Sonnet 4.6
Day logged: ✅
━━━━━━━━━━━━━━━━━━━━━━
Active overnight:
• [list any intentionally running services]
━━━━━━━━━━━━━━━━━━━━━━
Goodnight.
```

---

## Rules
- After close → heartbeat fires = HEARTBEAT_OK only. No new work.
- Services to leave running: curation-server (port 3057), staging nginx — these are infrastructure, not agents
- Kittoro stays live on eToro server — that's separate
- GitHub PAT 'dan' expiring ~Mar 25 — renew before close if it's overdue
