# AI Studio

Point at a tile or filter, describe the change, and send it to the coding agent on
your machine. AI Studio runs the agent headlessly, shows its output as it works, and
lets you review or undo its dashboard edits while you keep chatting. It is part of the
base install.

<figure class="shot-video"><video autoplay muted loop playsinline preload="metadata" poster="/static/studio-poster.webp" aria-label="AI Studio: requests pinned to tiles are sent to a coding agent, and the dashboard restyles while the conversation continues"><source src="/static/studio-demo.webm" type="video/webm"><source src="/static/studio-demo.mp4" type="video/mp4"></video></figure>

## Send a request

Open any dashboard served by `sqldash serve` and click **AI Studio**. Claude Code and
Codex appear automatically when their command line tools are installed, signed in, and on
the server's `PATH`. AI Studio runs the CLI, so the Codex or Claude IDE extension on its
own is not enough. Run `sqldash studio list` to see which agents it found.

1. Click **Annotate dashboard**, choose the tile, chart, or title you mean, and write
   your note beside it. Use **Add request** for changes that are not tied to one
   element.
2. Add any overall instructions in the message box.
3. Open **Included context** to see exactly what goes with the request, then click
   **Send to agent**, or press <kbd>Enter</kbd> in the message box.

The dashboard updates in place as the agent changes files, keeping your notes and the
conversation open. Keep chatting to refine. Nothing launches until you click
**Send to agent**.

AI Studio supports macOS and Linux. It is on by default when the server binds to a
loopback address and off otherwise, and `sqldash serve --no-studio` turns it off.

## Review and undo

- **View changes** compares the dashboard's YAML files before and after the latest
  turn, with connection settings omitted. Use `git diff` for exact text and for CSS.
- **Undo last edit** restores the files the latest turn changed, keeping earlier
  edits. Sending again starts a new checkpoint.
- **Stop agent** ends the agent's process group. Review partial edits even when a run
  fails or is stopped.

Edits stay on disk without committing or pushing, so the result is an ordinary diff
you review and commit like any other change.

## What the agent receives

The request includes the selected dashboard, tile identifiers, your notes, active
filter values, and metric definitions with connection settings omitted. Under
**Included context**, **Capture screenshot** grabs one frame of the dashboard tab for you
to preview before sending, or you can attach a PNG up to 1 MB. Query results are not
attached, and a request over 100 kB is refused before launch rather than cut short.

Your agent may send that context to a remote model, and it runs with your local
filesystem permissions. AI Studio passes only a small set of environment variables and
does not forward warehouse credentials, cloud tokens, or API keys unless you list them
in the entrypoint's `pass_env`.

## Tool approvals

For Claude Code, permission requests appear in the panel as **Allow once** and
**Deny** cards. **Auto-approve all tools** approves forwarded requests for the rest of
the session. It starts off and resets when you close the session.

For Codex, AI Studio runs `codex exec --skip-git-repo-check --json` with your request,
and Codex decides what it may change using your own Codex settings. AI Studio cannot
relay Codex's interactive approvals, so its choices come from that configuration.

> [!TIP]
> If Codex reports that it cannot write files, allow edits in the workspace by setting
> `sandbox_mode = "workspace-write"` in `~/.codex/config.toml`, or add a custom
> entrypoint that passes the sandbox flag, as shown below. AI Studio never adds
> permission-bypass flags for either agent.

## Custom entrypoints

Use any headless CLI or wrapper. Add one from **Agent settings** in the panel, or from
the terminal.

```bash
sqldash studio add "Codex, can edit" -- codex exec --skip-git-repo-check --sandbox workspace-write '{prompt}'
sqldash studio add "Claude alias" --shell /bin/zsh -- claude-custom -p '{prompt}'
sqldash studio list
sqldash studio check "Codex, can edit"   # checks the command resolves, without running it
```

Pass `{prompt}` as its own argument, and AI Studio substitutes the request text. `--shell`
runs a bash or zsh alias or function through a login shell, and `--env KEY=VALUE`
sets a variable for that entrypoint. Entrypoints are saved in your user configuration
directory under `sqldash/studio.json`, outside the repo.

Claude resumes the same conversation on every send. Other entrypoints receive the
latest dashboard context and your new request each turn.

## Style a dashboard

Pin a card and describe the look, such as "Make this revenue card the focal point, with
a violet background and a brighter number." Ask the agent to put styling in the
dashboard's `css:` block and to leave queries, metrics, and filters alone. Styles
refresh in place as the file changes. See [Themes](/docs/themes/) for what the CSS can
reach.
