---
name: bigmind-health
description: Runs a BigMind health check, closes stale sessions, vacuums old data, and reports system status. Use this skill at the start of a BigMind development session or when the system feels sluggish or has orphaned sessions.
---

# BigMind Health Check

## When to use
- Start of a BigMind development session
- Sessions appear orphaned or counts look wrong
- DB feels slow or bloated
- Monthly maintenance

## When NOT to use
- Normal work sessions (health check is optional unless something seems wrong)

## Workflow

### Step 1 — Get system stats
```
memory_get_stats()
```
Check: session count, fact count, chunk count, DB size. Flag anything that looks anomalous.

### Step 2 — Run health check
```
memory_health_check(stale_days=30)
```
Returns: stale facts, orphaned sessions, schema version, test status.

### Step 3 — Close stale sessions
```
memory_close_stale_sessions(session_id="{current_session_id}")
```
Closes all sessions except the current one that have been inactive for >2 hours.

### Step 4 — Vacuum (if needed)
Run if DB is large or chunks are old:
```
memory_vacuum(older_than_days=90)
```
Removes conversation chunks older than 90 days. Facts and session summaries are preserved.

### Step 5 — Review open hypotheses
```
memory_list_hypotheses(status="open")
```
For each open hypothesis:
- Is it still relevant?
- Can it be resolved now?
- Is confidence still accurate?

Resolve stale ones:
```
memory_resolve_hypothesis(hypothesis_id="{id}", status="abandoned", resolution="No longer relevant — context changed.")
```

### Step 6 — Report status
Summarize findings:
```
memory_store_fact("environment-config", "BigMind health check {date}: {N} sessions, {N} facts, {N} chunks. Schema v{N}. All OK / Issues found: [list].")
```

## Troubleshooting
- **DB locked:** Another IDE has BigMind open. Check `memory_get_active_sessions()` first
- **Vacuum fails:** WAL checkpoint may be pending — try `PRAGMA wal_checkpoint(TRUNCATE)` via direct SQLite if needed
- **Health check shows schema mismatch:** Run migrations manually via BigMind restart
