Scan

From BEKO2210/Firstbrain · View interactive version

Scan is an AI agent skill from the GitHub repository BEKO2210/Firstbrain. Scan the vault and rebuild cached indexes for all .md files

How to use this skill

Skill file

/scan -- Vault Scanner

Incrementally scans all vault .md files, extracts Level 1 metadata (frontmatter, wiki-links, tags, headings), and writes four cached JSON indexes to .claude/indexes/.

Usage

/scan              # Incremental scan (only re-parses changed files)
/scan --verbose    # Show per-file details (added/modified/deleted/unchanged)
/scan --full       # Force complete re-scan ignoring cached hashes

What It Does

  1. Discovers all .md files in the vault (excludes dot-directories: .claude/, .obsidian/, etc.)
  2. Compares each file's content hash against scan-state.json to detect changes
  3. Re-parses only added/modified files (or all files with --full)
  4. Writes four index files:
  1. Syncs embedding index (if @huggingface/transformers is installed):

Output

Default: One-line summary

Scanned 47 files (3 added, 2 modified, 1 deleted) in 0.8s

With --verbose: Per-file breakdown plus link/tag statistics.

With embeddings enabled:

Scanned 47 files (3 added, 2 modified, 1 deleted) in 0.8s
Embeddings: 5 updated, 1 removed (42 total)

Execution

// Synchronous (existing behavior, no embeddings):
const { scan } = require('./.agents/skills/scan/scanner.cjs');
const result = scan('.', { full: false, verbose: false });
// result: { added, modified, deleted, unchanged, total, elapsed, links, unresolvedLinks, tags }

// Async with embedding sync:
const { scanWithEmbeddings } = require('./.agents/skills/scan/scanner.cjs');
const result = await scanWithEmbeddings('.', { verbose: true });
// result.embedding = { embedded: 5, deleted: 1, total: 42 }
// result.embedding = { skipped: true, reason: '...' } if transformers not installed

Auto-Scan Behavior

Index Location

All indexes stored in .claude/indexes/ (gitignored, regenerable from vault content).

Limitations

Embedding Sync

Embedding sync happens automatically after file scanning when using scanWithEmbeddings(). It keeps the semantic search index up to date with vault content changes.

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.