writing-commands
This skill contains shell command directives (!`command`) that may execute system commands. Review carefully before installing.
Writing Commands
Overview
Commands are custom prompts triggered via /command-name in the TUI. They automate repetitive tasks with configurable agents, models, and dynamic prompt templating.
When to Use
- Creating a new custom command for repetitive workflows
- Adding argument handling or shell output injection to commands
- Configuring which agent or model handles a command
- Converting inline prompts to reusable commands
Don't use for: one-off prompts, complex multi-step workflows (use agents), or logic that needs code execution.
File Locations
.opencode/command/<name>.md # Project-local
~/.config/opencode/command/<name>.md # Global/personal
File name becomes the command name (e.g., test.md -> /test).
Frontmatter Options
---
description: Brief description shown in TUI
agent: build # Optional: agent to execute (default: current)
model: anthropic/... # Optional: override default model
subtask: true # Optional: force subagent invocation
---
| Option | Required | Description |
|---|---|---|
description |
No | Shown in TUI command list |
agent |
No | Agent to execute (defaults to current) |
model |
No | Override model for this command |
subtask |
No | Force subagent invocation (isolates context) |
template |
Yes* | Prompt text (JSON config only, body in markdown) |
*In markdown files, the body after frontmatter IS the template.
Prompt Templating
Arguments
| Placeholder | Description |
|---|---|
$ARGUMENTS |
All arguments as single string |
$1, $2... |
Positional arguments |
Create a React component named $1 in $2 directory.
Usage: /component Button src/components
Shell Output
Inject command output with backtick syntax:
Here are the current test results:
!`npm test`
Based on these results, suggest improvements.
Commands run from project root.
File References
Include file contents with @path:
Review the component in @src/components/Button.tsx.
Check for performance issues.
Quick Reference
| Pattern | Example |
|---|---|
| Simple command | /test -> runs test suite |
| With args | /component Button -> $1 = Button |
| Shell injection | !git log -5`` -> injects git output |
| File inclusion | @src/index.ts -> includes file content |
| Subagent isolated | subtask: true -> runs in isolated context |
JSON Config Alternative
Commands can also be defined in opencode.jsonc:
{
"command": {
"test": {
"template": "Run tests with coverage...",
"description": "Run tests with coverage",
"agent": "build",
"model": "anthropic/claude-3-5-sonnet-20241022",
},
},
}
Common Mistakes
| Mistake | Fix |
|---|---|
| Missing description | Always add for TUI discoverability |
Using $ARGUMENTS with positional |
Pick one style: $ARGUMENTS OR $1, $2 |
| Shell commands with side effects | Only use read-only commands in prompts |
| Overriding built-in without intent | Built-ins: /init, /undo, /redo, /share, /help |
| Forgetting quotes for JSON args | /cmd "{ \"key\": \"value\" }" |
Validation Checklist
- File name is lowercase, hyphen-separated
- Description is concise and descriptive
- Template uses correct placeholder syntax
- Shell commands are read-only (no mutations)
- File references use correct
@pathsyntax - Agent exists if specified
More from ian-pascoe/dotfiles
frontend-design
Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, artifacts, posters, or applications (examples include websites, landing pages, dashboards, React components, HTML/CSS layouts, or when styling/beautifying any web UI). Generates creative, polished code and UI design that avoids generic AI aesthetics.
20prompt-engineering-patterns
Master advanced prompt engineering techniques to maximize LLM performance, reliability, and controllability in production. Use when optimizing prompts, improving LLM outputs, or designing production prompt templates.
18writing-agents
Use when creating, editing, or reviewing agent configuration files (AGENT.md or opencode.json agents). Covers frontmatter options, mode selection, tool permissions, and common patterns.
2skill-writer
Guide users through creating Agent Skills for Claude Code. Use when the user wants to create, write, author, or design a new Skill, or needs help with SKILL.md files, frontmatter, or skill structure.
2writing-tools
Use when creating, editing, or reviewing custom OpenCode tools. Covers tool definition structure, argument schemas with Zod, context access, multi-tool files, and invoking scripts in other languages.
2writing-skills
Use when creating, editing, or reviewing SKILL.md files for AI agents. Covers frontmatter requirements, naming conventions, structure patterns, and common mistakes.
2