# Automate workspace operations

Source: https://libtmux.org/en/py/stable/workspace/guides/automation/

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

Pass an explicit workspace file, dedicated socket and `-d` when running tmuxp
from a script. `--yes` answers confirmations; it does not supply every missing
choice.

```console
$ tmuxp load -L workspace-guide -d workspace.yaml
```

Use [`ls --json`](https://libtmux.org/en/py/stable/workspace/cli/ls/) to read discovered workspace records:

```console
$ tmuxp ls --json
```

The output is an object with a `workspaces` array. Search has different empty
output and error behavior; read [search](https://libtmux.org/en/py/stable/workspace/cli/search/) and
[exit codes](https://libtmux.org/en/py/stable/workspace/reference/exit-codes/) before building a pipeline.

Use [export and reload](https://libtmux.org/en/py/stable/workspace/guides/export-session/) to capture a session. Review the
resulting commands and paths rather than treating capture as a complete backup.
