Files
opencode-primer/.opencode/plugins
Wesam Abousaid 5ce285d088 feat(.opencode): worked-example agents, commands, plugins, skills
This repo doubles as a fully-configured OpenCode project so readers can
see real files instead of abstract format docs.

Agents (.opencode/agents/, OpenCode YAML + markdown body):
- code-reviewer.md — read-only subagent, glob-gated bash perms,
  Severity/Where/Why/Fix output format. Rewrites the pre-refactor file
  which used incorrect frontmatter shape (no YAML, claude-sonnet-4.6
  as bare ID, made-up tool keys).
- security-auditor.md — OWASP-focused review subagent, deny edit,
  ask bash, CWE-aware output template.

Commands (.opencode/commands/):
- review.md, pr.md, test.md, optimize.md — uses real placeholders
  ($ARGUMENTS, @file, !shell), points the right agent at each task.

Plugins (.opencode/plugins/):
- protect-secrets.js — blocks tool calls touching .env*, secrets/,
  credentials*, SSH keys, .npmrc, .pypirc. Pure JS, no deps.
- audit-log.js — appends one JSON line per successful tool call to
  .opencode/audit.jsonl (also added to .gitignore).
- README.md — how to install/disable, sample audit-log line, link to
  docs/plugins.md.

Skills (.opencode/skills/git-release/SKILL.md):
- Proper folder-with-SKILL.md format. Trigger-shaped description so the
  model actually loads it when the conversation touches release prep.
2026-05-18 19:59:56 +02:00
..

.opencode/plugins/

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 successful tool call to .opencode/audit.jsonl.

How they load

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 run

Audit how this plugin folder fires

tail -f .opencode/audit.jsonl    # watch tool calls live

Sample line:

{"ts":"2026-05-18T19:30:12.451Z","tool":"edit","ok":true,"input_keys":["file_path","old_string","new_string"]}

Disabling temporarily

Three options:

  1. Move the plugin file out of .opencode/plugins/.

  2. Comment out the export default line.

  3. Gate the body of the plugin on an env var:

    if (process.env.OPENCODE_DISABLE_AUDIT_LOG) return {};
    

Writing your own

See docs/plugins.md for the full API, event list, and more patterns (auto-format on save, idle notifications, etc.).