A stale graph is worse than no graph — it sends the AI to files that no longer exist or misses new code entirely. This lesson covers three freshness strategies: manual, automatic, and continuous.
After this lesson, your graph stays current without you thinking about it.
The graph is a snapshot of your code at build time. Every file you add, rename, or refactor makes it slightly less accurate. When the agent consults a stale graph:
The fix is a freshness strategy that matches your development cadence.
Run when you remember (or when the agent gives bad structural answers):
graphify update .
This re-extracts only changed files and patches the existing graph. Faster than a full rebuild because it skips unchanged code.
# After a major refactor where files were deleted:
graphify update . --force
The --force flag allows the graph to shrink (normally it warns if the new graph has fewer nodes, assuming something went wrong).
Manual updates work fine if you commit infrequently or work in focused bursts. The graph only needs to be current at the start of an AI session.
Automatically update the graph after every commit:
graphify hook install
This adds a post-commit hook to .git/hooks/ that runs graphify update . after each commit. The update is fast (usually under 5 seconds for incremental changes).
| Pros | Cons |
|---|---|
| Zero friction — just commit normally | Adds a few seconds to every commit |
| Graph is always current at session start | Hook is local — won't propagate to clones |
| No extra commands to remember | May conflict with other post-commit hooks |
Git hooks are local and won't propagate when teammates clone. For team workflows, consider documenting the hook in your README or using a hook manager like pre-commit (which supports post-commit hooks too).
For active development sessions where you're making many changes before committing:
graphify watch .
This watches the filesystem for changes and auto-rebuilds affected portions of the graph. Best used in a dedicated terminal tab during a development session.
# Typical workflow:
# Terminal 1: graphify watch .
# Terminal 2: your editor
# Terminal 3: kiro CLI session (always has fresh graph)
| Cadence | Best strategy |
|---|---|
| Few commits per day, focused sessions | Manual — update before starting an AI session |
| Many commits, want zero friction | Git hook — automatic on every commit |
| Rapid iteration, uncommitted changes matter | Watch mode — real-time freshness |
For most developers, the git hook is the sweet spot: no extra commands, negligible overhead, always current.
How do you know when the graph is stale? Watch for these signals:
graphify benchmark shows a significantly different file count than git ls-files | wc -lWhat does graphify update . --force do that a regular update doesn't?
Which freshness strategy requires zero extra commands after setup?
graphify hook install