Graphify in Local Dev Loops — Predev Hooks and Stale Cache Invalidation
Local codebase intelligence tools are only valuable if their knowledge graphs remain completely up to date with ongoing code changes. If an AI coding assistant navigates a repository using a knowledge graph generated three weeks ago, it will reference deleted components, hallucinate obsolete function signatures, and miss recently created files.
However, forcing a full codebase re-indexing on every command introduces frustrating latency into developer workflows. To solve this, our repository implements an intelligent, non-blocking predev hook (`scripts/ai-context-if-stale.mjs`) that automatically checks repository staleness and refreshes Graphify context before `npm run dev` launches.
In modern npm scripts, the `predev` lifecycle hook executes automatically whenever a developer runs `npm run dev`. In our setup, `predev` runs two lightweight Node scripts: `node scripts/ai-doctor.mjs --quiet --warn` and `node scripts/ai-context-if-stale.mjs --quiet`.