You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 0cf4e2b
Browse filesBrowse the repository at this point in the historyBrowse files
improvement(workflow-code): reorganize the workflows-as-code docs with generated exit-code, diagnostic and limit references (#10334)
Workflows and workspace as code docs move under /workflows/code as a tutorial, how-to pages and generated references; exit codes, diagnostics and limits are generated from the engine (check:workflow-code-docs fails on drift); /workflows/workspace-code redirects to /workflows/code/workspace; CI recipes for a PR plan comment and a scheduled drift job; quick fixes from the docs audit.
Copy file name to clipboardExpand all lines: .claude/rules/sim-workflow-code.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,6 +48,14 @@ workspace directory).
48
48
|`apps/sim/blocks/sdk-names/<type>.json`| Frozen SDK builder names, one file per block type |
49
49
|`apps/sim/app/workspace/**/panel/components/code/`| The read-only Code tab |
50
50
51
+
Public docs live in `apps/docs/content/docs/workflows/code/`. The exit-code, diagnostic-code, limit
52
+
and per-kind layout tables of `exit-codes.mdx`, `diagnostics.mdx`, `limits.mdx` and `directory.mdx` sit between
53
+
`workflow-code-docs` markers and come from their owners (`source-exit-codes.ts`, SYNTAX.md and `workspace-code`'s
54
+
`diagnostics/codes.ts` TSDoc, the `*_LIMITS` constants, `WORKSPACE_KIND_SPECS`): edit the owner, then run
55
+
`bun run generate:workflow-code-docs` (`check:workflow-code-docs` fails on drift, a diagnostic code a page names that
56
+
no engine emits, a limit or diagnostic code with no docs entry, and a `typescript@x.y.z` pin other than the CLI's).
57
+
A limit also needs a label in the generator's `WORKFLOW_LIMIT_LABELS` or `WORKSPACE_LIMIT_LABELS`.
58
+
51
59
Dependencies point one way: `packages/workflow-types` → `packages/workflow-code` →
52
60
`packages/workspace-code` and `packages/workflow-sdk` → the CLI and `apps/sim`. `check:boundaries` keeps both engines and `packages/table-cells` pure (no
53
61
Node built-ins, `eval`, `globalThis`, dynamic import): they run in the browser, the CLI and the
Copy file name to clipboardExpand all lines: .cursor/rules/sim-workflow-code.mdc
+8Lines changed: 8 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -28,6 +28,14 @@ workspace directory).
28
28
| `apps/sim/blocks/sdk-names/<type>.json` | Frozen SDK builder names, one file per block type |
29
29
| `apps/sim/app/workspace/**/panel/components/code/` | The read-only Code tab |
30
30
31
+
Public docs live in `apps/docs/content/docs/workflows/code/`. The exit-code, diagnostic-code, limit
32
+
and per-kind layout tables of `exit-codes.mdx`, `diagnostics.mdx`, `limits.mdx` and `directory.mdx` sit between
33
+
`workflow-code-docs` markers and come from their owners (`source-exit-codes.ts`, SYNTAX.md and `workspace-code`'s
34
+
`diagnostics/codes.ts` TSDoc, the `*_LIMITS` constants, `WORKSPACE_KIND_SPECS`): edit the owner, then run
35
+
`bun run generate:workflow-code-docs` (`check:workflow-code-docs` fails on drift, a diagnostic code a page names that
36
+
no engine emits, a limit or diagnostic code with no docs entry, and a `typescript@x.y.z` pin other than the CLI's).
37
+
A limit also needs a label in the generator's `WORKFLOW_LIMIT_LABELS` or `WORKSPACE_LIMIT_LABELS`.
38
+
31
39
Dependencies point one way: `packages/workflow-types` → `packages/workflow-code` →
32
40
`packages/workspace-code` and `packages/workflow-sdk` → the CLI and `apps/sim`. `check:boundaries` keeps both engines and `packages/table-cells` pure (no
33
41
Node built-ins, `eval`, `globalThis`, dynamic import): they run in the browser, the CLI and the
Copy file name to clipboardExpand all lines: apps/docs/content/docs/cli/index.mdx
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -140,7 +140,7 @@ sim tables rows query --help
140
140
|[`workflow-mcp-servers`](/cli/workflow-mcp-servers)| Expose deployed workflows as MCP tools |
141
141
|[`meta`](/cli/meta)| Inspect API availability and credential status |
142
142
143
-
To edit a workflow as a TypeScript file, or a whole workspace as a directory, use `sim workflows source` and `sim workspaces source` (in preview). See [Workflows as code](/workflows/code) and [Workspace as code](/workflows/workspace-code).
143
+
To edit a workflow as a TypeScript file, or a whole workspace as a directory, use `sim workflows source` and `sim workspaces source` (in preview). See [Workflows as code](/workflows/code) and [Manage a workspace as code](/workflows/code/workspace).
144
144
145
145
The [command overview](/cli/commands) lists global options and root commands. The [complete reference](/cli/reference) contains every subcommand, argument, and option on one page. Both are generated from the CLI.
146
146
@@ -177,7 +177,7 @@ The repository is also a native Claude Code and Codex plugin, which exposes the
177
177
178
178
The skills assume `sim` is installed and signed in, so complete [Your first command](#your-first-command) first. They never store or print API keys. These agent skills are separate from the workspace skills you manage with [`sim skills`](/cli/skills).
179
179
180
-
To have a coding agent edit workflow files directly, see [Workflows as code for coding agents](/workflows/code#for-coding-agents).
180
+
To have a coding agent edit workflow files directly, see [Use workflows as code with coding agents](/workflows/code/coding-agents).
|`0`| Applied or created, or a dry run with no errors |
171
-
|`1`| The source has errors (each printed as `file:line:column` with its frame and hint), `create`'s workflow name is taken (`SOURCE_NAME_TAKEN`: pass `--name`), or command/request failure |
172
-
|`5`| The workflow changed since the directory was read (`409 SOURCE_STALE`): get it again, reapply the edit, and retry |
173
-
|`6`| The workflow or its folder is locked (`423`, `E_APPLY_LOCKED`); a locked block exits `1` (`E_APPLY_LOCKED_BLOCK`) |
174
-
|`7`| The source is over the size limits (`413`) |
175
-
|`9`| Still rate limited (`429`) after the CLI's retries; nothing was written |
176
-
|`10`| Busy, retry: another `sim` command is using `--dir`, or the workspace directory it is a workflow folder of (`SOURCE_DIR_BUSY`); nothing was read or written: run it again once the other finished |
177
-
|`13`|`AUTH_REQUIRED`: not logged in, or the server refused the credential; nothing was sent |
178
-
|`14`| Run without `--yes` and with no terminal to ask: the plan was printed with no errors and nothing was written; run the same command with `--yes`|
179
-
|`130`| Interrupted (Ctrl-C). A write already sent is finished and saved into the directory first, waiting up to 60s for its answer; a second Ctrl-C, or no answer by then, stops at once and prints that it may have been written and how to check |
|`0`| Clean: nothing to apply, and the server changed nothing since the directory was read |
184
-
|`1`| Command/request failure |
185
-
|`7`| The source is too large for the server to read in one dry run |
186
-
|`10`|`sim workspaces source status` only: another `sim workspaces source` command is using the directory (`SOURCE_DIR_BUSY`); nothing was read: run it again once the other finished |
187
-
|`11`| Local changes only: applying writes them |
188
-
|`12`| The server changed since the directory was read (drift, or a conflict with local changes) |
189
-
|`13`|`AUTH_REQUIRED`: not logged in, or the server refused the credential; the local changes are still shown |
|`1`| The source has errors, or a warning that fails the check on a block the edit added (see `--strict`), or no block catalog is cached: run the get once |
195
-
|`10`|`sim workspaces source check` only: another `sim workspaces source` command is using the directory (`SOURCE_DIR_BUSY`); nothing was read: run it again once the other finished |
196
-
197
-
| Code |`sim workflows source get --dir` or `sim workspaces source get`|
198
-
| --- | --- |
199
-
|`0`| Written |
200
-
|`1`| The directory holds edits no apply has saved (`SOURCE_LOCAL_EDITS`) or another workflow's source (`SOURCE_WORKFLOW_MISMATCH`): apply them, get into another directory, or pass `--force`; it is the other kind of source directory (`SOURCE_DIR_KIND_MISMATCH`, even with `--force`); for a workspace, `--workspace` names another workspace than the one the directory was read from (`SOURCE_OTHER_WORKSPACE`) or a downloaded binary file does not match its listing (`SOURCE_BLOB_MISMATCH`); or command/request failure |
201
-
|`7`| The workflow, or a kind of resource, is too large for one directory |
202
-
|`9`| Still rate limited (`429`) after the CLI's retries; nothing was written |
203
-
|`10`| Busy, retry: another `sim` command is using the directory (or, for a workflow folder, its workspace directory) (`SOURCE_DIR_BUSY`); nothing was read or written: run it again once the other finished |
204
-
|`13`|`AUTH_REQUIRED`: not logged in, the login expired, or the server refused the credential; nothing was read or written: run `sim login` and the get again |
205
-
|`130`| Interrupted (Ctrl-C): run the get again |
206
-
207
-
| Code |`sim workspaces source apply`|
208
-
| --- | --- |
209
-
|`0`| Applied, or a dry run with no errors |
210
-
|`1`| The source has errors, every change it would write was held back for a secret or credential the workspace cannot satisfy (nothing was written; its dry run exits `1` too), or command/request failure |
211
-
|`5`| A resource changed since the directory was read (`409 SOURCE_STALE`): get it again into a fresh directory, reapply the edit, and retry |
212
-
|`6`| A resource (a workflow or its folder, a table) is locked (`423`); a locked block exits `1` (`E_APPLY_LOCKED_BLOCK`) |
213
-
|`7`| The directory is over the size limits (`413`) |
214
-
|`8`| The apply stopped part-way: what was written is saved into the directory; apply again |
215
-
|`9`| Still rate limited (`429`) after the CLI's retries; nothing was written |
216
-
|`10`| Busy, retry: another apply is writing the workspace (`409 SOURCE_BUSY`), or another `sim workspaces source` command is using the same directory (`SOURCE_DIR_BUSY`); nothing was written: run the command again once the other finished |
217
-
|`13`|`AUTH_REQUIRED`: not logged in, or the server refused the credential; nothing was sent |
218
-
|`14`| Run without `--yes` and with no terminal to ask: the plan was printed with no errors and nothing was written; run the same command with `--yes`|
219
-
|`15`| Written in part: changes that use a declared secret with no value, or a credential key nothing binds to, were held back and the rest was applied and saved; set the secret or connect the credential, then apply again (a promotion with `--to` too). A dry run that would do so exits `15` too, having written nothing |
220
-
|`130`| Interrupted (Ctrl-C). A write already sent is finished and saved into the directory first, waiting up to 60s for its answer; a second Ctrl-C, or no answer by then, stops at once and prints that it may have been written and how to check |
221
-
222
-
Earlier CLI releases exited `1` when an apply held changes back, whether or not it wrote the rest, and its dry run exited `1` in either case. A script that reads `1` as "held back" should test for `15` too.
168
+
The source commands (`sim workflows source` and `sim workspaces source`) have codes of their own, among them `5` stale, `10` busy, `11` and `12` for `status`, `14` for an apply without `--yes`, and `15` for an apply that held changes back. [Exit codes](/workflows/code/exit-codes) lists each one with what to do next.
223
169
224
170
Both waits default to 3600 seconds; `--wait-timeout 0` waits indefinitely. `SIM_TIMEOUT_SECONDS` independently bounds one API request. A timeout does not cancel the underlying run or operation.
225
171
@@ -381,63 +327,14 @@ exit "$status"
381
327
382
328
## Workspace source in CI
383
329
384
-
Keep a [workspace source directory](/workflows/workspace-code) in a repository, `.sim/` included, and let CI plan each pull request and apply each merge. The dry run exits `1` on errors, `5` when the workspace changed since the committed base, and `15` when the apply would hold back changes that use a secret with no value or a credential nothing binds to; `check` downloads the block catalog once on a fresh runner. On GitHub Actions (`GITHUB_ACTIONS=true`), every source command also annotates each error and warning at its file and line, so they show inline on the pull request, and `apply` (a dry run too) appends its plan and errors to the job's step summary.
commit -m "chore(workspace): files the apply rewrote [skip ci]"
423
-
git push
424
-
fi
425
-
```
426
-
427
-
`check` runs first because it is offline and fast, and it regenerates `.sim/sdk/workspace.d.ts`, so the `tsc` step after it types resources the pull request adds. A workspace API key can apply tables, rows, knowledge bases, files, custom tools, MCP servers and credential bindings. Workflows, skills, secrets and deployments need a member's personal API key, and deployments need an admin. Apply rewrites files under the directory (each `.sim/base.json`, ids it allocated, values the server normalized), and the next apply compares with them, so the last step commits them back to the branch; `[skip ci]` keeps that commit from running the job again. That step runs even when the apply failed (`!cancelled()`), because an apply can fail having written part of its plan: exit `15` means it held back changes that use a secret with no value or a credential nothing binds to and applied the rest, and exit `8` means it stopped part-way. Either way the directory records what was written, so committing it keeps the next run from being refused as stale (exit `5`) for resources this run wrote; the job still fails, so set the secret, connect the credential or fix the failure, and push again. Where the branch is protected, run `sim workspaces source get --dir workspace` on a new branch instead and open a pull request. After merging two branches that each applied, a dry run with no changes means the files match the workspace. Exit `5` means a resource changed since this branch's base: get the workspace into a fresh directory and carry the edit over. Exit `10` means another apply is writing the workspace (or another command is using the directory), so retry; the `concurrency` key keeps two runs of this job from overlapping.
428
-
429
-
To promote the same directory to a second workspace, add a step with `--to` before the step that commits the files back:
The promotion writes `workspace/.sim/targets/<workspaceId>.json`, what it left in that workspace. Committing it lets the next run tell a change made in that workspace since (kept, or exit `5` when the directory changed the same resource) from one to promote.
330
+
Dry-run source on pull requests, apply on merge, comment the plan and detect drift on a schedule: see [Run in CI](/workflows/code/ci) for GitHub Actions recipes.
436
331
437
332
## Related docs
438
333
439
334
-[Output formats](/cli/output)
440
335
-[Workflow commands](/cli/workflows)
336
+
-[Workflows as code: run in CI](/workflows/code/ci)
337
+
-[Workflows as code: exit codes](/workflows/code/exit-codes)
441
338
-[Workflow imports and workspace sync](/cli/workflow-sync)
Copy file name to clipboardExpand all lines: apps/docs/content/docs/platform/self-hosting/environment-variables.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -199,7 +199,7 @@ Plain JavaScript without imports runs in isolated-vm within Node child workers i
199
199
200
200
| Variable | Description |
201
201
|----------|-------------|
202
-
|`WORKFLOW_CODE`| Set to `true` to enable [workflows as code](/workflows/code) and [workspace as code](/workflows/workspace-code): the read-only **Code** tab in the workflow builder, and the source API and MCP operations that the `sim workflows source` and `sim workspaces source` CLI commands call. Off when unset; while off, those operations answer `403`|
202
+
|`WORKFLOW_CODE`| Set to `true` to enable [workflows as code](/workflows/code) and [workspace as code](/workflows/code/workspace): the read-only **Code** tab in the workflow builder, and the source API and MCP operations that the `sim workflows source` and `sim workspaces source` CLI commands call. Off when unset; while off, those operations answer `403`|
0 commit comments