Skip to content
New · v0.9.35 is out
Integrations

Wire Gemini CLI to a knowledge graph of your repo

Setup guide · GEMINI.md · BeforeTool hook

Gemini CLI explores a codebase the way most terminal agents do: it lists directories, opens files, and holds what it read in context. Graphify gives it a second, cheaper option: a local knowledge graph in graphify-out/ that it can query for exact structure. The Gemini CLI integration uses two native mechanisms at once: always-on rules in GEMINI.md, and a BeforeTool hook that fires right before the agent reads a file or lists a directory.

What graphify gemini install writes

  • The skill: ~/.gemini/skills/graphify/SKILL.md on macOS and Linux (~/.agents/skills/graphify/SKILL.md on Windows, where Gemini CLI searches that path with higher priority). This is what /graphify triggers.
  • A GEMINI.md section: query-first rules in your project's GEMINI.md, so every conversation starts knowing the graph exists. The installer owns only its own section; the rest of the file is untouched.
  • A BeforeTool hook in .gemini/settings.json: it matches read_file|list_directory and runs graphify hook-guard gemini just before those tools execute.
GEMINI.md (section added by graphify gemini install, excerpt)
## graphify This project has a knowledge graph at graphify-out/ with god nodes,community structure, and cross-file relationships. Rules:- For codebase questions, first run `graphify query "<question>"`  when graphify-out/graph.json exists. Use `graphify path "<A>" "<B>"`  for relationships and `graphify explain "<concept>"` for focused  concepts.

Set it up

  1. Install the CLI. If graphify is not found afterwards, run uv tool update-shell and open a new terminal.
  2. From the project root: graphify gemini install. Prefer everything inside the repo? graphify gemini install --project writes the skill under .gemini/skills/ and prints a git add hint, so the setup is committable.
  3. Build the graph: type /graphify . in a Gemini CLI session. It writes graphify-out/ with graph.json (the queryable graph), graph.html (interactive), and GRAPH_REPORT.md (highlights, suggested questions).
  4. Ask something structural and watch the agent query the graph first.
terminal
$ uv tool install graphifyy$ graphify gemini install
in Gemini CLI
/graphify .

How the BeforeTool hook works

Gemini CLI exposes hooks that run before tool calls, and Graphify uses exactly one of them. Right before the agent runs read_file or list_directory, the hook checks whether graphify-out/graph.json exists. If it does, the tool call proceeds with a reminder attached: run graphify query "<question>" for a scoped subgraph instead of walking raw files. If there is no graph yet, the hook stays silent, so an uninitialized repo behaves exactly as before.

.gemini/settings.json (hook registered by the installer)
{  "hooks": {    "BeforeTool": [      {        "matcher": "read_file|list_directory",        "hooks": [          { "type": "command", "command": "graphify hook-guard gemini" }        ]      }    ]  }}

The hook never blocks: it always allows the tool call and only adds context. It is a shell-agnostic graphify subcommand rather than inline shell, so it behaves the same on macOS, Linux, and Windows, and the installer re-registers it on every run so an upgraded CLI never leaves a stale hook payload behind. In the installed file the command embeds the absolute path to your graphify executable.

Query results come back with file:line citations, and every edge is tagged EXTRACTED, INFERRED, or AMBIGUOUS, so the agent knows what was parsed from the AST versus connected by a model. The full command set is in the CLI reference.

Gemini CLI vs Google Antigravity

These are two different Graphify platforms. graphify gemini installcovers the Gemini CLI terminal agent described on this page. Google Antigravity, Google's agentic IDE, has its own installer (graphify antigravity install) that writes .agents rules and workflows instead, and its global skill lives at ~/.gemini/config/skills/. If you use both, install both; see Graphify + Google Antigravity.

Keeping the graph current

After code changes, graphify update . re-extracts only the files that changed (AST-only, no API cost); the GEMINI.md rules tell the agent to run it after modifying code. graphify hook install adds post-commit and post-checkout git hooks that do the same automatically.

Troubleshooting

  • graphify: command not found: the uv or pipx tool bin dir (~/.local/bin) is not on your PATH yet. Run uv tool update-shell (or pipx ensurepath) and open a new terminal.
  • No nudge appears before reads: that is expected until graphify-out/graph.json exists. The hook is deliberately silent without a graph, so build one with /graphify . first.
  • /graphify does nothing: confirm the skill file exists (~/.gemini/skills/graphify/SKILL.md, or ~/.agents/skills/ on Windows) and that GEMINI.md contains the graphify section, then start a new session.
  • Hook stopped firing after an upgrade: the hook command embeds the absolute executable path at install time. Re-run graphify gemini install; it replaces its own hook entry idempotently.
  • The graph lives somewhere else: the hook honors the GRAPHIFY_OUT environment variable when your output directory is not the default graphify-out/.

Gemini CLI FAQ

Is this the same as Google Antigravity support?

No. Gemini CLI and Google Antigravity are separate platforms in Graphify, with separate installers. graphify gemini install covers the Gemini CLI terminal agent; Antigravity has its own graphify antigravity install, which writes .agents rules and workflows and uses a different global skill directory (~/.gemini/config/skills/). Set up whichever you actually run, or both.

Does graphify gemini install overwrite my GEMINI.md?

No. The installer replaces or appends only its own graphify section (marked with a heading it owns) and leaves the rest of the file alone. Re-running the install refreshes that one section; graphify gemini uninstall removes the section and the BeforeTool hook again.

Can the hook block Gemini CLI from reading files?

No. The BeforeTool hook always allows the tool call; it only attaches a reminder to query the graph when graphify-out/graph.json exists, and stays completely silent when there is no graph. Strict blocking exists only on Claude Code, where the hook API supports a deny decision.

Does my code leave my machine?

Source code is parsed locally with tree-sitter (36 language grammars); building code edges never requires an API call. Non-code files such as docs and PDFs are read by the model you already use in Gemini CLI. Nothing is sent to Graphify: there is no telemetry and no account.

Where does the skill go on Windows?

On Windows, the global Gemini CLI skill installs to ~/.agents/skills/graphify/SKILL.md, which Gemini CLI searches with higher priority there; macOS and Linux use ~/.gemini/skills/graphify/SKILL.md. With --project, the skill lives inside the repo at .gemini/skills/graphify/SKILL.md on every platform.

How do I remove it?

graphify gemini uninstall removes the GEMINI.md section and the BeforeTool hook; graphify uninstall removes Graphify from every platform at once. Add --purge to also delete the graphify-out/ directory.

Next steps

The quickstart walks the whole flow from install to first query, and the CLI reference covers every command the rules point Gemini CLI at. The same graph serves your other assistants too: see Graphify + Claude Code, Graphify + Codex, or browse every assistant on the integrations page.

We use privacy-friendly analytics to improve Graphify. Cookies only load if you accept. Privacy policy