Answer: In V2, hooks are registered in setup by calling the hook method on the domain that owns the operation, such as ctx.tool.hook("execute.before", ...) or ctx.shell.hook("create.before", ...). Registrations stay active for the plugin's lifetime and are disposed when it unloads. Status: Confirmed Entry: tool/opencode/integrations/register-hooks-in-setup Revision: 1 Digest: sha256:41006cfc1523c2c6 (changes whenever the content changes) Timeline: Created: 2026-11-13T03:55:53Z Last changed: 2026-11-13T03:55:53Z Last verified: 2026-11-20T13:44:39Z Next check: 2026-11-21T13:44:39Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Source | As of tool hook registration | ctx.tool.hook("execute.before", ...) | [1] | 2026-11-20 shell hook registration | ctx.shell.hook("create.before", ...) | [1] | 2026-11-20 registration lifetime | Registrations stay active for the plugin’s lifetime and are disposed when it unloads. | [1] | 2026-11-20 manual removal | registration.dispose() | [1] | 2026-11-20 Sources: [1] opencode. "Migrate plugins from V1 | OpenCode". https://opencode.ai/docs/build/plugins/migrate-v1/ Role: primary. Accessed: 2026-11-20T13:44:39Z Quote: "tool.execute.before ctx.tool.hook("execute.before", ...)" (Supports: tool hook registration) Quote: "shell.env ctx.shell.hook("create.before", ...)" (Supports: shell hook registration) Quote: "Registrations stay active for the plugin’s lifetime and are disposed when it unloads." (Supports: registration lifetime) Quote: "Retain the returned registration only when the plugin needs to remove that particular hook or transform earlier with registration.dispose() ." (Supports: manual removal) Snapshot SHA-256: db1439aa8b57731696e9ec9c27b28c80bc13d20443cbb0a07a179685f7003acc (captured 2026-11-13T03:55:52Z) Verification: Method: Automated extraction from [1] with deepseek-flash (JSON output, thinking disabled). Every value was checked by code to appear verbatim in a quoted passage of [1]. On this check the text of [1] was unchanged since 2026-11-13T03:55:53Z, so the values verified then were kept. Cross-check: not-available at 2026-11-20T13:44:39Z. No independent second source is configured for this entry Last successful check: 2026-11-20T13:44:39Z Last attempt: 2026-11-20T13:44:39Z Notes and limitations: Extracted automatically from a single official source (section "Register hooks in setup"). Related: https://latestn.com/tool/opencode/integrations/replace-plugin-entrypoint How do I replace the entrypoint when porting an opencode V1 plugin to V2? https://latestn.com/tool/opencode/integrations/rpc-schema-validation How do I validate RPC input and output schemas in opencode Effect plugins? https://latestn.com/tool/opencode/integrations/run-opencode-as-acp-agent-in-zed How do I run opencode as an ACP agent in Zed? https://latestn.com/tool/opencode/integrations/raycast-console-mcp-server How do I add the OpenCode Console MCP server in Raycast? https://latestn.com/tool/opencode/integrations/raycast-extension-api-key-setup How do I configure the OpenCode extension for Raycast with an API key? https://latestn.com/tool/opencode/integrations/redeem-pairing-code How do I redeem an opencode pairing code? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-13T03:55:53Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/opencode/integrations/register-hooks-in-setup/latest Challenge this entry: Open challenges: None How: If a value here is wrong or out of date, send what is wrong and a link to evidence. Challenges are queued and checked against the evidence; they do not change the entry by themselves. If the entry changes as a result, the change log says so. Form: https://latestn.com/dispute/tool/opencode/integrations/register-hooks-in-setup POST: https://latestn.com/dispute/tool/opencode/integrations/register-hooks-in-setup with claim, evidence_url, and optionally field and contact (form-encoded or JSON) GET: https://latestn.com/dispute/tool/opencode/integrations/register-hooks-in-setup?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). How do I register hooks in setup for an opencode V2 plugin? Revision 1, last verified 2026-11-20T13:44:39Z. https://latestn.com/tool/opencode/integrations/register-hooks-in-setup (accessed 2026-11-21T09:52:51Z). @misc{LatestN_tool_opencode_integrations_register_hooks_in_setup_r1, title = {How do I register hooks in setup for an opencode V2 plugin?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/opencode/integrations/register-hooks-in-setup}}, note = {Revision 1; digest sha256:41006cfc1523c2c6; last verified 2026-11-20T13:44:39Z; accessed 2026-11-21T09:52:51Z} } Reuse: License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) Attribution: Copying and adapting are allowed, including commercially, if you credit LatestN and link to the entry you used. Each entry ends with a ready-made citation. URL: https://latestn.com/tool/opencode/integrations/register-hooks-in-setup