Working examples of OpenCode plugins. Drop-in to any project — pure JS, no npm dependencies.
| Plugin | What it does |
|---|---|
protect-secrets.js |
Blocks any tool call (read/write/bash) touching .env*, secrets/, credentials*, SSH keys, .npmrc, .pypirc. |
audit-log.js |
Appends a one-line JSON record of every completed tool call to .opencode/audit.jsonl. |
OpenCode auto-loads every .js / .ts file in .opencode/plugins/ at session start. No registration step.
opencode # loads both plugins automatically
opencode --pure # skip all plugins for one runtail -f .opencode/audit.jsonl # watch tool calls liveSample line:
{"ts":"2026-06-08T19:30:12.451Z","tool":"edit","arg_keys":["filePath","oldString","newString"],"title":"src/api/auth.ts"}Three options:
-
Move the plugin file out of
.opencode/plugins/. -
Comment out all exports in the file (every export is loaded, so a leftover one keeps the plugin alive) — or rename the file to a non-
.js/.tsextension. -
Gate the body of the plugin on an env var:
if (process.env.OPENCODE_DISABLE_AUDIT_LOG) return {};
See docs/plugins.md for the full API, event list, and more patterns (auto-format on save, idle notifications, etc.).