Turn /template into a tiny form builder for your AI sessions.
Pick a template → fill a form → preview → send a well-prepared prompt.
An OpenCode plugin that lets you pick a prompt template, fill in a small form (selects, radio buttons, checkboxes, text fields), preview the result, and send a well-prepared prompt into your current session.
/template → pick template → fill form → preview → send
- 📝 Form-driven prompts — six field types (
select,radio,checkbox,checkboxes,text,textarea) render into a native OpenCode form dialog - 👀 Preview loop — see the fully rendered prompt before it goes: send,
edit your answers again, or cancel with
Esc— nothing is sent by accident - 🕐 Recents & Repeat — the last 5 used templates appear in a "Recent" category, and the most recent one offers a Repeat entry that reuses your previous answers instantly
- 📁 Project over global — templates live in
.opencode/templates/*.md(project) and~/.config/opencode/templates/*.md(global); same file id → project wins - 🧭 Agent & model switches — frontmatter can route the prompt to a
specific
agent:or override themodel:per template - 🔍 Searchable picker — filter templates while typing, grouped into Project / Global / Recent categories
- 🛡️ Readable errors — invalid template files report their validation errors instead of breaking the picker
- 🧩 Placeholder filters —
default:"…"fallbacks,join:", "for checkbox groups, and automatic dropping of lines whose placeholders all resolve empty
The easiest way is the OpenCode CLI:
opencode plugin add github:egel/opencode-action-template-pluginOr add it to opencode.json(c) manually:
Then restart OpenCode (or run /reload). You should see a "Plugin loaded" toast.
Templates are Markdown files with YAML frontmatter, discovered in:
.opencode/templates/*.md— project (takes precedence)~/.config/opencode/templates/*.md— global
The frontmatter defines the form; the body is the prompt template with
{{ fieldId }} placeholders. Copy examples/*.md to get started.
A fuller example showing several field types, defaults, placeholders, and frontmatter switches:
---
name: Code review
description: Review code for bugs, security and quality issues
preview: true # show a send/edit/cancel preview (default true)
agent: plan # optional agent switch before sending
# model: anthropic/claude-sonnet-5-5 # optional model override
fields:
- id: path
type: text
label: Files or directory
placeholder: e.g. src/render.ts # hint shown in the empty input
- id: focus
type: select # single-choice list
label: Review focus
default: bugs # pre-selected option value
options:
- { title: Bugs, value: bugs }
- { title: Security, value: security }
- { title: Performance, value: performance }
- { title: Readability, value: readability }
- id: severity
type: radio # same UI as select, semantically exclusive
label: Only report issues of severity
default: major
options:
- { title: Critical, value: critical }
- { title: Major, value: major }
- { title: Minor, value: minor }
- id: also
type: checkboxes # toggle list with a "✔ Done" entry
label: Also verify
options:
- { title: Tests, value: tests, default: true }
- { title: Types, value: types, default: true }
- { title: Error handling, value: errors }
- { title: Naming, value: naming }
- id: strict
type: checkbox # simple yes/no
label: Be blunt in the summary?
checked: true # initial state
- id: notes
type: textarea
label: Extra notes
placeholder: Anything specific to look at?
---
Review {{ path | default:"the current changes" }} with focus on {{ focus }}.
Only report {{ severity }} issues or worse.
Also verify: {{ also | join:", " }}.
{{ strict == "yes" ? "" : "" }}Be direct in the summary.
> {{ notes }}| Type | UI | Prompt value |
|---|---|---|
select |
single-choice list | chosen option value |
radio |
single-choice list | chosen option value |
checkboxes |
toggle list with a ✔ Done entry |
array, joined by the join filter |
checkbox |
Yes/No list | yes or empty |
text |
single-line input | typed text |
textarea |
single-line input (multiline dialog planned) | typed text |
Field options: label, placeholder, default (text value or option value),
checked (for checkbox), and options with title, value, default.
{{ path | default:"the current changes" }}— fallback when empty{{ also | join:", " }}— join checkbox groups- Lines whose placeholders all resolve empty (e.g.
> {{ notes }}) are dropped
- Keep option
values lowercase and space-free — they end up in the prompt - Put optional sections on their own lines so they drop out cleanly when empty
- Use
agent: planfor templates that only research, and leave it unset for templates that edit code
Ready-to-copy templates live in examples/:
code-review.md— review code for bugs and qualityplan-feature.md— draft an implementation plancommit-message.md— write a commit message from a diff
Install from a local checkout (useful while hacking on the plugin itself) by
pointing the plugins entry at the path:
{
"$schema": "https://opencode.ai/config.json",
"plugins": [
{ "package": "<my_path_to_repo>/opencode-action-template-plugin" },
],
}Then restart OpenCode (or run /reload).
npm test # vitest
npm run typecheck-
/templateappears in slash and palette lists - Picker shows Project/Global categories and filters while typing
- Form pre-fills defaults; Esc at any step cancels without sending
- Checkbox toggles round-trip into the rendered prompt
- Preview "Edit answers again" reopens the form; "Send" submits into the session
- Repeat entry reuses last answers; recents category updates after send
- A broken template shows its validation errors; the picker still works
-
agent:/model:frontmatter switches are applied (or warned about)
textareafields use the single-line prompt dialog (multiline editor planned)- Checkbox groups toggle through a list with a
✔ Doneentry (inline multi-select planned) - Submitting requires an open session; run
/templatefrom inside one
Built for OpenCode · MIT licensed
{ "$schema": "https://opencode.ai/config.json", "plugins": ["github:egel/opencode-action-template-plugin"], }