Skip to main content
OpenCode is an open-source coding agent. Graphify CLI is the open-source Graphify. Put them together and every part of the loop is code you can read: the agent, the code graph it answers from, and the files that wire them together. This recipe sets that up, shows the workflows people run with it, and covers hosted Graphify for when you want a team graph instead.

The scenario

You use OpenCode every day, sometimes with a hosted model, sometimes with a local one. Each new session starts cold. Ask “what does the payments module do?” and OpenCode opens the README, then a config file, then source files one by one, and rebuilds the same picture it built yesterday. You want three things:
  1. OpenCode answers structural questions from a graph of the repository, with file and line citations.
  2. The graph stays current as you commit, pull and switch branches.
  3. Nothing in the setup is a black box. Every file it writes sits in your repository, readable and diffable.

What you’ll build

  • A local code graph in graphify-out/, built by Graphify CLI.
  • OpenCode wired to it with three plain files: a skill, an AGENTS.md section and a small plugin.
  • Git hooks that rebuild the graph after commits, checkouts, merges and rebases.
  • The graph served to OpenCode as a local MCP server.
  • Hosted Graphify over MCP, with OAuth sign-in and no API key.

Setup

  • OpenCode installed. See opencode.ai.
  • uv or pipx. See Installation for each operating system, including Windows.
  • A git repository to try it on.

Step 1: Install Graphify CLI

The package is graphifyy with two y’s. The command is graphify.

Step 2: Wire Graphify into OpenCode

In the repository root, run the OpenCode installer with --project:
That writes three files, all in your repository: Commit them so everyone on the repository gets the same setup:
Personal instead of per repository? graphify install --platform opencode writes the skill and the plugin to ~/.config/opencode/ for every project, without an AGENTS.md section.
Use the OpenCode command, not the bare graphify install. With no platform, graphify install sets up Claude Code. If an agent ran the bare command for you, run graphify claude uninstall to remove those files, then run graphify opencode install --project.

Step 3: Build the graph

You can build from the terminal or let OpenCode do it.
Code is parsed locally with tree-sitter. No model and no API key are involved:
This is the fastest path, and the same commands work in scripts and CI.
Either way you get:

Step 4: Ask OpenCode real questions

Start a new OpenCode session so it reads the updated AGENTS.md. When the plugin fires, the first shell command of the session shows this line:
These are the workflows people run most often with OpenCode and Graphify.

Understand a module before you touch it

OpenCode runs a scoped query instead of opening every file:

Trace a flow end to end

Behind the scenes:
path returns the shortest chain of calls and imports between two symbols. explain shows one symbol, where it lives, and everything connected to it. Swap in names from your code.

Check impact before a refactor

The answer comes from edges in the graph, each tagged EXTRACTED (read from the source), INFERRED (worked out by a resolver) or AMBIGUOUS (several possible targets). Treat INFERRED and AMBIGUOUS as leads to verify. For the full routine, see Plan a safe refactor.

Onboard to a repository you didn’t write

For a longer version, see Understand a new codebase in 30 minutes.

Step 5: Keep the graph fresh

OpenCode answers from the saved graph, not the files on disk, so an old graph gives old answers. Install the git hooks once per repository:
This adds post-commit, post-checkout, post-merge and post-rewrite hooks that rebuild the code graph in the background, so it follows you across branches. Hook rebuilds are code-only, so they never call a model. To refresh by hand, run graphify update .. See Keep your code graph up to date for what each hook does and the cases it skips on purpose. Keep vendored and generated folders out of the graph with a .graphifyignore. See Ignoring files.

Step 6: Keep the whole loop on your machine

OpenCode can run on a local model, and so can Graphify CLI. Code parsing never needs one. For docs, papers and community names, point Graphify at Ollama:
Then no source file leaves your machine at any step. Tuning for a laptop GPU is in Run a local code knowledge graph with Ollama. For other OpenAI-compatible servers, see LLM providers.

Step 7: Serve the graph to OpenCode over MCP

The skill and plugin have OpenCode run graphify commands in its shell. If you’d rather give it graph tools directly, serve the same graph.json as a local MCP server:
OpenCode starts graphify-mcp over stdio. Use an absolute path. The tool list is in the MCP tool reference, and server flags are in the MCP server quickstart.

Use hosted Graphify instead

Graphify hosts the graph for your team, rebuilds it on every push, and adds Memory, the Wiki and pull request reviews. OpenCode connects to it as a remote MCP server.
1

Add the server

In the project, run:
Add --global to use it in every project. Or add it to opencode.jsonc by hand:
opencode.jsonc
2

Sign in

OpenCode uses OAuth for remote servers by default, and Graphify needs no API key. Run opencode mcp list. If graphify shows needs authentication, open OpenCode, run /mcps, select graphify and sign in in the browser. opencode mcp auth graphify starts the same sign-in from the terminal.Running OpenCode over SSH or in a container? After you sign in, the browser lands on a local callback page that doesn’t load. Copy that page’s URL and paste it into OpenCode’s sign-in prompt.
3

Check it works

Start a session and paste:
You should see your indexed repositories. If the list is empty, index one first in the Quickstart.
Hosted repository tools include query_graph, graphify_find, graphify_callers, graphify_impact and recall. Your client shows the current list. To make OpenCode reach for them before it greps, add the hosted rule block from Make your AI coding agent use the graph to AGENTS.md. To skip a lookup, set a default repository on the URL, such as https://api.graphify.com/mcp?repo=acme/web-app. OpenCode exposes MCP tools through its Code Mode by default. Set "codemode": false on the graphify server if you want its tools on the model’s native tool list instead.

When it goes wrong

Remove it

This removes the skill, the plugin and the ## graphify section from AGENTS.md, and leaves the rest of the file alone. Add graphify hook uninstall to drop the git hooks. To remove a hosted or local MCP server, delete its entry from your OpenCode config.

Complete example

What you built

An open-source coding agent that starts from an open-source code graph, with the wiring committed to your repository and the graph rebuilt on every git event. Swap the model, swap the machine, and the setup still works.

FAQ

Yes, two ways. Graphify CLI installs a skill, an AGENTS.md section and a plugin with graphify opencode install --project. Hosted Graphify connects as a remote MCP server at https://api.graphify.com/mcp.
No. Code parsing is local and needs no model. Hosted Graphify signs you in with OAuth. A model is only used for docs, papers and images, and in OpenCode that can be your OpenCode model or a local one.
Yes. Both read the same graphify-out/. Run each agent’s installer, such as graphify opencode install --project and graphify claude install, and they query the same graph.
Start with the skill and plugin. They need nothing running. Add the local MCP server when you want OpenCode to call graph tools directly, or when several agents should read one graph.

Next steps

Make agents use the graph

Rules that make the agent query before it greps.

Fully local with Ollama

Docs and community names on a local model.

Start free with Graphify

We build and host the graph for you, keep it current on every push, and add Memory, the Wiki and pull request reviews on top.