explainx.ainewsletter3.5k
TrendingNewsPathwaysSkills
Pricing
explainx.ai

Upskill in AI — 16 free pathways, live workshops & bootcamps, and 50+ courses from practitioners. Plus the skills, tools, and MCP servers to practice on.

follow us

corporate training

support@explainx.ai

get started

Find your pathTake Free Evaluation

learn

pathways — start freeworkshopsbootcampscoursescertificationsmock testsexplainx universitycorporate traininglearn skills & mcp

discover

skillsmcp serversexplainx mcptoolsagentsllmsdesignsdictionaryagi trackerranks

company

aboutvisionmissionteaminstructorscommunityhackathonscareers

content

daily AI newsstate of AI — live resultsblogreleasespromptsgeneratorsresource libraryfor LLMsexplainx.ai kids

solutions

all solutionsdeveloper upskillingmarketing upskillingproduct manager upskillingleadership upskilling

newsletter · weekly

Get AI news, tools, and insights in your inbox.

supportprivacytermsdata rightshow we create contentsubmission guidelines

© 2026 AISOLO Technologies Pvt Ltd

On this page

  • Three input patterns: /, @, and !
  • How slash commands fit a typical workflow
  • Built-in slash commands (complete reference)
  • Custom slash commands (.md and JSON)
  • At commands (@): file references
  • Bash commands (!): shell passthrough
  • TUI configuration (tui.json)
  • Four-way comparison: OpenCode vs Claude Code vs Codex vs Gemini CLI
  • Commands worth memorizing first
  • Related explainx.ai guides
  • Summary
← Back to blog

explainx / blog

OpenCode Slash Commands: Complete TUI Reference (2026)

Every OpenCode slash command—/init, /undo, /compact, custom .md commands, @ file refs, and built-ins. Workflow guide from official docs.

Jun 11, 2026·8 min read·Yash Thakker
OpenCodeSlash CommandsAI CodingDeveloper ToolsTUI
go deep
OpenCode Slash Commands: Complete TUI Reference (2026)

OpenCode is an open-source agentic terminal for working with LLMs on your codebase—supporting multiple providers, subagents, MCP servers, and a keyboard-first TUI. For the full product guide (desktop app, Zen, LSP, privacy, harness comparison), see OpenCode: Open Source AI Coding Agent (2026). Beyond natural-language prompts, it exposes 17 built-in slash commands, custom markdown commands in .opencode/commands/, and @ / ! input patterns for file injection and shell passthrough.

Custom commands are defined in markdown with YAML frontmatter—you can override built-ins, pin agents and models per command, and force subagent invocation with subtask: true. This article is a complete reference from the official Commands and TUI documentation.

It is not a replacement for upstream docs. Use this as a map of the surface area and a workflow guide; verify behavior against opencode.ai/docs before you ship team runbooks.

Sister guides: Claude Code · Codex · Gemini CLI · Cursor CLI

TL;DR

table · 2 cols
QuestionAnswer
How do I see all commands?Type / in the TUI; run /help or open command palette with Ctrl+p
Custom commands?.md files in .opencode/commands/ or ~/.config/opencode/commands/
First session in a repo?/connect → /init → define custom commands
Long conversation?/compact (alias /summarize) to free context
Attach files?@path/to/file in prompts (fuzzy search, git-aware)
Run shell?!ls -la at start of message
Undo edits?/undo and /redo (requires Git repo)
Project memory file?AGENTS.md via /init
Sister guides?Claude Code · Codex · Gemini CLI · Cursor CLI
Weekly digest3.5k readers

Catch up on AI

Curated AI updates on agents, skills, and MCP — delivered to your inbox. Unsubscribe anytime.


Three input patterns: /, @, and !

OpenCode uses three prefixes with different roles—similar to Gemini CLI:

table · 3 cols
PrefixRoleExamples
/Built-in or custom slash commands/init, /compact, /test
@Fuzzy file search; inject content into prompt@packages/functions/src/api/index.ts
!Run shell command; output added as tool result!git status

Configured reference aliases also appear in @ autocomplete—type @alias for a reference root or @alias/ to browse files inside it.


How slash commands fit a typical workflow

mermaid
flowchart LR
  A[Setup /connect /init] --> B[Work /models custom cmds]
  B --> C[Context @files !shell]
  C --> D[Undo /undo /redo]
  D --> E[Share /share /export]
  E --> F[Sessions /new /sessions]

First session in a repo

table · 3 cols
StepCommandWhat it does
1/connectAdd a provider and API key
2/initGuided setup for AGENTS.md
3Create .opencode/commands/Add project-scoped custom workflows
4/modelsConfirm available models

During a task

table · 2 cols
CommandPurpose
/modelsList available models (keybind: Ctrl+x m)
/compactSummarize session to save tokens (alias: /summarize)
/thinkingToggle visibility of reasoning blocks
/detailsToggle tool execution details
@<path>Inject file content via fuzzy search
!<cmd>Run shell command; output enters conversation
Custom /review, /test, etc.Reusable prompts from .md command files

Session control and undo

table · 2 cols
CommandPurpose
/undoRemove last message + responses + revert file changes
/redoRestore previously undone message and file changes
/newStart new session (alias: /clear, keybind: Ctrl+x n)
/sessionsList and switch sessions (aliases: /resume, /continue)

Git requirement: /undo and /redo use Git internally to manage file changes—your project must be a Git repository.

Export and share

table · 2 cols
CommandPurpose
/exportExport conversation to Markdown; open in $EDITOR
/shareShare current session
/unshareUnshare current session
/editorOpen external editor for composing messages

Built-in slash commands (complete reference)

Every built-in command from the TUI documentation as of June 11, 2026.

table · 4 cols
CommandAliasesPurposeKeybind
/connect—Add provider and API key—
/compact/summarizeCompact/summarize current sessionCtrl+x c
/details—Toggle tool execution details—
/editor—Open $EDITOR for message compositionCtrl+x e
/exit/quit, /qExit OpenCodeCtrl+x q
/export—Export conversation to MarkdownCtrl+x x
/help—Show help dialog—
/init—Guided AGENTS.md setup—
/models—List available modelsCtrl+x m
/new/clearStart new sessionCtrl+x n
/redo—Redo after /undo (Git-backed)Ctrl+x r
/sessions/resume, /continueList and switch sessionsCtrl+x l
/share—Share current session—
/themes—List available themesCtrl+x t
/thinking—Toggle reasoning block visibility—
/undo—Undo last turn + revert files (Git-backed)Ctrl+x u
/unshare—Unshare current session—

Leader key: Default leader is Ctrl+x—many shortcuts require leader first (e.g. Ctrl+x then n for new session). Customize via tui.json keybinds.

Command palette: Ctrl+p opens the full command list beyond slash autocomplete.

Note: Custom commands with the same name override built-ins. If you define .opencode/commands/init.md, it replaces /init.


Custom slash commands (.md and JSON)

Custom commands are OpenCode's primary extensibility layer—repetitive prompts defined once, invoked with /command-name.

Scopes

table · 3 cols
ScopeDirectoryConfig alternative
Global~/.config/opencode/commands/command key in opencode.jsonc
Project.opencode/commands/Same JSON config, project-scoped

Check project commands into Git for team workflows.

Markdown command example

Create .opencode/commands/test.md:

markdown
---
description: Run tests with coverage
agent: build
model: anthropic/claude-3-5-sonnet-20241022
---

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

Invoke:

bash
/test

JSON config alternative

jsonc
{
  "$schema": "https://opencode.ai/config.json",
  "command": {
    "test": {
      "template": "Run the full test suite with coverage report and show any failures.\nFocus on the failing tests and suggest fixes.",
      "description": "Run tests with coverage",
      "agent": "build",
      "model": "anthropic/claude-3-5-sonnet-20241022"
    }
  }
}

Frontmatter / JSON options

table · 3 cols
OptionRequiredPurpose
template / bodyYesPrompt sent to the LLM
descriptionNoShown in TUI command picker
agentNoAgent to execute (defaults to current)
modelNoOverride model (provider/model format)
subtaskNoForce subagent invocation; isolates from primary context

Agent behavior: If the specified agent is a subagent, the command triggers subagent invocation by default. Set subtask: false to disable. Set subtask: true to force subagent mode even when the agent is configured as primary.

Template placeholders

table · 3 cols
SyntaxPurposeExample
$ARGUMENTSAll args after command name/component Button
$1, $2, $3Positional arguments/create-file config.json src "{...}"
!`command`Inline shell output in prompt!`npm test`
@path/to/fileInject file content in command template@src/components/Button.tsx

Component example:

markdown
---
description: Create a new component
---

Create a new React component named $ARGUMENTS with TypeScript support.
Include proper typing and basic structure.
bash
/component Button

Coverage analysis example:

markdown
---
description: Analyze test coverage
---

Here are the current test results:
!`npm test`

Based on these results, suggest improvements to increase coverage.

Review with file reference:

markdown
---
description: Review component
---

Review the component in @src/components/Button.tsx.
Check for performance issues and suggest improvements.

Shell commands in templates run from the project root; output becomes part of the prompt.


At commands (@): file references

table · 2 cols
PatternPurpose
@packages/functions/src/api/index.tsFuzzy file search; content auto-injected
@aliasConfigured reference root from autocomplete
@alias/docs/README.mdBrowse files inside a reference alias

Example prompt:

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

OpenCode respects .gitignore for file filtering (similar to Gemini CLI's git-aware @ behavior).


Bash commands (!): shell passthrough

table · 2 cols
PatternPurpose
!ls -laRun command; output added as tool result
Start message with !Shell output enters the conversation

Unlike slash commands, ! patterns are message prefixes, not CLI meta-commands.


TUI configuration (tui.json)

TUI behavior is configured separately from opencode.json via tui.json or tui.jsonc:

json
{
  "$schema": "https://opencode.ai/tui.json",
  "theme": "opencode",
  "leader_timeout": 2000,
  "keybinds": {
    "leader": "ctrl+x",
    "command_list": "ctrl+p"
  },
  "scroll_speed": 3,
  "diff_style": "auto",
  "mouse": true,
  "attention": {
    "enabled": true,
    "notifications": true,
    "sound": true
  }
}

Use OPENCODE_TUI_CONFIG for a custom config path. Disable keybinds by setting value to "none".

Notable keybinds beyond slash commands:

table · 2 cols
ActionDefault keybind
Agent listCtrl+x a
Agent cycleTab / Shift+Tab
Model variant cycleCtrl+t
Session forkconfigurable
Status viewCtrl+x s
Copy messageCtrl+x y

Full list: Keybinds documentation.


Four-way comparison: OpenCode vs Claude Code vs Codex vs Gemini CLI

table · 5 cols
TaskOpenCodeClaude CodeCodexGemini CLI
Project memory/init → AGENTS.md/init → CLAUDE.md/init → AGENTS.md/init → GEMINI.md
Custom commands.md in .opencode/commands/SkillsSkills/plugins.toml in .gemini/commands/
Free context/compact/compact/compact/compress
Switch model/models/model + /effort/model/model set
File attachment@path/ide/mention, /ide@path
Shell passthrough!command——!command
Undo file changes/undo, /redo/rewind—/restore, /rewind
Autonomous targetcustom cmd + agent/goal/goal—
Plan modecustom cmd + agent: plan/plan/plan/plan
Share session/share, /unshare/export, cloud/export/chat share
MCPvia config + keybinds/mcp/mcp/mcp
Subagentssubtask: true in commands/agents, /fork/agent, /fork/agents

Full references: OpenCode · Claude Code · Codex · Gemini CLI


Commands worth memorizing first

bash
/connect                       # add provider + API key
/init                          # AGENTS.md guided setup
/models                        # pick model
/compact                       # free context mid-session
@src/main.ts Explain this file # attach code
!git diff                      # shell output in chat
/undo                          # revert last turn + files
/sessions                      # switch saved sessions
/share                         # share session link
/export                        # markdown export

Quick custom command starter

bash
mkdir -p .opencode/commands
cat > .opencode/commands/plan.md << 'EOF'
---
description: Strategic plan only—no implementation
agent: plan
subtask: true
---

Create a step-by-step plan for: $ARGUMENTS
Do NOT write or modify code.
EOF

/plan Refactor the auth module

Related explainx.ai guides

  • Claude Code commands reference — Anthropic CLI
  • Codex slash commands reference — OpenAI CLI
  • Gemini CLI slash commands reference — Google CLI
  • Cursor CLI slash commands reference — Cursor terminal
  • What are agent skills? — skill patterns across hosts
  • What is MCP? — MCP in OpenCode config
  • Agent skills secure registry — OpenCode in the skills ecosystem
  • Goal mode complete guide — /goal on Codex and Claude Code
  • gstack skills factory — multi-CLI skill layouts

Primary sources: Commands — OpenCode Docs · TUI — OpenCode Docs · Keybinds


Summary

OpenCode's slash-command surface is lean on built-ins (17 commands) and deep on custom .md commands—with agent, model, and subtask overrides that none of the other three CLIs match one-to-one. The /undo / /redo pair with Git-backed file reversion is distinctive; so is subtask: true for context-isolated custom workflows.

Type /help or Ctrl+p to discover commands in your build. Treat opencode.ai/docs as source of truth; bookmark this guide alongside the Claude Code, Codex, Gemini CLI, and Cursor CLI references for cross-platform work.


Command names, keybinds, and custom command syntax reflect OpenCode documentation as of June 11, 2026. Re-check opencode.ai/changelog before documenting internal runbooks.

Spotted something out of date? Let us know.
Yash Thakker

Written by

Yash Thakker

Yash is an AI expert with over 300K learners. Join his workshops →

Related posts

Jun 11, 2026

Claude Code Commands: Complete Slash Command Reference (2026)

Claude Code exposes 90+ slash commands for setup, parallel agents, review, memory, and shipping. This is the complete reference: what each command does, when to use it, and how they fit a typical workflow.

Jun 11, 2026

Codex Slash Commands: Complete CLI Reference (2026)

Codex CLI exposes 40+ slash commands for models, permissions, goals, subagents, review, and session control. This is the complete reference: what each command does, when to use it, and how they fit a typical workflow.

Jun 11, 2026

Cursor CLI Slash Commands: Complete Reference (2026)

Cursor CLI exposes 25+ slash commands for Plan/Ask modes, models, sandbox, MCP, rules, and session control. This is the complete reference from official docs plus how commands fit a typical workflow.