[FEATURE] Let us configure delimiters for arguments passed to custom clash commands
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
First, the docs don't mention the delimiter that Claude Code uses to split arguments passed to custom Slash commands, but looks like it is ".
But " is a poor choice: if you pass a code block that contains string literals in Java, JavaScript, Python, C, C++, etc. they all clash with ".
Let us define our preferred delimiter(s) on per-project and global scopes.
Proposed Solution
Add these options to settings.json:
{
// user-defined delimeters for arguments passed to a slash command, by priority order:
"slashCommandDelimeters" : [
{ "open": "<arg>", "close": "</arg>", "regex": false }, // highest priority delimeter
{ "open": "HERE", "close": "HERE", "regex": false }, // another option (e.g. when the argument itself contains arbitrary XML)
{ "open": "\\s+", "close": "\\s+", "regex": true } // The default, a sequence of whitespace characters
]
}
Alternative Solutions
I've not thought about alternatives.
Priority
High - Significant impact on productivity
Feature Category
Interactive mode (TUI)
Use Case Example
I have this custom slash command, called rewordc for "Reword Comments":
---
description: Reword a comment in a specified file to improve clarity and accuracy.
allowed-tools: Edit, Glob, Grep, MultiEdit, Read, TodoWrite, Write
disable-model-invocation: true
argument-hint: [file-reference] [comment] [task]
---
_Problem:_
The comment $2 in $1 is wrong.
_Task:_
$1
If I could define my custom open/close delimiters, let's say <arg> and </arg> I could invoke it like this:
/rewordp @foo.java
<arg>
The JavaDoc comment for this public constant is incorrect:
~~~
/// The "Goodbye" constant
public static String HELLO = "Hello"
~~~
</arg>
<arg>
Change the comment to:
~~~
/// The "Hello" constant
~~~
</arg>
I think right now my only option is this---if we assume we can escape " in args, AND that newlines don't act as an arguments delimeter:
/rewordp @foo.java "The JavaDoc comment for this public constant is incorrect:
~~~
/// The \"Goodbye\" constant
public static String HELLO = "Hello"
~~~
"
"Change the comment to:
~~~
/// The \"Hello\" constant
~~~
"
In this example, I had to escape 4 double quotes, but there could be cases where the content/argument has hundreds of double quotes (e.g. some CSV files).
Additional Context
_No response_
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗