Complete toolkit for configuring and extending OpenCode: agent creation, custom slash commands, configuration management, plugin development, and SDK usage.
94%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
How to publish plugins to npm
Before creating a publishable package, MUST ask the user:
Package name: What should the npm package be called?
opencode-my-plugin@username/opencode-my-pluginnpm scope/username: If scoped, what's their npm username or org?
Version: Starting version? (default: 0.1.0)
License: MIT, Apache-2.0, etc.? (default: MIT)
Description: One-line description of what the plugin does
Example prompt:
"Before I create the npm package, I need a few details:
- What should the package name be? (e.g.,
opencode-background-processor@yourusername/opencode-background-process)- What's your npm username/scope if using a scoped package?
- Starting version? (default: 0.1.0)
- License? (default: MIT)"
Users do NOT need to run npm install - OpenCode automatically installs plugin dependencies at runtime.
Users simply add the plugin name to their config:
{
"plugin": [
"my-plugin@1.0.0", // Pinned version - won't auto-update
"another-plugin", // No version = "latest" - updates on launch
],
}On launch, OpenCode:
bun add --force for each plugin (auto-installs)latest and caches actual versionThis means the README SHOULD NOT include npm install instructions - just tell users to add the plugin to their config.
Package structure:
my-plugin/
├── src/
│ └── index.ts # Main plugin entry
├── dist/ # Built output (gitignored)
├── package.json
├── tsconfig.json
├── README.md
├── LICENSE
├── example-opencode.json # Example config for users
├── .gitignore
└── .npmignorepackage.json (replace placeholders with user's answers):
{
"name": "<PACKAGE_NAME>",
"version": "<VERSION>",
"description": "<DESCRIPTION>",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": ["dist", "README.md", "LICENSE"],
"keywords": ["opencode", "opencode-plugin", "plugin"],
"license": "<LICENSE>",
"peerDependencies": {
"@opencode-ai/plugin": "^1.0.0"
},
"devDependencies": {
"@opencode-ai/plugin": "^1.0.0",
"@types/bun": "^1.2.0",
"@types/node": "^22.0.0",
"typescript": "^5.7.0"
},
"scripts": {
"clean": "rm -rf dist",
"build": "npm run clean && tsc",
"prepublishOnly": "npm run build"
},
"publishConfig": {
"access": "public"
}
}Notes:
peerDependencies for @opencode-ai/plugin - OpenCode provides this at runtime"publishConfig": { "access": "public" } for scoped packagesexample-opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["<PACKAGE_NAME>"]
}README.md Installation Section:
## Installation
Add to your `opencode.json`:
```json
{
"plugin": ["<PACKAGE_NAME>"]
}
```
OpenCode automatically installs plugin dependencies at runtime.Publish:
For scoped packages (first time):
npm publish --access publicFor unscoped or subsequent publishes:
npm publishWhen users pin to a specific version (e.g., my-plugin@1.0.0), they won't see updates automatically.
SHOULD include an update checker that shows a toast when newer versions are available. See references/update-notifications.md for the full implementation.
| Mistake | Fix |
|---|---|
Missing type: "module" | Add to package.json |
| Not building before publish | Add prepublishOnly script |
| Wrong main entry | Point to compiled JS, not TS |
| Missing @opencode-ai/plugin dep | Add as peerDependency |
| Scoped package 404 | Add publishConfig.access: "public" |
| Assumed package name | MUST ask user for name/scope first |