# `BeamAgent.SlashCommands`
[🔗](https://github.com/beardedeagle/beam-agent/blob/main/lib/beam_agent/slash_commands.ex#L1)

Slash command management for the BeamAgent SDK.

This module provides global slash command registration -- listing, registering,
unregistering, and querying slash commands that are shared across all sessions.
Mutations notify the reload bus so live sessions react without restart.

## When to use directly vs through `BeamAgent`

Most callers interact with slash commands through `BeamAgent`. Use this module
directly when you need focused access to slash command operations -- for example,
in a command palette UI, a command management dashboard, or a configuration
tool that bulk-enables/disables commands.

## Quick example

```elixir
# Register a slash command:
:ok = BeamAgent.SlashCommands.register("review", %{
  name: "/review",
  description: "Review code in the current file",
  handler: :review_handler,
  enabled: true
})

# List all commands:
commands = BeamAgent.SlashCommands.list()
for c <- commands, do: IO.puts(c.name)

# Unregister:
:ok = BeamAgent.SlashCommands.unregister("review")
```

## Architecture deep dive

This module is a thin Elixir facade that delegates every call to the
`:beam_agent_catalog` Erlang module's global registry functions. Zero
business logic, zero state, zero processes live here -- the Erlang module
owns the implementation. The underlying command data is stored in the
unified ETS table managed by `:beam_agent_registry`.

See also: `BeamAgent`, `BeamAgent.Catalog`, `BeamAgent.Skills`.

# `command_def`

```elixir
@type command_def() :: %{
  :id =&gt; binary(),
  :name =&gt; binary(),
  :kind =&gt; :agent | :plugin | :slash,
  :enabled =&gt; boolean(),
  optional(:description) =&gt; binary(),
  optional(:handler) =&gt; (map() -&gt; {:ok, map()} | {:error, term()}),
  optional(:config) =&gt; map()
}
```

A slash command definition stored in the global registry.

# `clear`

```elixir
@spec clear() :: :ok
```

Remove all registered slash commands.

# `ensure_table`

```elixir
@spec ensure_table() :: :ok
```

Create the global registry ETS table. Idempotent.

# `get`

```elixir
@spec get(binary()) :: {:ok, command_def()} | {:error, :not_found}
```

Fetch a single slash command by id.

# `list`

```elixir
@spec list() :: [command_def()]
```

List all registered slash commands.

# `register`

```elixir
@spec register(binary(), map()) :: :ok
```

Register a slash command globally (shared across all sessions).

## Parameters

- `id` -- unique binary identifier for the command.
- `opts` -- map of command options (`:name`, `:description`, `:handler`, `:enabled`, `:config`).

# `unregister`

```elixir
@spec unregister(binary()) :: :ok
```

Unregister a slash command by id. Idempotent.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
