opencode-plugin-development

Design and register OpenCode plugins with event hooks and custom tools.

130|8|Updated Jan 23, 2026
One-click install
npx skills add https://github.com/sandgardenhq/sgai --skill opencode-plugin-development-sandgardenhq
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: opencode-plugin-development
Source: https://github.com/sandgardenhq/sgai/tree/main/cmd/sgai/skel/.sgai/skills/opencode-plugin-development
Command: npx skills add https://github.com/sandgardenhq/sgai --skill opencode-plugin-development-sandgardenhq

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It provides a clear, practical guide to extending OpenCode with plugins so teams can add features, enforce policies, and react to events without modifying core code.

Core Features & Use Cases

  • Hook-based Extensibility: Implement event handlers, tool definitions, and pre-execution guards to customize behavior.
  • Custom Tools: Define typed tools with args schemas and execution logic for domain-specific operations.
  • Policy & Safety Controls: Intercept tool execution to block sensitive file access or enforce project rules.
  • Use Case: Add a notification plugin that alerts when a session goes idle, create a custom analyzeCode tool for pattern checks, and protect .env and secrets from read tools.

Quick Start

Ask to create a new plugin in .sgai/plugin that adds a custom tool and a tool.execute.before hook to block access to .env files, then load it in OpenCode and run a quick test.

Frequently Asked Questions about opencode-plugin-development

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create custom plugins and hooks for OpenCode?▼

You can create OpenCode plugins by registering event handlers, defining custom tools with args schemas, and intercepting tool execution to build custom workflows using the OpenCode SDK.

Can I use OpenCode plugins to block access to sensitive files like .env?▼

Yes, you can intercept tool execution with pre-execution guards to enforce policy and prevent OpenCode tools from reading sensitive files such as .env and secrets.

How do I define custom tools with TypeScript for OpenCode?▼

OpenCode supports TypeScript-friendly plugin interfaces, allowing you to define typed tools with args schemas and execution logic for domain-specific operations within your project.

What is the best way to trigger notifications when an OpenCode session goes idle?▼

You can extend OpenCode by building a notification plugin that hooks into session events, allowing you to alert your team when a session goes idle without modifying core code.

Do I need the Bun shell context to develop OpenCode plugins?▼

The OpenCode plugin development process uses the OpenCode SDK and operates within the Bun shell context to handle TypeScript-friendly interfaces and pre-execution validation.

When should I use OpenCode hooks for workflow customization?▼

Use OpenCode hooks when you need to add domain-specific tooling, enforce project rules, or react to events without modifying core code, keeping your custom logic isolated in plugins.