OpenCode plugins and permissions: hooks, rules, and a working guard OpenCode's plugin and permission system lets developers fence agent actions with ordered rules where the last matching rule wins, and with TypeScript plugin hooks at execute.before, permission evaluate, and execute.after, according to the project's documentation. The permission evaluate hook runs only for allow and ask decisions, since an explicit configured deny is final and never reaches the hook, and its message becomes the denial reason the model reads. OpenCode 2 renamed the plugin package to @opencode/plugin with Plugin.define, breaking OpenCode 1 plugins that export a function and import @opencode-ai/plugin. OpenCode plugins and permissions: hooks, rules, and a working guard OpenCode plugins are TypeScript modules that hook into the agent's events, and OpenCode permissions are ordered rules that decide whether an action runs, asks you first, or is denied. Plugins extend what the agent can do; permissions fence what it may do. This post covers loading a plugin, the hook points around a tool call, the permission rule format, and a guard example built from them — then the check neither of them performs. Loading a plugin A plugin is loaded from the plugins array in opencode.json c , or discovered automatically under .opencode/plugins/ in the project and ~/.config/opencode/plugins/ globally. The plugins documentation https://opencode.ai/docs/plugins/ lists the accepted forms: an npm package, a package pinned to a version, a scoped package, or a local directory. // opencode.jsonc { "$schema": "https://opencode.ai/config.json", "plugins": " email protected ", "./plugins/local" , } The CLI manages global packages: opencode plugin add