A Claude Code-style next-prompt suggestion for the OpenCode TUI. After each turn, a short "next question / action" is proposed as ghost text above the prompt. Tab inserts it into the input field; Enter sends it.
- OpenCode ≥ 2.2.3 (TUI plugin API V2). Built and type-checked against
@opencode/plugin@2.2.3.
Why 2.2.3 or later? A TUI plugin renders inside OpenCode's terminal UI, so it is bound to the version of OpenTUI that OpenCode ships. Since OpenCode 2.2.3, TUI plugins require OpenTUI 0.8 (a breaking change in that release); earlier 2.x releases ship an older OpenTUI and cannot load this plugin. Newer 2.x releases keep working as long as they make no breaking change to the TUI plugin API — none as of 2.3.0.
-
Clone the repository and install its dependencies:
git clone https://github.com/ALCyllene/OpencodePromptSuggestionPlugin.git cd OpencodePromptSuggestionPlugin npm installThe runtime bundles (
solid-js,@opentui/*,@opencode/plugin) are provided by OpenCode itself; installing here is mainly for type-checking and keeping the package self-contained. -
Make the plugin discoverable. Pick one:
Symlink into a scanned plugins directory (recommended):
# Global (all projects): mkdir -p ~/.config/opencode/plugins ln -s "$PWD" ~/.config/opencode/plugins/prompt-suggestion # Or per-project: # mkdir -p <project>/.opencode/plugins # ln -s "$PWD" <project>/.opencode/plugins/prompt-suggestion
The plugin directories are watched: the plugin is loaded/unloaded on the fly, without restarting the TUI.
Or reference it from your configuration, in
opencode.json(c)orcli.json(a TUI-only plugin belongs incli.jsonto stay active against a remote server): -
That's it — a suggestion appears after the end of each turn.
| Action | Effect |
|---|---|
| End of a turn | A suggestion is generated (config default model) |
Tab (a suggestion is shown) |
Inserts the text into the prompt |
Tab (no suggestion) |
Normal behavior (prompt autocompletion) |
| New user prompt | Dismisses the current suggestion |
PSG_DEBUG=/tmp/psg.log opencodeLogs the plugin's life (load, slot, generation, acceptance, prompts) to the given file.
- Trigger: the
session.execution.succeededevent (end of turn), listened on viacontext.data.on. - Context: the last 8 messages via
client.session.context. - Generation:
client.experimental.generate.text(one stateless LLM call per turn — the same trade-off as Claude Code). The model is the config default, read viaclient.config.get, requested in thelowvariant (reduced reasoning effort). When the model has no such variant, the server refuses without any LLM call and the plugin retries without a variant. - "Generating suggestion…" state: shown above the prompt while generating (dismissed if a new prompt is typed).
- Display: the
session.composer.topslot (above the composer), using thetheme.text.mutedcolor. - Acceptance: a conditional
Tabkeymap layer (enabled) that inserts the text viainsertTexton the focused renderable.
- One extra LLM call per turn (cost and latency, ~1–5 s depending on the model).
- A suggestion is only generated for the session currently on screen.
Tabonly inserts while the prompt has focus; otherwise the key is left to the host and the suggestion stays displayed.
npm install
npm run typecheckThe plugin is a single file, src/tui.tsx, exposed through the ./tui
entrypoint. It is typed against the official Context from
@opencode/plugin/tui.

{ "$schema": "https://opencode.ai/config.json", "plugins": ["/absolute/path/to/OpencodePromptSuggestionPlugin"] }