# swarmops ws hook

> Release: 0.11.0 · Last changed: 2026-11-08 · Source: https://github.com/KeiaiLab/SwarmOps/blob/stable/docs/reference/commands/ws-hook.md

The agent hosts' hooks: read the hook's JSON on stdin, print what the hook expects.

worktree-create makes the session's workspace and prints its path on stdout; worktree-remove keeps uncommitted edits as a rescue changeset and deletes the workspace; config prints the settings entries that register both. Errors go to stderr as an envelope, with its exit code. The opencode-\* verbs serve OpenCode: each prints one JSON object on stdout, its answer or the error's envelope with its exit code.

```yaml
title: "swarmops ws hook"
description: "The agent hosts' hooks: read the hook's JSON on stdin, print what the hook expects."
group: "workspaces"
since: "0.3.0"
mutates: true
identity_required: false
mcp_tool: ""
envelope_op: "ws_hook"
exit_codes: [0]
errors: []
syntax: "swarmops ws hook [OPTIONS] <VERB>"
```

## Syntax

```text
swarmops ws hook [OPTIONS] <VERB>
```

## Required arguments

### `VERB`

Syntax: `<VERB>`.

Which hook. Values: `worktree-create`: The `WorktreeCreate` hook; `worktree-remove`: The `WorktreeRemove` hook; `config`: The settings entries that register both; `opencode-create`: OpenCode's create: {source, destination, ref?, name?} to {path, name, head}; `opencode-remove`: OpenCode's remove: {directory, force?} to {removed, name, head, rescued}; `opencode-list`: OpenCode's list: {source} to {entries: \[{path, kind}\]}.

## Optional arguments

The command also takes the [global options](../cli.md#global-options).

## Examples

### CLI

No recorded example yet.

## Return information

`swarmops mcp` prints no envelope: stdout carries the MCP protocol until stdin ends, and a command line it refuses has its envelope on stderr.

Envelope `op`: `ws_hook`.

Exit codes:

- `0`: Success.

## Errors

No golden step shows this command failing yet.

Any command that opens a store may also fail with a store error, such as [`E_NOT_A_REPO`](../errors.md#e_not_a_repo), [`E_IO`](../errors.md#e_io) or [`E_STORE_CORRUPT`](../errors.md#e_store_corrupt); a command line the grammar refuses is [`E_INVALID_ARG`](../errors.md#e_invalid_arg) (exit 2).

## See also

- [`swarmops ws create`](ws-create.md)
- [`swarmops ws status`](ws-status.md)
- [`swarmops ws diff`](ws-diff.md)
- [`swarmops ws commit`](ws-commit.md)
- [`swarmops ws rebase`](ws-rebase.md)
- [`swarmops ws resolve`](ws-resolve.md)
- [`swarmops ws land`](ws-land.md)
- [`swarmops ws materialize`](ws-materialize.md)
- [`swarmops ws discard`](ws-discard.md)
- [`swarmops ws snapshot`](ws-snapshot.md)
- [`swarmops ws list`](ws-list.md)
- [`swarmops ws info`](ws-info.md)
- [`swarmops ws delete`](ws-delete.md)
- [CLI reference](../cli.md)
- [Error codes](../errors.md)
