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. 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
| Question | Answer |
|---|---|
| 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 |
Three input patterns: /, @, and !
OpenCode uses three prefixes with different roles—similar to Gemini CLI:
| Prefix | Role | Examples |
|---|---|---|
/ | 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
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
| Step | Command | What it does |
|---|---|---|
| 1 | /connect | Add a provider and API key |
| 2 | /init | Guided setup for AGENTS.md |
| 3 | Create .opencode/commands/ | Add project-scoped custom workflows |
| 4 | /models | Confirm available models |
During a task
| Command | Purpose |
|---|---|
/models | List available models (keybind: Ctrl+x m) |
/compact | Summarize session to save tokens (alias: /summarize) |
/thinking | Toggle visibility of reasoning blocks |
/details | Toggle 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
| Command | Purpose |
|---|---|
/undo | Remove last message + responses + revert file changes |
/redo | Restore previously undone message and file changes |
/new | Start new session (alias: /clear, keybind: Ctrl+x n) |
/sessions | List 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
| Command | Purpose |
|---|---|
/export | Export conversation to Markdown; open in $EDITOR |
/share | Share current session |
/unshare | Unshare current session |
/editor | Open external editor for composing messages |
Complete AI Builder Bootcamp
Claude, Python automation & full-stack — 12 live sessions with Yash Thakker.
The Complete AI Builder Bootcamp is the best AI development course for learning Claude AI, prompt engineering, Python automation, and full-stack web development. This intensive 6-week live bootcamp teaches you how to build AI-powered applications using Claude Projects, Claude Artifacts, Claude Code, and the complete Claude ecosystem. You'll master prompt engineering techniques, learn to create custom Claude connectors and MCP integrations, build Python automation workflows, develop full-stack websites with AI assistance, and create AI marketing agents.
The bootcamp includes 12 live Zoom sessions with Yash Thakker, founder of AISOLO Technologies and instructor to 350,000+ students. You'll build 8+ portfolio projects including AI playbooks, full-stack note-taking applications, Python automation scripts, marketing agents, and personal portfolio websites. The curriculum covers AI fundamentals, Claude Projects and Artifacts, Claude Co-work, Claude plugins and skills, Claude Code for Python development, full-stack development, AI marketing, and capstone projects.
Students receive 1-year access to all recordings, permanent Discord community access, a certificate of completion, and personalized career guidance. All enrollments include a 7-day money-back guarantee. This is the most comprehensive Claude AI bootcamp available, taking students from zero AI knowledge to expert AI builder in 6 weeks.
Built-in slash commands (complete reference)
Every built-in command from the TUI documentation as of June 11, 2026.
| Command | Aliases | Purpose | Keybind |
|---|---|---|---|
/connect | — | Add provider and API key | — |
/compact | /summarize | Compact/summarize current session | Ctrl+x c |
/details | — | Toggle tool execution details | — |
/editor | — | Open $EDITOR for message composition | Ctrl+x e |
/exit | /quit, /q | Exit OpenCode | Ctrl+x q |
/export | — | Export conversation to Markdown | Ctrl+x x |
/help | — | Show help dialog | — |
/init | — | Guided AGENTS.md setup | — |
/models | — | List available models | Ctrl+x m |
/new | /clear | Start new session | Ctrl+x n |
/redo | — | Redo after /undo (Git-backed) | Ctrl+x r |
/sessions | /resume, /continue | List and switch sessions | Ctrl+x l |
/share | — | Share current session | — |
/themes | — | List available themes | Ctrl+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
| Scope | Directory | Config 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:
---
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:
/test
JSON config alternative
{
"$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
| Option | Required | Purpose |
|---|---|---|
template / body | Yes | Prompt sent to the LLM |
description | No | Shown in TUI command picker |
agent | No | Agent to execute (defaults to current) |
model | No | Override model (provider/model format) |
subtask | No | Force 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
| Syntax | Purpose | Example |
|---|---|---|
$ARGUMENTS | All args after command name | /component Button |
$1, $2, $3 | Positional arguments | /create-file config.json src "{...}" |
!`command` | Inline shell output in prompt | !`npm test` |
@path/to/file | Inject file content in command template | @src/components/Button.tsx |
Component example:
---
description: Create a new component
---
Create a new React component named $ARGUMENTS with TypeScript support.
Include proper typing and basic structure.
/component Button
Coverage analysis example:
---
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:
---
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
| Pattern | Purpose |
|---|---|
@packages/functions/src/api/index.ts | Fuzzy file search; content auto-injected |
@alias | Configured reference root from autocomplete |
@alias/docs/README.md | Browse files inside a reference alias |
Example prompt:
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
| Pattern | Purpose |
|---|---|
!ls -la | Run 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:
{
"$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:
| Action | Default keybind |
|---|---|
| Agent list | Ctrl+x a |
| Agent cycle | Tab / Shift+Tab |
| Model variant cycle | Ctrl+t |
| Session fork | configurable |
| Status view | Ctrl+x s |
| Copy message | Ctrl+x y |
Full list: Keybinds documentation.
Four-way comparison: OpenCode vs Claude Code vs Codex vs Gemini CLI
| Task | OpenCode | Claude Code | Codex | Gemini CLI |
|---|---|---|---|---|
| Project memory | /init → AGENTS.md | /init → CLAUDE.md | /init → AGENTS.md | /init → GEMINI.md |
| Custom commands | .md in .opencode/commands/ | Skills | Skills/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 target | custom cmd + agent | /goal | /goal | — |
| Plan mode | custom cmd + agent: plan | /plan | /plan | /plan |
| Share session | /share, /unshare | /export, cloud | /export | /chat share |
| MCP | via config + keybinds | /mcp | /mcp | /mcp |
| Subagents | subtask: true in commands | /agents, /fork | /agent, /fork | /agents |
Full references: OpenCode · Claude Code · Codex · Gemini CLI
Commands worth memorizing first
/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
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 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 —
/goalon 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.