Slash Commands Reference
Command Quick Reference
| Command | Aliases | Shortcut | Purpose |
|---|---|---|---|
/help | - | Ctrl+X H | Show help dialog |
/new | /clear | Ctrl+X N | Start a new session |
/undo | - | Ctrl+X U | Undo last message |
/redo | - | Ctrl+X R | Redo undone message |
/compact | /summarize | Ctrl+X C | Compact/summarize current session |
/connect | - | - | Add AI provider |
/models | - | Ctrl+X M | List available models |
/sessions | /resume, /continue | Ctrl+X L | List and switch sessions |
/share | - | Ctrl+X S | Create public link to share conversation |
/unshare | - | - | Unshare current session |
/export | - | Ctrl+X X | Export conversation as Markdown |
/themes | - | - | List available themes |
/editor | - | Ctrl+X E | Open external editor for message |
/init | - | Ctrl+X I | Create/update AGENTS.md |
/details | - | Ctrl+X D | Toggle tool execution details |
/thinking | - | - | Toggle AI thinking process display |
/exit | /quit, /q | Ctrl+X Q | Exit OpenCode |
Session Control
/new
Start a new conversation session. This clears the current context and begins fresh.
Aliases: /clear
Shortcut: Ctrl+X N
Use Cases
- New task: Start working on a different problem
- Context reset: Clear accumulated context to reduce token usage
- Fresh start: Begin without previous conversation history
/undo
Undo the last message in the conversation. This requires a Git repository.
Shortcut: Ctrl+X U
Use Cases
- Mistake correction: Remove an incorrect question
- Flow control: Backtrack conversation to try different approach
- Context cleanup: Remove messages that led conversation astray
/redo
Redo a previously undone message. This requires a Git repository.
Shortcut: Ctrl+X R
Use Cases
- Restore messages: Bring back undone content
- Flow recovery: Restore conversation flow after undo
- Experimentation: Try different conversation paths
/compact
Compact and summarize the current session to reduce token usage while preserving context.
Aliases: /summarize
Shortcut: Ctrl+X C
Use Cases
- Long conversations: Reduce tokens in extended sessions
- Cost optimization: Lower API costs while maintaining context
- Performance: Speed up responses by reducing context size
Navigation and Switching
/models
Display a list of all available AI models from configured providers.
Shortcut: Ctrl+X M
Use Cases
- Model selection: Choose the best model for current task
- Provider comparison: See what models each provider offers
- Capability matching: Find models with specific features
/sessions
List all conversation sessions and switch between them.
Aliases: /resume, /continue
Shortcut: Ctrl+X L
Use Cases
- Context switching: Jump between different projects
- Session history: Review past conversations
- Multi-project work: Manage multiple ongoing tasks
/themes
List available color themes for the TUI interface.
Use Cases
- UI customization: Personalize your OpenCode interface
- Visibility: Adjust colors for better readability
- Preference: Match your terminal theme
Tool Integration
/editor
Open an external editor to compose longer messages or prompts.
Shortcut: Ctrl+X E
Use Cases
- Long prompts: Compose detailed instructions
- Formatted input: Use your editor’s features
- Multi-line messages: Write complex queries more easily
/export
Export the current conversation as Markdown format.
Shortcut: Ctrl+X X
Use Cases
- Documentation: Save conversations for reference
- Sharing: Share conversations with team members
- Archival: Keep records of important interactions
/share
Create a public shareable link to the current conversation.
Shortcut: Ctrl+X S
Use Cases
- Collaboration: Share conversations with colleagues
- Support requests: Provide context when asking for help
- Knowledge sharing: Distribute useful AI interactions
/unshare
Remove public access to a previously shared conversation.
Use Cases
- Privacy control: Revoke public access to conversations
- Cleanup: Remove old shared links
- Security: Unshare accidentally shared sensitive content
System Configuration
/connect
Interactively add a new AI provider to OpenCode.
Use Cases
- Setup: Configure new AI providers
- Provider addition: Add more model options
- Key updates: Update or change provider credentials
/init
Create or update the AGENTS.md file in your project to help OpenCode understand your project structure.
Shortcut: Ctrl+X I
Use Cases
- Project setup: Initialize OpenCode for new projects
- Context improvement: Help AI understand project structure
- Configuration: Update project metadata
/details
Toggle the display of detailed tool execution information.
Shortcut: Ctrl+X D
Use Cases
- Debugging: See what tools AI is executing
- Learning: Understand how OpenCode works
- Transparency: Monitor AI actions in detail
/thinking
Toggle the display of AI thinking process and reasoning.
Use Cases
- Understanding: See how AI approaches problems
- Debugging: Identify reasoning issues
- Learning: Learn from AI problem-solving approach
Help and Exit
/help
Display the help dialog with available commands and shortcuts.
Shortcut: Ctrl+X H
Use Cases
- Quick reference: Look up available commands
- Learning: Discover new features
- Shortcuts: Find keyboard shortcuts
/exit
Exit the OpenCode TUI.
Aliases: /quit, /q
Shortcut: Ctrl+X Q
Special Syntax
File Reference: @filename
Reference file contents within your prompts to add them to the conversation context.
Syntax
@path/to/file.ext
Examples
Explain this code: @src/main.go
Refactor @components/Header.tsx to use hooks
Review these files: @api/users.ts @api/auth.ts
Use Cases
- Code review: Ask AI to analyze specific files
- Refactoring: Provide context for code changes
- Explanation: Get detailed explanations of code
Shell Command: !command
Execute shell commands and include their output in the conversation context.
Syntax
!shell-command
Examples
What changed recently? !git log -10 --oneline
Analyze test failures: !npm test
Review directory structure: !tree -L 2 src/
Use Cases
- Dynamic context: Include current system state
- Error analysis: Share error outputs with AI
- Status checking: Include command output in questions
Custom Commands
You can create custom slash commands by placing Markdown files in specific directories.
File Locations
Project-level (all platforms):
<PROJECT_DIR>/.opencode/commands/
Global-level (macOS/Linux):
~/.config/opencode/commands/
# or
$XDG_CONFIG_HOME/opencode/commands/
Global-level (Windows):
%APPDATA%\opencode\commands\
File Format
Custom command files use Markdown with YAML frontmatter:
---
description: Brief description of the command
agent: optional-agent-name
model: optional-model-name
---
Command content or prompt template.
You can use placeholders:
- $ARGUMENTS for user-provided arguments
- @filename for file references
- !command for shell commands
Naming
The filename (without .md extension) becomes the command name:
review-pr.md→/review-prgenerate-tests.md→/generate-tests
Examples
File: .opencode/commands/review-pr.md
---
description: Review pull request changes
model: anthropic/claude-3.5-sonnet
---
Please review the following PR changes and provide:
1. Code quality assessment
2. Potential bugs or issues
3. Suggestions for improvement
!git diff origin/main...HEAD
File: .opencode/commands/explain.md
---
description: Explain code in detail
---
Please provide a detailed explanation of: @$ARGUMENTS
Include:
- Purpose and functionality
- Key components
- Best practices used or violated
- Suggestions for improvement
Best Practices
Additional tips:
- Keep commands focused on a single task
- Use descriptive names
- Document expected arguments
- Test commands in a safe environment first
- Version control project-level commands