We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

The Prompt Box

OpenCode's prompt box does more than just accept raw text. It has some nice ergonomic features that are worth knowing about.

Selecting Files

Type @ and start typing a filename. OpenCode will open a menu you can navigate with the arrow keys, then you can press Enter to attach it. For example:

Explain how functions work in @docs/spec.md

Selecting a text file has OpenCode read it into your prompt. That saves the model from having to request a read-file tool call, though large files can be truncated.

Shortcuts

Some default TUI shortcuts include:

  • Enter sends the prompt. While the agent is working, it sends a steering message.
  • Shift+Enter adds a newline. If your terminal doesn't support that combination, try Ctrl+J.
  • Up recalls an earlier prompt when the cursor is at the start of the input. Down moves forward through prompt history when the cursor is at the end.
  • Ctrl+C clears the prompt box.
  • Ctrl+X, then E, opens your prompt in your external editor (VISUAL, or EDITOR if VISUAL isn't set). Save and close the editor; OpenCode reads the draft back when the editor process exits. GUI editors need a wait flag, such as code --wait.

Copy/Paste

You can paste text normally into the prompt box. By default, long pastes appear as a compact label. Don't worry, OpenCode still gets the full text.

By default, selecting text with the mouse in the TUI copies it to your clipboard. You'll see a "Copied to clipboard" toast when it succeeds.

Shell Mode

Type ! at the start of an empty prompt to enter shell mode. It runs a shell command directly, without asking the model to run it. It's useful for quick commands, not interactive terminal programs.

That said, the command and its output become part of the session, so your next prompt can refer to the result. You can use Esc to leave shell mode without running anything.

Assignment

Create a doubling example using the prompt box. This SlopLang code doubles a number and prints the result:

clanker double(number) {
    ship number * 2✨
}
hallucinate(double(21))✨ — prints 42

Tell OpenCode to run and submit the CLI tests from the project root.