Keeping the Graph Fresh

Lesson 5 · Learn Graphify · ~8 minutes

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.

Win

After this lesson, your graph stays current without you thinking about it.

The Staleness Problem

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.

Strategy 1: Manual Update

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

Note

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.

Strategy 2: Git Hook

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

ProsCons
Zero friction — just commit normallyAdds a few seconds to every commit
Graph is always current at session startHook is local — won't propagate to clones
No extra commands to rememberMay conflict with other post-commit hooks
Team Repos

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

Strategy 3: Watch Mode

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)

Choosing Your Strategy

CadenceBest strategy
Few commits per day, focused sessionsManual — update before starting an AI session
Many commits, want zero frictionGit hook — automatic on every commit
Rapid iteration, uncommitted changes matterWatch mode — real-time freshness

For most developers, the git hook is the sweet spot: no extra commands, negligible overhead, always current.

Detecting Staleness

How do you know when the graph is stale? Watch for these signals:

Verify Your Understanding

What does graphify update . --force do that a regular update doesn't?

Which freshness strategy requires zero extra commands after setup?

Do This Now

  1. Install the git hook: graphify hook install
  2. Make a small code change and commit — verify the hook ran
  3. Check the graph output timestamp to confirm it updated