# How to Create and Use Custom Slash Commands in DeepSeek-Reasonix

> Learn how to create and use custom slash commands in DeepSeek-Reasonix. Define your own scripts to automate tasks and enhance your workflow with this powerful feature.

- Repository: [YHH/DeepSeek-Reasonix](https://github.com/esengine/DeepSeek-Reasonix)
- Tags: how-to-guide
- Published: 2026-06-22

---

**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`](https://github.com/esengine/DeepSeek-Reasonix/blob/main/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`](https://github.com/esengine/DeepSeek-Reasonix/blob/main/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`](https://github.com/esengine/DeepSeek-Reasonix/blob/main/reasonix.toml) configuration file. As implemented in [`internal/config/config.go`](https://github.com/esengine/DeepSeek-Reasonix/blob/main/internal/config/config.go), the `CommandDirs()` function retrieves these paths during startup.

Typical default configurations include:

```toml

# 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`:

```text
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`](https://github.com/esengine/DeepSeek-Reasonix/blob/main/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:

1. **Choose or create a directory** listed in `command_dirs` (or add a new path to [`reasonix.toml`](https://github.com/esengine/DeepSeek-Reasonix/blob/main/reasonix.toml)). The default `$HOME/.reasonix/commands` requires no additional configuration.

2. **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.

3. **Reload the command registry** using one of these methods:
   - Type `/reload` in the Reasonix UI (handled by `managementNotice`).
   - Execute `reasonix reload` from the CLI.
   - Restart the application.

4. **Invoke your command** by typing `/your-command-name` followed 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`:

```text
goodbye
#!/usr/bin/env bash
NAME=${1:-World}
echo "Good-bye, $NAME!"

```

**Invocation:**

```text
/goodbye Alice

```

**Result in chat UI:**

```text
Good-bye, Alice!

```

## Command Loading and Execution Architecture

When Reasonix initializes or processes a reload request, the **`ReloadCommands`** method in [`internal/control/controller.go`](https://github.com/esengine/DeepSeek-Reasonix/blob/main/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_command` to enable UI completion suggestions.

Execution occurs through the **sandbox package** ([`internal/sandbox/seatbelt.go`](https://github.com/esengine/DeepSeek-Reasonix/blob/main/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`](https://github.com/esengine/DeepSeek-Reasonix/blob/main/internal/control/slash.go)**: Contains `SlashArgItems` for completion generation and `managementNotice` for built-in verb handling.
- **[`internal/control/controller.go`](https://github.com/esengine/DeepSeek-Reasonix/blob/main/internal/control/controller.go)**: Implements `ReloadCommands` for directory scanning, mapping, and the `slash_command` tool registration.
- **[`internal/config/config.go`](https://github.com/esengine/DeepSeek-Reasonix/blob/main/internal/config/config.go)**: Provides the `CommandDirs()` function that reads the `command_dirs` configuration key.
- **[`internal/sandbox/seatbelt.go`](https://github.com/esengine/DeepSeek-Reasonix/blob/main/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.toml`](https://github.com/esengine/DeepSeek-Reasonix/blob/main/reasonix.toml) under the **`command_dirs`** key.
- The controller loads commands via **`ReloadCommands`** and exposes them as the **`slash_command`** tool for UI integration.
- Scripts execute in sandboxed subprocesses with arguments available as **`$1`**, **`$2`**, and so on.
- Changes require reloading via **`/reload`** or 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`](https://github.com/esengine/DeepSeek-Reasonix/blob/main/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`](https://github.com/esengine/DeepSeek-Reasonix/blob/main/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.