CLI

Every command has the same shape, and every verb takes its spec with --config.

sg <group> <verb> [flags]
sg help | sg version            # also: sg --help, sg --version
sg <group> --help               # list a group's verbs
sg <group> <verb> --help        # one verb's flags

Conventions

  • Confirmation. Commands that change something print their plan and ask … [y/N]:. Only an answer starting with y or Y continues. --yes skips the question and nothing else.
  • Fresh plans. Apply commands always build their own plan just before acting. An earlier plan output is never reused.
  • List flags. --target, --force-volume-share and --confirm-root-data can be repeated or take comma-separated values.
  • The ledger. Every command opens the ledger next to its spec: <spec-dir>/.sg/state.db by default.
Exit codeMeansOutput
0Success, help, a completed read-only report (even one showing drift), or a declined confirmationstdout
1Runtime failure, safety refusal or configuration errorsg <group> <verb>: <error> on stderr
2Usage error: bad or missing flag, unexpected argument, unknown group or verbthe error plus usage, on stderr

sg machine

VerbEffect
initLocal only. Interviews you and writes machine.yaml, or validates and registers an existing one with --config
planRead-only. Connects over SSH and prints ordered changes with risk grades
createChanges the host. Applies the plan
statusRead-only. Recorded state, drift, last-applied times. Never repairs
rollbackChanges the host. Undoes the last run's changes, in reverse, sg-owned only
destroyChanges the host. Tears down every recorded sg artifact, in reverse

sg machine init

sg machine init [--config <machine.yaml>] [interview flags]
FlagDefaultMeaning
--configValidate and register an existing spec. No interview
--nameaskedMachine name
--addressaskedHost address sg reaches over SSH
--key-pathaskedController-local SSH private key sg connects with
--deploy-public-key-pathaskedController-local public key installed for the deploy user
--distroaskedubuntu-22.04 or ubuntu-24.04
--outputmachine.yamlFile to write
--forcefalseOverwrite an existing output file

The interview flags can't be combined with --config. Registration never contacts the host or reads key contents.

sg machine plan

sg machine plan --config <machine.yaml>

Connects only after local checks pass. Uploads nothing and records no history. Refuses if the Tailscale auth key variable is unset or empty.

sg machine create

sg machine create --config <machine.yaml> [--yes]

All eight changes are executable in this build. storage.zfs and install.lxd hold data and are never removed by rollback.

sg machine status

sg machine status --config <machine.yaml>

Drift is reported, never repaired. A completed report exits 0.

sg machine rollback

sg machine rollback --config <machine.yaml> [--all] [--force] [--yes]
FlagMeaning
--allSelect every currently applied change, not just the most recent run's
--forceSkip changes named as irreversible. Never bypasses safety or ownership checks
--yesApprove the shown plan without asking

sg machine destroy

sg machine destroy --config <machine.yaml> [--with-packages] [--yes]
FlagMeaning
--with-packagesAlso remove packages sg installed. Kept by default
--yesApprove the shown plan without asking

Deletes recorded instances and the pool file. Refuses on a recorded cluster member.

sg cluster

sg cluster create

sg cluster create --config <cluster.yaml> [--yes]

Needs three or more sg-created members with identical LXD channels; members[0] bootstraps. Shows its plan and asks once. Membership grants shared root-level trust.

sg cluster destroy

sg cluster destroy --config <cluster.yaml> [--with-machines] [--yes]
FlagMeaning
--with-machinesFull machine teardown of every recorded member. Currently the only teardown that completes
--yesApprove the shown plans without asking

Without --with-machines it refuses with sg:cluster-teardown-unsupported on the pinned LXD version.

sg application

VerbEffectGeneration?
initLocal only. Validates and registers the specno
planRead-only. Prints the plan and its hashno
deployChanges the cluster. Deploys and verifies health and exposureyes, on a verified OK finish
statusRead-only. State and health; never repairsno
restartInterrupts service. Restarts instances and verifies healthno
scaleEdits the spec and the clusteryes
upgradeEdits the spec and the clusteryes
rollbackChanges the cluster. Redeploys generation N-1yes (N+1)
destroyDeletes owned instances and volumesno

sg application init

sg application init --config <application.yaml>

Prints <file>: valid (genesis/v1). registered <app> on cluster <cluster>. Never rewrites the spec or moves an existing binding.

sg application plan

sg application plan --config <application.yaml> [--force-volume-share <volume>] [--confirm-root-data <instance>]
FlagMeaning
--force-volume-shareVolume approved for same-member sharing. Repeatable
--confirm-root-dataInstance acknowledged as carrying service data on its root disk. Affects the preview only

sg application deploy

sg application deploy --config <application.yaml> [--yes] [--force-volume-share <volume>] [--confirm-root-data <instance>]
FlagMeaning
--yesDeploy the fresh plan without asking
--force-volume-shareVolume approved for same-member sharing. Repeatable
--confirm-root-dataInstance acknowledged as carrying service data on its root disk. Permits only a restart that keeps the root disk

sg application status

sg application status --config <application.yaml>

Columns: INSTANCE, STATE, HEALTH, MEMBER, DRIFT.

sg application restart

sg application restart --config <application.yaml> [group|instance] [--yes]

At most one selector: a group name, an instance key (web-0) or a full instance name. No selector means every owned instance. A selector that matches nothing refuses.

sg application scale

sg application scale --config <application.yaml> <group> --count <n> [--target <instance=member>] [--dry-run] [--yes]
FlagMeaning
--countDesired instance count. Required; 0 is valid; negative is a usage error
--targetThe complete resulting placement. Repeat for every resulting instance
--dry-runPreview the edited spec and the deploy plan. No writes, no prompt
--yesCommit and deploy without asking

sg application upgrade

sg application upgrade --config <application.yaml> <group> [--image <image>] [--service <name> --version <version>] [--dry-run] [--yes]
FlagMeaning
--imageReplacement image for the group
--serviceThe service whose version changes
--versionThe new release. Never latest
--dry-runPreview without writes or prompts
--yesCommit and deploy without asking

At least one of --image or --version is required.

sg application rollback

sg application rollback --config <application.yaml> [--yes]

Redeploys generation N-1's recorded spec as generation N+1. Refuses with sg:rollback-unavailable when there's no valid N-1.

sg application destroy

sg application destroy --config <application.yaml> [--yes] [--force-volume-share <volume>]

Removes owned instances and their volumes. Unowned artifacts print as retained: <kind> <name> is not owned by sg.

sg panel

sg panel [--listen <addr:port>]
FlagDefaultMeaning
--listen127.0.0.1:7070Loopback, or tailnet:<port> for this host's verified tailnet address

panel is a single verb, not a group. Extra arguments are a usage error. See The admin panel.