Skip to content

Use OpenCode's tool.execute.before event instead of AGENTS.md #71

Closed

Description

@johnsaigle

Claude Code does two things: writes a CLAUDE.md section telling Claude to read graphify-out/GRAPH_REPORT.md before answering architecture questions, and installs a PreToolUse hook (settings.json) that fires before every Glob and Grep call. ...
Codex, OpenCode, OpenClaw, Factory Droid write the same rules to AGENTS.md in your project root. These platforms don't support PreToolUse hooks, so AGENTS.md is the always-on mechanism.

I'm pretty sure this can be done via OpenCode's plugins system.

See:

I think this can even be scoped to just the Glob and Grep calls in OpenCode via a opencode.json file.

Activity

  1. safishamsi commented on Apr 8, 2026

    @safishamsi
    Member

    Confirmed — OpenCode's tool.execute.before plugin event is the right hook for this. The implementation requires a JavaScript plugin file (.opencode/plugins/graphify.js) and registration in opencode.json. We're tracking this for the next platform integration release. The AGENTS.md approach continues to work in the meantime.

  2. safishamsi commented on Apr 9, 2026

    @safishamsi
    Member

    Implemented in the latest commit. Running graphify opencode install now does three things: writes the AGENTS.md section as before, writes .opencode/plugins/graphify.js with a tool.execute.before handler, and registers the plugin in opencode.json. The hook checks for graphify-out/graph.json before each bash call and prepends the graph reminder to the command output so OpenCode sees it in the tool result. Uninstall removes both the plugin file and the opencode.json entry. Thanks for flagging this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions