Commands & Slash Commands
Relevant source files
The following files were used as context for generating this wiki page:
Commands and Slash Commands in the Oh-My-OpenCode project serve as high-level triggers for complex agentic workflows. They provide a structured interface for users to initiate specific tasks—such as repository initialization, intelligent refactoring, or planning—which are then orchestrated by specialized Agents. These commands encapsulate multi-phase logic, including discovery, analysis, planning, and execution, ensuring that AI operations are deterministic and safe.
The system relies on a template-based architecture where each command defines its own usage, parameters, and internal state machine. For instance, commands like /init-deep and /refactor utilize specialized templates to guide the agent through concurrent exploration and multi-step verification.
Sources: src/features/builtin-commands/templates/refactor.ts:3-16, src/features/builtin-commands/templates/init-deep.ts:1-12, sisyphus-prompt.md:52-70
Command Execution Lifecycle
Commands follow a rigorous lifecycle to ensure technical accuracy and minimize AI "slop" (over-engineering or hallucinatory actions). The execution typically transitions through an intent gate, concurrent exploration, and a planning phase before any code modifications occur.
Intent Gate and Validation
Every command starts with an Intent Gate (Phase 0). The system classifies the request (e.g., Trivial, Explicit, Exploratory, or Open-ended) and validates the user's requirements. If the scope is ambiguous, the system is constrained to ask for clarification rather than making assumptions.
Sources: src/features/builtin-commands/templates/refactor.ts:20-47, sisyphus-prompt.md:72-92
Concurrent Exploration
Complex commands trigger parallel exploration to gather repository context without blocking the main session. This often involves spawning multiple "explore" or "librarian" agents to analyze project structure, find entry points, and detect coding conventions simultaneously.
Sources: src/features/builtin-commands/templates/init-deep.ts:25-45, src/agents/hephaestus.ts:246-270
The following diagram illustrates the standard workflow for a high-complexity slash command:
Built-in Slash Commands
The project includes specialized commands designed for repository management and code evolution.
/init-deep
This command generates hierarchical AGENTS.md files across the project. It uses a scoring matrix to determine which directories warrant documentation based on file count, code ratio, and symbol density.
Sources: src/features/builtin-commands/templates/init-deep.ts:1-12, src/features/builtin-commands/templates/init-deep.ts:135-155
| Option | Type | Description |
|---|---|---|
--create-new | Flag | Removes existing AGENTS.md files and regenerates from scratch. |
--max-depth | Number | Limits the directory depth for analysis (Default: 3). |
| Sources: src/features/builtin-commands/templates/init-deep.ts:5-7 |
/refactor
The /refactor command handles intelligent code transformations. It is constrained by a "Verification Strategy" that mandates existing tests pass before and after changes. If coverage is low, the command is instructed to block the refactor or request new tests.
Sources: src/features/builtin-commands/templates/refactor.ts:163-178
| Strategy | Description |
|---|---|
safe | Conservative changes, requires maximum test coverage. |
aggressive | Allows broader changes with adequate coverage. |
| Sources: src/features/builtin-commands/templates/refactor.ts:12-14 |
Command Constraints and Guardrails
To prevent destructive actions, slash commands operate under strict operational constraints defined in the system prompts.
The /start-work Protocol
Planning agents like Prometheus are forbidden from executing code directly. Instead, they generate a work plan file in .sisyphus/plans/*.md. The user must then execute the /start-work command to transition from planning to implementation.
Sources: src/agents/prometheus/identity-constraints.ts:40-55, src/agents/prometheus/identity-constraints.ts:135-145
Verification and QA
Commands that modify the codebase MUST include agent-executable QA scenarios. These scenarios must not require human intervention and should utilize tools like curl, bun test, or playwright.
Sources: src/agents/prometheus/identity-constraints.ts:184-210, sisyphus-prompt.md:286-300
Summary
Commands and Slash Commands provide the entry point for the Oh-My-OpenCode orchestration layer. By enforcing a template-driven approach with mandatory phases for discovery and planning, the system ensures that complex repository-wide operations like deep initialization and refactoring are performed with high accuracy and full context awareness.
Sources: sisyphus-prompt.md:16-30, src/agents/hephaestus.ts:114-125