OpenCode Commands
OpenCode commands let you create custom shortcuts for repetitive tasks. Run them with /command-name in the TUI.
What it is
Commands are markdown files in .opencode/commands/ that define prompts. When you run a command, it executes the prompt with any arguments you pass.
How to create
Create .opencode/commands/<name>.md:
---
description: Do something useful
agent: explore
---
Your prompt here. Use $ARGUMENTS or $1, $2, etc. for args.Arguments
$ARGUMENTS- all arguments$1,$2,$3- individual positional arguments
Example:
/write-note https://github.com/user/repoSpecial placeholders
- Shell output:
!command“ - injects command output into the prompt - File references:
@filename- includes file content in the prompt
Options
description- shown in TUIagent- which agent to use (default: current)subtask- force subagent modemodel- override default model
Example command
Here’s the write-note command I created:
---
description: Write a blog note from a URL
agent: explore
---
Write a short blogpost/note about the project at $1.
...Now I can run /write-note https://github.com/user/repo to automatically create notes from GitHub repos.
Built-in commands: /init, /undo, /redo, /share, /help. Custom commands can override these.
Check the docs at opencode.ai/docs/commands for more.