DEV Community

imper
imper

Posted on

/disconnect for opencode — a tiny TUI plugin I wish existed before I made it

I use opencode as my daily TUI coding agent. It's good. But there's one thing that kept biting me.

When you want to remove a single provider — say you rotated a key and want the old entry gone — opencode doesn't ship a clean way to do it. The choices are:

  1. Re-auth every provider from scratch
  2. Open ~/.local/share/opencode/auth.json in vim and pray the trailing comma survives

I did option 2 maybe four times before I got annoyed enough to write a plugin.

What I built

opencode plugin opencode-tui-utils
Enter fullscreen mode Exit fullscreen mode

Then inside the TUI:

/disconnect
Enter fullscreen mode Exit fullscreen mode

It opens opencode's own provider picker — the same dialog component the rest of the TUI already uses — so it doesn't feel like a bolted-on script. You pick the provider you want gone, confirm, done.

Token values are never printed. Only provider names and auth types are shown, so you can run it in a recorded session without paranoia.

The other commands

Since I was writing the plugin loader anyway, I added the three other slash commands I kept wanting:

  • /lsp-toggle — flip LSP on/off without restarting the TUI
  • /websearch-toggle — same for web search
  • /tool-status — print what's currently enabled

The toggle commands update your shell profile and prompt for a restart, which matches opencode's existing pattern for launch-gated flags.

Why a plugin instead of a fork

opencode's plugin system is just JSON: drop the package into ~/.config/opencode/tui.json under "plugin", restart, the slash command shows up in the palette next to the built-ins. No fork to maintain, no rebase pain when opencode updates.

This also means adding command #5 is mechanical — there's a shared API wrapper and the loader handles registration. If you've got a slash command you keep missing in opencode, there's a "command ideas up for grabs" section in CONTRIBUTING.md.

Where to find it


Built by @Blue-B — happy to take feedback, especially from anyone using opencode in a workflow I haven't thought of.

Top comments (0)