Skip to content
New · v0.9.35 is out
Integrations

Set up OpenCode with a knowledge graph of your codebase

Setup guide · AGENTS.md · opencode.json plugin

OpenCode is an open-source terminal agent, and Graphify meets it with an equally open-source integration: a local knowledge graph in graphify-out/, wired in through two native OpenCode mechanisms. Always-on rules go in AGENTS.md, and a small JavaScript plugin, registered through opencode.json, reminds the agent the graph exists the first time it reaches for bash. Both are plain project files you can read, commit, and diff.

What graphify opencode install writes

  • An AGENTS.md section: query-first rules in your project's AGENTS.md, the file OpenCode reads in every session. The installer owns only its own section; the rest of the file is untouched.
  • A plugin: .opencode/plugins/graphify.js, hooking OpenCode's tool.execute.before event.
  • A registration in .opencode/opencode.json, appending the plugin to the "plugin" array (existing config is preserved).
  • The skill: ~/.config/opencode/skills/graphify/SKILL.md globally, or .opencode/skills/graphify/SKILL.md with --project. This is what /graphify triggers.
.opencode/opencode.json (written by the installer)
{  "plugin": [".opencode/plugins/graphify.js"]}

One gotcha before you start

The bare graphify install command targets Claude Code by design. That matters here because a natural move is to ask the OpenCode agent itself to install Graphify, and if it runs the bare command, you end up with Claude Code files under ~/.claude/ and no OpenCode wiring at all. Always use the platform-specific command:

terminal
$ uv tool install graphifyy$ graphify opencode install

(graphify install --platform opencode is equivalent; add --project to keep the skill inside the repo.) If the bare command already ran, nothing is broken: run graphify claude uninstall to drop the unwanted pieces, then graphify opencode install.

Build the graph, then ask

Type /graphify . in an OpenCode session. The skill maps the project into graphify-out/: graph.json (the queryable graph), graph.html (interactive view), and GRAPH_REPORT.md (highlights and suggested questions). From then on, structural questions route through graphify query "<question>" (a scoped subgraph), graphify path "<A>" "<B>" (the dependency route between two symbols), and graphify explain "<concept>"(one node's full neighborhood). Every result carries file:line citations, and every edge is tagged EXTRACTED, INFERRED, or AMBIGUOUS, so the agent knows what was parsed versus guessed.

in OpenCode
/graphify .

How the plugin behaves

The plugin is deliberately small and deliberately polite. Before a tool call runs, it checks two things: is this the bash tool, and does graphify-out/graph.json exist? Only when both are true does it prepend a one-time reminder to the command, telling the agent to run graphify query for focused questions instead of grepping raw files. It fires at most once per session and never blocks or rewrites what the agent intended to do.

.opencode/plugins/graphify.js
// .opencode/plugins/graphify.js (excerpt)export const GraphifyPlugin = async ({ directory }) => {  let reminded = false;   return {    "tool.execute.before": async (input, output) => {      if (reminded) return;      if (!existsSync(join(directory, "graphify-out", "graph.json"))) return;       if (input.tool === "bash") {        // prepends a one-time knowledge-graph reminder to the command        reminded = true;      }    },  };};

Two implementation details worth knowing because they were shaped by real bug reports: the reminder text is plain words with no backticks (backticks inside the quoted echo would trigger shell command substitution), and it is joined to the command with ; rather than &&, because Windows PowerShell 5.1 rejects && as a statement separator. OpenCode cannot hard-block a tool call, so there is no strict mode here; blocking exists only on Claude Code.

Keeping the graph current

After edits, graphify update . re-extracts only the files that changed (AST-only, no API cost); the AGENTS.md rules tell the agent to run it after modifying code. graphify hook install adds post-commit and post-checkout git hooks that refresh the graph automatically. The full command set is in the CLI reference.

Troubleshooting

  • Graphify installed but OpenCode shows no sign of it: check whether you ran the bare graphify install. It targets Claude Code; run graphify opencode install instead (see the gotcha above).
  • No reminder appears before bash commands: expected until graphify-out/graph.json exists, and also after the first bash call of a session, since the reminder is one-shot by design.
  • /graphify does nothing: for a project-scoped install, confirm the skill is at .opencode/skills/graphify/SKILL.md and that AGENTS.md has the graphify section, then start a new session.
  • Plugin listed twice in opencode.json: harmless but tidy-uppable; the entry uses forward slashes on every platform, and re-running graphify opencode install will not add duplicates.
  • graphify: command not foundin OpenCode's shell: the uv or pipx tool bin dir (~/.local/bin) is not on PATH. Run uv tool update-shell (or pipx ensurepath) and restart OpenCode.

OpenCode FAQ

I ran graphify install inside OpenCode and nothing changed. Why?

Bare graphify install targets Claude Code by design, so it wrote Claude Code files (~/.claude/...) instead of OpenCode's. This bites especially when you ask the OpenCode agent itself to set Graphify up. The fix: run graphify opencode install (or graphify install --platform opencode), which writes the AGENTS.md section, the plugin, and the OpenCode skill paths.

What exactly does the plugin do?

It hooks tool.execute.before and, only when graphify-out/graph.json exists, prepends a one-time reminder to the first bash command of the session: query the graph before grepping raw files. It never blocks anything, fires at most once per session, and is a no-op in repos without a graph.

Should I commit the plugin and opencode.json?

Yes. .opencode/plugins/graphify.js, the opencode.json plugin entry, and the AGENTS.md section are plain project files, so committing them means one install covers the whole team. Teammates need the graphifyy CLI installed and a built graph for the queries to work.

Where does the skill live?

Globally at ~/.config/opencode/skills/graphify/SKILL.md; with --project it is written inside the repo at .opencode/skills/graphify/SKILL.md, where OpenCode discovers it.

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 OpenCode. Nothing is sent to Graphify: there is no telemetry and no account.

How do I remove it?

graphify opencode uninstall removes the AGENTS.md section, deletes the plugin, and deregisters it from opencode.json; 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 OpenCode at. The same graph serves every assistant you run: see Graphify + Codex (the other AGENTS.md platform), Graphify + Claude Code, or browse the full list on the integrations page.

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