summaryrefslogtreecommitdiffhomepage
path: root/packages/web/src
diff options
context:
space:
mode:
authorDax <[email protected]>2025-08-22 17:04:28 -0400
committerGitHub <[email protected]>2025-08-22 17:04:28 -0400
commit133fe41cd5fb0ec3dc03a90e58526408297878fd (patch)
tree82aac357a61fe9e7a6802974f6c7cf169a9f22a8 /packages/web/src
parent74c1085103e130cb07522e3ad725f17eca3e5832 (diff)
downloadopencode-133fe41cd5fb0ec3dc03a90e58526408297878fd.tar.gz
opencode-133fe41cd5fb0ec3dc03a90e58526408297878fd.zip
slash commands (#2157)
Co-authored-by: adamdotdevin <[email protected]>
Diffstat (limited to 'packages/web/src')
-rw-r--r--packages/web/src/content/docs/docs/commands.mdx167
-rw-r--r--packages/web/src/content/docs/docs/index.mdx26
2 files changed, 172 insertions, 21 deletions
diff --git a/packages/web/src/content/docs/docs/commands.mdx b/packages/web/src/content/docs/docs/commands.mdx
new file mode 100644
index 000000000..93be346c6
--- /dev/null
+++ b/packages/web/src/content/docs/docs/commands.mdx
@@ -0,0 +1,167 @@
+---
+title: Commands
+description: Create custom commands for repetitive tasks.
+---
+
+Define custom commands to automate repetitive coding tasks.
+
+---
+
+## Create command files
+
+Create markdown files in the `command/` directory to define custom commands.
+
+Create `.opencode/command/test.md`:
+
+```md
+---
+description: Run tests with coverage
+agent: build
+model: anthropic/claude-3-5-sonnet-20241022
+---
+
+Run the full test suite with coverage report and show any failures.
+Focus on the failing tests and suggest fixes.
+```
+
+The frontmatter defines command properties. The content becomes the template.
+
+Use the command by typing `/` followed by the command name.
+
+```bash frame="none"
+"/test"
+```
+
+---
+
+## Create command files
+
+For complex commands, create markdown files in the `command/` directory.
+
+Create `.opencode/command/test.md`:
+
+```md
+---
+description: Run tests with coverage
+agent: build
+model: anthropic/claude-3-5-sonnet-20241022
+---
+
+Run the full test suite with coverage report and show any failures.
+Focus on the failing tests and suggest fixes.
+```
+
+The frontmatter defines command properties. The content becomes the template.
+
+---
+
+## Use arguments
+
+Pass arguments to commands using the `$ARGUMENTS` placeholder.
+
+```md
+---
+description: Create a new component
+---
+
+Create a new React component named $ARGUMENTS with TypeScript support.
+Include proper typing and basic structure.
+```
+
+Run the command with arguments:
+
+```bash frame="none"
+"/component Button"
+```
+
+---
+
+## Inject shell output
+
+Use `!`command`` to inject shell command output into your prompt.
+
+```md
+---
+description: Analyze test coverage
+---
+
+Here are the current test results:
+`!npm test`
+
+Based on these results, suggest improvements to increase coverage.
+```
+
+```md
+---
+description: Review recent changes
+---
+
+Recent git commits:
+`!git log --oneline -10`
+
+Review these changes and suggest any improvements.
+```
+
+Commands run in your project's root directory and their output becomes part of the prompt.
+
+---
+
+## Reference files
+
+Include files in your command using `@` followed by the filename.
+
+```md
+---
+description: Review component
+---
+
+Review the component in @src/components/Button.tsx.
+Check for performance issues and suggest improvements.
+```
+
+The file content gets included in the prompt automatically.
+
+---
+
+## Command properties
+
+Configure commands with these optional frontmatter properties:
+
+- **description**: Brief explanation of what the command does
+- **agent**: Agent to use (defaults to "build")
+- **model**: Specific model to use for this command
+
+```md
+---
+description: Code review assistant
+agent: build
+model: anthropic/claude-3-5-sonnet-20241022
+---
+
+Review the code for best practices and suggest improvements.
+```
+
+---
+
+## Command directory
+
+Store command files in these locations:
+
+- `.opencode/command/` - Project-specific commands
+- `command/` - Global commands in config directory
+
+Project commands take precedence over global ones.
+
+---
+
+## Built-in commands
+
+opencode includes several built-in commands:
+
+- `/init` - Initialize project and create AGENTS.md
+- `/undo` - Revert the last changes
+- `/redo` - Restore reverted changes
+- `/share` - Share the current conversation
+- `/help` - Show available commands and keybinds
+
+Use `/help` to see all available commands in your setup.
diff --git a/packages/web/src/content/docs/docs/index.mdx b/packages/web/src/content/docs/docs/index.mdx
index 858a605b2..31587850f 100644
--- a/packages/web/src/content/docs/docs/index.mdx
+++ b/packages/web/src/content/docs/docs/index.mdx
@@ -41,26 +41,10 @@ You can also install it with the following:
- **Using Node.js**
<Tabs>
- <TabItem label="npm">
- ```bash
- npm install -g opencode-ai
- ```
- </TabItem>
- <TabItem label="Bun">
- ```bash
- bun install -g opencode-ai
- ```
- </TabItem>
- <TabItem label="pnpm">
- ```bash
- pnpm install -g opencode-ai
- ```
- </TabItem>
- <TabItem label="Yarn">
- ```bash
- yarn global add opencode-ai
- ```
- </TabItem>
+ <TabItem label="npm">```bash npm install -g opencode-ai ```</TabItem>
+ <TabItem label="Bun">```bash bun install -g opencode-ai ```</TabItem>
+ <TabItem label="pnpm">```bash pnpm install -g opencode-ai ```</TabItem>
+ <TabItem label="Yarn">```bash yarn global add opencode-ai ```</TabItem>
</Tabs>
- **Using Homebrew on macOS and Linux**
@@ -308,4 +292,4 @@ Here's an [example conversation](https://opencode.ai/s/4XP1fce5) with opencode.
And that's it! You are now a pro at using opencode.
-To make it your own, we recommend [picking a theme](/docs/themes), [customizing the keybinds](/docs/keybinds), [configuring code formatters](/docs/formatters), or playing around with the [opencode config](/docs/config).
+To make it your own, we recommend [picking a theme](/docs/themes), [customizing the keybinds](/docs/keybinds), [configuring code formatters](/docs/formatters), [creating custom commands](/docs/commands), or playing around with the [opencode config](/docs/config).