GuidesHosting choices

OpenCode commands: CLI, TUI slash commands and keybinds

OpenCode 2's commands: every CLI command, the TUI's slash commands and keys, the Ctrl+X leader, cli.json keybinds, and custom commands with $ARGUMENTS.

November 28, 2026The Everpod team
The short answer

opencode opens the full-screen terminal interface (the TUI) in the current folder; opencode run "..." sends one prompt and prints the reply; opencode serve, auth, models, session, mcp, stats and upgrade do the rest. Inside the TUI, type / for commands such as /models, /agents, /new, /sessions, /undo and /compact; Ctrl+P lists every action, and Ctrl+X is the leader key (Ctrl+X then M for models). A custom command is a Markdown file: .opencode/commands/review.md becomes /review, and $ARGUMENTS in its body takes what you type after it. This is OpenCode 2 (2.4.2, November 26, 2026); version 1 differs in places, noted below.

Which version the docs describe

OpenCode 2 is the @opencode/cli package, 2.4.2 on the npm registry as of November 28, 2026; version 1 is opencode-ai, still at 1.19.6. The version 2 docs live at opencode.ai/docs, which calls itself the “OpenCode V2 Documentation site”, and version 1’s under /v1/docs. Not every /v1 page has caught up: on November 28, /v1/docs/tui/ showed the version 2 TUI page, while /v1/docs/commands/ still showed version 1’s custom commands. Everything on this page about version 2 comes from the /docs pages and the source at the v2.4.2 tag; version 1’s TUI comes from its own docs source at v1.19.6. If you are not sure which you have, the OpenCode 1 to 2 upgrade guide shows how to tell and what changes.

The CLI commands

Every command takes --help. From the version 2.4.2 source and the commands reference:

CommandWhat it does
opencode [dir]
Opens the TUI, in dir if given. -c continues the last session, -s <id> a given one, --prompt pre-fills a prompt
opencode mini
A minimal interactive interface instead of the full-screen one
opencode run
One prompt, reply printed, then exit; -m, --agent, -c, -s, --fork, -w (new git worktree), -f (attach a file), --format json, --title, --archived, --thinking, --auto
opencode auth
list, login, logout, switch (the active account), export, import
opencode models
Lists every model you can use; it takes no arguments
opencode session
list (-n, --format json), delete (the session and its child sessions), export (--sanitize), import (--directory)
opencode mcp
list, add, auth, logout for MCP servers
opencode plugin
list, add, check, update, remove
opencode stats
Usage and cost: --days 7, --models, --cost, --project ., --json
opencode serve
The API and web server in the foreground
opencode service
The shared background server: start, restart, status, stop, get, set, unset
opencode pair
One-time links and a QR code that sign a browser or an app in to the server; the links expire after five minutes
opencode reload
Reloads configuration without restarting the server
opencode api
A request to the running server, such as opencode api GET /api/session
opencode acp
An Agent Client Protocol server on stdin and stdout, for editors
opencode debug
agents, config (where settings came from), paths, heap-dump
opencode machine
add, list, remove: “Manage remote machines” (in the source, not yet in the docs)
opencode upgrade
To the latest, or a version such as opencode upgrade 2.4.2; alias update; --method names the install method
opencode uninstall
Stops the services and removes OpenCode, keeping sessions and config; --dry-run previews it

Two global flags change where the work happens. By default every command talks to one shared background server for your account, which outlives your terminal; --standalone runs a private one for that command alone, and --server <url> connects to another. The background server has its own guide, OpenCode’s background service. --print-logs sends logs to standard error.

auth export prints your saved credentials, secrets included, as JSON (the docs: “The file contains secrets.”). If you move them to another machine that way, keep the file readable by you alone and delete it afterwards:

(umask 077; opencode auth export anthropic > credentials.json)
# copy it across, then on the other machine:
opencode auth import credentials.json && rm credentials.json
Copied

run is the one for scripts and timers; its flags, JSON output and permission behaviour are in opencode run on cron or a systemd timer, and serve and its password in the OpenCode API guide. Version 2 has no web, attach, github, pr or top-level export command; those are version 1’s.

The TUI’s slash commands

Type / at the start of the prompt and a list opens; keep typing to filter it. The built-in commands in 2.4.2, from its source and the TUI page, with their aliases and default keys:

CommandWhat it doesKey
/new
New sessionCtrl+X N
/sessions (/resume, /continue)
Switch sessionCtrl+X L
/open (/projects)
Recent sessions and projectsCtrl+O
/clear
Clear session
/models
Switch modelCtrl+X M; F2 cycles recent ones
/variants (/thinking, /effort)
The model’s variant, such as reasoning effortCtrl+T cycles
/agents
Switch agentCtrl+X A; Shift+Tab cycles
/undo, /redo
Revert the last message and the work after it, and put it backCtrl+X U, Ctrl+X R
/compact
Compact the sessionCtrl+X C
/rename, /fork, /timeline
Rename the session, fork it, jump to a messageCtrl+R, none, Ctrl+X G
/copy, /export
Copy the last reply; export the transcriptCtrl+X Y, Ctrl+X X
/editor
Edit the prompt in $VISUAL or $EDITORCtrl+X E
/btw <question>
A side question that sees the session but stays out of it
/connect (/login, /auth)
Connect a provider or other integration
/mcps, /usage, /status
MCP servers, usage, status/status: Ctrl+X S
/pair (/web)
Pair a browser or phone with this server
/settings, /themes, /reload, /restart
Settings, theme, reload config, restart the background service
/update, /highlights, /debug, /help
Update, release notes, debug info, help
/exit (/quit, /q)
ExitCtrl+C, Ctrl+D or Ctrl+X Q

/pair is still there in version 2, and is the same thing as opencode pair: one-time links that sign a browser or an app in to your server. Opening OpenCode from your phone covers doing that safely on a server. Version 1’s /share is another matter: the version 2 TUI page does not list it, the old sharing page at opencode.ai/docs/share/ returned 404 on November 28, 2026, and the command lists in the 2.4.2 terminal’s source carry no share command.

Keys worth knowing

Switching agents is Shift+Tab; what Build and Plan are and how to add your own is in the OpenCode agents guide. To keep a TUI session running after your SSH connection drops, start it inside tmux.

Changing the keys, and the leader

Version 2 keeps its keys in ~/.config/opencode/cli.json (or under $XDG_CONFIG_HOME), and the settings page says “There is no project-local CLI settings file.” Version 1’s tui.json is replaced by it. The leader is itself a binding. The keybinds page’s example moves it to Ctrl+Space and gives it more time; the server.pair line here adds a key for pairing, which has none by default:

{
  "$schema": "https://opencode.ai/v2/cli.json",
  "keybinds": {
    "leader": "ctrl+space",
    "model.list": "<leader>m",
    "server.pair": "<leader>p"
  },
  "leader": {
    "timeout": 2000
  }
}
Copied

A value of "none" or false turns a binding off, several keys go comma-separated ("ctrl+c,ctrl+d,<leader>q"), and an action name OpenCode does not know is ignored rather than refused, so a typo fails silently. Many actions ship with no key, among them server.pair, session.fork and theme.switch; the keybinds page lists every ID.

Writing a custom command

A command is a Markdown file in .opencode/commands/ for one project or ~/.config/opencode/commands/ for every project. The file name is the command, and a subfolder becomes part of it: .opencode/commands/team/review.md runs as /team/review. The frontmatter is optional and the body is the prompt. From the commands page:

---
description: Review code for correctness
agent: plan
model: openai/gpt-6.1-sol#high
---

Review $ARGUMENTS. Report bugs first.
Copied

Arguments: $ARGUMENTS is everything typed after the command, so /review src/auth.ts sends “Review src/auth.ts. Report bugs first.”. $1, $2 and so on take single arguments; quotes group words, the highest-numbered placeholder takes everything left over, and a missing one becomes empty. A template with neither gets the arguments appended after a blank line.

A shell block puts a command’s output into the prompt. It runs in the project’s folder, after the arguments are filled in:

---
description: Review the uncommitted changes
---

Review this diff:

!`git diff --stat && git diff`
Copied

That block runs when you invoke the command, not when the agent asks, and the docs are plain about it: “Shell blocks run when OpenCode evaluates the command, outside the agent’s tool permission flow.” Your permission rules never see it, so read a command from someone else’s repository before you run it. One change from version 1 trips people up: an @path written in the file is no longer expanded and reaches the model as plain text. Attach the file with @ in the prompt when you invoke the command instead.

The same command can live in opencode.json, under commands with the prompt in template (where that file goes is in OpenCode’s config guide):

{
  "$schema": "https://opencode.ai/config.json",
  "commands": {
    "review": {
      "description": "Review code for correctness",
      "template": "Review $ARGUMENTS. Report bugs first."
    }
  }
}
Copied

Files and config share one list: a project’s command beats a global one of the same name, the nearest .opencode/ beats one further up, and a custom command can replace a built-in. OpenCode reloads them as they change, so a new file shows up without a restart. Only .md files count, and the old singular folder .opencode/command/ is still read. A command is a prompt you type; a skill is one the model picks for itself, and the OpenCode skills guide covers that side.

On OpenCode 1

Version 1’s TUI has the same leader, Ctrl+X, with its keys in tui.json, and a slightly different list: /share and /unshare (“Share current session.” and “Unshare current session.”), /init (“Guided setup for creating or updating AGENTS.md”), /details, /thinking, and /new with the alias /clear. Its /undo uses Git, so the project “needs to be a Git repository”. On the command line it adds web, attach, github, pr, agent, export, import and db, and the TUI itself takes --model and --agent. Custom commands are the same files with two differences: the JSON key is command, singular, and an @file in the template is read into the prompt.

Run OpenCode on an always-on developer pod.

A developer pod is a permanent cloud computer (VPS), set up and secured for you, with your pick of Claude Code, Codex, OpenCode, Pi, Hermes and OpenClaw installed. Run more agents at once than your laptop can hold, and keep them working when it’s closed. From $24 a month, built in about ten minutes.