OpenCode SDK Development

Create and integrate custom OpenCode tools and plugins using the OpenCode SDK.

Updated Dec 5, 2025
One-click install
npx skills add https://github.com/hhopkins95/ai-systems --skill opencode-sdk-development
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: OpenCode SDK Development
Source: https://github.com/hhopkins95/ai-systems/tree/main/.claude/skills/opencode-sdk
Command: npx skills add https://github.com/hhopkins95/ai-systems --skill opencode-sdk-development

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

OpenCode SDK Development provides a structured guide for creating custom tools and plugins using the OpenCode SDK. It enables developers to extend OpenCode capabilities with a consistent tool model and plugin system.

Core Features & Use Cases

  • Client SDK usage for interacting with the OpenCode server (sessions, messages, files)
  • Plugin system for creating tools with schema validation
  • Guidance and examples for building custom tools and plugins using the @opencode-ai/sdk and @opencode-ai/plugin packages

Quick Start

Create a basic OpenCode tool using the example in .opencode/tool/ (or ~/.config/opencode/tool/). For example, implement a greeting tool that accepts a name and returns a greeting.

Frequently Asked Questions about OpenCode SDK Development

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

FAQPage Schema
How do I create a custom OpenCode tool using the SDK?

Create a custom OpenCode tool by defining it with the tool(...) pattern, specifying parameters via Zod-based tool.schema validation, and implementing the tool logic. Place your tool definition in `.opencode/tool/` or `~/.config/opencode/tool/`, then initialize it using createOpencode for local or global discovery.

What is the plugin architecture in OpenCode SDK and how do I use it?

The OpenCode SDK plugin system provides hooks for extending functionality: tool (define tools), event, config, chat.message, chat.params, permission.ask, and tool.execute.before/after hooks. Use these hooks in your plugin to intercept and customize tool behavior, validation, and execution within your OpenCode workflow.

Can I use OpenCode SDK to build tools that integrate with client-server sessions?

Yes. The OpenCode SDK supports client/server initialization via createOpencode and createOpencodeClient, enabling you to wire interactions for sessions, files, and tool execution. This allows your custom tools to work across distributed OpenCode environments with full session and file management.

Do I need to validate tool arguments, and how does OpenCode handle schema validation?

Yes, argument validation is built into OpenCode tools via tool.schema using Zod-based schema definitions. Define your tool's expected parameters as a Zod schema within tool.schema to automatically validate inputs before execution, ensuring type safety and consistent tool behavior.

What packages do I need to develop OpenCode tools and plugins?

Use @opencode-ai/sdk for the core SDK client/server functionality and @opencode-ai/plugin for building plugin hooks and custom tool definitions. Both packages provide the APIs needed to create, validate, and integrate custom tools into your OpenCode environment.

Can I use OpenCode SDK for both local and global tool development?

Yes, OpenCode SDK supports both local and global tool development workflows. Configure your tool definitions in `.opencode/tool/` for local scope or `~/.config/opencode/tool/` for global scope, then use createOpencode or createOpencodeClient for discovery based on your deployment target.