# BRAIN.md - External Memory System

**Purpose:** Structured external memory to reduce context window usage and improve recall accuracy.

**Rule:** If it's not in BRAIN.md, it doesn't exist. Context window is for *active* work only.

---

## 🎯 Active Projects (Top 3 Only)

*Keep only the 3 most active projects here. Archive others to memory files.*

| Project | Status | Last Update | Next Action |
|---------|--------|-------------|-------------|
| Mission Control | In Progress | 2026-02-22 | Complete Phases 6-9 |
| Gantt Board | Maintenance | 2026-02-20 | Bug fixes as needed |
| Blog Backup | Maintenance | 2026-02-18 | Daily digest running |

---

## 🧠 Key Decisions Log

*Recent architectural or strategic decisions with rationale.*

**2026-02-22: Memory Optimization Implementation**
- **Decision:** Applied Ramya's memory optimizations (BRAIN.md, write discipline, heartbeat state)
- **Rationale:** Token bloat was causing slower responses and missed context
- **Impact:** Reduced skill load, structured memory system

**2026-02-20: Mission Control Architecture**
- **Decision:** Phased approach (dashboard first, automation later)
- **Rationale:** Vox's article showed closed-loop requires solid foundation
- **Impact:** Focus on read-only Phases 6-9 before auto-proposals

---

## 📋 Recurring Patterns

*Code patterns, conventions, and templates used frequently.*

### Supabase Table Naming
```
<project>_<table> with underscores (NO hyphens)
Examples: mission_control_documents, blog_messages, heartbeat_status
```

### Project Creation Checklist
1. Check TOOLS.md for existing projects
2. Create in `/Users/mattbruce/Documents/Projects/OpenClaw/[Web|iOS]/`
3. Update TOOLS.md immediately
4. Set correct git identity (OpenClaw Bot vs Matt Bruce)

### Git Identity Rules
- **OpenClaw projects:** OpenClaw Bot / ai-agent@topdoglabs.com
- **Matt's projects:** Matt Bruce / mbrucedogs@gmail.com

---

## ⚠️ Gotchas & Lessons

*Mistakes made and how to avoid them.*

1. **Table Names:** Always use underscores, never hyphens in Supabase
2. **Gitea Server:** Runs on 192.168.1.128:3000 (NOT localhost!)
3. **Port 3000:** Reserved for Gantt Board dev (don't use for other projects)
4. **Skills Load:** 58 skills available - check SKILL.md before assuming capability

---

## 🔗 Quick Links

*Frequently accessed resources.*

- Mission Control: https://mission-control-rho-pink.vercel.app/
- Gantt Board: https://gantt-board.vercel.app
- Gitea: http://192.168.1.128:3000
- Supabase Dashboard: https://qnatchrjlpehiijwtreh.supabase.co

---

## 📝 Write Discipline

**After EVERY task, you MUST:**

1. **Log to memory file** → `memory/YYYY-MM-DD.md`
   - What was requested
   - What was decided
   - What was done

2. **If mistake made** → Append to `memory/LEARNINGS.md`
   - What went wrong
   - Why it happened
   - How to avoid next time

3. **If significant context** → Update `MEMORY.md`
   - Only during heartbeat reviews
   - Curated wisdom, not raw logs
   - Keep under 100 lines

**Remember:** Text > Brain. If you don't write it down, it dies with the session.
