[FEATURE]: Support escaping $ in custom commands #7079

Open
opened 2026-02-16 18:06:07 -05:00 by yindo · 0 comments
Owner

Originally created by @lucasrcezimbra on GitHub (Jan 21, 2026).

Originally assigned to: @thdxr on GitHub.

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Description

Problem

Custom command templates use $ARGUMENTS, $1, $2, etc. as placeholders for argument substitution. However, there is currently no way to escape these patterns when you need to include them as literal text in the template.

Use Case

I have a meta-command called opencode-new-command that helps create new OpenCode custom commands. In this command template, I want to instruct the LLM to use the placeholder syntax in the generated commands:

---
description: Create a new OpenCode command
---
Create a new custom command based on the user's requirements.
Use $1, $2, etc. for positional arguments and $ARGUMENTS for all arguments.

When I run /opencode-new-command my-new-cmd, the template gets processed and $1 is replaced with my-new-cmd, resulting in:

Use my-new-cmd, $2, etc. for positional arguments and  for all arguments.

This confuses the LLM since the instructions about placeholder syntax are mangled.

Current Behavior

  • $1, $2, etc. → replaced with positional arguments
  • $ARGUMENTS → replaced with all arguments
  • $$1, $$ARGUMENTS → results in $<value> (prepends $ to substituted value, doesn't escape)
  • \$1, \$ARGUMENTS → results in \<value> (prepends \ to substituted value, doesn't escape)

Expected Behavior

A way to escape $ so that literal $ARGUMENTS, $1, $2 text can be included in templates. Suggestions:

  • \$1 → literal $1
  • $$1 → literal $1 (double-dollar escape)
Originally created by @lucasrcezimbra on GitHub (Jan 21, 2026). Originally assigned to: @thdxr on GitHub. ### Feature hasn't been suggested before. - [x] I have verified this feature I'm about to request hasn't been suggested before. ### Describe the enhancement you want to request ## Description ### Problem Custom command templates use `$ARGUMENTS`, `$1`, `$2`, etc. as placeholders for argument substitution. However, there is currently no way to escape these patterns when you need to include them as literal text in the template. ### Use Case I have a meta-command called `opencode-new-command` that helps create new OpenCode custom commands. In this command template, I want to instruct the LLM to use the placeholder syntax in the generated commands: ```md --- description: Create a new OpenCode command --- Create a new custom command based on the user's requirements. Use $1, $2, etc. for positional arguments and $ARGUMENTS for all arguments. ``` When I run `/opencode-new-command my-new-cmd`, the template gets processed and `$1` is replaced with `my-new-cmd`, resulting in: ``` Use my-new-cmd, $2, etc. for positional arguments and for all arguments. ``` This confuses the LLM since the instructions about placeholder syntax are mangled. ### Current Behavior - `$1`, `$2`, etc. → replaced with positional arguments - `$ARGUMENTS` → replaced with all arguments - `$$1`, `$$ARGUMENTS` → results in `$<value>` (prepends `$` to substituted value, doesn't escape) - `\$1`, `\$ARGUMENTS` → results in `\<value>` (prepends `\` to substituted value, doesn't escape) ### Expected Behavior A way to escape `$` so that literal `$ARGUMENTS`, `$1`, `$2` text can be included in templates. Suggestions: - `\$1` → literal `$1` - `$$1` → literal `$1` (double-dollar escape)
yindo added the discussion label 2026-02-16 18:06:07 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7079