# Driving Zene Studio from another program

A first script against the control socket — start the session, discover commands, make one change safely.

Source: https://zenestudio.org/guides/driving-zene

Markdown version of the Zene Studio page at https://zenestudio.org/guides/driving-zene. For a map of the whole site, see
https://zenestudio.org/llms.txt.

---
This guide takes you from a socket that exists to a script you can undo. It assumes you are
comfortable in a terminal.

## 1. Start a session with a socket

```bash
zene --control-socket /tmp/zene.sock
```

Opt-in and off by default — without this flag there is **no socket at all**.

:::warning
The socket is local and **unauthenticated**. Anyone who can reach that path can drive the session —
including rendering, exporting and overwriting your project. Keep it in a private directory:

```bash
mkdir -p ~/.zene && chmod 700 ~/.zene
zene --control-socket ~/.zene/session.sock
```
:::

## 2. Find out what you can call

Never guess. Ask:

```bash
echo '{"command":"control.commands_list"}' | nc -U ~/.zene/session.sock
```

You get every command with its schema and its reversibility class.

## 3. Understand the reversibility class before you call

| Class | Meaning |
| --- | --- |
| `not_mutating` | Read-only. Safe to poll. |
| `snapshot` | Capture state first if you need to restore it. |
| `true_inverse` | Undoable by running the inverse. |
| `irreversible` | **Cannot be undone.** Confirm with a human first. |

There are 13 irreversible commands out of 340. Know which ones they are before you automate
anything.

## 4. Make one safe change

Start with a `not_mutating` command — a read. Once you trust the round trip, make a small write and
**immediately undo it**:

```bash
# Undo reaches the same history as Ctrl+Z in the GUI.
echo '{"command":"control.undo"}' | nc -U ~/.zene/session.sock
```

That property is the safety net. A scripted edit and a manual edit are the same kind of
thing.

## 5. Handle honest refusals

`mixer.set_pan` refuses every call. A mixer channel in this tree has no pan property.

Treat refusals as a **normal outcome**:

- log them,
- branch on them,
- never retry in a loop.

## 6. Automate something real

At this point you can build the automation other DAWs make you do by hand. Batch fades,
routing changes, and renders across a set of projects are all within reach.

Two rules:

1. **Snapshot before bulk operations.** A hundred `true_inverse` commands are individually safe and
   collectively hard to reason about.
2. **Do it on a scratch project first.**

## Related

- [The control socket](/docs/control/control-socket)
- [Command reference](/docs/control/command-reference)
- [The MCP bridge](/docs/control/mcp-bridge) — the same thing, for AI agents.
- [How we verify](/docs/control/verification)