Starting interactive mode
Launch OpenCode in interactive mode by running the command without any flags:The TUI launches in an alternate screen buffer, preserving your terminal history when you exit.
Chat interface
The main chat interface consists of three key areas:Message area
The message area displays the conversation history between you and the AI assistant. Messages are rendered with:- Markdown formatting for rich text display
- Syntax highlighting for code blocks
- Tool call visualization showing AI actions (file edits, command execution)
- Timing information for assistant responses
- Session summaries when auto-compact is enabled
Editor area
The editor at the bottom of the screen is where you compose messages:- Type your message directly in the editor
- Press
EnterorCtrl+Sto send - Use
\followed byEnterto add a newline without sending - Press
Ctrl+Eto open your external editor (set via$EDITORenvironment variable) - Attach files using
Ctrl+Fto open the file picker
Managing attachments
When you attach files, they appear above the editor with document icons:- Press
Ctrl+Rfollowed by a number (0-9) to delete a specific attachment - Press
Ctrl+Rfollowed byRto delete all attachments - Press
Escto cancel delete mode
You can attach up to 5 files per message. Attachments are sent with your message to provide context to the AI.
Sidebar (session info)
When a session is active, the right sidebar displays:- Current session title
- File change history for the session
- List of files modified during the conversation
Session management
OpenCode organizes conversations into sessions that are persisted to a SQLite database.Creating sessions
PressCtrl+N to create a new session. This clears the current conversation and starts fresh.
Switching sessions
PressCtrl+S to open the session switcher dialog:
- Use
↑/↓orj/kto navigate sessions - Press
Enterto select a session - Press
Escto close without switching
Auto-compact feature
When a conversation approaches the model’s context window limit (95% of tokens), OpenCode can automatically summarize the session:- The AI creates a summary of the conversation
- A new session is created with the summary
- You can continue working without losing context
.opencode.json:
You can also manually trigger session compaction using the “Compact Session” command via
Ctrl+K.Model selection
PressCtrl+O to open the model selection dialog:
- Use
↑/↓orj/kto navigate models - Use
←/→orh/lto switch between providers (OpenAI, Anthropic, etc.) - Press
Enterto select a model - Press
Escto close without changing
Commands
PressCtrl+K to open the command palette, which provides quick access to:
Built-in commands
Initialize Project
Creates or updates an
OpenCode.md file with project-specific context including build commands, style guidelines, and coding conventions.Compact Session
Manually triggers session summarization, creating a new session with a summary of the current conversation.
Custom commands
You can create custom commands by adding Markdown files to:~/.config/opencode/commands/for user commands (prefixed withuser:).opencode/commands/in your project for project-specific commands (prefixed withproject:)
$NAME placeholder format:
File picker
PressCtrl+F to open the file picker dialog:
- Navigate directories using arrow keys
- Select files to attach to your message
- Press
Enterto confirm selection - Press
Escto close without attaching
Theme customization
PressCtrl+T to open the theme switcher:
- Browse available themes (OpenCode, Catppuccin, Dracula, Gruvbox, etc.)
- Press
Enterto apply a theme - Press
Escto close without changing
Canceling operations
When the AI is processing (indicated by a spinner):- Press
Ctrl+Xto cancel the current operation - The agent stops generating and waits for your next input
Viewing logs
PressCtrl+L to view application logs:
- See debug information, errors, and warnings
- Navigate using standard viewport controls
- Press
Esc,Backspace, orqto return to chat
Enable debug logging with the
-d flag when starting OpenCode to see more detailed log messages.Permission system
When the AI attempts to perform actions (run commands, edit files, fetch URLs), OpenCode displays a permission dialog:- Allow (a): Grant permission for this single action
- Allow for session (s): Grant permission for all similar actions in this session
- Deny (d): Reject the action
←/→ or Tab to switch between options, then press Enter to confirm.
Help dialog
PressCtrl+? or ? (when not editing) to view all available keyboard shortcuts organized by context.
Exiting OpenCode
PressCtrl+C to show the quit confirmation dialog:
- Press
Ctrl+Cagain to confirm and exit - Press any other key to cancel and continue