Skip to content

AI Tools: Built-in Commands

OpenCode has slash commands that control how it works. Type / in the TUI to see available commands.

Essential Commands

CommandWhat It Does
/initInitialize OpenCode for the current project (creates AGENTS.md)
/undoUndo the last change OpenCode made
/redoRedo a change that was undone
/shareCreate a shareable link to the current conversation
/helpShow help information
/connectSet up or switch an LLM provider
/modelSwitch to a different model mid-session

Undo and Redo

Made a mistake? No problem.

/undo

OpenCode reverts the last change it made. Run /undo multiple times to step back further.

Changed your mind again?

/redo

Sharing Sessions

Sharing your session is useful for asking for help or showing your work.

/share

This creates a link to your current conversation and copies it to your clipboard. Example: https://opencode.ai/s/4XP1fce5

Conversations are never shared unless you explicitly run /share.

Custom Commands

You can create custom slash commands for repetitive tasks. Create .opencode/commands/test.md:

markdown
---
description: Run tests with coverage
---

Run the full test suite and show any failures.
Focus on the failing tests and suggest fixes.

Now you can run /test in the TUI.

Keyboard Shortcuts

ShortcutAction
TabToggle between Plan mode and Build mode
@Fuzzy search and reference a file
Ctrl+CCancel the current response
Up/DownNavigate conversation history

Quiz

Q1: What command creates a shareable link to your OpenCode session?

  • [ ] A) /undo
  • [ ] B) /share
  • [ ] C) /link
  • [ ] D) /export
Answer

B) /share

The /share command creates a link to your current conversation and copies it to your clipboard. Conversations are never shared unless you explicitly run this command.

Q2: How do you undo a change OpenCode made?

  • [ ] A) Close the terminal
  • [ ] B) Type /undo
  • [ ] C) Delete the file manually
  • [ ] D) Type /revert
Answer

B) Type /undo

The /undo command reverts the last change OpenCode made. You can run it multiple times to step back further.

Q3: What does the Tab key do in OpenCode?

  • [ ] A) Closes the program
  • [ ] B) Toggles between Plan mode and Build mode
  • [ ] C) Saves the current file
  • [ ] D) Opens a new tab in your terminal
Answer

B) Toggles between Plan mode and Build mode

Tab switches between Plan mode (explains what it would do but makes no changes) and Build mode (reads, edits, and creates files).

Built for XBot Robotics Team 488