@zitadel/cli 0.1.0-alpha.9 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +2758 -210
  2. package/bin/run.js +8 -0
  3. package/dist/index.mjs +25199 -0
  4. package/dist/index.mjs.map +1 -0
  5. package/dist/lib/oclif/help.mjs +71 -0
  6. package/dist/lib/oclif/help.mjs.map +1 -0
  7. package/dist/skills-hint-BSspFzhr.mjs +173 -0
  8. package/dist/skills-hint-BSspFzhr.mjs.map +1 -0
  9. package/oclif.manifest.json +5836 -246
  10. package/package.json +73 -13
  11. package/skills/zitadel-cli/SKILL.md +442 -0
  12. package/skills/zitadel-cli/references/driving-login-ui.md +89 -0
  13. package/SKILLS.md +0 -157
  14. package/dist/commands/apply.mjs +0 -62
  15. package/dist/commands/apply.mjs.map +0 -1
  16. package/dist/commands/doctor.mjs +0 -569
  17. package/dist/commands/doctor.mjs.map +0 -1
  18. package/dist/commands/eject.mjs +0 -145
  19. package/dist/commands/eject.mjs.map +0 -1
  20. package/dist/commands/logs.mjs +0 -58
  21. package/dist/commands/logs.mjs.map +0 -1
  22. package/dist/commands/plan.mjs +0 -52
  23. package/dist/commands/plan.mjs.map +0 -1
  24. package/dist/commands/reset.mjs +0 -79
  25. package/dist/commands/reset.mjs.map +0 -1
  26. package/dist/commands/setup.mjs +0 -856
  27. package/dist/commands/setup.mjs.map +0 -1
  28. package/dist/commands/start.mjs +0 -288
  29. package/dist/commands/start.mjs.map +0 -1
  30. package/dist/commands/status.mjs +0 -112
  31. package/dist/commands/status.mjs.map +0 -1
  32. package/dist/commands/stop.mjs +0 -105
  33. package/dist/commands/stop.mjs.map +0 -1
  34. package/dist/docker-CnGQK3ZK.mjs +0 -432
  35. package/dist/docker-CnGQK3ZK.mjs.map +0 -1
  36. package/dist/docker-guidance-ypN3IM3o.mjs +0 -21
  37. package/dist/docker-guidance-ypN3IM3o.mjs.map +0 -1
  38. package/dist/oclif-B7lBzh3R.mjs +0 -808
  39. package/dist/oclif-B7lBzh3R.mjs.map +0 -1
  40. package/dist/orca-U142Wrau.mjs +0 -2556
  41. package/dist/orca-U142Wrau.mjs.map +0 -1
  42. package/dist/ports-B09RjuHx.mjs +0 -111
  43. package/dist/ports-B09RjuHx.mjs.map +0 -1
  44. package/dist/processes-Cw8TO1SY.mjs +0 -120
  45. package/dist/processes-Cw8TO1SY.mjs.map +0 -1
  46. package/dist/project-Cd0L3PtM.mjs +0 -87
  47. package/dist/project-Cd0L3PtM.mjs.map +0 -1
  48. package/dist/sync-BojoQm2P.mjs +0 -733
  49. package/dist/sync-BojoQm2P.mjs.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zitadel/cli",
3
- "version": "0.1.0-alpha.9",
3
+ "version": "0.1.0",
4
4
  "description": "Agent-friendly Zitadel CLI",
5
5
  "homepage": "https://github.com/zitadel/nextgen/tree/main/apps/cli#readme",
6
6
  "bugs": {
@@ -22,7 +22,7 @@
22
22
  "bin",
23
23
  "dist",
24
24
  "oclif.manifest.json",
25
- "SKILLS.md"
25
+ "skills"
26
26
  ],
27
27
  "publishConfig": {
28
28
  "access": "public"
@@ -30,7 +30,13 @@
30
30
  "oclif": {
31
31
  "bin": "zitadel",
32
32
  "dirname": "zitadel",
33
- "commands": "./dist/commands",
33
+ "description": "Manage your Zitadel project and local identity server from the command line.",
34
+ "commands": {
35
+ "strategy": "explicit",
36
+ "target": "./dist/index.mjs",
37
+ "identifier": "COMMANDS"
38
+ },
39
+ "helpClass": "./dist/lib/oclif/help",
34
40
  "topicSeparator": " ",
35
41
  "plugins": [
36
42
  "@oclif/plugin-help",
@@ -40,7 +46,45 @@
40
46
  "@oclif/plugin-autocomplete",
41
47
  "@oclif/plugin-search",
42
48
  "@oclif/plugin-version"
43
- ]
49
+ ],
50
+ "topics": {
51
+ "users": {
52
+ "description": "Manage the users of the project."
53
+ },
54
+ "teams": {
55
+ "description": "Manage the teams of the project."
56
+ },
57
+ "sessions": {
58
+ "description": "Inspect and revoke the sessions of the project."
59
+ },
60
+ "events": {
61
+ "description": "Read the audit event stream of the project."
62
+ },
63
+ "grants": {
64
+ "description": "Manage collaboration grants on the project."
65
+ },
66
+ "projects": {
67
+ "description": "Inspect and update the projects visible to this credential."
68
+ },
69
+ "schemas": {
70
+ "description": "Inspect user-schema revisions."
71
+ },
72
+ "branding": {
73
+ "description": "Work with login branding revisions."
74
+ },
75
+ "auth-method": {
76
+ "description": "Turn sign-in methods on or off for a user schema."
77
+ },
78
+ "auth-method:password": {
79
+ "description": "Turn password sign-in on or off."
80
+ },
81
+ "auth-method:passkey": {
82
+ "description": "Turn passkey sign-in on or off."
83
+ },
84
+ "auth-method:sso": {
85
+ "description": "Add or remove identity providers."
86
+ }
87
+ }
44
88
  },
45
89
  "type": "module",
46
90
  "dependencies": {
@@ -53,28 +97,44 @@
53
97
  "@oclif/plugin-search": "^1.2.50",
54
98
  "@oclif/plugin-version": "^2.2.46",
55
99
  "@oclif/plugin-which": "^3.2.55",
100
+ "@zitadel/api": "0.1.0",
101
+ "@zitadel/config": "0.1.0",
102
+ "@zitadel/server": "0.1.0",
56
103
  "ajv": "^8.20.0",
57
104
  "consola": "^3.4.2",
58
105
  "magicast": "^0.5.3",
106
+ "mixpanel": "^0.18.1",
59
107
  "safe-stable-stringify": "^2.5.0",
108
+ "semver": "^7.7.3",
109
+ "undici": "^7.29.1",
110
+ "wrap-ansi": "^7.0.0",
60
111
  "zod": "^4.3.6",
61
112
  "picocolors": "^1.1.1",
62
- "@zitadel/server": "0.1.0-alpha.9",
63
- "@zitadel/api": "0.1.0-alpha.9"
113
+ "rosie-skills": "^0.8.5"
64
114
  },
65
115
  "devDependencies": {
66
- "@types/node": "^25.6.0",
116
+ "@types/node": "^24.19.1",
117
+ "@types/semver": "^7.7.1",
118
+ "@types/wrap-ansi": "^3.0.0",
119
+ "@vitest/coverage-v8": "^4.1.11",
120
+ "@zitadel/api-mock": "0.0.0",
121
+ "@zitadel/sdk-next": "0.1.0",
67
122
  "msw": "^2.14.6",
68
123
  "oclif": "^4.17.46",
69
- "tsdown": "^0.21.10",
70
- "vitest": "^3.0.0",
71
- "@zitadel/sdk-next": "0.1.0-alpha.9",
72
- "@zitadel/api-mock": "0.0.0"
124
+ "tsdown": "^0.23.0",
125
+ "typescript": "^6.0.3",
126
+ "vite": "^8.3.1",
127
+ "vitest": "^4.1.11"
73
128
  },
74
129
  "scripts": {
75
130
  "build": "tsdown",
76
- "typecheck": "tsc --noEmit",
131
+ "typecheck": "tsc --noEmit -p tsconfig.app.json && tsc --noEmit -p tsconfig.spec.json",
132
+ "pretest": "pnpm run build",
77
133
  "test": "vitest run",
78
- "readme": "oclif readme"
134
+ "test:all": "pnpm run test",
135
+ "check-advisories": "vitest run --config vitest.advisories.config.ts",
136
+ "readme": "oclif readme",
137
+ "lint": "biome check .",
138
+ "build-release": "node ../../scripts/release-clean.mjs local-dist && pnpm run build"
79
139
  }
80
140
  }
@@ -0,0 +1,442 @@
1
+ ---
2
+ name: zitadel-cli
3
+ description: >-
4
+ Set up and manage Zitadel authentication in a local project with the
5
+ agent-friendly `zitadel` CLI. Use when the user wants to add login,
6
+ registration, or session handling, create a Zitadel project, scaffold auth
7
+ for a Next.js, Nuxt, SvelteKit, SolidStart, Qwik Router, TanStack Start, React,
8
+ Vue, Angular, Solid, Svelte, or Qwik app, or plan and apply Zitadel config
9
+ changes from repo state.
10
+ ---
11
+
12
+ # Zitadel CLI
13
+
14
+ The `zitadel` CLI integrates Zitadel auth into an existing project and keeps the
15
+ local config (`zitadel.json` and `.zitadel/**`) as the source of truth. Every
16
+ command emits a JSON envelope, so you should drive it non-interactively and
17
+ parse the result rather than scraping human output.
18
+
19
+ This skill teaches how to *drive* the CLI — how to invoke it, its output modes,
20
+ and its envelope. It deliberately does **not** enumerate the commands. The CLI
21
+ is self-describing, and this skill and the installed CLI version move
22
+ independently: a user may install the skill once and upgrade the CLI later, so
23
+ any command or flag list hardcoded here would drift out of lockstep and mislead.
24
+ Ask the CLI for its current surface (see [Discovering commands](#discovering-commands))
25
+ and treat what it prints as authoritative over anything you remember.
26
+
27
+ ## Installing and invoking
28
+
29
+ Run the CLI with `npx`, which fetches and caches it on demand — there is nothing
30
+ to install first:
31
+
32
+ ```sh
33
+ npx @zitadel/cli@latest <command> --non-interactive --json
34
+ ```
35
+
36
+ Use an exact version (`npx @zitadel/cli@0.1.0`) in agent scripts and bug
37
+ reports for reproducibility. The CLI is a preview: until 1.0.0 a minor version
38
+ can break, and its release note says so with **Breaking:**.
39
+ The CLI requires Node.js 24+. When `setup` creates a new app it first checks the running Node.js against the `engines.node` of the framework CLI it is about to run (`@angular/cli`, `nuxi`, `create-vite`, `create-next-app`). Only the Angular CLI refuses a Node it does not accept, and that range can be newer than 24.0: if `setup` refuses with `E_VALIDATION` naming the Node versions Angular accepts, switch to one of them and run it again. The Angular CLI checks each major on its own, so only 22.22.3+ on 22, 24.15.0+ on 24 and 26.x are accepted (23 and 25 run with a warning), and Node 27 or later is refused even though the published range reads `>=26.0.0`. For the other frameworks the CLI carries on, so `setup` adds a warning to the envelope's `warnings` and continues.
40
+
41
+ The app's framework must be at or above a minimum version: Next.js 15.2.3,
42
+ React 18, Vue 3.2, Nuxt 4, Angular 17, Solid 1.6, Svelte 5, Qwik 2.0.0-beta.45. Newer major
43
+ versions are not refused. `setup` and `doctor` refuse an app below its minimum,
44
+ by declared range or installed release, with `E_UNSUPPORTED_PROJECT_SHAPE`
45
+ (exit 3); `setup` refuses before it scaffolds or patches anything, while
46
+ `doctor --fix` can still repair unrelated files, so do not assume a floor error
47
+ left the project untouched. The message names the minimum and the hint says to
48
+ upgrade, so upgrade the app and rerun rather than retrying.
49
+
50
+ ## Using the CLI
51
+
52
+ - **Drive it non-interactively.** Always pass `--non-interactive --json` (short:
53
+ `-n`). The JSON object on stdout is the machine contract — parse it rather than
54
+ scraping human output. `--non-interactive` also disables every prompt, so a
55
+ command that would otherwise ask for an answer fails fast with `E_VALIDATION`
56
+ naming the flag to pass instead of blocking. Supply each answer as a flag; run
57
+ the command's `--help` to see which flags exist and which are required.
58
+ - **Output modes.** `--json` is the agent contract and is unaffected by the
59
+ terminal — color and width never apply to it, so you do **not** need
60
+ `--no-color` or other cosmetic flags when you parse JSON; don't sprinkle them
61
+ on every call. Human mode adapts to the terminal: a TTY gets aligned tables,
62
+ while a piped or redirected run (or `--plain`) gets one tab-separated record
63
+ per line and nothing else. If you ever read human output, set `NO_COLOR=1`
64
+ once in the environment rather than repeating `--no-color` per command.
65
+ - **Don't truncate `--json` with `head`/`tail`.** The envelope is one bounded
66
+ object; slicing it with `head -c`/`head -n` yields invalid JSON and silently
67
+ drops records or fields, so you end up reasoning from partial data. It is
68
+ finite — read it whole, or narrow it *at the source*: use a `list` verb's
69
+ `filter_fields` and pagination to fetch fewer records, or pipe to `jq` to pull
70
+ just what you need (e.g. `… resources --json | jq '.data.resources[].name'`).
71
+ `--help` output is bounded too — read it in full rather than `head`-ing it, or
72
+ you will miss flags further down.
73
+ - **Working directory.** Add `--cwd <path>` when operating outside the current
74
+ working directory.
75
+ - **Telemetry.** The CLI sends anonymous usage telemetry by default, and
76
+ agent-driven runs are exactly the ones worth learning from — leave it on.
77
+ Don't add `--no-telemetry` to commands. An opt-out exists for users who need
78
+ it (`ZITADEL_TELEMETRY=0`, or the standard `DO_NOT_TRACK`, in their
79
+ environment), but that is the user's environment choice, not a flag to attach
80
+ to every call.
81
+ - **Flag conventions.** Flags follow what a model already expects from curl, ssh
82
+ and wget: `--help`/`-h`, `--version`, `-v`/`--verbose`, kebab-case long flags,
83
+ both `--flag value` and `--flag=value`, and `--no-telemetry`-style negation.
84
+ Two deliberate deviations worth knowing: `-n` is `--non-interactive` (not
85
+ `--dry-run`, which is long-only), and machine output is `--json` (not
86
+ `--output json`). `api` takes `-X` for the method, as curl does, and `-F` for
87
+ a typed field, as `gh api` and `vercel api` do (not curl's form field).
88
+ - **Writing a resource's body.** A `create` or `update` takes every field of
89
+ its body as a flag, nested ones too: a nested field's flag is its dot path
90
+ joined with `-` (`oidc.client_id` is `--oidc-client-id`), a list is a
91
+ repeated flag, a boolean takes `--no-<flag>` for `false`, and an open record
92
+ (`attributes`) takes repeated `key=value` entries. `--set <path>=<value>`
93
+ (or `<path>:=<json>` for JSON) reaches any field by its dot path, and
94
+ `--data` / `--file` take the whole document. They combine: the document
95
+ first, then the field flags, then each `--set`, with objects merging key by
96
+ key. `resources --json` lists each write's fields with their dot path
97
+ (`name`), `flag` (`null` when only `--set` reaches it), `kind` and
98
+ `required`; `--dry-run --json` returns the body that would be sent. For a
99
+ deeply nested body, writing the document and passing it with `--file -` is
100
+ often simplest.
101
+ - **Calling an operation no command covers.** `zitadel api <operation>` calls
102
+ any operation of the API with the resolved server and `.zitadel/secret`.
103
+ Name it by its `operationId` (`queryUsers`, as the API reference and
104
+ `@zitadel/api` spell it) or by its path (`/users/query`; `-X` picks the
105
+ method where a path has several). Path parameters follow as arguments, in
106
+ path order; a `project_id` left out is the project's own. `-F name=value`
107
+ (or `name:=json`) sets a query parameter when the operation declares one by
108
+ that name, else a dot path into the body, typed by the operation's schema;
109
+ a list parameter takes one `-F` per value. `--input <path>` or `--input -`
110
+ takes the whole body, under the `-F` fields. `--paginate` follows
111
+ `next_page_token` to the last page. `--dry-run` sends nothing and returns
112
+ the request. An operation only an end user's session or the login flow's
113
+ cookie authenticates is refused with `E_VALIDATION`. Prefer a resource
114
+ command where one exists: `api ls --json` names it in each operation's
115
+ `command`.
116
+ - **Never put secrets on the command line.** A property whose name reads as a
117
+ credential (`password`, `client_secret`, `api_key`, …) is refused anywhere on
118
+ argv when it holds free-form text — as a field flag, a `--set` or
119
+ `--attributes` entry, and inside an inline `--data` body alike, since argv is
120
+ visible to other processes and kept in shell history. Send such bodies with
121
+ `--file <path>` or `--file -` (stdin), which never pass through argv. A
122
+ `${{ NAME }}` reference to a project variable is not a secret and may stay on
123
+ argv (a connection's `client_secret` takes nothing else); write it in single
124
+ quotes, since inside double quotes the shell reads `${` as its own expansion.
125
+ - **Streams.** Capture stdout and stderr separately when scripting. The machine
126
+ contract is one parseable JSON object on stdout; installer, audit, and
127
+ package-manager progress belongs on stderr.
128
+
129
+ ## Discovering commands
130
+
131
+ The CLI ships its own command list and per-command flags, always correct for the
132
+ installed version. **Do not guess a command name.** Before running any command you
133
+ are not certain of, run `zitadel --help` first and use the exact name it prints:
134
+ command and resource names — including whether a resource is singular or plural
135
+ and the exact verb — are whatever `--help` shows, never what you would assume. A
136
+ wrong guess costs a failed call and a round of recovery; one cheap `--help` up
137
+ front avoids it. `zitadel --help` is a flat list and cheap to read, so reach for
138
+ it first; treat the CLI's own output as authoritative over anything you remember:
139
+
140
+ ```sh
141
+ npx @zitadel/cli@latest --help # every command, grouped by purpose
142
+ npx @zitadel/cli@latest commands # flat list of all commands
143
+ npx @zitadel/cli@latest <command> --help # a command's flags, which are required, and examples
144
+ npx @zitadel/cli@latest resources --json # the resource surface in one call (see below); contacts no server
145
+ npx @zitadel/cli@latest api ls --json # every API operation, its parameters, body and paging; contacts no server
146
+ ```
147
+
148
+ `--help` groups the surface into project commands (create a project and scaffold
149
+ auth), local-server commands (run a local Zitadel), configuration commands
150
+ (`plan`/`apply` plus the config resources), and resource commands (the uniform
151
+ `<resource> <verb>` surface). Read the groups from `--help` rather than from
152
+ memory, since they change as the CLI gains commands.
153
+
154
+ Use `zitadel --help` to find *which* command to run. Use `resources --json` when
155
+ you need a resource's *fields*: it reports the whole runtime-resource surface at
156
+ once — every resource, its verbs, each verb's `create_fields` / `update_fields`
157
+ (flag name, kind, `required`, any closed value set), its `filter_fields` /
158
+ `sort_fields`, and the `delete_outcome` a destructive verb returns — so prefer it
159
+ over reading `<resource> --help` one at a time. A `list` verb's envelope carries
160
+ `data.count`, the number of items it returned. A list returns one page unless
161
+ you pass `--all`, so a "how many …?" question is one `list --all --json` call:
162
+ read the count, do not page and tally.
163
+
164
+ ## Reading the envelope
165
+
166
+ Each invocation prints one JSON object:
167
+
168
+ - `status`: `ok` | `skipped` | `error`.
169
+ - `cli_version`, `command`, `source`: always present.
170
+ - On success: `data` with the command-specific payload.
171
+ - On a no-op: `reason` (e.g. `already-initialized`, `already-claimed`,
172
+ `nothing-to-eject`).
173
+ - On failure: `code` (e.g. `E_VALIDATION`, `E_NETWORK`, `E_NOT_FOUND`,
174
+ `E_CONFLICT`) and `message`, usually with a `hint`, and `details` when there
175
+ is structured context.
176
+ - `next_commands`: the suggested follow-ups, inside `data` on success and at
177
+ the top level on a no-op or failure. Prefer these over free-text hints.
178
+ - `warnings`: things that went wrong without stopping the command, such as a
179
+ value that was not published. Always present on success (often empty), and
180
+ present on a no-op or failure when there are any. Read them before you report
181
+ success: a warning usually means a follow-up step is needed.
182
+ - A `list` verb emits `data: { items, count, next_page_token }`; when a page
183
+ remains, `data.next_commands` carries the exact command for the next page.
184
+ - `plan` and `apply` emit `data.changes`: one row per touched resource
185
+ (`{kind, action, file, id?, previous_id?, moved_from?}`, action ∈ create/
186
+ update/revision/delete/move). A `move` is a file that took over a resource
187
+ from a removed one (`moved_from`). Plan rows preview; apply rows report, with
188
+ the resulting platform ids. Use it to verify an edit did what you intended.
189
+ `data.unsupported_deletions` counts removed files whose resource cannot be
190
+ deleted yet (they are kept, and are not part of `total`); on `apply` the files
191
+ are listed in `data.unsupported_deletion_files`.
192
+ - `apply` leaves the files under `.zitadel/` as written: what the server stores
193
+ is never written back, and a field a file leaves out reads as the server's
194
+ default, so `plan` reports no change after an `apply`. `data.files_updated`
195
+ lists the one rewrite: a flow whose `user_schema` pinned a schema revision id
196
+ the apply superseded, re-pinned to the new revision's id.
197
+ - A write verb's `--dry-run` reports what it would send without calling the
198
+ platform, so you can preview a mutation before making it.
199
+ - `api` emits the response body as `data`, exactly as the API reference
200
+ documents it (`null` for a response without one); with `--paginate`, the
201
+ page's list holds every page's items. `api --dry-run` emits the request
202
+ instead: `{operation, method, url, body?}`. A refusal from the server is the
203
+ error envelope, with its status and body in `details`.
204
+
205
+ Common error codes point at their own fix in `next_commands`:
206
+
207
+ - `E_VALIDATION`: the body or flags are wrong; `message` names what, and
208
+ `details` often lists the missing or available values.
209
+ - `E_CREDENTIAL_MISSING`: a connection's `client_id` or `client_secret` names a
210
+ project variable that does not exist; `details.variable` is the name. Publish it
211
+ with `variables set NAME --project-level` (add `--secret` for the secret), then retry.
212
+ - `E_LOCAL_SERVER_NOT_RUNNING`: start the local runtime, then retry with
213
+ `--server local`.
214
+ - `E_NOT_FOUND`: an HTTP 404 — a missing resource, or a `--server` that is not a
215
+ Zitadel platform API. Follow `next_commands`.
216
+ - `E_PORT_IN_USE`: the requested local runtime port already has a listener; stop
217
+ that process or choose another port.
218
+
219
+ In human mode the output follows the terminal (TTY table, or tab-separated lines
220
+ when piped or `--plain`); `--json` is unaffected and remains the contract.
221
+
222
+ Text the server returns is escaped before it is printed, in `--json` as in human
223
+ mode, so a stored value cannot drive the reader's terminal. Control, format and
224
+ bidi characters appear as visible `\xNN`, `\uNNNN` or `\u{NNNNN}` text, so a
225
+ value that contained one is not the stored value byte for byte — do not send it
226
+ back in an update as if it were. When you need the exact value, call the platform
227
+ API directly with the project secret.
228
+
229
+ Exit codes mirror the error class (3 = validation, 4 = network or not-found,
230
+ 5 = conflict, 1 = auth, 2 = not-implemented, 130 = cancelled). `E_NETWORK`
231
+ covers a server that answered 5xx and one that never answered — refused,
232
+ unresolvable, or silent past the 30-second request deadline. Ctrl-C exits
233
+ 130: a command waiting on the server stops at once with `E_CANCELLED`, and
234
+ any other command exits within a second, possibly without an envelope. An
235
+ unknown command is handled by the CLI's help layer, not the envelope.
236
+
237
+ ## Clarify before you configure
238
+
239
+ Driving the CLI non-interactively does not mean deciding *for* the user. When
240
+ the user asks to add authentication but has not said *how*, don't silently pick
241
+ defaults — ask them first, in one short batched question, then run the CLI
242
+ non-interactively with their answers. The two things sit on different sides of
243
+ the conversation: you clarify with the human, then drive the CLI headlessly.
244
+
245
+ Ask about:
246
+
247
+ - **Sign-in methods** — password (the usual default), passkeys, and single
248
+ sign-on. If they want SSO, which providers? A provider the CLI does not list
249
+ by name is still possible: run `zitadel auth-method sso enable --help` to see
250
+ whether the installed CLI takes one, and which settings it needs, and ask for
251
+ those too.
252
+ - **Profile fields** — which attributes sign-up collects. The starting field
253
+ set depends on the use-case you pick (see *Presets and use-cases* below) —
254
+ the default (`minimal`) is the login identifier only, **not** names. Confirm
255
+ which fields they want (first/last name, phone, username, display name) and
256
+ choose the use-case or edit the schema accordingly.
257
+
258
+ Offer only what the installed CLI actually supports: read the real sign-in
259
+ presets, profile fields, and SSO options from the CLI first (`setup --help`,
260
+ `resources --json`) and present those, not a list you remember — the options
261
+ move with the CLI version.
262
+
263
+ ## Presets and use-cases — map the answers, don't trust the names
264
+
265
+ `setup` has two independent axes, and their names do **not** mean what they look
266
+ like. Read the current sets from `setup --help`, but know the traps:
267
+
268
+ - **Use-case = which profile fields the schema collects.** `minimal` is the
269
+ login identifier **only** — it does *not* include names. First + last name is
270
+ `--use-case consumer` (adds `givenName` + `familyName`); add a company with
271
+ `--use-case business`. Choosing `minimal` because the developer said "keep it
272
+ minimal" leaves an identifier-only schema that ignores the names they asked
273
+ for.
274
+ - **Preset = how they sign in (the login flow + auth methods).**
275
+ `password-first` makes password the primary step **but still leaves passkeys
276
+ enabled**; `passkey-first` leads with a passkey. Neither one gives you
277
+ password-only. If the developer does not want passkeys, turn them off
278
+ yourself: set `x-auth-methods.passkey.enabled` to `false` in
279
+ `.zitadel/schemas/*.json`, then `apply`.
280
+
281
+ Translate the developer's answers into the right axis values, then **verify
282
+ against what actually deployed**: read the live schema back
283
+ (`schemas get <objectType> --json`) and confirm the fields and auth methods
284
+ match what they asked for — don't assume a preset name did it.
285
+
286
+ Skip the questions and proceed with the defaults above — stating the assumptions
287
+ you made so the user can correct them — in exactly two cases: the user already
288
+ told you what they want, or you are running non-interactively (a one-shot/headless
289
+ invocation) or were explicitly told to just set it up.
290
+
291
+ ## Answering the user
292
+
293
+ Report what changed, in the user's terms — not how you drove the CLI. The
294
+ flags, `--json`, the `plan`/`apply` split, exit codes, and the number of
295
+ commands you ran are your internal business; the user asked for an outcome, not
296
+ a transcript. Say what they got.
297
+
298
+ - Good: "Added an optional phone number to your user schema and deployed it."
299
+ - Avoid: "I ran `plan` and `apply`, both with `--non-interactive --json`, and
300
+ both returned ok."
301
+
302
+ Quote a command or flag only when the user asks *how* something works, or when
303
+ they need to run something themselves. Otherwise keep the mechanics out of the
304
+ answer.
305
+
306
+ ## Golden path
307
+
308
+ The high-level workflow is stable even as individual flags evolve — run each
309
+ command's `--help` for its current flags (for example, `setup --help` lists the
310
+ framework, sign-in preset, and profile-field options):
311
+
312
+ ```sh
313
+ npx @zitadel/cli@latest doctor --non-interactive --json
314
+ npx @zitadel/cli@latest start --non-interactive --json
315
+ npx @zitadel/cli@latest setup --framework next --server local --non-interactive --json
316
+ npx @zitadel/cli@latest doctor --non-interactive --json
317
+ npx @zitadel/cli@latest plan --non-interactive --json
318
+ npx @zitadel/cli@latest apply --non-interactive --json
319
+ ```
320
+
321
+ `setup` scaffolds into an empty directory, or patches an existing app project
322
+ where it detects a framework. What `start` leaves in a directory —
323
+ `.zitadel/local/` and the `.gitignore` line that ignores it — still counts as
324
+ empty, so the golden path runs `setup` right after `start` in the same
325
+ directory. Any other non-empty directory stops setup with a hint to pass
326
+ `--force`. Pass it only for a directory whose contents may be replaced: files
327
+ the new app also has, such as `package.json`, are overwritten. Without a
328
+ terminal `setup` cannot ask which framework to scaffold, so pass `--framework`;
329
+ the error lists the choices in `details.frameworks`. `setup --dry-run` creates
330
+ no app: where it would scaffold one, it previews the project, and
331
+ `data.files_written` is empty, because those files depend on the generated app.
332
+ When setup fails after scaffolding a new app, before its default schema and
333
+ flow are uploaded, it removes the app again and puts back what the directory
334
+ held, so rerunning the same `setup` starts over.
335
+
336
+ `start` reuses a server already running in the directory only when it is the
337
+ release this CLI ships; one an earlier release started is restarted, and its
338
+ data stays. `setup --server local` refuses a binary-runtime server another
339
+ release started with `E_CONFLICT` before it creates anything: that server's API
340
+ is its own release's. Its `next_commands` run `start`, then `setup` again.
341
+
342
+ In an existing app, `--framework` has to name the framework setup detects
343
+ there; another one stops setup with `E_CONFLICT` instead of offering
344
+ `--force`. Setup reports its conflicts with the app before it creates a
345
+ project, and the error's `hint` says whether `--force` resolves one: it
346
+ replaces a file at a path setup writes, but not the app's root component or
347
+ request boundary at another path.
348
+
349
+ The app may also live in a subdirectory of the one `start` ran in: `setup`,
350
+ `console`, `--server local` and `doctor` read `.zitadel/local/` from the working
351
+ directory or the nearest parent that has it (up to the home directory), so
352
+ `mkdir my-app && cd my-app` after `start` works too. `doctor` checks that
353
+ server and its port, but runs its project checks in the working directory, so run
354
+ it from the app. When that server is unhealthy it suggests `start` and
355
+ `reset --force` with `--cwd` set to the directory that holds it (when that path needs
356
+ shell quoting the commands are left out, the hint names the directory, and
357
+ `doctor --json` returns the argument lists in `details.suggested_args` to run as they are). `stop`,
358
+ `reset`, `logs` and `status` read only the working directory's
359
+ `.zitadel/local/`, so run them where `start` ran. On a local
360
+ server that hosts the platform project, `setup` attaches the project to the
361
+ local admin's team and ends `data.next_commands` with `console`; when it finds
362
+ no local admin for that server on the way up, it says so in the envelope's
363
+ `warnings` and the project stays unattached, so the local console does not
364
+ list it.
365
+
366
+ When `setup --sso` or `sso enable` adds a social sign-in provider, the user
367
+ must register the connection's redirect URI with the provider themselves: give
368
+ them `data.sso[].callback_uri` from `setup`, or `data.callback_uri` from
369
+ `sso enable`, verbatim. Each connection has its own URI, so a URI from another
370
+ provider or an older CLI version does not work.
371
+
372
+ After `setup`, follow `data.next_commands` to start the app. Prove the generated
373
+ auth flow in a visible browser by registering a unique user, logging out, logging
374
+ back in with the same email/password, and ending on the signed-in profile page.
375
+ Do not treat a rendered login or registration form as completion.
376
+
377
+ To move a set-up app to another dev port (the dev server exits with
378
+ `EADDRINUSE`, or another app needs the port), run `setup --dev-port <port>` in
379
+ the app; never change the port in one file by hand. In a directory with a
380
+ `zitadel.json`, `setup` returns `status: "skipped"` with `reason:
381
+ "already-initialized"`, unless `--dev-port` is given: then it moves the app.
382
+ It allows the new origin on the server first, and a refusal changes nothing.
383
+ It then rewrites the dev script or dev-server config, `ZITADEL_ISSUER` in
384
+ `.env.local`, `zitadel.json`, `.zitadel/secret` and the README/AGENTS.md
385
+ guidance, and removes the old origin. `data.previous_issuer` and `data.issuer`
386
+ name both origins, and `data.moved` is `false` when the app was already on that
387
+ port. A social sign-in provider still redirects to the old port: `warnings`
388
+ names the redirect URI to add at each provider. Restart the dev server
389
+ afterwards.
390
+
391
+ To change how users sign in after setup, use the `auth-method` commands. Each
392
+ sign-in method has its own command, with `--schema` when the project has more
393
+ than one:
394
+
395
+ - `auth-method password enable` and `auth-method password disable`
396
+ - `auth-method passkey enable` and `auth-method passkey disable`
397
+ - `auth-method sso enable --provider google` adds a provider. It prompts for
398
+ the client id and secret, or takes `--client-id` with the secret piped on
399
+ stdin when non-interactive. Any other OpenID Connect provider is
400
+ `--provider custom` with `--slug`, `--display-name`, `--issuer` and optionally
401
+ `--scopes` (default `openid profile email`).
402
+ An issuer on `http://localhost:<port>` (a test provider on this machine)
403
+ works against a server `zitadel start` runs as a process: `start` sets
404
+ `NEXTGEN_HTTPCLIENT_ALLOW_LIST=localhost,127.0.0.0/8,::1/128` unless
405
+ `.env.local`, `.env` or the shell sets it, and setting it empty turns it off.
406
+ Under `--runtime docker` localhost is the container, so the provider is not
407
+ reachable. Otherwise `sso enable` warns in `warnings` that sign-in will fail.
408
+ `auth-method sso disable --provider google` removes a provider; a custom one
409
+ is named by its slug, as in `auth-method sso disable --provider acme-sso`.
410
+
411
+ The commands change only local files, apart from
412
+ `auth-method sso enable`, which also stores the provider's credentials on the
413
+ project. When they refuse, they write and publish nothing, on a dry run too.
414
+ They refuse to disable a method a login flow still asks for, to change a method
415
+ while a login flow has errors that prevent checking it, to enable password on a
416
+ schema without `x-identifier`, to edit a value that is not the shape they edit,
417
+ and to edit a schema that points at an external URL. Disabling the schema's last
418
+ way to sign in needs `--force` when non-interactive; only pass it for a schema
419
+ whose users are managed through the API, and ask the user first. That refusal's
420
+ `details.suggested_args` lists the `--force` re-run first, then the methods that
421
+ could be enabled instead. A dry run of the change is not refused: it previews it
422
+ and warns that no way to sign in would be left. A method that is enabled but not
423
+ offered by any active flow is reported in `warnings` (and in `data.not_offered`
424
+ for password and passkey). Every command reports `data.changed`, the
425
+ project-relative files it wrote (on a dry run, the files it would write), empty
426
+ when nothing changed. Follow `data.next_commands` (`plan`, `apply`, and
427
+ `variables set` when a credential did not reach the project) to publish the
428
+ change. When a path or schema name would need shell quoting, `next_commands` is
429
+ empty and `data.next_args` (or `details.suggested_args` on a refusal) holds the
430
+ same commands as argument lists.
431
+
432
+ Repo config is authoritative: edit `zitadel.json` or files under `.zitadel/`,
433
+ then re-run `plan` and `apply`. See the reference below for driving the login UI
434
+ and the config-sync details.
435
+
436
+ ## Reference files
437
+
438
+ Load on demand:
439
+
440
+ - [`references/driving-login-ui.md`](references/driving-login-ui.md) — driving the
441
+ `<zitadel-login>` component in a browser, and the authoritative repo-config
442
+ workflow (schemas, flows, branding).
@@ -0,0 +1,89 @@
1
+ ### Driving the login UI
2
+
3
+ `<zitadel-login>`, `<zitadel-session>`, and `<zitadel-logout>` are Lit elements
4
+ with open shadow roots. The stable automation hooks live inside nested shadow roots, so a flat
5
+ `document.querySelector('[data-testid="zitadel-input-email"]')` will not find
6
+ the native control. Browser drivers with shadow-DOM-aware locators, such as
7
+ Playwright, can target the hooks directly. Generic DOM-eval drivers should
8
+ pierce shadow roots recursively:
9
+
10
+ ```js
11
+ function deepQuery(sel, root = document) {
12
+ const hit = root.querySelector(sel);
13
+ if (hit) return hit;
14
+ for (const el of root.querySelectorAll("*")) {
15
+ if (el.shadowRoot) {
16
+ const result = deepQuery(sel, el.shadowRoot);
17
+ if (result) return result;
18
+ }
19
+ }
20
+ return null;
21
+ }
22
+ ```
23
+
24
+ Use host hooks such as `zitadel-field-email`, `zitadel-field-password`, and
25
+ `zitadel-action-submit` when targeting the Lit atoms. Use native shadow-control
26
+ hooks such as `zitadel-input-email`, `zitadel-input-password`, and
27
+ `zitadel-action-submit-button` when filling or clicking the underlying input or
28
+ button. Hooks stay method-named even when the flow engine names a credential
29
+ field `x-auth-methods#<method>`; only the `name` attribute carries that raw
30
+ form key. Enter inside a field submits the step's primary action, but only for
31
+ key events that carry `key: "Enter"` — drivers whose synthesized key events
32
+ omit it (some CDP wrappers) should click `zitadel-action-submit` instead.
33
+
34
+ For sign-out, the profile page that setup generates renders `<zitadel-session>`:
35
+ click its `zitadel-session-logout` host, or the native button inside it,
36
+ `zitadel-session-logout-button`. An app that renders `<zitadel-logout>` instead
37
+ hides sign-out behind an avatar menu: click the "Open user menu" button, then
38
+ pierce to `.signout-btn` (Playwright: `zitadel-logout .signout-btn`), which
39
+ carries no hook. A `<zitadel-logout>` with a `<template>` child shows no menu:
40
+ click the app's own element marked `data-action="logout"`. The canonical
41
+ component hook list lives in `packages/components/README.md`.
42
+
43
+ The checked-in automated regression path is `moon run e2e:journey`, which
44
+ exercises fresh-app setup plus registration, logout, and login across the
45
+ supported frameworks.
46
+
47
+ Repo config is authoritative: edit `zitadel.json` or files under `.zitadel/`,
48
+ then re-run `plan` and `apply`. Schema and flow files are synced from
49
+ `.zitadel/schemas/*.json` and `.zitadel/flows/*.json`. Login templates
50
+ (branding) are synced from `.zitadel/branding/`: a single `branding.json`
51
+ descriptor (layout, asset URLs) plus a sibling `login.liquid` LiquidJS
52
+ template referenced as `"liquid_template": { "$file": "./login.liquid" }`. Scaffold them with the
53
+ `branding eject` command (`--design centered|minimal`,
54
+ interactive picker on a TTY); setup never scaffolds them. Branding is
55
+ revisioned and immutable: every edit — including a `.liquid`-only edit —
56
+ plans as a `revise` and `apply` publishes a new revision; the login serves
57
+ the newest one. `plan` validates templates with the authoritative LiquidJS
58
+ validator (`E_VALIDATION` lists rule ids such as `no-script-tag` and
59
+ `mandatory-gates`; every template must keep a `{% mandatory_gates %}` tag,
60
+ where the login adds any required field and the primary action the template
61
+ left out). Asset URLs must be absolute `https://`; during development, images
62
+ may use `http://` on `localhost`, `127.x.x.x`, or `[::1]` (not `*.localhost`).
63
+ `typography.font_url` needs a `typography.font_family`, is always `https://`,
64
+ and is loaded only when the login runs as `variant="page"`, which setup
65
+ generates only when it creates a Next.js or Nuxt app itself, in an empty
66
+ directory. Keep exactly one descriptor in
67
+ `.zitadel/branding/` — extra `*.json` files there fail the scan.
68
+ Server-provisioned defaults remain a fallback for non-CLI project
69
+ creation, but CLI-created projects are authored from local files first. Flows are
70
+ revisioned like branding: an edit plans as a `revise` and `apply` publishes a new
71
+ immutable flow revision. A flow names its schema by `objectType` in
72
+ `user_schema` and runs against the schema's newest revision, so a schema revise
73
+ needs no change to `user_schema`; one that removes or renames a property a step
74
+ collects needs that step's `fields` updated, and `plan` checks only the flows it
75
+ uploads. A login pinned by `flow-name` serves that flow's newest active
76
+ revision; an unpinned login serves the newest active unscoped revision for its
77
+ purpose in the project, whatever its flow's name. Older revisions stay active,
78
+ so an `audience` added after a flow was applied without one doesn't take that
79
+ earlier revision out of the running. Removing a flow file does not retire the
80
+ flow. Managed files carry a marker comment; `eject` removes only
81
+ files that still carry it, preserving anything the user replaced. For app-local
82
+ development, `--server local` resolves through `.zitadel/local/runtime.json` and
83
+ requires a healthy
84
+ `npx @zitadel/cli@latest start` runtime. The `.zitadel/local/` that `start`
85
+ writes into the directory still counts as empty, so a same-directory `setup`
86
+ scaffolds without `--force` (this is exactly what the golden path does).
87
+ `setup` installs dependencies
88
+ with the detected package manager by default; pass `--skip-install` when the
89
+ agent or host workflow will install dependencies separately.