Overview
Custom commands let you define reusable workflows that encapsulate your team’s best practices, coding standards, and common tasks. They transform complex multi-step processes into simple commands.Creating Commands
Define commands inopencode.json:
Command Structure
Basic Command
Minimal command definition:With Arguments
Commands can accept arguments:With Specific Agent
Assign commands to specialized agents:With Specific Model
Use a specific model for a command:As Subtask
Execute command as a subtask (uses Task tool):- Run in isolated context
- Can use specialized agents
- Results are summarized back to main agent
- Useful for complex, independent tasks
Template Syntax
Positional Arguments
Use$1, $2, $3, etc. for individual arguments:
All Arguments
Use$ARGUMENTS for all arguments as a single string:
Escaping
To use literal$ in templates:
Multi-line Templates
Use arrays for multi-line templates:Real-World Examples
Development Workflow
Testing Commands
Code Quality
Documentation
Refactoring
Database
Command Discovery
Users can discover commands through:Autocomplete
Type/ to see all available commands:
Command Help
Commands show their descriptions in autocomplete with argument hints:List Commands Programmatically
Via API:Sharing Commands
Team Commands
Commitopencode.json to share commands with your team:
Global Commands
Add personal commands globally:Priority
When the same command name exists in multiple places:- Project -
.opencode/opencode.json(highest priority) - Project root -
opencode.json - Global -
~/.config/opencode/opencode.json - Built-in -
/init,/review(lowest priority)
Command Libraries
Create reusable command libraries:opencode.json:
Best Practices
Be specific
Write detailed templates that clearly describe expectations
Use agents
Assign specialized agents to appropriate commands
Add examples
Include examples in templates to guide the agent
Keep descriptions short
Use concise descriptions that explain when to use the command
Related Topics
Commands Config
Full command configuration reference
Agents
Create specialized agents
In-Session Commands
Learn about built-in commands
MCP Prompts
Add commands from MCP servers