GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [feat] custom slash commands · Issue #299 · anomalyco/opencode

[feat] custom slash commands #299

New issue
Copy link
New issue
Copy link
Closed
Closed
[feat] custom slash commands#299
Copy link
Assignees
tmeireadamdotdevin

Description

@monotykamary
monotykamary
opened on Jun 21, 2025
Issue body actions

There's an opportunity to add support for custom slash commands similar to Claude Code's slash command system, allowing users to create reusable prompts and workflows as markdown files.

Background

Currently, opencode has a keybinding-based command system with built-in triggers (like /help, /new, /sessions), but lacks the ability to create custom slash commands. Claude Code provides a powerful slash command system that allows users to:

  • Create custom commands as .md files
  • Support both project-level and personal commands
  • Use dynamic arguments and bash execution
  • Reference files directly in commands

Proposed Feature

Custom Slash Commands

Allow users to create custom slash commands by placing .md files in:

  • Project commands: .opencode/commands/*.md (shared with team)
  • Personal commands: ~/.opencode/commands/*.md (user-specific)

Command Syntax

/project:<command-name> [arguments]
/user:<command-name> [arguments]

Command File Format

Commands would be markdown files with optional YAML frontmatter:

---
description: "Analyze code for performance issues"
allowed-tools: ["bash", "read", "edit"]
---

Analyze this code for performance issues and suggest optimizations:

$ARGUMENTS

Key Features

  1. Namespacing: Support subdirectories for organization

    • .opencode/commands/frontend/component.md → /project:frontend:component
  2. Dynamic Arguments: Use $ARGUMENTS placeholder for user input

    # Usage: /project:fix-issue 123
    # Command: Fix issue #$ARGUMENTS following our coding standards
  3. Bash Command Execution: Execute bash commands with ! prefix

    ## Context
    - Current git status: !`git status`
    - Recent commits: !`git log --oneline -10`
  4. File References: Include file contents with @ prefix

    Review the implementation in @src/utils/helpers.js
    Compare @src/old-version.js with @src/new-version.js

Implementation Plan

1. Command File System

  • Create command directory scanning logic
  • Support both .opencode/commands/ (project) and ~/.opencode/commands/ (user)
  • Parse markdown files with YAML frontmatter

2. Command Parser

  • Extend existing completion system in packages/tui/internal/completions/
  • Add custom command discovery and parsing
  • Support namespaced command syntax

3. Command Execution Engine

  • Extend command registry in packages/tui/internal/commands/command.go
  • Implement dynamic command registration from files
  • Add argument substitution ($ARGUMENTS)
  • Add bash execution support (! prefix)
  • Add file reference support (@ prefix)

4. Integration Points

  • Modify chat editor to handle custom slash commands
  • Update completion provider to include custom commands
  • Extend command execution logic in TUI

Benefits

  1. Improved Workflow: Users can create reusable prompts for common tasks
  2. Team Collaboration: Project-level commands can be shared via version control
  3. Consistency: Standardize common workflows across team members
  4. Flexibility: Support for dynamic arguments and file references
  5. Extensibility: Easy to add new commands without code changes

Examples

Project Command: Code Review

.opencode/commands/review.md:

---
description: "Perform code review with context"
---

## Context
- Current branch: !`git branch --show-current`
- Modified files: !`git diff --name-only`

## Task
Review the following changes for:
- Code quality and best practices
- Security vulnerabilities
- Performance implications

$ARGUMENTS

Usage: /project:review Please focus on the authentication logic

Personal Command: Quick Fix

~/.opencode/commands/quickfix.md:

---
description: "Quick bug fix with standard format"
---

Fix the following issue following our coding standards:

Issue: $ARGUMENTS

Please:
1. Identify the root cause
2. Implement a minimal fix
3. Add appropriate tests
4. Update documentation if needed

Usage: /user:quickfix Button click handler not working on mobile

Related Work

This feature is inspired by Claude Code's slash command system, which provides similar functionality. The implementation would leverage opencode's existing command and completion infrastructure.

Acceptance Criteria

  • Support creating custom commands via .md files
  • Implement project-level (.opencode/commands/) and user-level (~/.opencode/commands/) command directories
  • Support namespaced commands via subdirectories
  • Implement $ARGUMENTS placeholder for dynamic content
  • Support bash command execution with ! prefix
  • Support file references with @ prefix
  • Integrate with existing completion system
  • Commands appear in / completion dropdown
  • Maintain backward compatibility with existing command system
Reacted by Nitsan Avni, Jason Ish, Liang-Shih Lin, Adrien DE SEDE, Harrison King, Justin Vogt, Sebastian Flügge, Daniel Williams, Zach Daniel, yanosea and 26 more
Reacted by Saatvik Arya, bobbyfinger, BryanAMDG, Liang-Shih Lin, Sebastian Flügge, Felipe Rubio, yanosea, peter-tran-13, Benjamin von Polheim, Micha(el) Bladowski and 9 more
Reacted by Thomas Roche

Activity

  1. monotykamary
    changed the title [-]feature request: custom slash commands[/-] [+][feat] custom slash commands[/+] on Jun 22, 2025
  2. thdxr
    assigned
    adamdotdevin
    on Jun 22, 2025
  3. adamdotdevin commented on Jun 22, 2025

    @adamdotdevin
    adamdotdevin
    on Jun 22, 2025
    Member
    More actions

    if anyone wants to take a stab at this, please let me know here. we can use a modal for custom command args, but i wonder if we could just support them inline in the editor textarea, like:

    > /project:fix-issue 113
    

    would be cool to avoid all the complexity of the modal

  4. tmeire commented on Jun 22, 2025

    @tmeire
    tmeire
    on Jun 22, 2025
    Contributor
    More actions

    if anyone wants to take a stab at this, please let me know here. we can use a modal for custom command args, but i wonder if we could just support them inline in the editor textarea, like:

    > /project:fix-issue 113
    

    would be cool to avoid all the complexity of the modal

    @adamdotdevin can you assign it to me? I'll take a stab at this tomorrow.

    Reacted by Adam
  5. adamdotdevin
    assigned
    tmeire
    on Jun 22, 2025
  6. pattobrien commented on Jun 23, 2025

    @pattobrien
    pattobrien
    on Jun 23, 2025
    More actions

    It'd be awesome if the main implementation for custom commands used the MCP Prompt primitive.

    Reacted by Ed Zynda, Eli Oshinsky and Kent
    Reacted by Thomas Meire
  7. tmeire commented on Jun 25, 2025

    @tmeire
    tmeire
    on Jun 25, 2025
    Contributor
    More actions

    @thdxr @adamdotdevin I've implemented the basics (but majority) of this ticket in PR #385 . Would love some feedback on the general direction & some thoughts on how you would implement bash & file references support.

    The main functionality is implemented on the server side to make sure it's available on future clients without effort.

    • prompts are passed to the tui using the config endpoint
    • prompts are then injected into the command list
    • after completion, the command is injected into the textarea to allow for additional arguments
    • the command with arguments are send to the server
    • the server translates the command to the stored prompt

    Things where the implementation differs from the OP:

    • User commands are stored in ~/.local/opencode as per xdg
    • Allowed tools are parsed from the md files, but not used yet
    • Bash execution and file references are not implemented yet
    • It doesn't use the MCP prompts; the general support for those looks very weak at best
  8. ezynda3 commented on Jun 25, 2025

    @ezynda3
    ezynda3
    on Jun 25, 2025
    Contributor
    More actions

    Would it be possible to have named args just like we had before the refactor? 56160f8

    Reacted by Imran
  9. syabro commented on Jun 26, 2025

    @syabro
    syabro
    on Jun 26, 2025
    More actions

    /project:frontend:component
    Do we really need project/user prefixes? It's a huge downside for UX
    I want to type /com and get /commit suggestion. I don't want to type /project:com

    Reacted by Adam and Adam Spiers
  10. adamdotdevin commented on Jun 26, 2025

    @adamdotdevin
    adamdotdevin
    on Jun 26, 2025
    Member
    More actions

    /project:frontend:component
    Do we really need project/user prefixes? It's a huge downside for UX
    I want to type /com and get /commit suggestion. I don't want to type /project:com

    fwiw, the fuzzy matching should still allow you to match "com" in that example, but i've also thought it'd be nice to drop this distinction (even if only for aesthetic purposes)

  11. seflue commented on Jul 5, 2025

    @seflue
    seflue
    on Jul 5, 2025
    More actions

    It would be great, if I could refer to my existing claude-code slash-commands or github prompt files like the custom instructions.

    Regarding the namespacing: In claude-code this namespacing is just a convention. Files are matched directly but there is no working auto completion for namespaces. The lookup is somehow fuzzy, if the command file was not found, the LLM tries to find it using file system tools. What I would prefer, if the namespaced commands are actually discovered and I can then just fuzzy match, like OpenCode already does. So it is primarily a matter of discovery and presentation within a list. Namespaces would be great, because then I could define stuff like /idea:new or /feat:new. I have this already in my slash commands in claude-code, but the ergonomics are far from ideal, because the autocompletion, although it matches the relevant commands doesn't show the namespaces. This is something, where I see some potential for OpenCode to provide a better user experience.

  12. ll931217 commented on Jul 5, 2025

    @ll931217
    ll931217
    on Jul 5, 2025
    Contributor
    More actions

    I really want this in OpenCode, so I took the initiative, I am really new to golang. Got the basics working. Took me a while to wrap my head around the packages.

    I was able to add fuzzy find on my commands, I am able to supply arguments to the command file. Here is the code if anyone wants to try it out.

    I want to first test the code some more and fix up where there is issues.

    Reacted by yanosea, Sebastian Flügge, Callum Arnold and Vikash Loomba
  13. KP-Jaco commented on Jul 11, 2025

    @KP-Jaco
    KP-Jaco
    on Jul 11, 2025
    More actions

    Huge +1 to this. I have a lot of custom slash commands set up in claude code so this would really close the loop.

    Reacted by JonBoyleCoding and Robin
  14. hujianxin commented on Jul 31, 2025

    @hujianxin
    hujianxin
    on Jul 31, 2025
    More actions

    I'm really looking forward to this feature. It will bring about huge changes.

    Reacted by Rafał Krzyważnia
  15. jayair
    marked Add /custom-commands feature to execute prompts defined in Markdown files #1216 as a duplicate of this issue on Aug 8, 2025
  16. thoroc commented on Aug 12, 2025

    @thoroc
    thoroc
    on Aug 12, 2025
    More actions

    Would be nice to have so we can use the bmad method.

  17. monotykamary commented on Aug 12, 2025

    @monotykamary
    monotykamary
    on Aug 12, 2025
    ContributorAuthor
    More actions

    apologies, I read that as the "be mad" method

    Reacted by Thomas Roche, V4G4X, Liang-Shih Lin, Gabe Duarte and shekohex
  18. fettpl commented on Aug 18, 2025

    @fettpl
    fettpl
    on Aug 18, 2025
    More actions

    @thdxr @jayair Is there any solid plan for this feature? There's a statement in #707 regarding you bringing it to internal discussion, but no follow-up.

    Reacted by Justin Donnaruma, Cristóbal Carnero Liñán, Tobias Walle, Sebastian Flügge, Robin, Liang-Shih Lin, Antonio Lorusso, Mohammad Kermani, Martinffx and Adam Spiers
  19. jayair commented on Aug 18, 2025

    @jayair
    jayair
    on Aug 18, 2025
    Contributor
    More actions

    Yeah we are hoping to get to it this week.

    Reacted by fettpl, Thomas Roche, Liang-Shih Lin, Micha(el) Bladowski, Tobias Walle, Mohammad Kermani, Hu Jianxin, Mitch Lloyd, Martinffx, Tyler Barnes and 5 more
  20. ndrwstn commented on Aug 27, 2025

    @ndrwstn
    ndrwstn
    on Aug 27, 2025
    More actions

    Probably can close this issue --> #2157 ?

  21. rekram1-node
    closed this as completedon Aug 27, 2025
  22. martinffx commented on Nov 12, 2025

    @martinffx
    martinffx
    on Nov 12, 2025
    More actions

    @jayair would you be open to a PR add command namespaces like you get in Claude Code?

    https://code.claude.com/docs/en/slash-commands#namespacing

  23. rekram1-node commented on Nov 12, 2025

    @rekram1-node
    rekram1-node
    on Nov 12, 2025
    Member
    More actions

    @martinffx how would that work given the current way slash commands are read from subdirs of commands dir

  24. martinffx commented on Nov 12, 2025

    @martinffx
    martinffx
    on Nov 12, 2025
    More actions

    @rekram1-node idk, I've not looked into it yet.

    I am checking that contributions like that are welcome, as a community contribution of commands was rejected, and I'm not sure what sort of contributions you are open to.

  25. rekram1-node commented on Nov 12, 2025

    @rekram1-node
    rekram1-node
    on Nov 12, 2025
    Member
    More actions

    @martinffx so we accept a lottt of contributions, this was originally rejected a while ago because so many things were in flux and the team wanted to get the baseline apis and blocks to build with to a consistent state.

    Now that we are in a better state almost any contirbution is welcome we just prefer if it is a huge change to ask questions before making huge prs.

    But this doesnt sound like a huge change to me I just wanted to clarify

  26. martinffx commented on Nov 12, 2025

    @martinffx
    martinffx
    on Nov 12, 2025
    More actions

    @rekram1-node ok, I understand. Just wanted to confirm that was not still the case before getting stuck into something.

    So it looks like my issue is not really an issue anymore. When porting over my commands from CC back in August, none of my commands in subfolders would be read. It seems that it has been resolved since; command/code/review.md will be picked up as /code/review now.

    Which is basically what I wanted, still think CC's namespaces are a little more elegant, i.e. /code:review. But that is more of an aesthetic preference than a functional limitation.

  27. rekram1-node commented on Nov 12, 2025

    @rekram1-node
    rekram1-node
    on Nov 12, 2025
    Member
    More actions

    Sounds good, if u still want the namespaces we can probably add them I just worry about breaking workflows so I'd need to see what the change would encompass

  28. bussard76
    added a commit that references this issue on May 12, 2026

    feat: small improve workspace UI and visual consistency (anomalyco#299)

    bbe42b7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @adamdotdevin
    adamdotdevin
  • @tmeire
    tmeire

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.