<!-- Generated from the Command Code docs: https://commandcode.ai/docs -->

# Verify a mod

A mod that fails to import, exports no factory, or throws in its factory becomes a **warning - never a crashed session**. That safety also means a broken mod can fail silently if you never check. This section is the verification loop: load it, list it, exercise it, reload it.

## 1. Load it without installing

```bash
cmd --mod ./your-mod.ts
```

`--mod` is repeatable, loads ahead of installed mods, and wins name collisions - the fastest try-it loop. No build step: jiti compiles the TypeScript at load.

## 2. Confirm it registered

```bash
cmd mods list
```

Your mod must appear, with no load warnings. If it does not appear, the warning printed by `cmd mods list` says why (import error, no default-export factory, factory threw, duplicate name).

## 3. Exercise every surface it registers

- **Slash command** - type `/` in the chat input: the command must appear in autocomplete with its description. Run it; `{message}` renders an info row, `{prompt}` starts an automated turn.
- **Tool** - ask the model to use it by name ("call count_todos"). The tool call renders in the feed like any built-in.
- **Hook** - trigger the behavior it guards (for a `beforeToolCall` blocker, ask for the blocked action and watch the block reason land as the tool result).
- **Input interception** - type the pattern `transformInput` matches and confirm the rewrite/consume happened.
- **Status** - `cmd.ui.setStatus('text')` must show up as a segment on the row under the input, replace itself on the next call, and disappear on `setStatus(null)`.
- **Widget** - an `above-editor` widget draws right above the prompt, a `below-editor` one under it; `cmd.ui.refreshWidgets()` (or a `cmd.state.set`) repaints it.
- **Pane** - open it (`/mods open <pane>`, or the mod's own command): it draws above the prompt with its buttons' Alt+keys on its last line; `Alt+<key>` presses one, `Alt+0` closes it. For inputs and selects, `Alt+↑` focuses it: Tab through the fields, type, press Enter, and check the pane redraws with the new `value`.
- **Toast** - `cmd.ui.toast('text')` shows above the prompt and clears itself.
- **Override** - send a prompt that runs a tool: a `spinner` override shows beside the working line, a `tool_row` override replaces that tool's row. If a row still looks built-in, the override returned `undefined` or threw (look for `mod_error` with `ui.override:` in its hook).
- **Permission answers** - with an `onPermissionRequest` hook, trigger a call that would prompt: an answered prompt never appears. `cmd mods inspect` lists the hook so reviewers see it too.
- **Renderer** - `cmd.showEntry` rows render styled; an unregistered type pretty-prints as JSON.

### Test: block-dangerous-commands guards rm -rf

```text copy filename="Prompt"
Run rm -rf /tmp/scratch-dir
```

Expected result:

-  The mod's confirm dialog appears before the shell command runs
-  Declining blocks the tool - the model sees the block reason and adapts
-  No `tool_running` fires for the blocked call

## 4. Iterate: save, and it reloads

In the interactive TUI, saving a mod's file reloads it in place, with no restart: the feed says `[mods] ✓ reloaded <name>` (or why it did not). The old code gets `onSessionEnd` with `reason: 'reload'`, then every registration it made is disposed, except tools added with `addTool`. Those keep the old code until the next session. `cmd.state` survives, and `onSessionStart` fires again with `source: 'reload'`. A save that throws while loading leaves the old code running. `/mods reload [name]` reloads on demand. Two things need more than a reload: tools (the tool set is fixed per session, so start a new session or `/reload`) and new mod files (`/reload` re-discovers). `COMMANDCODE_MODS_HOT_RELOAD=0` turns the watcher off.

## 5. Headless check (CI)

```bash
cmd -p "exercise the mod" --mod ./your-mod.ts
```

Print mode loads user-scope and `--mod` mods with the UI bridge degraded to deterministic defaults (confirm → false, select/input → undefined). A mod that must work in CI should behave sensibly under those defaults.

## 6. List it on the mods hub

Publish the mod, then add it to the Command Code mods hub with a PR to the public registry. See [Listing a mod on the mods hub](./packaging.md#listing-a-mod-on-the-mods-hub) for the steps and fields.

## Working from the bundled examples

Ask Command Code to build the mod you want and it starts from a bundled example rather than a blank file - see [Runnable examples](./overview.md#runnable-examples) for the list. Each one loads through the real mod loader in CI on every test run, so what you start from is proven to load.
