Refresh codegraph after git operations
Codegraph's file watcher keeps the graph fresh for individual saves, but it
does NOT observe the many file changes that happen during a git pull,
rebase, merge, or branch checkout. After those, the graph may point at
line numbers that no longer exist, or miss symbols introduced by the change.
When to call
Trigger immediately after the user mentions (or runs via Bash) any of:
git pullgit rebasegit mergegit checkout <branch>orgit switch <branch>- "I just pulled"
- "Switched to [branch]"
- "Rebased onto main"
How to refresh
Call
mcp__codegraph__scan_statusto see how stale the graph is.- If
fresh=true, do nothing. - If
fresh=false, proceed.
- If
Preferred: call
mcp__codegraph__incremental_reindex. It compares stored per-file git blob SHAs to the current HEAD and re-indexes only the files whose content changed. Handles deletions too. Fast and correct for branch switches, pulls, rebases.If
incremental_reindexreturnsmode=fallback_full(old index without blob tracking), it already ran a full scan: you're done.Only call
mcp__codegraph__scan_repoif the user explicitly asks for a full rebuild.Report the result to the user briefly (e.g. "Refreshed codegraph: 12 files re-indexed, 2 deleted.").
Don't
- Don't reindex on every unrelated message; only when a git operation that changes many files has just occurred.
- Don't ask the user to restart the MCP server:
scan_repohandles it live through the existing connection. - Don't re-scan if
fresh=true; it wastes time and load.
Token-saving rule of thumb
Calling scan_status costs ~1 JSON blob. Running scan_repo only when
needed saves you from relying on stale symbol_lookup results and then
having to manually verify with file reads.