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:- OpenCode answers structural questions from a graph of the repository, with file and line citations.
- The graph stays current as you commit, pull and switch branches.
- 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.mdsection 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.
uvorpipx. See Installation for each operating system, including Windows.- A git repository to try it on.
Step 1: Install Graphify CLI
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:
Commit them so everyone on the repository gets the same setup:
Step 3: Build the graph
You can build from the terminal or let OpenCode do it.- From the terminal
- From OpenCode
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.
Step 4: Ask OpenCode real questions
Start a new OpenCode session so it reads the updatedAGENTS.md. When the plugin fires, the first shell command of the session shows this line:
Understand a module before you touch it
Trace a flow end to end
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
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
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: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:Step 7: Serve the graph to OpenCode over MCP
The skill and plugin have OpenCode rungraphify commands in its shell. If you’d rather give it graph tools directly, serve the same graph.json as a local MCP server:
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.
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
## 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
Does Graphify work with OpenCode?
Does Graphify work with OpenCode?
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.Do I need an API key?
Do I need an API key?
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.
Should I use the skill or the local MCP server?
Should I use the skill or the local MCP server?
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.