Developer

CLI automation contract

Build reliable scripts with versioned JSON, deterministic input, and stable error and exit codes.

  • --json
  • --yes
  • schema_version: 1
--jsonEmit exactly one schema-version-1 envelope on stdout.
--yesUse deterministic defaults and approve charges, reviewed syncs, replacements, and overwrites. Missing choices fail with input_required.
stdout and stderrMachine results go to stdout. Diagnostics and progress go to stderr.
CredentialsTokens are never returned in JSON and should be supplied through protected environment variables.
Success envelope
{
  "schema_version": 1,
  "ok": true,
  "command": "project.bindings",
  "result": { "bindings": [] }
}
Failure envelope
{
  "schema_version": 1,
  "ok": false,
  "command": "operation.start",
  "error": {
    "code": "input_required",
    "message": "...",
    "details": {}
  }
}

Reference

Stable exit and error codes

Use the process exit status for broad handling and the JSON error code for specific recovery.

ExitStable codeMeaning
0successThe command completed successfully or an interactive choice was cancelled before work.
1internal_failure / command_failedAn unexpected failure or a command-level failure occurred.
2invalid_usageArguments or command usage are invalid.
3authentication_failedAuthentication is missing, expired, or rejected.
4input_requiredRequired input was unavailable in noninteractive execution.
5local_failureA local file, tool, configuration, or filesystem action failed.
6gateway_failureThe gateway could not be reached or returned an invalid response.
7remote_rejectionThe remote service rejected a valid request.
8operation_failedThe operation reached a failed or aborted terminal state.
130interruptedThe process was interrupted; accepted server work is not automatically aborted.

Command results

Fields returned by each command

Fields are additive within schema version 1. Consumers should ignore fields they do not recognize.

CommandResult fieldsNotes
login / statusapi_url, user_id, credential_sourceAuthentication metadata without exposing the token.
logoutapi_url, stored_token_removed, environment_authentication_activeReports stored-token removal and remaining environment authentication.
project.bindbinding | cancelled, pathReturns the binding or a user-cancelled result.
project.forgetpath, removed[], cancelledIdentifies removed bindings and cancellation.
project.bindingsbindings[]Returns all matching local bindings.
project.syncbinding, mode, path, preview, applied, summary, media[], cancelledIncludes preview/apply mode, summary, media changes, and cancellation.
operation.startcancelled, path, project_id, operation_id, status, lifecycle_status, detached, output_target, remove_track, sources_accepted, required_credits, available_credits, outputs[], applied_tracks, skipped_tracks, removed_tracksIdentifies the operation and whether execution detached.
operation.watchoperation_id, project_id, status, lifecycle_status, progress_status, failures[], local_output_pendingReports lifecycle/progress state, failures, and pending local output.
operation.applycancelled, path, operation_id, project_id, status, output_target, remove_track, partial, outputs[], applied_tracks, skipped_tracks, removed_tracksReports written outputs, track actions, and partial-result state.

Deterministic input

--json may still prompt on stderr. Add --yes to disable prompts, then supply every nondeterministic choice through flags, configuration, or protected environment variables.

subft --json --yes operation start PATH --lang de --project-id PROJECT_ID --detach

Cancellation and partial results

Interactive cancellation exits 0 with cancelled: true before work is committed. Ctrl-C exits 130 without aborting accepted server work. With --yes, incomplete output requires --allow-partial and the command still exits nonzero after applying available tracks.

subft --json --yes operation apply OPERATION_ID PATH --allow-partial