# Automate workspace operations

Source: https://libtmux.org/en/ts/latest/workspace/guides/automation/

> Run detached commands with explicit inputs and machine-readable results.

**Workspace Manager concept example** A working example of the core library. It can change without notice.



Give automation an explicit file, endpoint and attachment choice. Continue the
[installation walkthrough](https://libtmux.org/en/ts/latest/workspace/guides/installation/) with this detached operation:

```console
$ tmux-workspace load \
    -S "$WORKSPACE_TMP/tmux.sock" \
    -d \
    --json \
    workspace.yaml
```

Check the process exit status, parse its JSON result, then inspect any reported
partial effects. A failed later input does not imply that earlier sessions
were removed. Keep stderr separate from the result stream.

## Follow progress

Use NDJSON when the caller needs records while a load is running:

```console
$ tmux-workspace load \
    -S "$WORKSPACE_TMP/tmux.sock" \
    -d \
    --ndjson \
    workspace.yaml
```

Parse one complete JSON value per line. Treat a closed stream or missing final
result as incomplete work. Do not infer success from an earlier creation event.

## Make retries deliberate

Use a unique session name for independent jobs. Reusing a name follows the
loader's existing-session policy; it is not a request to reset that session.
Capture IDs and retained effects from the result before deciding what to clean
up or retry. Remove only sessions the job owns.

Read [output](https://libtmux.org/en/ts/latest/workspace/reference/output/) and [errors](https://libtmux.org/en/ts/latest/workspace/reference/exit-codes/)
for the command's machine interface. A pane's process can outlive the CLI and
can fail after successful command delivery.

[CLI source](https://github.com/libtmux/libtmux-ts/blob/f36d692552bb9a373b45338bb5fece854e57cc3d/packages/workspace-cli/README.md).
