Brain rescan

From coco-research/coco · View interactive version

Brain rescan is an AI agent skill from the GitHub repository coco-research/coco. Use when project files changed since the last brain scan, CLAUDE.local.md was updated, or a periodic refresh is due. Rescans incrementally, writes new entities, decisions, and documents; needs project_brain.db (run /brain-init first).

How to use this skill

Skill file

/brain:rescan --- Incremental Knowledge Rescan

Detects what changed since the last scan and updates the brain DB with new knowledge.

Prerequisites

Procedure

Step 1: Run the scanner

python3 ~/.claude/skills/brain/scripts/brain/brain_cli.py scan

Check the output:

RESCAN DELTA
============
Last scan:      {last_scan}
New files:      N
Changed files:  N
Removed files:  N
Unchanged:      N

New/changed files:
  + docs/NewDoc.html          (new)
  ~ CLAUDE.local.md           (changed)
  + emails/Latest_Thread.txt  (new)

Knowledge sources:
  CLAUDE.local.md:  found / not found (changed: yes/no)
  Memory files:     N files (N new/changed)
  Documents:        N new, N changed
  Emails:           N new, N changed

Step 2: Process only new/changed files

Follow the same extraction logic as /brain-init Step 4, but only for files in the delta:

If CLAUDE.local.md is new or changed:
If memory files are new or changed:
For new/changed documents and emails:
For removed files:

Step 3: Present extraction summary

RESCAN RESULTS
==============
Project: {name} ({slug})

New/updated entities:    N (list)
New decisions:           N (list)
New events:              N (list)
New document entities:   N (list)
Skipped (unchanged):     N files

Total proposed writes: NN

Ask: "Write to brain? [Y/n/adjust]"

Step 4: Execute writes and update manifest

Same write order as /brain-init Step 6:

  1. Entities (upsert)
  2. Relationships
  3. Decisions (dedup check)
  4. Events (dedup check)
  5. Document entities (upsert)

After all writes, sync to MemPalace and brain.json:

from brain.memory_bridge import full_sync
full_sync("project_brain.db", project_slug)

Then update the manifest:

python3 ~/.claude/skills/brain/scripts/brain/brain_cli.py scan-update

Step 5: Report

BRAIN UPDATED (rescan)
======================
Entities:      +N, ~N updated (total: N)
Decisions:     +N (total: N)
Events:        +N (total: N)
Documents:     +N (total: N)

Manifest updated: N files tracked
Next scan will only process changes after {now}.

When to use /brain-rescan vs /brain-update

| Scenario | Use |

|----------|-----|

| End of conversation session | /brain-update (extracts from conversation) |

| New files added to project folder | /brain-rescan (extracts from files) |

| Updated CLAUDE.local.md | /brain-rescan |

| First time in a project with existing brain | /brain-init (handles both init + scan) |

| Periodic refresh | /brain-rescan |

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.