Skip to content

CLI usage

CLI usage

FlowDelta’s CLI is the flow-delta binary, published in @syntax-syllogism/flow-delta. In a source checkout, the entry point is src/cli.ts.

Terminal window
npx @syntax-syllogism/flow-delta <options>

Once the package is installed (npm install or npm install -g), the flow-delta binary is on your PATH or in node_modules/.bin, so npx flow-delta <options> works too. A bare npx flow-delta with nothing installed fails, because there’s no unscoped flow-delta package on npm.

From a source checkout, run the TypeScript entry point through the local runner: node --import tsx src/cli.ts <options> or npx --no-install tsx src/cli.ts <options>.

The CLI has four modes. They’re mutually exclusive, and the flags you pass select one.

Choose one input mode per invocation. FlowDelta rejects flags from other modes before reading inputs or creating the output directory. In Git mode, --changed-only belongs to comparisons, and --at belongs to snapshots.

As-built mode: render one current Flow

As-built mode makes a self-contained snapshot of a single Flow. There’s no before and after, so the artifact uses element-type colors, an element inventory, read-only property panels, and a provenance footer.

Terminal window
# Local file
npx @syntax-syllogism/flow-delta --as-built --file path/to/My_Flow.flow-meta.xml
# Latest Active (or highest) org version, or a named version
npx @syntax-syllogism/flow-delta --as-built --org my-org --flow My_Flow
npx @syntax-syllogism/flow-delta --as-built --org my-org --flow My_Flow --flow-version 3
# One git ref; --path may be a literal path or supported glob
npx @syntax-syllogism/flow-delta --as-built --repo /path/to/repo --at v1.2 --path 'force-app/**/*.flow-meta.xml'

Give exactly one of the three input forms. The Git pattern is relative to the repository root. A snapshot with no matches fails. --json writes the machine-readable snapshot as <stem>.diff.json, and --out picks the output directory. As-built mode can’t be combined with diff version flags (--old, --new, --from, --to, --from-version, --to-version) or with --interactive, --changed-only, or --keep.

Explain a Flow

Add --format md to an as-built command to print an execution outline on stdout. The outline starts with the trigger and indents decision outcomes, loop bodies, wait events, scheduled paths, and fault paths. A → go to line refers to an element already listed, which also covers cycles. Elements the trigger can’t reach are listed at the end under Unreachable elements:. A Flow with no start element prints (no start element) and then lists its elements flat.

The outline is for reading. --format json still prints the compact snapshot of nodes and edges, so agents that need control flow should walk edges there.

Terminal window
flow-delta --as-built --file My_Flow.flow-meta.xml --format md
flow-delta --as-built --org my-org --flow My_Flow --flow-version 3 --format md
flow-delta --as-built --repo /path/to/repo --at v1.2 --path 'force-app/**/*.flow-meta.xml' --format md
## Account Before Save (Record-Triggered Flow, v3, Active)
Trigger: Account · Before save · Create/Update
Entry conditions: 1 filter
1. Check Industry — Decision: 1 outcome + default
If Technology ($Record.Industry EqualTo "Technology"):
2. Set Rating — Assignment: $Record.Rating = "Hot"
Otherwise (Default Outcome):
End

Git globs print one outline per matching Flow, separated by blank lines. Use --out or --json to also write snapshot artifacts.

File mode: compare two local files

Terminal window
npx @syntax-syllogism/flow-delta \
--old path/to/before.flow-meta.xml \
--new path/to/after.flow-meta.xml \
--out ./flow-delta-out \
--json
  • --old and --new are the two .flow-meta.xml files. Both are required.

Git mode: compare two refs

Terminal window
npx @syntax-syllogism/flow-delta \
--repo /path/to/sfdx-repo \
--from <base-ref> --to <head-ref> \
--path 'force-app/**/*.flow-meta.xml' \
--out ./flow-delta-out \
--json
  • --repo is the repository to read.
  • --from and --to are the two git refs: SHAs, branches, or tags.
  • --path is a repository-root-relative path or glob (* within a segment, ** across segments, ?), even when --repo points to a subdirectory. Full-tree discovery unions the paths from both refs.
  • --changed-only uses Git’s changed path list with rename detection disabled. Renames appear as removal at the old path and addition at the new path.
  • If the pattern matches neither tree, the CLI warns on stderr and succeeds with an empty report. A pattern that matches only unchanged files succeeds quietly in changed-only mode.

--repo, --from, --to, and --path are all required. --changed-only is the only optional one.

Both products share the metadata and Git input boundary described in metadata-io.md. It normalizes pattern separators, reads Git paths without unquoting or trimming, and returns distinct paths in a stable order. Flag validation and default patterns stay in each CLI.

Org mode: compare two versions from Salesforce

Org mode reuses the Salesforce CLI’s authentication. The alias or username must start with a letter, digit, or underscore and can also contain internal spaces, periods, hyphens, plus signs, and @. Both Salesforce runners reject unsupported Windows shell characters before invoking a command shim. It retrieves two historical Flow versions as metadata XML and sends them through the same pipeline as file mode:

Terminal window
npx @syntax-syllogism/flow-delta \
--org my-org \
--flow My_Flow \
--from-version 1 --to-version 2 \
--out ./flow-delta-out \
--json
  • --org is a Salesforce org alias or username already authenticated in sf.
  • --flow is the Flow developer name. Leave it out to pick from an interactive list.
  • --from-version and --to-version are the two version numbers. Leave either out to use the interactive picker, which defaults to the latest two versions.
  • --interactive always shows the picker.
  • --keep keeps the temporary Salesforce project for troubleshooting. Otherwise it’s deleted after the diff.

The picker needs a TTY. In CI or any other non-interactive setting, pass --flow, --from-version, and --to-version.

FlowDelta uses sfd when available for faster org queries and retrieves, including as-built snapshots. Sign in first with sf org login web. Set FLOW_DELTA_SF_CLI to one of these values:

  • auto (default) tries sfd first and retries a failed query or retrieve with sf.
  • sf always uses the Salesforce CLI.
  • sfd always uses sfd and reports its errors directly.

Values are case-sensitive. Invalid values warn once and use auto. Set FLOW_DELTA_DEBUG=1 to see fallback reasons on stderr. Fallback is silent by default. Errors cover a missing CLI, an unauthenticated org, an unknown Flow, an unavailable version, and a legacy Flow without a modern <start> element.

On Windows, FlowDelta uses the sfd.cmd and sf.cmd shims. The shell that launches Node needs the CLI directories on its PATH. If PowerShell finds sf but Git Bash doesn’t, add the Salesforce CLI directory to Git Bash’s PATH, or run the command from PowerShell.

Common flags

FlagDefaultMeaning
--out <dir>./flow-delta-outOutput directory. Created if it’s missing.
--jsonoffAlso write <flow>.diff.json next to the HTML.

Help and version

--help (or -h) prints the usage text. --version prints the binary name and the package version, then exits:

Terminal window
npx flow-delta --version # flow-delta 0.11.0

All six binaries in the package support both flags: flow-delta, flexipage-delta, flow-delta-gitlab, flow-delta-github, flexipage-delta-gitlab, and flexipage-delta-github. --version is checked before any other argument is parsed, so it doesn’t read inputs or write output, even when other flags are present. An unknown option exits with code 1 and an error message instead of a stack trace.

Output

For each flow, the output directory gets:

Output stems come from artifactStem in src/util/file-name.ts. FlowDelta uses the new XML file’s name in file mode, the Flow API name (developerName) in org mode, and the metadata file’s name in Git mode. An as-built file uses its own name, and as-built org output uses the Flow API name. The stem drops the .flow-meta.xml suffix. A short, deterministic hash is appended when a name needs sanitizing, ends in a dot, or comes from a nested Git path. Git mode checks for stem collisions and fails the run with Artifact filename collision. FlexiPageDelta uses the same rules, with .flexipage-meta.xml as the suffix.

  • <stem>.html, the self-contained interactive diff or snapshot. Open it in a browser.
  • <stem>.diff.json, the machine-readable FlowDiff, only with --json. As-built output has mode: "snapshot" and present nodes and edges.

The CLI prints one summary line per flow:

My_Flow: nodes 1 added, 0 deleted, 1 modified; edges 2 added, 0 deleted

As-built mode prints an inventory instead:

My_Flow: 12 elements, 11 connectors

When curated flow-root attributes changed, the line gets a suffix:

My_Flow: nodes 0 added, 0 deleted, 0 modified; edges 0 added, 0 deleted; flow attributes: 1 changed (status)

After the run, the CLI prints the absolute output directory, for example Artifacts written to C:\path\to\flow-delta-out.

Failures don’t spread. In git mode, if one flow fails to parse, the CLI logs an error and sets a non-zero exit code, but keeps going with the remaining flows.

Output for scripts and agents (--format)

--format md prints a Markdown change report for comparisons and an execution outline for as-built snapshots. --format json prints a single JSON document using the flow-delta/compact@1 schema, including when Git mode finds multiple flows or no changes. Both formats work with file, Git, org, and as-built inputs. As-built JSON includes every element and connector in the snapshot. Use Markdown for reading and the versioned JSON schema for parsing.

Terminal window
flow-delta --old before.flow-meta.xml --new after.flow-meta.xml --format md
flow-delta --org dev --flow My_Flow --from-version 1 --to-version 2 --format json

Stdout contains only the report. Flow summaries, progress, and errors go to stderr. Formatted org diffs require --flow, --from-version, and --to-version. --format cannot be combined with --interactive.

With --format, pass --out to also write HTML or --json to write HTML and <stem>.diff.json. --json uses ./flow-delta-out when --out is omitted. The file still uses the existing FlowDiff schema that CI reporters read.

Render fixture artifacts

The fixture renderer accepts flow, flexipage, or all:

Terminal window
npm run render:fixtures -- flow # → flow-delta-out/fixtures/<case>.html
npm run render:fixtures -- flexipage # → flexipage-delta-out/fixtures/<case>.html
npm run render:fixtures # both product fixture sets

all is the default. It writes Flow artifacts to flow-delta-out/fixtures/ and FlexiPage artifacts to flexipage-delta-out/fixtures/. You can put a custom output directory after the selector. In all mode, it gets flow/ and flexipage/ subdirectories. The older bin/render-fixtures.sh OUT_DIR form still works, for Flow only.

bin/render-fixtures.sh renders every selected fixture pair and names each artifact after its fixture directory, so two fixtures with the same internal metadata name never collide. See testing.md.

For GitLab MR reporting and artifact links, see ci.md.

FlexiPageDelta CLI

The same package ships FlexiPageDelta as the flexipage-delta binary. It compares .flexipage-meta.xml files and writes an offline outline artifact, plus a template-aware wireframe when geometry is available. The default output directory is ./flexipage-delta-out:

Terminal window
npx flexipage-delta \
--old path/to/before.flexipage-meta.xml \
--new path/to/after.flexipage-meta.xml \
--out ./flexipage-delta-out \
--json

Git mode takes the same --repo, --from, --to, --path, --changed-only, --out, and --json flags. Without --path, it defaults to force-app/**/*.flexipage-meta.xml:

Terminal window
npx flexipage-delta \
--repo /path/to/sfdx-repo \
--from <base-ref> --to <head-ref> \
--changed-only \
--json

The output is <stem>.html, plus <stem>.diff.json with JSON output on. Stems follow the output naming rules. The summary counts components, regions, region metadata changes, and page attributes. See flexipage.md for the identity and canonicalization rules and how the outline behaves.