# Brain:rescan

Use when project files changed since the last brain scan, CLAUDE.local.md was updated...

- Repository: https://github.com/coco-research/coco (797 stars)
- Category: AI and agents
- License: see repository
- Last updated: 2026-11-01
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add coco-research/coco --skill brain:rescan -g -a claude-code -y`
Codex: `npx skills add coco-research/coco --skill brain:rescan -g -a codex -y`
Cursor: `npx skills add coco-research/coco --skill brain:rescan -g -a cursor -y`
Gemini CLI: `npx skills add coco-research/coco --skill brain:rescan -g -a gemini-cli -y`

## Description

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).

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# /brain:rescan --- Incremental Knowledge Rescan

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

## Prerequisites

- `project_brain.db` must exist in the project folder (or parent). If not found, tell the user: "No brain DB found. Run `/brain-init` first."
- At least one project must exist in the DB.

## Procedure

### Step 1: Run the scanner

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

Check the output:
- If `is_first_scan: true` → this folder was never scanned. Tell the user and proceed with full scan.
- If `new_files: 0` and `changed_files: 0` → "Everything up to date. No changes since last scan ({last_scan})." → done.
- Otherwise, show the delta:

```
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:
- Re-read and extract entities, decisions, events
- Use `upsert_entity` so existing entities get updated rather than duplicated
- For decisions: check existing decisions in DB, only add genuinely new ones (compare decision text)

#### If memory files are new or changed:
- Read only the new/changed memory files
- Extract project decisions, system references

#### For new/changed documents and emails:
- Register as `document` entities via `upsert_entity`
- Metadata includes path, type, size

The rest: https://github.com/coco-research/coco/blob/HEAD/systems/brain/skills/brain-rescan/SKILL.md
