Skip to content

Commit e6caffc

Browse files
sjwiesmanclaude
andauthored
Add mz-deploy documentation (#37052)
Adds user-facing documentation for `mz-deploy`, the declarative SQL project deployment tool, under `doc/user/content/manage/mz-deploy/`. ## What's here - **Get started** — quickstart covering project creation, connection profiles, compile, and the deploy lifecycle. - **Installation** — macOS/Linux tabs that download the latest release tarball from `binaries.materialize.com` and extract it into `/usr/local`, following the existing `mz-debug` install pattern. The architecture is resolved at runtime via `uname -m`, so a single command covers Apple Silicon (`arm64`) and Intel macs as well as `x86_64`/`aarch64` Linux. - **Project structure, infrastructure, local development, deployments, stable APIs, profiles** — reference pages for the full workflow. - **Editor setup** — VS Code, Neovim, and Helix integration. - **AI agent setup** — Claude Code and Codex configuration, including a new **Claude Code on the web** section explaining how to install `mz-deploy` into the Anthropic-managed cloud sandbox via its Setup script field. The sandbox is always Linux and runs as root, so the script uses the `unknown-linux-gnu` build, resolves the architecture at runtime, and needs no `sudo`. The section also notes the Trusted vs None network-mode constraint and points users at committing `.claude/settings.json` so the language server carries over to cloud sessions. ## Notes Documentation only — no code changes, so no Rust/Python lint or test steps apply. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 6df9fe5 commit e6caffc

13 files changed

Lines changed: 1743 additions & 0 deletions

doc/user/content/manage/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ This section contains various resources for managing Materialize.
2525
|-------|-------------|
2626
| [Using dbt to manage Materialize](/manage/dbt/) | Guides for using dbt to manage Materialize |
2727
| [Using Terraform to manage Materialize](/manage/terraform/) | Guides for using Terraform to manage Materialize |
28+
| [Using mz-deploy to manage Materialize](/manage/mz-deploy/) | SQL-native CLI for zero-downtime blue/green deployments |
2829

2930
## Usage and billing
3031

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
title: "Use mz-deploy to manage Materialize"
3+
description: "Deploy and manage Materialize objects with mz-deploy, a SQL-native CLI for zero-downtime deployments."
4+
disable_list: true
5+
menu:
6+
main:
7+
parent: manage
8+
weight: 40
9+
identifier: "manage-mz-deploy"
10+
name: "Manage with mz-deploy"
11+
---
12+
13+
{{< warning >}}
14+
`mz-deploy` is a v0.1 release and is not yet recommended for production use.
15+
{{< /warning >}}
16+
17+
`mz-deploy` is a CLI that manages your Materialize deployment from plain SQL
18+
files in a git repository. It catches errors before they reach production, lets
19+
you test view logic locally, and deploys changes without downtime.
20+
21+
## Installation
22+
23+
On macOS and Linux, we recommend installing `mz-deploy` with
24+
[Homebrew](https://brew.sh/):
25+
26+
```shell
27+
brew install materializeinc/materialize/mz-deploy
28+
```
29+
30+
For direct downloads and other installation options, see
31+
[Get started](/manage/mz-deploy/get-started/#prerequisites-and-installation).
32+
33+
## Why mz-deploy
34+
35+
### Write plain SQL, deploy safely
36+
37+
Everything lives in `.sql` files — one object per file, organized by database
38+
and schema. `mz-deploy` tracks dependencies between objects, diffs your project
39+
against the live environment, and deploys only what changed. Durable objects
40+
like secrets, connections, sources, and tables are converged in place (like
41+
Terraform). Views, materialized views, indexes, and sinks go through a staged
42+
deployment so changes can be validated before going live.
43+
44+
### Catch errors before deploying
45+
46+
`mz-deploy compile` type-checks every SQL statement against your dependency
47+
schemas — locally, with no database connection required. Inline unit tests let
48+
you mock dependencies and verify view logic with deterministic inputs before
49+
anything touches a real environment. Changes that break types or dependencies
50+
fail fast on your laptop or in CI, not in production.
51+
52+
### Ship without downtime
53+
54+
When you deploy, `mz-deploy` creates your changes in isolated staging schemas
55+
alongside production. Once all materialized views finish computing their initial
56+
results, a single atomic swap cuts traffic over to the new version. Running
57+
queries are never interrupted, and if something goes wrong, the staging
58+
deployment can be cleaned up without affecting production.
59+
60+
## When to use it
61+
62+
| Tool | Best for | Manages infrastructure | Zero-downtime deployments |
63+
|------|----------|----------------------|--------------------------|
64+
| **Plain SQL / psql scripts** | Manual execution. No dependency tracking, no diff, no rollback. Where most teams start. | No | No |
65+
| **mz-deploy** | SQL-native, git-based workflow with offline type-checking, unit tests, and staged deployments. | Yes | Yes |
66+
| **[dbt](/manage/dbt/)** | Teams already invested in dbt. Manages views and materialized views. | No (clusters, connections, secrets are out of scope) | Yes (via `dbt-materialize` adapter macros) |
67+
| **[Terraform](/manage/terraform/)** | Teams managing Materialize alongside other cloud infrastructure. | Yes | No |
68+
69+
## Available guides
70+
71+
{{< multilinkbox >}}
72+
{{< linkbox title="To get started" >}}
73+
[Get started with mz-deploy](/manage/mz-deploy/get-started/)
74+
{{</ linkbox >}}
75+
{{< linkbox title="Develop" >}}
76+
- [Project structure](/manage/mz-deploy/project-structure/)
77+
- [Infrastructure](/manage/mz-deploy/infrastructure/)
78+
- [Local development](/manage/mz-deploy/local-development/)
79+
- [Editor setup](/manage/mz-deploy/editor-setup/)
80+
- [AI agent setup](/manage/mz-deploy/agent-setup/)
81+
{{</ linkbox >}}
82+
{{< linkbox title="Deploy" >}}
83+
- [Deployments](/manage/mz-deploy/deployments/)
84+
- [Stable APIs](/manage/mz-deploy/stable-apis/)
85+
- [Profiles](/manage/mz-deploy/profiles/)
86+
{{</ linkbox >}}
87+
{{</ multilinkbox >}}
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
---
2+
title: "AI agent setup"
3+
description: "Configure AI coding agents like Claude Code and Codex to work with mz-deploy projects."
4+
menu:
5+
main:
6+
parent: manage-mz-deploy
7+
weight: 44
8+
identifier: "mz-deploy-agent-setup"
9+
name: "AI agent setup"
10+
---
11+
12+
`mz-deploy` was built with AI coding agents in mind. Every new project ships
13+
with agent-readable documentation, the CLI provides agent-optimized help, and
14+
the language server gives agents real-time feedback on SQL correctness.
15+
16+
## Project skill
17+
18+
The community [MaterializeInc/agent-skills](https://github.com/MaterializeInc/agent-skills)
19+
repo publishes an agent skill for `mz-deploy` that teaches agents your
20+
project's conventions: one object per file, file paths map to qualified
21+
names, how the deployment lifecycle works, unit test syntax, and how to get
22+
detailed help with `mz-deploy help <command>`.
23+
24+
The skill is not installed by default. Install it in your project with:
25+
26+
```sh
27+
npx -y skills add MaterializeInc/agent-skills -a universal -a claude-code --project
28+
```
29+
30+
This drops the skill into `.agents/skills/mz-deploy/` and wires up a
31+
`.claude/skills/` symlink so Claude Code picks it up. Agents that consume
32+
the universal skill format (Codex and others) load it from the same
33+
location. You don't need to explain the project's conventions — the agent
34+
already knows them.
35+
36+
Update to the latest version later with:
37+
38+
```sh
39+
npx -y skills update
40+
```
41+
42+
## Claude Code on the web
43+
44+
[Claude Code on the web](https://code.claude.com/docs/en/claude-code-on-the-web)
45+
runs each session in a fresh, Anthropic-managed cloud sandbox. The sandbox
46+
doesn't have `mz-deploy` installed, so install it with a **setup script** — a
47+
Bash script that runs once, as root, before Claude Code starts.
48+
49+
In the cloud environment settings, set the **Setup script** field to:
50+
51+
```bash
52+
#!/bin/bash
53+
set -euo pipefail
54+
ARCH=$(uname -m)
55+
curl -L "https://binaries.materialize.com/mz-deploy-latest-$ARCH-unknown-linux-gnu.tar.gz" \
56+
| tar -xzC /usr/local --strip-components=1
57+
```
58+
59+
The sandbox runs Ubuntu on Linux, so this always uses the `unknown-linux-gnu`
60+
build and resolves the architecture (`x86_64` or `aarch64`) at runtime. The
61+
binary lands in `/usr/local/bin`, which is already on `PATH`. The script runs as
62+
root, so no `sudo` is needed. Setup scripts have network access under the
63+
default **Trusted** network mode; if your environment uses **None**, the
64+
download will fail.
65+
66+
To configure the language server in the sandbox as well, commit the
67+
`.claude/settings.json` from [Configuring for Claude Code](#configuring-for-claude-code)
68+
to your repository — it carries over to cloud sessions automatically.
69+
70+
## Agent-optimized help
71+
72+
```bash
73+
mz-deploy help <command> # Detailed guide for a single command
74+
mz-deploy help --all # All command guides concatenated
75+
```
76+
77+
Unlike `--help` (which prints brief CLI usage), `help` returns full guides
78+
with behavior notes, examples, error recovery steps, and related commands.
79+
80+
## Language server
81+
82+
The mz-deploy language server gives agents the same benefits it gives human
83+
editors: parse error diagnostics on every file change, go-to-definition across
84+
your project, and column-aware completions scoped to actual dependencies.
85+
86+
For agents, this means fewer incorrect SQL suggestions — the agent sees real
87+
column names and types from your `types.lock` rather than guessing.
88+
89+
### Configuring for Claude Code
90+
91+
Add to your project's `.claude/settings.json`:
92+
93+
```json
94+
{
95+
"lsp": {
96+
"mz-deploy": {
97+
"command": "mz-deploy",
98+
"args": ["lsp", "-d", "."],
99+
"filePatterns": ["*.sql"]
100+
}
101+
}
102+
}
103+
```

0 commit comments

Comments
 (0)