Skip to main content
To keep docs in sync with code, generate the structural part of them from the code, and regenerate it whenever the code changes. Graphify rebuilds its graph on each commit through git hooks, or on each save with graphify watch, and graphify export wiki turns that graph into Markdown. Hand-written guides stay hand-written. The map of what calls what never drifts.

What you’ll build

  • Git hooks that rebuild the graph after commits, checkouts, merges and rebases.
  • A watch process for live rebuilds while you code.
  • A generated wiki in graphify-out/wiki/ you can publish or read in your editor.
  • A freshness check that tells you when a graph is stale.

Setup

Step 1: Install the git hooks

This installs post-commit, post-checkout, post-merge and post-rewrite hooks. Each runs a code-only rebuild, so no API key is needed. The same command registers a merge driver for graphify-out/graph.json, covered in Shared team graph. Make a commit and check the report’s freshness line:
The commit should match git rev-parse HEAD.

Step 2: Rebuild on save with watch

When you want the graph to follow you between commits, install the watch extra and run watch:
Watch rebuilds the graph when code files change. Each rebuild ends with:
Use hooks or watch, not both, on the same checkout. Hooks suit most people. Watch suits long refactors where you query the graph between saves.

Step 3: Generate the wiki

This writes one Markdown article per community, plus graphify-out/wiki/index.md. On the open-source Graphify repository it wrote 904 articles. Each article lists the community’s key members, how many connections each has, and its source file. The hooks rebuild the graph in a background process, so the commit returns at once. Don’t chain the wiki export onto the hook, because it can run before the rebuild finishes. Regenerate the wiki when you need it, or in CI (see Production patterns).

Step 4: Name the communities (optional)

Without an LLM, communities are numbered. To give them readable names, run graphify label with a model configured. It reruns clustering and always generates names:
Labels cost tokens, so run this on a schedule rather than on every commit.

When it goes wrong

The hook didn’t run. Run graphify hook status. If your repository uses a hooks manager such as Husky or core.hooksPath, the hooks may live in a different folder. Check where git looks with git config core.hooksPath. Docs and diagrams changed but the graph didn’t. update and the hooks re-extract code only. For Markdown, PDFs and images, run /graphify --update in your AI assistant. The wiki is huge. Large repositories produce hundreds of articles. Publish index.md and the communities that hold your god nodes, not all of them.

Production patterns

  • Don’t hand-edit generated articles. Link to them from your guides instead.
  • Rebuild the wiki in CI on the default branch so the published copy matches what shipped.
  • In Graphify, the hosted product, the wiki is built for each connected repository and stays current as you push. See Wiki.

Complete example

What you built

Your graph and wiki now rebuild themselves from the code. Docs that describe structure can’t fall behind, because they come from the same commit.

Next steps

Keep the graph current

How update, watch and hooks rebuild the graph.

Shared team graph

Commit the graph and merge it cleanly across branches.

Try it in Graphify

We build and host the graph for you. Start with a 14-day Pro trial, then keep up to 3 repositories on Free. No card required.