Skip to content

TUI

Using the OpenCode terminal user interface.

OpenCode provides an interactive terminal interface or TUI for working on your projects with an LLM.

Running OpenCode starts the TUI for the current directory.

Terminal window
opencode

Or you can start it for a specific working directory.

Terminal window
opencode /path/to/project

Once you’re in the TUI, you can prompt it with a message.

Give me a quick summary of the codebase.

File references

You can reference files in your messages using @. This does a fuzzy file search in the current working directory.

How is auth handled in @packages/functions/src/api/index.ts?

The content of the file is added to the conversation automatically.

Configured references also appear in @ autocomplete. Type @alias to add the reference root as context, or type @alias/ to autocomplete files inside that reference.

Compare our setup with @docs/README.md

Bash commands

Start a message with ! to run a shell command.

!ls -la

The output of the command is added to the conversation as a tool result.


Commands

When using the OpenCode TUI, you can type / followed by a command name to quickly execute actions. For example:

/help

Most commands also have keyboard shortcuts using ctrl+x as the default leader key. Learn more.

Here are all available slash commands:


connect

Add a provider to OpenCode. Allows you to select from available providers and add their API keys.

/connect

compact

Compact the current session. Alias: /summarize

/compact

Keybind: ctrl+x c


details

Toggle tool execution details.

/details

editor

Open external editor for composing messages. Uses the editor set in your EDITOR environment variable. Learn more.

/editor

Keybind: ctrl+x e


exit

Exit OpenCode. Aliases: /quit, /q

/exit

Keybind: ctrl+x q


export

Export current conversation to Markdown and open in your default editor. Uses the editor set in your EDITOR environment variable. Learn more.

/export

Keybind: ctrl+x x


help

Show the help dialog.

/help

init

Guided setup for creating or updating AGENTS.md. Learn more.

/init

models

List available models.

/models

Keybind: ctrl+x m


new

Start a new session. Alias: /clear

/new

Keybind: ctrl+x n


redo

Redo a previously undone message. Only available after using /undo.

Internally, this uses Git to manage the file changes. So your project needs to be a Git repository.

/redo

Keybind: ctrl+x r


sessions

List and switch between sessions. Aliases: /resume, /continue

/sessions

Keybind: ctrl+x l


share

Share current session. Learn more.

/share

themes

List available themes.

/themes

Keybind: ctrl+x t


thinking

Toggle the visibility of thinking/reasoning blocks in the conversation. When enabled, you can see the model’s reasoning process for models that support extended thinking.

/thinking

undo

Undo last message in the conversation. Removes the most recent user message, all subsequent responses, and any file changes.

Internally, this uses Git to manage the file changes. So your project needs to be a Git repository.

/undo

Keybind: ctrl+x u


unshare

Unshare current session. Learn more.

/unshare

Editor setup

Both the /editor and /export commands use the editor specified in your EDITOR environment variable.

Terminal window