---
name: cloudcruise
description: CloudCruise CLI reference for building, editing, and debugging CloudCruise workflows — builder agent sessions, workflow/component CRUD, vault credentials, runs, and debug snapshots. Use whenever a task involves the `cloudcruise` CLI or CloudCruise workflows.
---

# CloudCruise CLI

Command-line tool for managing CloudCruise workflows and runs. All output is JSON to stdout; errors go to stderr — consume stdout only, never merge with `2>&1` when parsing, and branch `builder status` poll loops on exit codes rather than matching strings in the JSON (`run get` exits 0 for every run state, so run polls match `status` against the Run statuses table).

## Setup

```bash
npm install -g @cloudcruise/cli
cloudcruise login
```

`cloudcruise login` is the primary authentication path. It uses browser OAuth, saves tokens to the OS keychain, and sets up the active workspace when possible. For CI or other non-interactive use, set `CLOUDCRUISE_TOKEN`; legacy API-key auth is still supported with `CLOUDCRUISE_API_KEY` for individual commands.

Some coding-agent sandboxes cannot access the OS keychain. In that case, profile-backed OAuth may appear missing even
when the user is authenticated; run commands that use profile OAuth outside the sandbox.

### Install Skills for Coding Agents

After installing the CLI, run this in your project root to expose the skill reference to your coding agent:

```bash
cloudcruise install --skills                  # all targets: .claude/skills/, .cursor/skills/, .agents/skills/
cloudcruise install --skills --target claude   # .claude/skills/ only
cloudcruise install --skills --target cursor   # .cursor/skills/ only
cloudcruise install --skills --target codex    # .agents/skills/ only (same for devin, agents)
```

### Staying Up to Date

Off a TTY, the CLI reports on stderr, one JSON line each:

- `{"updateAvailable":{...}}`: a newer CLI exists. Tell the user and suggest `remedy` (`npm i -g @cloudcruise/cli@latest`). If they use the CloudCruise plugin in their coding agent, they update it there too.
- `{"skillsRefreshed":{...}}`: an older CLI installed these skills; the CLI reinstalled them from the running version. Tell the user which skills were refreshed (`paths`, they show up in `git status`) and which were kept because someone edited them (`keptEdited`). Re-read any skill you already loaded.
- `{"skillsWarning":{...}}`: installed skills don't match the CLI. Run its `remedy`.

Skills refresh on the first command after a CLI upgrade, in the current project only, and only packs that `install --skills` stamped and nobody edited since. An edited pack stays stale and keeps the `skillsWarning`; ask the user before running its `remedy`, which overwrites the edits. `settings.skillsAutoUpdate: false` in `~/.cloudcruise/config.json` turns this off; `CLOUDCRUISE_SKILLS_AUTO_UPDATE=0|1` overrides the setting.

## Commands

### Auth

```bash
cloudcruise login                            # Primary browser OAuth login
cloudcruise login --profile <name>           # Log in to a named auth profile
cloudcruise login --workspace-id <id>         # Save an active workspace on the profile
cloudcruise auth status                      # Check auth (masked key, source)
cloudcruise auth switch <profile>            # Set the active auth profile
cloudcruise auth profiles                    # List all auth profiles
cloudcruise auth logout                      # Remove saved credentials
```

For legacy API-key setup, avoid passing secrets as command-line arguments. Use stdin for a stored profile, or set `CLOUDCRUISE_API_KEY` for one-off command execution:

```bash
printf '%s' "$CLOUDCRUISE_API_KEY" | cloudcruise auth login --api-key-stdin
CLOUDCRUISE_API_KEY="sk_..." cloudcruise workflows list
```

### Workspaces

```bash
cloudcruise workspaces list                  # List workspaces available to the authenticated user
cloudcruise workspaces show                  # Show the active workspace for the auth profile
cloudcruise workspaces use <workspace_id>    # Set the active workspace for the auth profile
cloudcruise workspaces clear                 # Clear the active workspace for the auth profile
```

After OAuth login, the CLI auto-selects the only available workspace. If multiple workspaces are available in a non-interactive agent session, parse the login JSON for `workspace_selection_required: true` and `available_workspaces`, then run `cloudcruise workspaces use <workspace_id>` or pass `--workspace-id <workspace_id>` on later commands.

### Workflows

Use `workflows` commands to edit existing workflows. For new workflows, use the builder instead.

```bash
cloudcruise workflows list                                                       # List all workflows in the workspace
cloudcruise workflows list --folder "Claims/EOB"                                # List workflows inside a specific folder
cloudcruise workflows folders                                                    # List all folders (allFolderPaths = full tree)
cloudcruise workflows folders --path "Claims"                                   # List direct subfolders under a folder (with workflow counts)
cloudcruise workflows folders --search invoice                                  # Search folders/workflows by name or id
cloudcruise workflows get <workflow_id>                                          # Get the default branch's head with nodes
cloudcruise workflows get <workflow_id> --version 2.1.0                          # Get a specific version (or a range: "^2.1.0", "2.x", 2 = latest 2.x.x)
cloudcruise workflows get <workflow_id> --branch fix-login                       # Get a branch's latest version (name or id)
cloudcruise workflows versions <workflow_id>                                     # List version history (newest first)
cloudcruise workflows versions <workflow_id> --limit 10                          # Cap the list
cloudcruise workflows update <workflow_id> --file w.json --version-note "..."   # Update workflow (creates new version)
cloudcruise workflows update <workflow_id> --stdin --version-note "..."          # Update from piped JSON
cloudcruise workflows update <workflow_id> --file w.json --force                 # Overwrite even if a newer version exists
cloudcruise workflows update <workflow_id> --file w.json --release-version 3.0.0 # Save as release 3.0.0 instead of the automatic bump
cloudcruise workflows validate-input <workflow_id> --file payload.json           # Validate a run input payload against the saved input schema
cloudcruise workflows delete <workflow_id> [<workflow_id>...]                     # Permanently delete workflows (no confirmation)
```

**validate-input** checks a payload against the workflow's *saved* `input_schema` (push schema edits first). Exit `0` = valid; `1` = payload invalid, with per-field errors on stdout; `2` = the schema itself does not compile — fix the schema, no payload can pass. `<alias>` vault placeholders pass validation. Exit 0 means schema-valid, not run-will-succeed. Also accepts `--stdin`.

**delete** is permanent and asks no confirmation. Runs and results are kept. stdout is one array with an entry per id: `{ id, status: "deleted" | "not_found" | "error", message? }`. It continues past failures and exits non-zero if any id failed: `4` when all failures are `not_found`, the shared code when all failures share one, else `1`. A workflow's webhooks are deleted with it.

**Workflow folders** are virtual: they are derived from each workflow's `folder_path` (a slash-separated string like `Claims/EOB`, max 5 levels) plus placeholder rows for empty folders. There is no folder ID. `workflows folders` returns `allFolderPaths` (the complete folder tree) and `folders` (direct subfolders under `--path`, with per-folder `workflow_count`). `workflows list --folder <path>` returns every workflow whose `folder_path` matches that path exactly (non-recursive).

**When adding new nodes, always generate UUIDs with `cloudcruise utils uuid`.** Node IDs must be valid UUIDs -- do not use natural language IDs like `"click-submit-button"`.

**Edit pattern:** fetch → edit → push:

```bash
cloudcruise workflows get <workflow_id> > workflow.json
# Edit workflow.json with your file editing tools (targeted replacements, not full rewrites)
# Leave read-only fields (id, version_id, created_at, …) in place; the body is sent as-is.
cloudcruise workflows update <workflow_id> --file workflow.json --version-note "Description of changes" > next.json && mv next.json workflow.json
```

**Versions and branches:** workflow versions are semver strings (`version`, e.g. `"2.1.0"`) identified by `version_id`; there is no workflow `version_number`. `--version` takes an exact version, a semver range (quote it: `"^2.1.0"`, `"~2.1.3"`, `"2.x"`; the highest match wins) or `N` for the latest `N.x.x`. `--version-number <N>` is the legacy form of `--version N`. `--version`, `--version-number` and `--branch` are mutually exclusive.

**Stale check:** `update` only succeeds if the body's `version_id` is still the latest version on its branch. Otherwise it creates no version and exits 13 (`WORKFLOW_VERSION_CONFLICT`). The stderr envelope names the latest version (`latestVersion`: id, version, branchId, author, time, note; `number` only from older backends). Re-fetch with `workflows get`, re-apply your edit and update again. Pass `--force` only to overwrite the other save on purpose. A body without `version_id` is not checked.

The version note comes only from `--version-note`; the body's `version_note` is not sent.

The update saves to the body's `branch_id` (the branch `get` read it from); `--branch <name|id>` overrides it. A protected branch rejects the save with 403: save to another branch and open a pull request (see Branches and Pull Requests). `--bypass-protection` only works for a login whose workspace role is in the branch ruleset's bypass list; API keys can't bypass. `--release-version <x.y.z>` sets the new version instead of the automatic bump; it must be higher than the version the body is based on.

Your own update also creates a new latest version. `update` prints it (same shape as `get`, new `version_id`); keep it as the working copy, as above, or the next push from the old copy exits 13.

**Rolling back versions:** `workflows versions` lists history newest first. Fetch a prior version's full JSON via `--version <x.y.z>` (same shape as latest), then push it back with `--force` to roll back (its `version_id` is not the latest, so the stale check would reject it) — history is preserved as a new version on top:

```bash
cloudcruise workflows get <workflow_id> --version 2.1.0 > rollback.json
cloudcruise workflows update <workflow_id> --file rollback.json --force --version-note "Rollback to 2.1.0"
```

**Login workflow edit pattern:** For existing login workflows, make the first three nodes `START (logged-in destination URL)` → `IF (already logged in?)` → false branch login recovery. On the false branch, set `clear_cookies_on_false: true`, then add a `NAVIGATE` node to the login page before the credential-entry steps.

**Download capture pattern:** In manual workflow edits, add a `FILE_DOWNLOAD` node immediately after any `CLICK` that triggers a download. The builder adds this automatically; direct workflow edits do not.

**Iterative build pattern** (for creating workflows node-by-node without the builder):

```bash
# 1. Start with a minimal workflow: START (target URL) → END
#    Run with --debug to capture a snapshot of the landing page
#    run start returns { session_id } immediately; poll run get until the status is terminal
cloudcruise run start <workflow_id> --input '{}' --debug
cloudcruise run get <session_id>

# 2. Discover elements → validate → add nodes → run again → repeat
cloudcruise snapshot suggest <session_id> <end_node_id>
cloudcruise snapshot test "//input[@name='email']" <session_id> <end_node_id>
# Edit workflow.json, push and keep the new version as the working copy:
#   cloudcruise workflows update <workflow_id> --file workflow.json --version-note "..." > next.json && mv next.json workflow.json
cloudcruise run start <workflow_id> --input '{}' --debug
cloudcruise run get <session_id>   # poll until terminal
# On success: inspect END node's snapshot for the next page state.
# On failure: inspect the failed node's snapshot (see Debug Snapshots).
```

### Branches and Pull Requests

Branches and pull requests work like git and `gh pr`. Every `--branch`/`--head`/`--base` takes a branch name or id; a pull request is `12`, `#12` or its id. Every command needs `--workflow <workflow_id>`.

```bash
cloudcruise branches list --workflow <workflow_id>                        # is_default marks the branch unpinned runs use
cloudcruise branches create fix-login --workflow <workflow_id>            # From the default branch (--from <branch>, --from-version 2.1.0)
cloudcruise branches set-default <branch> --workflow <workflow_id>
cloudcruise branches delete <branch> --workflow <workflow_id>             # Not the default branch; --close-open-prs closes its PRs
cloudcruise workflows get <workflow_id> --branch fix-login > workflow.json
cloudcruise workflows update <workflow_id> --file workflow.json --branch fix-login --version-note "..."
cloudcruise run start <workflow_id> --branch fix-login                    # Test the branch
cloudcruise prs create --workflow <workflow_id> --head fix-login --title "Fix login XPath"   # --base defaults to the default branch
cloudcruise prs list --workflow <workflow_id>                             # --state open|merged|closed|all
cloudcruise prs view 12 --workflow <workflow_id>                          # Includes approvals
cloudcruise prs diff 12 --workflow <workflow_id>                          # Conflicts + match_heads
cloudcruise prs approve 12 --workflow <workflow_id>                       # Not your own PR
cloudcruise prs merge 12 --workflow <workflow_id>
cloudcruise prs close 12 --workflow <workflow_id>
```

**Merging with conflicts.** When the branches changed the same item differently, `prs merge` exits 14 (`MERGE_CONFLICTS`); the stderr envelope's `message` names each conflict and `conflicts` lists their keys and summaries. Run `prs diff`: each conflict has a `key`, a one-line `summary` and the `base`/`source`/`target` values (`source` = the PR's branch, `target` = the branch it merges into). Then merge with the diff's `match_heads` and an answer for every conflict:

```bash
cloudcruise prs merge 12 --workflow <workflow_id> --match-heads <match_heads> \
  --resolve nodes:<node_id>=target --resolve max_retries:\$value=source   # source | target | delete (delete: not for single values)
cloudcruise prs merge 12 --workflow <workflow_id> --match-heads <match_heads> --take source       # Every remaining conflict
cloudcruise prs diff 12 --workflow <workflow_id> --resolutions-template r.json   # Edit custom values, then:
cloudcruise prs merge 12 --workflow <workflow_id> --match-heads <match_heads> --resolutions-file r.json
```

Precedence: `--resolutions-file`, then `--resolve`, then `--take`. A conflict with `depends_on` follows the side its driving conflict takes. With `--match-heads`, if a branch moved since the diff, nothing is merged and it exits 13 (`STALE_MERGE_PREVIEW`): diff again. Pass `--match-heads` on a conflict-free merge too, to merge exactly what you reviewed. A `--resolutions-file` value equal to one side counts as that side, so an unedited `--resolutions-template` file merges. Unknown or unanswered keys exit 2 before anything is sent.

**Resolve and test before merging (like merging main into your branch in git).** Open a pull request from the base into your branch, merge it with resolutions, test your branch, then merge your branch: it no longer conflicts.

```bash
cloudcruise prs create --workflow <workflow_id> --head main --base fix-login --title "Sync main"
cloudcruise prs diff <n> --workflow <workflow_id>
cloudcruise prs merge <n> --workflow <workflow_id> --match-heads <match_heads> --resolve ...
cloudcruise run start <workflow_id> --branch fix-login
cloudcruise prs create --workflow <workflow_id> --head fix-login && cloudcruise prs merge <m> --workflow <workflow_id>
```

**Review and permissions.** A branch's ruleset can block direct saves (403: use a PR) and require approvals before merging (403 `Needs N approval(s)`). You can't approve your own PR; an API key acts as the user who created it, so another member has to approve. `prs merge --admin` (skip required approvals) and `workflows update --bypass-protection` need a login whose workspace role is in the ruleset's bypass list; API keys can't use them. Errors carry a `hint` with the next step.

### Workflow Components

Components are reusable sub-workflows. A component can be pasted into many workflows; an `update` to the component propagates to every workflow that uses it (`--no-propagate` to skip). Component-data shape mirrors a workflow body (nodes/edges).

```bash
cloudcruise components list                                                    # List components in your workspace
cloudcruise components get <component_id>                                      # Get latest version with componentData
cloudcruise components get <component_id> --version-number 3                   # Specific historical version
cloudcruise components versions <component_id>                                 # Version history (newest first)
cloudcruise components usage <component_id>                                    # Workflows that use this component
cloudcruise components create --name "Login flow" --file c.json                # Create from JSON
cat data.json | cloudcruise components create --name "Login flow" --stdin      # Create from stdin
cloudcruise components rename <component_id> --name "New name"                 # Rename only
cloudcruise components update <component_id> --file c.json --version-note "…"  # New version + propagate to instances
cloudcruise components update <component_id> --stdin --no-propagate            # Update without propagating
cloudcruise components delete <component_id>                                   # Delete the component
```

**Edit pattern:** same fetch → edit → push as workflows. Read-only fields (`id`, `component_id`, `version_id`, `version_number`, `version_note`, `created_at`, `created_by`, `updated_at`, `workspace_id`) are stripped from the update body. The CLI accepts either the full get-response (auto-unwraps `componentData`/`component_data`) or just the `componentData` payload.

```bash
cloudcruise components get <component_id> > component.json
# Edit component.json
cloudcruise components update <component_id> --file component.json --version-note "Fixed login XPath"
```

**Before updating, check what propagation will affect.** `update` defaults to `propagate=true` and will create a new version of every workflow that embeds the component. Inspect first, then decide:

```bash
cloudcruise components usage <component_id>                                   # List affected workflows
cloudcruise components update <component_id> --file c.json --version-note "…" # Default: propagate
cloudcruise components update <component_id> --file c.json --no-propagate     # Component-only update
```

### Utils

```bash
cloudcruise utils uuid              # Generate a random UUID (for new node IDs)
cloudcruise utils uuid --count 5    # Generate multiple UUIDs
```

### Runs

```bash
cloudcruise run start <workflow_id>                          # Start run, returns { session_id } immediately (non-blocking)
cloudcruise run start <workflow_id> --debug                  # Start with debug snapshots on every node + network traffic recording
cloudcruise run start <workflow_id> --dry-run                # Run but skip final submit/save actions (nodes marked end_here_on_dry_run)
cloudcruise run start <workflow_id> --no-notifications       # Suppress workspace run notifications (Slack/email) for this run
cloudcruise run start <workflow_id> --input '{"key":"val"}'  # Start with input variables
cloudcruise run start <workflow_id> --version "^2.1.0"       # Run the highest tagged release matching a version or range
cloudcruise run start <workflow_id> --branch <branch_id>     # Run a branch's head (default: the default branch's head)
cloudcruise run get <session_id>                             # Get run status, errors, screenshots, output (poll until status is terminal, see Run statuses)
cloudcruise run list --workflow <id> --status execution.failed --since 7d --limit 50 # List runs with filters (--status takes a run status below)
cloudcruise run interrupt <session_id>                       # Stop a running session
cloudcruise run decision <session_id> # Show the pending Decision Required question (decision_id, fields, options, answer_by) in the agent.decision_requested shape (null when nothing is pending, including when a remembered answer was applied automatically, which sends agent.decision_applied)
cloudcruise run answer-decision <session_id> --decision-id <id> --value choice=keep # Answer a Decision Required question (ids from run decision or the agent.decision_requested webhook) (--value <field=value> repeatable, --text, --directive requeue|add_error_code|fail)
cloudcruise run respond <session_id> --data '{"approval_code":"123456"}' # Submit user interaction data to a run paused on a USER_INTERACTION node (--data/--file/--stdin)
cloudcruise run live-view <session_id>                       # Fresh viewer URL + one-time auth token to watch an active session (re-run to renew after the previous token is used)
cloudcruise run errors <workflow_id> --since 24h             # Error analytics (24h, 7d, 30m)
cloudcruise run snapshots <session_id> <node_id>             # Debug snapshots for a specific node
cloudcruise run network <session_id>                         # All recorded network traffic of a run (--include-noise, --output <path>)
```

**Run statuses.** `run get` and `run list` report `status` as one of these exact strings:

- Terminal: `execution.success`, `execution.failed`, `execution.stopped`
- Not terminal: `execution.queued`, `execution.requeued` (retrying, same `session_id`), `execution.start`, `execution.step`, `execution.paused` (workflow or credential paused; won't progress on its own, so stop polling and tell the user)

These differ from `builder status` values: runs never report `completed`, `error` or `interrupted`.

```bash
S=$(cloudcruise run start <workflow_id> --input '{}' | jq -er .session_id) || exit 1
for i in $(seq 1 60); do
  st=$(cloudcruise run get "$S" | jq -er .status) || break
  case "$st" in
    execution.success|execution.failed|execution.stopped) break ;;
    execution.paused) echo "run paused"; break ;;
  esac
  sleep 10
done
echo "$st"
```

### Snapshots

Tools for downloading debug snapshots, auto-generating XPath selectors, and validating them against the page DOM. **Use these instead of manually downloading and searching HTML.**

```bash
cloudcruise snapshot fetch <session_id> <node_id>                  # Download HTML, screenshots, metadata to ./snapshots/
cloudcruise snapshot fetch <session_id> <node_id> --output-dir dir # Custom output directory
cloudcruise snapshot fetch <session_id> <node_id> --html           # Download only the HTML snapshot
cloudcruise snapshot fetch <session_id> <node_id> --image          # Download only the screenshot(s)
cloudcruise snapshot suggest <session_id> <node_id>                # Auto-suggest unique XPaths for all interactive elements
cloudcruise snapshot suggest --file page.html                      # Suggest from a local HTML file
cloudcruise snapshot suggest <sid> <nid> --filter input,button     # Only suggest for specific tags
cloudcruise snapshot test "<xpath>" <session_id> <node_id>         # Test an XPath against a snapshot (check uniqueness)
cloudcruise snapshot test "<xpath>" --file page.html               # Test against a local HTML file
cloudcruise snapshot test "<xpath>" <sid> <nid> --count            # Only return match count
```

### Vault

```bash
cloudcruise vault list                                              # List all vault entries (summary)
cloudcruise vault list --full                                       # List with all fields
cloudcruise vault get --user-id <id> --domain <domain>              # Get entry (encrypted fields; field names/types only)
cloudcruise vault get --user-id <id> --domain <domain> --decrypt    # Get entry (plaintext, incl. field values and answers)
cloudcruise vault create --user-id <id> --domain <domain> \
  --user-name <name> --password <pass>                              # Create with auto-encrypt
cloudcruise vault create --user-id <id> --domain <domain> \
  --tfa-method AUTHENTICATOR --tfa-method EMAIL \
  --additional-fields-file fields.json \
  --security-questions-file questions.json                          # Several TFA methods, fields, questions
cloudcruise vault update --user-id <id> --domain <domain> \
  --password <new_pass>                                             # Update specific fields
cloudcruise vault create --stdin < payload.json                     # Create from pre-encrypted JSON
cloudcruise vault tfa-code --user-id <id> --domain <domain>         # Current 2FA code
cloudcruise vault tfa-code --user-id <id> --domain <domain> \
  --method EMAIL                                                    # Pick the method (entry with several methods)
cloudcruise vault tfa-code --user-id <id> --domain <domain> \
  --field "Backup OTP"                                              # Code of a Totp additional field
cloudcruise vault clear-state --user-id <id> --domain <domain>       # Clear browser state (force fresh login)
cloudcruise vault encrypt "plaintext"                               # Encrypt a value (no API call)
cloudcruise vault decrypt "ciphertext"                              # Decrypt a value (no API call)
echo "secret" | cloudcruise vault encrypt --stdin                   # Encrypt from stdin
```

### Error Codes

```bash
cloudcruise error-codes list                                        # List workspace error codes
cloudcruise error-codes list --workflow-id <id>                     # Only codes linked to a workflow
cloudcruise error-codes get <id>                                    # One code by id (exit 1 if not in the workspace)
cloudcruise error-codes create --code <NAME> --description "<text>" # Find-or-create by name; prints { id, created, ... }
cloudcruise error-codes create --code <NAME> --description "<text>" \
  --action pause                                                    # Actions: alert (default), cancel, pause, retry
cloudcruise error-codes update <id> --description "<text>"         # Change only the fields passed
cloudcruise error-codes create --file code.json                     # Or pass one JSON object (API field names), not both
```

`create` returns an existing code unchanged when the name is taken (`"created": false`); run `update` if its fields differ from what you need. The `retry` action only labels the error; nothing reruns the run.

When editing the DSL directly (outside the builder), create or look up codes here and put the returned `id` into `error_on_false_message`, `error_message` or `selector_error_message`. Names, placeholders and free text are rejected by `workflows update`. See the DSL skill's Error Codes section.

### Builder

Use the builder to create new workflows from scratch. For editing existing workflows, use `workflows get` + `workflows update` instead.

When the user asks to build a "workflow" / "cloudcruise workflow" / "cc workflow", **all web interaction goes through the builder** — do not browse the target site yourself with other tools. The builder agent handles all browsing; send it instructions and poll for results.

```bash
# ── Start a new workflow from scratch ──
# Always pass --open-builder when opening a session (builder start and builder edit both take it).
cloudcruise builder start --start-url "https://app.example.com" --name "Login flow" --open-builder
cloudcruise builder start --start-url "https://app.example.com" --open-builder \
  --vault-user-id "f47ac10b-58cc-4372-a567-0e02b2c3d479" --vault-domain "https://app.example.com" \
  --proxy country --proxy-value US

# ── Interact with the builder agent ──
cloudcruise builder send "Click the login button"              # Returns immediately
cloudcruise builder status                                     # Check status (hits /status; also the keepalive)
# status returns: { status: "processing"|"awaiting-human-input"|"agent-errored"|"completed"|"idle"|"ended", terminal, isProcessing, workflowId?, ... }
# and its exit code encodes that status so a driver can switch on $?:
#   0 proceed (completed/idle/ended) · 7 answer (awaiting-human-input) · 8 intervene (agent-errored) · 9 tick+re-arm (processing)

# ── Respond to human input requests ──
printf '%s' "123456" | cloudcruise builder respond --message-id "msg-456" --value-stdin
printf '%s' '{"email":"user@example.com","password":"s3cret"}' | cloudcruise builder respond --message-id "msg-456" --responses-stdin

# ── Inspect conversation state ──
cloudcruise builder conversations list     # List live builder conversations for the workspace (newest first)
cloudcruise builder workflow               # Get current workflow definition (nodes, edges)
cloudcruise builder messages               # Get conversation history (pagination envelope)
cloudcruise builder messages --limit 5     # Last 5 messages only
cloudcruise builder messages --limit 20 --offset 20            # Page backward from the end
cloudcruise builder messages --limit 20 --offset 0 --no-tail   # Page forward from the start

# ── Read an ended conversation's transcript (archive, not the live log) ──
# `messages` exits 4 once a conversation is gone; the archive still answers.
# `chat: null` means no transcript (never saved, or retention expired) — exit is still 0.
cloudcruise builder conversations get "conv-abc123"              # Full transcript
cloudcruise builder conversations get "conv-abc123" --limit 20   # Last 20 messages only
cloudcruise builder conversations get "conv-abc123" --limit 0    # Metadata only, no transcript
cloudcruise builder conversations get "conv-abc123" --limit 0 --output ./conv.json   # Full response to file, metadata to stdout

# ── Target a specific conversation (concurrent/multi-conversation) ──
cloudcruise builder status --conversation "conv-abc123"
CLOUDCRUISE_CONVERSATION="conv-abc123" cloudcruise builder send "Click login"

# ── Conversation lifecycle ──
cloudcruise builder save        # Persist workflow to the database
cloudcruise builder interrupt   # Stop the agent's current processing
cloudcruise builder end         # End the conversation and clean up
```

**Credentials for builder sessions.** A workflow with a non-empty `vault_schema` needs its credential supplied, or login fails at the password step. Both `builder start` and `builder edit` take `--vault-user-id <permissioned_user_id>` + `--vault-domain <domain>` (both-or-neither) for a single credential; edit matches the domain to the workflow's `vault_schema` alias. For a multi-credential workflow, bind extra aliases via `builder edit --input '{"<alias>":"<permissioned_user_id>"}'`. `builder edit` also takes `--use-example-inputs` to pre-fill non-credential inputs from the workflow's `input_schema` examples (server-side).

**Editing a branch or version.** `builder edit --workflow <workflow_id> --branch fix-login` edits that branch's latest version, and the session's saves go to that branch. `--version 2.1.0` (or a range) starts from that version instead. Without either, the default branch is edited. A protected branch rejects the builder's saves: create a branch first (`branches create`), edit it, then open a pull request.

**Conversation resolution is server-driven** — there is no local session file. `start` prints the `conversationId`; the server roster (`builder conversations list`) is the source of truth for what's live. When exactly one conversation is live in your workspace, every other builder command resolves to it automatically. When more than one is live, commands error with exit 5 (ambiguous) and you must pass `--conversation <id>` (or set `CLOUDCRUISE_CONVERSATION`). With none live, they exit 2. `--conversation` overrides everything, including workspace scope. Each command echoes `conversation <id> (via flag|env|roster)` to stderr so you can tell how it resolved.

**Important guidelines:**

- `builder send` returns immediately — use `builder status` to check for completion
- Break complex tasks into small steps (e.g. "log in", then "navigate to X", then "search for Y")
- Poll `builder status` in a loop — if it returns `processing`, wait a few seconds and call it again. `status` also keeps the session alive (it hits `/status`), so keep polling rather than letting an idle session get reaped.
- **`awaiting-human-input` is how the builder asks for information it needs** (e.g. email, password, 2FA code). When you see it, relay the question to the user, then pass their answer back with `builder respond`. The agent may request multiple inputs at once — check `humanInput.fields` for the full list and pipe a JSON object keyed by field name to `--responses-stdin`. Never pre-emptively browse the site or ask the user for form values — let the builder discover what it needs.
- For a human-input field with `type: "error"`, respond with a structured JSON object, never a primitive such as `"accepted"`. To accept the proposed code, send `{"kind":"accept_suggestion"}`. To choose another workspace code, send `{"kind":"existing","error_code_id":"<id>"}`. To confirm removal, send `{"kind":"remove_confirmed"}`. Use `--value-stdin` for a single field or place the object under the field's name with `--responses-stdin` for multiple fields.
- Treat `terminal: true` as "this turn has settled; stop polling," then branch on `status`: respond to `awaiting-human-input`, proceed after `completed`, intervene after `agent-errored`, or stop after `ended`. Only fall back to direct DSL editing after `completed`, `agent-errored`, or `ended` — not while input is pending.
- **Wait for the turn to settle before sending the next message** — sending while the agent is processing interrupts the current turn, and a busy send returns HTTP 409 `SESSION_BUSY` (exit code 6)

**Writing effective builder messages:**

- **Describe the goal, not the clicks** — say "Download all EOBs from the claims table" not "Click the first download link in the third column". The builder sees the page and will figure out selectors, logic, and interaction details on its own.
- **Don't tell the builder how to build** — never specify execution types ("use STATIC"), selector strategies ("use an XPath with @id"), or node structure ("add a LOOP node"). The builder has access to the page DOM and knows the workflow DSL; let it make implementation decisions.
- **Reference credentials naturally** — "Log in using the vault credentials" is enough. The builder knows to use vault credential templates.

**Status codes** (`builder status` — exit code in parens): `completed` (0) → proceed to next step. `awaiting-human-input` (7) → respond then re-check. `agent-errored` (8) → inspect messages, send corrective instruction. `processing` (9) → wait and re-check. `idle` (0) → no pending work. `ended` (0) → session is over. `terminal: true` means the current turn has settled and needs no more polling (`completed`, `awaiting-human-input`, `agent-errored`, or `ended`); it does not mean the conversation has ended. A driver can branch on the exit code alone without parsing stdout — note that a non-zero `status` exit (7/8/9) is the *state*, not a command failure.

**409 exit codes:** `builder send` on a busy session → `SESSION_BUSY` (exit 6). `builder respond` after the input was already answered → `ALREADY_ANSWERED` (exit 7). `workflows update` on a stale body → `WORKFLOW_VERSION_CONFLICT` (exit 13). `prs merge` with a branch that moved since `prs diff` → `STALE_MERGE_PREVIEW` (exit 13); with unanswered conflicts → `MERGE_CONFLICTS` (exit 14). The code is printed to stderr.

`builder screenshot`/`html` with no attached browser → `NO_BROWSER_ATTACHED` (exit 10); provision/warm a browser, then retry.

A run refused because the workspace is out of browser hours → HTTP 402 `USAGE_LIMIT_EXCEEDED` (exit 12). Do not retry and do not re-authenticate: relay the message to the user. The stderr envelope's `reason` says what unblocks it: `NO_PAYMENT_METHOD` (add a card), `PAYMENT_FAILED` (update the payment method), `USAGE_CAP_REACHED` (the organization's own cap), `INCLUDED_HOURS_EXCEEDED` (change plan).

**Send + status-poll pattern:**

```bash
cloudcruise builder send "Log me in"
# → {"conversationId":"conv-abc123","accepted":true}

# Poll until the current turn settles (terminal: true), then branch on status
cloudcruise builder status
# → {"status":"processing","terminal":false,"isProcessing":true}

cloudcruise builder status
# → {"status":"completed","terminal":true,"isProcessing":false,"workflowId":"wf_..."}

# If agent needs input (single value):
# → {"status":"awaiting-human-input","terminal":true,"conversationId":"conv-abc123","humanInput":{"messageId":"m1","prompt":"What's the 2FA code?","fields":[{"name":"code","type":"text"}]}}
printf '%s' "123456" | cloudcruise builder respond --message-id m1 --value-stdin
cloudcruise builder status

# If agent needs multiple inputs at once:
# → {"status":"awaiting-human-input","terminal":true,"humanInput":{"messageId":"m1","prompt":"...","fields":[{"name":"npi",...},{"name":"last_name",...}]}}
printf '%s' '{"npi":"1234567890","last_name":"Ziegler"}' | cloudcruise builder respond --message-id m1 --responses-stdin
cloudcruise builder status

# If agent needs credentials (type: "auth"):
# → {"status":"awaiting-human-input","terminal":true,"humanInput":{"messageId":"m1","prompt":"...","fields":[{"name":"Portal Credentials","type":"auth",...}]}}
# 1. Look up the vault entry to get the domain:
cloudcruise vault list
# 2. Respond with { permissioned_user_id, domain }:
printf '%s' '{"Portal Credentials":{"permissioned_user_id":"d2b9d80e-...","domain":"https://example.com"}}' | cloudcruise builder respond --message-id m1 --responses-stdin

# If the agent proposes an error code (type: "error", rowType: "set"):
# → {"humanInput":{"messageId":"m2","fields":[{"name":"Error code","type":"error","rowType":"set","suggestedCode":"CLAIM_NOT_FOUND",...}]}}
printf '%s' '{"kind":"accept_suggestion"}' | cloudcruise builder respond --message-id m2 --value-stdin

# To select an existing error code instead:
printf '%s' '{"kind":"existing","error_code_id":"3f2b9c1e-..."}' | cloudcruise builder respond --message-id m2 --value-stdin

# To confirm a proposed removal (type: "error", rowType: "remove"):
printf '%s' '{"kind":"remove_confirmed"}' | cloudcruise builder respond --message-id m3 --value-stdin
cloudcruise builder status
```

**Driving one turn from a script.** Branch on the `status` exit code; don't parse
stdout to decide whether a turn is over. Pass the message via `"$(cat file)"` —
composing a long message inline invites the shell to eat it (backticks inside a
double-quoted argument get command-substituted, truncating the message silently).

```bash
CID=conv-abc123
cloudcruise builder send --conversation "$CID" "$(cat task.txt)"   # returns immediately
while :; do
  cloudcruise builder status --conversation "$CID" >/dev/null 2>&1; rc=$?
  case $rc in
    0) break ;;                      # completed / idle / ended — turn is over
    9) sleep 15 ;;                   # processing — re-check (this also keeps the session alive)
    7) echo "needs input";  break ;; # awaiting-human-input — relay, then `builder respond`
    8) echo "agent errored"; break ;;# inspect `builder messages`, send a correction
    *) echo "status exit $rc"; break ;;
  esac
done
```

**Reading the agent's report.** `builder messages` records carry
`{ role, type, status, text }`. The report you want is the **last record with
`role: "assistant"` and non-empty `text`**; `role: "tool"` rows have no `text`, and
`type: "reasoning"` rows are the agent thinking rather than reporting. Use `--limit`
rather than pulling the whole history — a long build accumulates hundreds of records.

**Opening the builder UI.** `builder open` opens the current conversation. The app
URL is inferred from the API base URL and can be overridden with `--app-url`
(`--app-url http://localhost:3000` against a local API). The page is
`<app-url>/workflows/builder/<conversationId>`.

**Full example: Login → Navigate → Search**

```bash
# Start
cloudcruise builder start --start-url "https://app.example.com" --name "Search workflow" --open-builder \
  --vault-user-id "f47ac10b-58cc-4372-a567-0e02b2c3d479" --vault-domain "https://app.example.com"

# Step 1: Login
cloudcruise builder send "Log in using the vault credentials"
cloudcruise builder status   # repeat until "completed"

# Step 2: Navigate
cloudcruise builder send "Click on Reports in the nav bar, then select Monthly Summary"
cloudcruise builder status   # repeat until "completed"

# Step 3: Search and extract
cloudcruise builder send "Search for order 12345 and extract the status"
cloudcruise builder status   # repeat until "completed"

# Save and clean up
cloudcruise builder save
cloudcruise builder end
```

## Workflow DSL Reference

See the **cloudcruise-workflow-dsl** skill for the complete workflow DSL reference: all node types, parameters, edge structure, variable system, execution types, XPath best practices, data model schema extensions, and error codes. Read it before writing, editing, or debugging any workflow node.

## Error-Fix-Verify Loop

Pattern for diagnosing and fixing workflow failures:

```bash
# 1. Diagnose
cloudcruise run get <session_id>
cloudcruise workflows get <workflow_id> > workflow.json

# 2. Reproduce with snapshots (failed runs often lack them)
#    run start returns { session_id } immediately; poll run get until the status is terminal
cloudcruise run start <workflow_id> --input '{}' --debug
cloudcruise run get <new_session_id>

# 3. Inspect the failed node (see Debug Snapshots for timing details)
cloudcruise snapshot fetch <new_session_id> <failed_node_id>
cloudcruise snapshot suggest <new_session_id> <failed_node_id>
cloudcruise snapshot test "<new_xpath>" <new_session_id> <failed_node_id>

# 4. Fix and push
cloudcruise workflows update <workflow_id> --file workflow.json --version-note "Fixed XPath for submit button"

# 5. Verify (run start returns { session_id }; poll run get until terminal)
cloudcruise run start <workflow_id> --input '{}'
cloudcruise run get <new_session_id>
```

## Debug Snapshots

After a `--debug` run, use `snapshot` commands to inspect pages and generate XPaths. Use the `node_id` from `run get` errors or from the `run get` node results.

```bash
cloudcruise snapshot fetch <session_id> <node_id>
cloudcruise snapshot suggest <session_id> <node_id>
cloudcruise snapshot test "//input[@name='email']" <session_id> <node_id>
```

**`snapshot suggest`** returns JSON with each element's tag, suggested XPath, uniqueness (`match_count === 1`), alternatives, meaningful attributes, and visible text. Prioritizes `@name`, `@id`, `@data-qa`/`@data-testid`, `@aria-label`, `@placeholder`, and visible text. Filters out generated IDs and non-semantic classes.

**`snapshot test`** confirms an XPath matches exactly one element (`unique: true`). Always test before pushing a workflow update.

**Also view the screenshot** (saved by `snapshot fetch`) to check visibility, popups, or unexpected pages.

If `snapshot fetch` reports no HTML, the run was not `--debug`. Re-run with `--debug`.

**Network traffic:** a `--debug` run also records the run's network traffic (on workers with network capture). `run network <session_id>` returns all of it in one JSON document, oldest first: `{ session_id, complete, omitted_bodies, events[] }`. Each event has `retry`, `method`, `status`, `url`, `category`, `content_type`, headers, bodies and `*_truncated`. Filter locally:

```bash
cloudcruise run network <session_id> | jq '.events[] | select(.url | test("/api/")) | {method, status, url}'
```

Noise (preflights, analytics, assets) is filtered unless `--include-noise`. `complete: false` means the run is still going. Credentials are redacted. One call returns at most 100 MB of bodies; `omitted_bodies` counts those returned as `null`.

**Snapshot timing:** Snapshots capture page state _when a node starts executing_ (i.e., post-action state of the _previous_ node). To see what appeared after a node's action, inspect the _next_ node's snapshot. On success, the END node shows final state. On failure, the END node has no snapshot — use the _failed_ node's snapshot instead.

## Key Details

- `run get` returns: status, data (the output), errors (with node_id, error_code, llm_error_category, llm_error_description), screenshot_urls (with node_id)
- `run start` returns `{ session_id }` immediately and does not block or stream. Poll `run get <session_id>` until `status` is `execution.success`, `execution.failed` or `execution.stopped` (see Run statuses).
- `run list --since` accepts duration strings: `24h`, `7d`, `30m`; without `--since`, the API defaults to the last 24 hours
- `run errors --since` accepts duration strings: `24h`, `7d`, `30m`
- `workflows update` requires: nodes, edges, name, input_schema, output_schema, max_retries. Keep all other fields from the GET response (e.g., description, enable_xpath_recovery, proxy_setting, version_id).
- `workflows update` exits 13 (`WORKFLOW_VERSION_CONFLICT`) when the body's `version_id` is not the latest, including after your own previous update: keep `update`'s output as the working copy, re-fetch and re-apply, or pass `--force`.
- All commands accept `--api-key`, `--base-url`, and `--encryption-key` overrides
- Auth resolution: `--api-key` flag > `CLOUDCRUISE_API_KEY` env > `~/.cloudcruise/config.json`
- Encryption key resolution: `--encryption-key` flag > `CLOUDCRUISE_ENCRYPTION_KEY` env > profile config

## Working with Vault Credentials

The vault stores encrypted credentials to be used in workflows. Encrypted client-side: `user_name`, `password`, `tfa_secret`, every additional field `value`, and every security question `question` and `answer`. The CLI handles encryption/decryption automatically.

**Encryption key setup** -- required for vault create, update, get --decrypt, encrypt, and decrypt. `cloudcruise login` does NOT fetch the key automatically (it is a client-side key the server never hands out); you must supply it yourself:

```bash
# Recommended: store on a profile via stdin (kept in the OS keychain)
printf '%s' "<64-hex-key>" | cloudcruise login --encryption-key-stdin

# Or set it per-session via environment variable
export CLOUDCRUISE_ENCRYPTION_KEY="<64-hex-key>"
```

The encryption key is a 64-character hex string (256-bit AES key) from [workspace settings](https://app.cloudcruise.com/settings/encryption-keys).

Raw `--encryption-key <hex>` and `--api-key <key>` flags are **rejected by default** to keep secrets out of shell history and `ps` output. Use `--encryption-key-stdin` (or the env var) instead; set `CLOUDCRUISE_ALLOW_ARG_SECRETS=true` only for local testing.

**Two paths for create/update:**

- **Flag-driven** (plaintext flags, CLI encrypts automatically):
  `vault create --user-id X --domain Y --user-name "user" --password "pass"`
- **JSON payload** (`--file`/`--stdin`, assumed pre-encrypted):
  Use `vault encrypt` to prepare individual fields, then assemble the JSON and pipe to `vault create --stdin`.

**IMPORTANT:** Always use `vault encrypt` without `--raw` for pre-encrypted payloads. The `--raw` flag skips JSON serialization and produces ciphertext the vault API will reject (401).

**Important details:**

- The API field is `user_name` (not `username`). Use the `--user-name` flag.
- Vault entries are looked up by `--user-id` + `--domain`, not by UUID.
- `vault list` returns summary fields only. Use `--full` for all fields (additional fields and security questions as in `vault get`).
- `vault get` returns encrypted fields by default. Add `--decrypt` for plaintext.
- The `--domain` must be a valid URL. `localhost` domains are rejected -- use `http://127.0.0.1:<port>` instead.
- The vault_schema `domain` and the vault entry `domain` must match exactly.
- Session/persistence fields (`cookies`, `local_storage`, `persist_*`, concurrency, expiry) have no dedicated flags -- use `--file`/`--stdin` with full JSON. `vault get` output lacks field values and answers: drop `additional_fields` and `security_questions` from it before sending, or the API answers 400.
- Secret flags (`--password`, `--user-name`, `--tfa-secret`) are visible in `ps` output. Use `--stdin` or `--file` for sensitive values.

**TFA methods.** Repeat `--tfa-method` for several methods: `AUTHENTICATOR`, `EMAIL`, `MAGIC_LINK`, `SMS`. The entry stores them as `tfa_methods`; on update the given methods replace the stored set, and `--no-tfa-method` removes them all. `AUTHENTICATOR` uses the built-in `--tfa-secret`.

**Additional fields** are typed values on an entry, set with `--additional-fields-file <path>` or `--additional-fields-stdin`: a plaintext JSON array the CLI encrypts value by value.

```json
[
  { "name": "Member ID", "type": "Text", "value": "M-123" },
  { "name": "Home", "type": "Address", "value": { "street": "1 Main St", "city": "Springfield", "state": "IL", "zip": "62701", "country": "US" } },
  { "name": "Backup OTP", "type": "Totp", "value": "JBSWY3DPEHPK3PXP" }
]
```

- Types: `Text`, `Email`, `Url`, `Phone`, `Date` (`YYYY-MM-DD`), `MonthYear` (`MM/YYYY`), `Address` (object), `Concealed`, `Totp` (base32 seed or `otpauth://` URI).
- Limits: 50 fields, 100-char names unique per entry, 2 KB per value. The API checks formats and limits.
- Workflows read them as `{{context.inputs.<ALIAS>.FIELDS.<name>}}`. A `Totp` field is used as `tfa_field` of an `AUTHENTICATOR` TFA node instead.

**Security questions** are question/answer pairs that a `SECURITY_QUESTION` TFA node answers at run time. Set them with `--security-questions-file <path>` or `--security-questions-stdin`: `[{"question": "What is your mother's maiden name?", "answer": "Smith"}]`. Order is kept. Limits: 20 questions, 500 characters per question, 1 KB per answer, questions unique per entry. Answers are never workflow variables.

- On update, each list replaces the stored list; `[]` clears it (no encryption key needed); omitting the flag keeps it.
- Only one flag per command can read stdin.
- Entries bound to a secret provider take fields and questions from the provider item; the API rejects a non-empty list for them.
- `vault get` shows fields as `{name, type}` and questions as their ciphertext, without answers. `--decrypt` shows values, questions and answers.

**2FA codes.** `vault tfa-code` prints the entry's current code: `{type, code, expires_in_seconds}` for `AUTHENTICATOR`, `{type, code, received_at}` for the latest `EMAIL` code (404 if none arrived recently). An entry with several methods needs `--method` (400 otherwise). `--field <name>` generates the code of a `Totp` additional field. `SMS` and `MAGIC_LINK` codes cannot be read (409).

## Credential Setup for Workflows

Pattern for creating vault credentials and wiring them into a workflow:

```bash
# 1. Create a credential
cloudcruise vault create \
  --user-id "f47ac10b-58cc-4372-a567-0e02b2c3d479" \
  --domain "https://app.example.com" \
  --user-name "user@example.com" \
  --password "s3cret"

# 2. Wire the credential into the workflow's vault_schema and run_input_variables
#    vault_schema maps an alias to a domain:
#      { "USER": { "type": "credential", "domain": "app.example.com" } }
#    run_input_variables maps the alias to a permissioned_user_id:
#      { "USER": "f47ac10b-58cc-4372-a567-0e02b2c3d479" }

# 3. Run the workflow with the credential (returns { session_id }; poll run get for completion)
cloudcruise run start <workflow_id> --input '{"USER": "f47ac10b-58cc-4372-a567-0e02b2c3d479"}'
```

**Workflow node template syntax for vault credentials:**

Nodes reference vault credentials via `{{context.inputs.ALIAS.FIELD}}` where `ALIAS` is the vault_schema key and `FIELD` is `USER_NAME`, `PASSWORD`, or `TFA_SECRET` (uppercase). Additional fields: `{{context.inputs.ALIAS.FIELDS.<name>}}`.

Example INPUT_TEXT node using vault credentials:

```json
{
  "id": "<uuid>",
  "name": "Enter username",
  "action": "INPUT_TEXT",
  "parameters": {
    "selector": "//input[@name='email']",
    "text": "{{context.inputs.USER.USER_NAME}}",
    "execution": "STATIC"
  }
}
```

**Switching credentials** is as simple as changing the `--input` value to a different `permissioned_user_id`:

```bash
cloudcruise run start <workflow_id> --input '{"USER": "b91a8def-12c4-4a67-8e3f-5c6d7e8f9a0b"}'
```
