● zegit · proves
zg CLI reference
The complete zg command surface — the developer and agent-facing CLI. Documented from the source, not the design prose.
Code is authoritative
Where product/architecture documents describe a richer design than what ships (for example a zg build command), this reference follows what the binary actually does today — zg --help at v0.0.173.
Top-level commands
| Command | Description |
|---|---|
zg version | Show version, commit, build time. |
zg update | Self-update from the latest release on github.com/zegit-zoo/zg; verifies the checksums signature with the Control Plane's artifact key first. --check only reports. |
zg init | Bootstrap a repo: .zegit/config.yaml, ZEGITFILE, .zegit/agents/, the pre-push hook, and the wired gateway remote. --solo for a one-person repo. |
zg auth | Local IAM / Control-Plane auth: init-ca, enroll, login, status, ssh-cert, logout, automation-*. |
zg validate | Run the pipeline, assemble an AoV, evaluate policy, sign into refs/zegit/aov/<sha>. |
zg push | Push a ref with before/after verification of the remote; --wait-forward waits until the forges mirror it. |
zg verify-forward | Check that a ref reached every forge remote (forwarding is asynchronous). |
zg evidence | Evidence record ops: evaluate, keygen, sign, verify, bundle, verify-bundle, verify-aov. |
zg aov | Inspect the AoV of a commit (verdict under both clocks); mirror AoV refs into the Control Plane. |
zg tr | Tag Requests with quorum: create, list, get, approve, finalize, watch, withdraw, reject, invalidate. |
zg policy | Release policy as a protected ref: show, scope, inspect, propose, approve, activate, withdraw, request-activation. |
zg audit | Verify shipped audit-log batches offline — from files, an export zip, or straight from the bucket. |
zg git / zg git-shim | Opt-in git mode: a git shim that routes gateway pushes and release tags through zegit; everything else is plain git. |
zg ssh | The core.sshCommand for wired clones — zegit's certificate and pinned host key for the gateway host only, plain ssh elsewhere. |
zg install skill | Install the bundled agent skill into local tooling (--agent claude). |
zg revert | Owner-only break-glass revert to a safe tag. |
zg breakglass / zg canary | Owner ceremonies: provision and drill the sealed break-glass owner, and plant canary automation identities that page on use. |
zg ceremony | CA key ceremony — generate the ZeGit Root CA, the quorum-verdict key pair, or run the YubiHSM ceremony. |
A global --json flag is available on commands for machine-readable output; the JSON contract is stable within a major version (fields are added, never renamed or removed). Any zg subcommand that is not a zg verb is handed to git unchanged.
zg validate
The core loop. Resolves HEAD's commit and tree, loads .zegit/config.yaml, runs each step with a streaming transcript, computes a policy digest over .zegit/config.yaml + ZEGITFILE, assembles the record, evaluates policy, and — unless blocked — signs a DSSE AoV to refs/zegit/aov/<commit>. It refuses up front when the committed .zegit/config.yaml is not the pipeline the ZEGITFILE pins, and warns when the zg binary was built from a dirty tree (the gateway rejects such release evidence).
zg validate # sign an AoV for HEAD
zg validate --risk review # set the risk policy: allow | review | block
zg validate --no-sign --json # evaluate only; print the decision
zg validate --key dev.key # sign with an explicit key
zg validate --trust # record this repo's pipeline as trusted on this machine
# (required when ZEGIT_VALIDATE_REQUIRE_TRUST=1)Exit codes
| Code | Meaning |
|---|---|
0 | ALLOW |
10 | REQUIRE_REVIEW |
20 | BLOCK (a required step failed, or risk blocks) |
1 / 2 | IO/exec error / usage error |
zg auth
Two modes: local IAM (a single-machine simulation, no ZEGIT_CP_URL) and Control-Plane mode (when a CP URL is configured).
| Subcommand | Description |
|---|---|
auth init-ca | Create a local CA root (ca/root.crt, ca/root.key). |
auth enroll | Enroll a passkey and record an identity + role. |
auth login | WebAuthn ceremony → a short-lived leaf cert at cert/cert.pem; in CP mode also a gateway SSH cert and the pinned gateway host key. --validity narrows the window; --org scopes the leaf to one organization; ZEGIT_NO_BROWSER=1 prints the URL. |
auth status | Show the current cert: identity, role, expiry. |
auth ssh-cert | Fetch a gateway SSH user certificate for the current session (ssh/id_zegit{,-cert.pub}). |
auth logout | End the session on this machine (cert, key, CP cookie, SSH cert); --purge removes the enrolment too. |
auth automation-keygen | Generate an ed25519 automation keypair. |
auth automation-register | Owner registers an automation pubkey at the CP (--role developer|provisioner). |
auth automation-login | Passwordless cert issuance for agents (challenge → sign → login). |
zg auth login
zg auth status --json
zg auth enroll --identity jonas@acme --role maintainer
zg auth enroll --canary # CP mode: a decoy invitation that pages when redeemedThe store is $ZEGIT_HOME, else $XDG_CONFIG_HOME/zegit, else ~/.config/zegit. An optional config.json there sets cp_url and identity; ZEGIT_CP_URL wins when both are set.
Login cert validity scales with role
Default login cert lifetimes are developer 8h, maintainer 1h, owner 5m — the more privilege, the more often you touch the passkey. The full model, including delegating a login cert to an agent, is on Identity & certificates.
zg evidence
The lower-level evidence pipeline — it mirrors the envelope state machine (unsigned → validated → signed).
| Subcommand | Description |
|---|---|
evidence evaluate | Evaluate a record against the policy engine; --stamp writes a validated envelope. |
evidence keygen | Generate an ed25519 keypair (PKCS#8 + PKIX PEM); prints a key_id. |
evidence sign | Sign an evaluated record into a DSSE envelope. |
evidence verify | Verify a signed AoV DSSE envelope. |
evidence bundle | Assemble a CRA Evidence Bundle for a release tag (--tag, --prev, --sbom, --out); exits 20 with ZG_ERR_EVIDENCE_INCOMPLETE when a commit in the range lacks a valid AoV unless --allow-incomplete. |
evidence verify-bundle | Verify a bundle offline against a Root CA (fail-closed: no resolvable root is an error). |
evidence verify-aov | Verify the AoV at refs/zegit/aov/<commit> against a CA root — strictly at now, then on the accepted-evidence clock. |
zg evidence keygen --out .zegit/keys/dev
zg evidence evaluate run.jsonl --stamp validated.jsonl --risk allow
zg evidence sign validated.jsonl --key .zegit/keys/dev.key --out aov.dsse
zg evidence verify aov.dsse --key .zegit/keys/dev.pubSee CRA & compliance for the bundle commands in context.
zg tr — Tag Requests
The human-in-the-loop release gate. TR refs live at refs/zegit/tr/<tag>; approvals at refs/zegit/tr/<tag>/approvals/<keyid>.
| Subcommand | Description |
|---|---|
tr create <tag> | Open a TR at a commit (default HEAD); threshold/roles from ZEGITFILE. Refuses a commit that is not on master unless --allow-off-master. |
tr list | List open TRs and their quorum status (local refs only — tr get asks the Control Plane). |
tr get <tag> | Show a TR, its approvals, and the authoritative quorum verdict. |
tr approve <tag> | Approve with a fresh passkey touch (or approve in the Control Plane's Tag Requests page). |
tr finalize <tag> | Create the signed annotated tag once the Control Plane confirms quorum for that exact commit. |
tr watch <tag> | Poll finalize until quorum is met; --push <remote> then pushes the tag with ref-advance verification. |
tr withdraw <tag> | Retract your own open request (nothing is deleted). |
tr reject / tr invalidate <tag> --reason | Owner/maintainer verdict that closes the request with the reason on record. |
The creator can't self-approve
The creator's own approval never counts toward quorum unless the repo sets allow_aov_self_approval: true. zg tr finalize exits 30 (ZG_ERR_QUORUM_NOT_MET) if quorum isn't met; zg tr watch exits 31 when its window closes with quorum still unmet.
zg policy — release policy as a protected ref
Once a policy is activated at refs/zegit/policy it — not the tree's ZEGITFILE — decides how releases are gated, and replacing it always needs two distinct owner approvals (the very first activation needs one). The ZEGITFILE stays the proposal source. With ZEGIT_CP_URL set, proposals and approvals are mirrored to the Control Plane's Policy Center; the git ref stays authoritative.
| Subcommand | Description |
|---|---|
policy show | Print the active policy and its blob; --org <slug> shows an organization baseline. |
policy scope | Print the validation: block that pins the current .zegit/config.yaml (digest + required step ids) — append it to ZEGITFILE, then propose. |
policy propose | Sign HEAD's ZEGITFILE as a proposal replacing the active policy; --org proposes an organization baseline. |
policy inspect <blob> | Decode a proposal: policy, proposer cert, verdict, approvals on file, and what activate would do (--diff). |
policy approve <blob> | Sign an owner approval (other roles are refused — they would never count). |
policy activate <blob> | Point refs/zegit/policy at the proposal once the owner quorum holds; --push <remote> pushes approvals and the ref together. |
policy withdraw / policy request-activation <blob> | Control-Plane-only: retract a proposal, or ask the hosting gateway to activate it once quorum holds. |
zg aov
zg aov inspect [<commit>] shows everything an approver or auditor should see for one commit: the decoded record (subject, steps, decision, policy digest, actor, producer), the signer's certificate, the verdict under both clocks, and the tree cross-check. Exits 20 when the commit has no AoV — fetch them first with git fetch gateway 'refs/zegit/aov/*:refs/zegit/aov/*'. zg aov mirror backfills the Control Plane's Attestations page from local AoV refs; it is idempotent and the CP refuses envelopes that do not verify against its trust root.
zg push & zg verify-forward
zg push <remote> <refspec> pushes with the companion AoV ref in the same transaction, retries a transport that died after the pre-push gate, and verifies the remote ref actually advanced. zg verify-forward <ref> checks the ref reached every forge remote — forwarding from the gateway to GitHub and Gitea is asynchronous.
| Exit | Meaning |
|---|---|
4 | A remote holds a non-ancestor sha (diverged). |
5 | Missing, behind, or unreachable — retry class. |
6 | Push reported success but the remote ref did not land on the expected sha. |
7 | The tip has no AoV anywhere — run zg validate first. |
zg init
Bootstraps a repo and installs a guarded pre-push hook. The hook pushes refs/zegit/aov/*, and for each refs/tags/v* being pushed it verifies a matching TR ref exists (else aborts) and pushes it first. Idempotent and composes with an existing hook. After a Control-Plane login it also writes the wired-clone setup into the clone's own .git/config: a gateway remote using the zegit-gateway: URL prefix and core.sshCommand = zg ssh.
zg init # current repo
zg init --repo . --force
zg init --solo # allow_aov_self_approval: true for a one-person repo
zg init --slug org/repo # registry slug for the gateway remote (default: from origin)zg git-shim — zg as your git
Opt-in drop-in: zg git-shim install writes a git shim (default ~/.local/bin/git; put that directory first on PATH). In a governed repo — one with a ZEGITFILE — git push gateway … then validates a commit without an attestation before pushing, and git tag vX.Y.Z (any name matching tag_request.release_tags) opens a Tag Request instead of a local tag. Every other git command is untouched; zg git … is always plain git; zg git-shim status / uninstall report and opt out. Commits are not wrapped — that ceremony stays in hooks.
zg update & zg audit
zg update installs the latest release from github.com/zegit-zoo/zg after verifying the checksums signature against the Control Plane's artifact key and the archive's sha256 against the checksums (cosign on PATH); --check only reports, --forge gitea --forge-url reads an internal mirror. zg audit verify checks shipped audit-log batches offline — DSSE signature on each batch's Merkle root, root recomputation, intra- and cross-batch chain linkage — from files, an export zip, or straight from an S3 bucket with a read-only key.
zg revert & zg ceremony
zg revert <tag> is an owner-only break-glass: it restores the tree to a safe tag, requires a passkey touch, signs an AoV, and resets HEAD. zg ceremony generate produces the ZeGit Root CA (root.crt + root.key, default validity three years) and prints the key-ceremony next steps; zg ceremony quorum-key generates the Control Plane's quorum-verdict key pair, which every gateway needs to verify tag verdicts; zg ceremony hsm runs the two-custodian YubiHSM ceremony.
zg revert v0.9.0 --message "roll back the bad release"
zg ceremony generate --cn "ZeGit Root CA" --out ./ceremony
zg ceremony quorum-key --out ./ceremonyAuthoritative reference, generated from the component repos. Spot something stale? Tell us.