TUI
Run OpenCode from your project, type a request, and press Enter.
cd ~/code/my-project
opencodeExplain how authentication works in this projectPress Shift+Enter, Ctrl+Enter, Alt+Enter, or Ctrl+J for a new line. While OpenCode is working, Enter steers the active session; press Ctrl+X, then Enter to queue the prompt for later.
The directory you start OpenCode in is where it searches files and runs shell commands. Directories in the same Git repository, including its worktrees, belong to one project. A directory without version control is its own project.
Pass a directory to start in another project:
opencode ~/code/another-projectPress Ctrl+O to open recent sessions and projects. Press Right on a project to list its worktrees, and Ctrl+N there to create a new one.
Type @ to search for a file, then select it to attach that file to the prompt. Keep typing after @ to narrow the results.
Review @src/auth.ts for error handling problemsYou can include a line or range after the path.
Explain @src/auth.ts#20-45Type ! at the start of an empty prompt to enter shell mode. Enter a command and press Enter; press Esc to leave shell mode without running one.
!git statusShell commands run in the session’s working directory and their output stays in the session.
Type / to list slash commands. Continue typing to filter the list, then press Enter to run the selected command.
/modelsCommon commands include /new, /sessions, /models, /agents, /undo, /redo, and /editor. Press Ctrl+P to open the command palette for every action available in the current view.
After an update, OpenCode shows what’s new in the release once on the home screen. Run /highlights to see it again, or set "highlights": false in cli.json to stop it from opening automatically.
Run /btw <question> to ask a quick question about the conversation so far. The answer uses the session’s context and current model but is not added to the conversation, so it does not affect later prompts. A /btw indicator shows in the prompt footer while it runs, and the answer opens in a dialog; press C to copy it.
/btw why did the test in step 2 fail?Press Ctrl+X, then M to choose a model, or run /models. Press F2 to cycle through recently used models.
Press Ctrl+X, then A to choose an agent, or run /agents. Press Shift+Tab to cycle agents.
Each session is a separate conversation with its own history and directory. Run /new or press Ctrl+X, then N to start one for a separate task; earlier sessions stay available. New sessions start in the directory you launched OpenCode in, or in the current session’s directory with session.new_location set to inherit.
Press Ctrl+X, then L or run /sessions to return to an existing session. In that list, Ctrl+A switches between sessions in the current directory and sessions in all projects. Ctrl+O opens recent sessions and projects together.
Tabs are enabled by default. Use Ctrl+Tab and Ctrl+Shift+Tab to move between them, Ctrl+X then W to close one, and Ctrl+Shift+T to reopen the last closed tab.
Press Ctrl+X, then U, or run /undo, to revert the latest user message and the work that followed it. The reverted prompt returns to the composer so you can edit it.
Press Ctrl+X, then R, or run /redo, to restore the reverted work. Sending a new prompt instead accepts the revert and continues from that point.
Set VISUAL or EDITOR, then press Ctrl+X, then E, or run /editor, to edit the current prompt in that editor. Save and exit to return the text to the composer, then press Enter to send it.
export EDITOR="nvim"
opencodeThe leader key is Ctrl+X by default. See Keybinds to change these shortcuts.