# `BB.Reactor.Step.Command`
[🔗](https://github.com/beam-bots/bb_reactor/blob/main/lib/bb/reactor/step/command.ex#L5)

Reactor step that executes a BB command.

This step wraps BB.Command execution with process monitoring to detect
safety disarm events. When a command stops due to safety state change,
the step returns `{:halt, :safety_disarmed}` to stop the reactor.

## Options

- `:command` - (required) The command name as an atom (e.g., `:move_to`)
- `:timeout` - Timeout in milliseconds (default: `:infinity`)
- `:compensate` - Command to run during undo (e.g., `:return_home`)

## Result

Returns a `BB.Reactor.Step.Command.Result` struct containing:

- `:command` - The command name that was executed
- `:goal` - The goal map passed to the command
- `:outcome` - The result returned by the command
- `:robot_module` - The robot module used

## Compensation (Undo)

If `:compensate` is specified and the reactor needs to roll back this step,
the compensation command is invoked with `%{original: result}` as its goal,
giving it access to the original command, goal, and outcome.

## Safety Handling

The step monitors the command process. If the command exits with `:disarmed`
reason (due to safety state change), the step returns `{:halt, :safety_disarmed}`
which stops the reactor execution.

---

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