How to Create and Use Custom Slash Commands in DeepSeek-Reasonix
Custom slash commands in DeepSeek-Reasonix are user-defined scripts stored in configured directories that execute in a sandboxed environment when invoked with a leading slash, with the first line of the file serving as the command name and subsequent lines containing the executable script.
DeepSeek-Reasonix extends its interactive AI capabilities through a flexible custom slash command system that allows users to execute personal workflows directly from the chat interface. These commands are parsed by the controller and can be created by adding script files to designated command directories defined in your reasonix.toml configuration. When invoked, they run in isolated subprocesses and return output as standard chat turns.
What Are Custom Slash Commands?
A slash command is any user input line that begins with the / character. The system distinguishes between built-in management verbs—such as /model, /goal, or /reload—and user-defined custom commands.
According to the source code in internal/control/slash.go, the controller handles recognition through two primary functions:
SlashArgItems: Builds the list of possible completions for a given command line, supporting both built-in and custom commands.managementNotice: Processes built-in management verbs directly within the controller.
When a command is not recognized as built-in, the controller searches the loaded custom command map for a matching name.
Where Custom Commands Are Stored
Custom commands reside in command directories specified by the command_dirs array in your reasonix.toml configuration file. As implemented in internal/config/config.go, the CommandDirs() function retrieves these paths during startup.
Typical default configurations include:
# reasonix.toml
command_dirs = [
"$HOME/.reasonix/commands", # per-user directory
"./commands", # project-local directory
]
Each directory contains plain-text files (any extension) describing individual commands. The file structure follows a strict format:
- Line 1: The command name (single word, no spaces, no leading slash).
- Lines 2+: The shell script executed when the command is invoked.
Example Command File
Create a file at $HOME/.reasonix/commands/hello.cmd:
hello
#!/usr/bin/env bash
echo "Hello, $USER! The current project is $(pwd)"
When you type /hello in a Reasonix session, the controller maps this to the file above and executes the script in a sandboxed subprocess via internal/sandbox/seatbelt.go, capturing stdout/stderr for the chat interface.
How to Create a Custom Slash Command
Follow these steps to add your own commands to DeepSeek-Reasonix:
-
Choose or create a directory listed in
command_dirs(or add a new path toreasonix.toml). The default$HOME/.reasonix/commandsrequires no additional configuration. -
Create a new file in that directory. The filename is arbitrary, but the content must follow the standard format. The first line defines the invocable name, and the remainder contains your script.
-
Reload the command registry using one of these methods:
- Type
/reloadin the Reasonix UI (handled bymanagementNotice). - Execute
reasonix reloadfrom the CLI. - Restart the application.
- Type
-
Invoke your command by typing
/your-command-namefollowed by optional arguments. Arguments are passed to the script as positional parameters$1,$2, etc.
Complete Working Example
Create a goodbye command at $HOME/.reasonix/commands/goodbye.cmd:
goodbye
#!/usr/bin/env bash
NAME=${1:-World}
echo "Good-bye, $NAME!"
Invocation:
/goodbye Alice
Result in chat UI:
Good-bye, Alice!
Command Loading and Execution Architecture
When Reasonix initializes or processes a reload request, the ReloadCommands method in internal/control/controller.go performs the following:
- Scans all directories returned by
CommandDirs(). - Builds an in-memory map of command name → script content.
- Registers a synthetic tool named
slash_commandto enable UI completion suggestions.
Execution occurs through the sandbox package (internal/sandbox/seatbelt.go), which provides constrained subprocess environments. This ensures custom scripts cannot harm the host system while allowing full access to standard shell utilities, Python interpreters, or other scripting languages specified via shebang lines.
Key Source Files Reference
Understanding the implementation requires familiarity with these specific components:
internal/control/slash.go: ContainsSlashArgItemsfor completion generation andmanagementNoticefor built-in verb handling.internal/control/controller.go: ImplementsReloadCommandsfor directory scanning, mapping, and theslash_commandtool registration.internal/config/config.go: Provides theCommandDirs()function that reads thecommand_dirsconfiguration key.internal/sandbox/seatbelt.go: Manages sandboxed execution of custom scripts in isolated subprocesses.
Summary
- Custom slash commands are plain-text files where the first line defines the command name and subsequent lines contain the executable script.
- Command directories are configured in
reasonix.tomlunder thecommand_dirskey. - The controller loads commands via
ReloadCommandsand exposes them as theslash_commandtool for UI integration. - Scripts execute in sandboxed subprocesses with arguments available as
$1,$2, and so on. - Changes require reloading via
/reloador restarting Reasonix.
Frequently Asked Questions
Do custom slash commands support arguments?
Yes. Arguments provided after the command name are passed as positional parameters to the script. In bash scripts, access them using $1, $2, etc., or ${1:-default} for optional arguments with fallback values. The parsing logic preserves the exact argument string for the sandboxed execution environment.
What scripting languages can I use for custom commands?
Any language that supports shebang declarations works, including Bash, Python, Ruby, or Node.js. The file must be executable or contain a valid shebang (e.g., #!/usr/bin/env python3) on the second line. The sandbox executes the file directly, respecting the interpreter specified.
Why doesn't my new command appear in the completion menu?
First, verify the file is located in a directory listed under command_dirs in your reasonix.toml. Ensure the first line contains only the command name with no leading slash or spaces. Run /reload or restart Reasonix to trigger ReloadCommands in internal/control/controller.go to rescan the directories. Check file permissions to ensure the controller can read the file.
Are custom commands scoped per-project or global?
Commands are available wherever their containing directory is listed in the configuration. Place scripts in $HOME/.reasonix/commands for global availability across all sessions, or use ./commands for project-specific tools. You can organize commands by modifying the command_dirs array to include multiple paths.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →