Skip to content

CLI commands, options and exit codes

The CLI validates and inspects graphs, exports representations, manages template files, prepares migrations and reports analysis results. This reference identifies the executable and argument grammar for each operation so your application’s scripts can distinguish a result from a usage or processing failure. Command-line workflows combines these commands into tasks.

Installation context Invocation
Application with the Composer package installed vendor/bin/execkernel <command>
Core source checkout with its Composer dependencies installed php bin/execkernel <command>
Auxiliary tools in that checkout php bin/ek-debug condition …; php bin/ek-validate-graph …

Composer declares only bin/execkernel as a package binary. The two auxiliary scripts have their own options and exit codes. A missing Composer autoloader exits with 5 before a command runs.

The main CLI accepts --help or -h alone, or directly after a recognized command/subcommand name; it prints help and exits 0. Calling it without a command exits 4. There is no general --version flag. The version field in JSON command envelopes is the CLI contract constant 1.0.0, not the package release number.

Options take --name=value or --name value. Boolean options accept a bare flag or 1/true/yes/on and 0/false/no/off, case-insensitively. Unknown and repeated options fail; only graph commands allow repeated --allow-custom-handler. The graph parser also accepts -- before a literal positional input. Scaffold, migration, optimizer and benchmark options do not accept arbitrary positional arguments.

In the synopsis tables, uppercase names such as INPUT and PLAN are placeholders for your paths or values.

Command after execkernel Result
validate INPUT [--json] Strict graph validation; summary and warnings.
lint INPUT [--json] Graph validation plus lint findings.
explain INPUT [--lang=LANG] [--json] Nodes, transitions and display text for the resolved language.
graph stats INPUT [--json] Graph identity, version/language fields and structural counts.
graph export INPUT --format=FORMAT [--out=PATH] Encoded graph representation on stdout or in a new file.

These commands accept a graph file, inline JSON/YAML, or - for stdin. Existing .dsl/.flowdsl files use the FlowDSL importer; .json, .yaml and .yml select their corresponding parsers. Other input is detected as JSON when its first non-whitespace character is { or [, otherwise YAML. An inline FlowDSL document is not selected by this detection.

Option Commands Default and restriction
--json validate, lint, explain, graph stats false; emits the command envelope. Not accepted by graph export.
--lang=LANG explain; Mermaid exports Omitted: use available/default-language resolution. An empty language is rejected by explain.
--allow-custom-handler=NAME All five commands Repeatable allowlist entry; empty names fail.
--allowed-custom-handlers=A,B All five commands Comma-separated entries, merged with repeated entries and deduplicated. Omission passes null; an explicitly empty list passes [].
--format=FORMAT graph export Required: json, yaml/yml, mermaid or mermaid-rich.
--out=PATH graph export Omitted: stdout. A file target must be new and its parent directory must exist.
--orientation=TD|LR Mermaid exports TD.
--include-webhooks mermaid-rich false. Required when a rich export contains webhook configuration.

--lang, --orientation and --include-webhooks are rejected for JSON/YAML exports. A visual Mermaid export cannot take --include-webhooks. Rich Mermaid embeds a lossless representation, which can include webhook credentials when explicitly requested; choose the artifact’s destination accordingly.

Export writes warnings to stderr so they do not corrupt the graph on stdout. Other graph commands put warnings in data.warnings with --json. A warning does not by itself make a successful lint command exit nonzero.

From the checkout, the bundled onboarding template supplies a complete input:

Terminal window
php bin/execkernel validate \
resources/templates/wizard/wizard_onboarding_v1/v1/json/graph.json \
--json

It exits 0. The relevant result fields are:

{
"ok": true,
"command": "validate",
"summary": {
"nodes": 2,
"edges": 1,
"terminal_nodes": 1,
"warnings": 0
},
"data": {"warnings": []}
}

This excerpt omits the envelope’s version and execution timestamp. Adding an unknown flag fails with exit 4 and EK-LOADER-004, with context.reason = "unknown_option".

All three commands accept --json, default false.

Command Required options Optional options and defaults Output
scaffold list None --family, --format, --status: no filter Validated catalogue entries, sorted by code and version.
scaffold init --template, --version, --family --output=./templates; --dry-run=true Proposed paths and a pending manifest; writes only with --dry-run=false.
scaffold export --template, --version, --format, --output None beyond --json Selected graph file and README.md copied to the output directory.

Families are wizard, decision_tree, eligibility and funnel. Status is pending or published. Format is json, dsl or mermaid, but export also requires that the published template actually declares and contains it. The current bundled templates provide JSON.

init does not register the resulting directory as a different CLI catalogue. Its default dry run checks destinations without writing. Scaffold can create missing output directories, rejects existing target files and refuses symlink traversal or .. components. See Template manifest schema for identity and layout.

Graph snapshots are JSON files. Plans use the migration plan format, including its JSON/YAML and .femig parsing rules. Every command accepts --json, default false.

Command Required options Optional options Result
migrate diff --before, --after, --version --author, --description, --output Proposed plan in data.plan.
migrate validate --plan, --graph --mode Validates the materialized candidate without writing it.
migrate apply --plan, --graph --mode, --output Resulting data.graph_snapshot.
migrate rollback --plan, --graph-before, --graph-after, --rollback-version --mode, --author, --description, --output rollback_plan and resulting graph_snapshot.
migrate list --dir --output Sorted filenames immediately inside the directory: .json, .yaml, .yml or .femig.
migrate inspect --plan --output Parsed plan in data.plan.

--mode defaults to strict and accepts strict or loose. Author and description are absent by default. --output is absent by default; when supplied, it writes the result artifact as JSON to a new file in an existing parent directory. --json independently controls stdout’s command envelope.

A migration output is an artifact for your application to validate and publish. These commands do not update a running graph repository or persistent user sessions. Rollback requires the before/after snapshots; it is not an instruction to undo an unspecified deployment.

execkernel optimize --graph=JSON \
[--mode=strict|permissive] \
[--block-warnings | --max-warnings=N] \
[--max-paths=N] [--max-work=N]
Option Default Accepted value
--graph Required JSON graph source accepted by JsonGraphLoader.
--mode strict strict or permissive.
--block-warnings Warnings do not fail Boolean; true fails on any warning in strict mode.
--max-warnings No warning threshold Nonnegative integer; mutually exclusive with --block-warnings.
--max-paths 1000 Integer 1–1,000,000.
--max-work 100000 Integer 1–1,000,000.

The report is always JSON on stdout; there is no --json, output-path or graph-rewrite option. It includes structural, semantic and simulated findings. The bounds limit exploration, so an incomplete simulation must be interpreted from its coverage fields.

For a produced report, fatal findings exit 2. Strict mode exits 1 for errors or warnings above the selected threshold, otherwise 0. Permissive mode exits 0 unless a fatal finding exists. Usage/loading failures use their own handling, including 4 or 5. Graph analysis and optimization explains what the report establishes.

execkernel bench --report --measurement=MEASURED.json \
--output=REPORT.md [--output-json=REFERENCE.json]
execkernel bench --report \
[--phpbench=FILE] [--k6=FILE] [--locust=FILE] [--metrics=FILE] \
--output=REPORT.md [--output-json=REPORT.json] [--template=FILE]
execkernel bench --compare --baseline=BASELINE.json --report=CURRENT.json
Mode Inputs and defaults Exit behavior
Measured report --measurement and --output required; optional --output-json. Cannot mix dependency-format sources or --template. 0 generated; 2 processing/write failure.
Combined report At least one of --phpbench, --k6, --locust, --metrics; --output required. Optional JSON output and custom Markdown template; omitted template uses the bundled report template. 0 generated; 5 processing/write failure.
Compare --baseline plus exactly one report path: --report=PATH or --report-path=PATH. Report-generation options are rejected. 0 within baseline; 1 regression; 2 missing/incompatible data or read/parse failure.

Malformed option combinations exit 4. Output artifacts must be new; the CLI does not truncate existing reports. bench reads measurements; it does not run load generators. Compare compatible measured records from the same protocol as explained in Performance and benchmarking. A historical target file is not evidence that a baseline was measured.

With --json, ordinary graph, scaffold and migration success contains ok, command, version, timestamp, summary and data. A failure contains ok: false and error with ek_code, severity, message, context, timestamp and optional hint. Timestamps are ISO 8601 strings. Graph export, optimizer and bench use the outputs specified above.

Exit Common main-CLI mapping
0 Successful command.
1 EK-VALID-*, EK-VALIDATION-*, EK-GRAPH-*, EK-META-*, EK-OUTPUT-*; also EK-SEC-LOD-001 and EK-IMPORT-001/002/004.
2 EK-RULE-* and EK-IMPORT-003.
3 EK-SESSION-*, EK-STATE-*, EK-SELECT-*, EK-CYCLE-* and EK-RUN-*.
4 Usage; EK-LOADER-*, EK-API-* and EK-IMPORT-005.
5 Internal failures, EK-SYS-*, EK-INT-* and unmapped families.

Optimizer, bench and the auxiliary tools have the mode-specific meanings described here. Do not interpret every 2 as a rule failure.

php bin/ek-validate-graph \
[--allowed-custom-handlers=A,B] [--allow-custom-handler=NAME] INPUT
php bin/ek-debug condition --graph=INPUT --state=STATE.json --edge=ID \
[--timestamp=UNIX] [--session-id=ID] [--include-context]

ek-validate-graph uses the graph parser and strict validation. Success is JSON with status: "ok", graph_code and warnings, exit 0. Usage, including --help/-h, exits 1; validation or processing failure exits 2.

ek-debug condition accepts graph input through the graph parser and a JSON session state. Only one of graph/state can use stdin. Edge and timestamp use canonical signed integers. Timestamp defaults to state.updated_at; session-id is optional correlation. --include-context is a bare flag, absent by default.

The debugger returns an isolated, read-only observation with availability, allowed, condition details, a separate navigation result, timestamp_source and effects_executed: false. It has no application plugins, custom registry, store or sandbox. A valid observation exits 0 even if the option is blocked or deferred; usage exits 1 and failure to produce an observation exits 2. The debugging guide explains how to interpret it.