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 withyorYcontinues.--yesskips the question and nothing else. - Fresh plans. Apply commands always build their own plan just before acting. An earlier
planoutput is never reused. - List flags.
--target,--force-volume-shareand--confirm-root-datacan be repeated or take comma-separated values. - The ledger. Every command opens the ledger next to its spec:
<spec-dir>/.sg/state.dbby default.
| Exit code | Means | Output |
|---|---|---|
0 | Success, help, a completed read-only report (even one showing drift), or a declined confirmation | stdout |
1 | Runtime failure, safety refusal or configuration error | sg <group> <verb>: <error> on stderr |
2 | Usage error: bad or missing flag, unexpected argument, unknown group or verb | the error plus usage, on stderr |
sg machine
| Verb | Effect |
|---|---|
init | Local only. Interviews you and writes machine.yaml, or validates and registers an existing one with --config |
plan | Read-only. Connects over SSH and prints ordered changes with risk grades |
create | Changes the host. Applies the plan |
status | Read-only. Recorded state, drift, last-applied times. Never repairs |
rollback | Changes the host. Undoes the last run's changes, in reverse, sg-owned only |
destroy | Changes the host. Tears down every recorded sg artifact, in reverse |
sg machine init
sg machine init [--config <machine.yaml>] [interview flags]
| Flag | Default | Meaning |
|---|---|---|
--config | Validate and register an existing spec. No interview | |
--name | asked | Machine name |
--address | asked | Host address sg reaches over SSH |
--key-path | asked | Controller-local SSH private key sg connects with |
--deploy-public-key-path | asked | Controller-local public key installed for the deploy user |
--distro | asked | ubuntu-22.04 or ubuntu-24.04 |
--output | machine.yaml | File to write |
--force | false | Overwrite 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]
| Flag | Meaning |
|---|---|
--all | Select every currently applied change, not just the most recent run's |
--force | Skip changes named as irreversible. Never bypasses safety or ownership checks |
--yes | Approve the shown plan without asking |
sg machine destroy
sg machine destroy --config <machine.yaml> [--with-packages] [--yes]
| Flag | Meaning |
|---|---|
--with-packages | Also remove packages sg installed. Kept by default |
--yes | Approve 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]
| Flag | Meaning |
|---|---|
--with-machines | Full machine teardown of every recorded member. Currently the only teardown that completes |
--yes | Approve the shown plans without asking |
Without --with-machines it refuses with sg:cluster-teardown-unsupported on the pinned LXD version.
sg application
| Verb | Effect | Generation? |
|---|---|---|
init | Local only. Validates and registers the spec | no |
plan | Read-only. Prints the plan and its hash | no |
deploy | Changes the cluster. Deploys and verifies health and exposure | yes, on a verified OK finish |
status | Read-only. State and health; never repairs | no |
restart | Interrupts service. Restarts instances and verifies health | no |
scale | Edits the spec and the cluster | yes |
upgrade | Edits the spec and the cluster | yes |
rollback | Changes the cluster. Redeploys generation N-1 | yes (N+1) |
destroy | Deletes owned instances and volumes | no |
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>]
| Flag | Meaning |
|---|---|
--force-volume-share | Volume approved for same-member sharing. Repeatable |
--confirm-root-data | Instance 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>]
| Flag | Meaning |
|---|---|
--yes | Deploy the fresh plan without asking |
--force-volume-share | Volume approved for same-member sharing. Repeatable |
--confirm-root-data | Instance 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]
| Flag | Meaning |
|---|---|
--count | Desired instance count. Required; 0 is valid; negative is a usage error |
--target | The complete resulting placement. Repeat for every resulting instance |
--dry-run | Preview the edited spec and the deploy plan. No writes, no prompt |
--yes | Commit and deploy without asking |
sg application upgrade
sg application upgrade --config <application.yaml> <group> [--image <image>] [--service <name> --version <version>] [--dry-run] [--yes]
| Flag | Meaning |
|---|---|
--image | Replacement image for the group |
--service | The service whose version changes |
--version | The new release. Never latest |
--dry-run | Preview without writes or prompts |
--yes | Commit 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>]
| Flag | Default | Meaning |
|---|---|---|
--listen | 127.0.0.1:7070 | Loopback, 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.