Skip to content

Commands ​

Basic commands set up a project and show what is known. Lifecycle commands move a variant through the flow of steps. The MCP server and the library offer the same commands. The CLI-only commands (ui, mcp, completions) are on the CLI page.

Basic commands ​

variant init ​

Bootstrap the current directory for Variant in up to three steps, each of which --<step>=false turns off:

  • file: write variants.yaml with every autodetected value: the database (Postgres, MySQL, MariaDB as dialect mysql, or SQLite), variant.abbr, variant.prefix, and one watch per Vite or NestJS app and per package with a watch script. Other accepted values of a setting follow # on the same line. Secrets are never written: a password or a URL with credentials becomes ${NAME} with a comment such as # from ../mise.local.toml. For Postgres, host, port, user and password are ${NAME} the same way, and database is the detected name. variant.main and variant.root are omitted.
  • gitignore: append <prefix>* to .gitignore (created when absent, left alone when the line exists).
  • mise: add github:jubr/variant-worktrees (latest) to the closest Mise file inside the git checkout, skipping *.local.* files; mise.toml is created when there is none. Nothing is installed. A file that is not valid TOML is left alone and reported, and so is a Mise that cannot be found (the message names where it looked and variant.mise.binPath). A failing Mise step stops no other step.
bash
variant init
variant init --prefix wt- --mise=false
variant init --force

--prefix (default _v-) must not be empty or contain a path separator. init refuses to run when a variants.yaml or variants.yml is found (the lookup of every other command) and changes nothing, unless --file=false skips that step or --force replaces the variants.yaml of this directory. The result lists what each step did, and a bun line: init also checks that the first bun on PATH is the version Mise pins (see Bun on PATH). In the result, bun has a status of matches, differs or unchecked, a message and the hint lines that say how to fix a difference. The check never fails init and changes nothing. With --json or --yaml it is the returned object. The MCP tool is variant_init. The extension command Variant: Initialize in this Repo shows the same steps; its confirm button is Initialize, and Prefix sits in a collapsed Advanced disclosure. Without a config file the Explorer section offers Onboard, which opens that dialog; an activity-bar Variant Worktrees tree lists the same rows.

variant config ​

Print the detected configuration: variants.yaml, then the environment as Mise prints it, then the process environment. The printed object includes the resolved variant.main and variant.root even though init does not write them, and it includes built-in defaults and discovered watches. Inside a variant worktree that has its own variants.yaml or variants.yml, that file is loaded and an ancestor file is not. db.port may be a positive integer or a string of digits or one ${NAME}; the printed value is the resolved integer.

The text is YAML. A comment names where a value came from, on that key. A child with the same origin is not commented again. A child from somewhere else is commented on its own line. The file path is relative to the working directory and uses /: ./variants.yaml when the file is there, ../variants.yaml when it is a parent.

  • # from <path> — the loaded file set the value
  • # from env NAME — that variable supplied the value, including a ${NAME} in the file when NAME is set. A ${NAME:-fallback} whose variable is unset stays the file, because the fallback is written there
  • # autodetect <reason> — the value was discovered. <reason> is one word: watch, config, or connection
  • # autodetect from <source> — the discovery names a source the key does not. abbr quotes the main directory's base name. main names AGENTS.md or git rev-parse --git-common-dir. root names AGENTS.md only when it is not the same path as main
  • # default — a built-in default filled a key the file omits

A comment that only repeats its key is left off, including runtime and a main or root that is only the config directory. Items of an array written in the file use that file's origin, so the comment sits on the key that holds the array. source is not printed; where db came from is the comment on those fields.

On a terminal, with NO_COLOR unset, keys are cyan, strings green, numbers and booleans bright magenta, and comments bright black. Null, [], {}, colons, and dashes stay the default color. A pipe, or NO_COLOR set to any value including empty, prints the same characters with the comments and no color. --json and --yaml print the same document with no comments and no color. A password is *** in all three.

bash
variant config

variant list ​

List the known database variants as a table, one row per variant, with the columns slug, mode, uptime, url, log and dir. url is the complete URL of the first watch that has one, uptime is how long the longest-running process of the variant has been up, log is the absolute path of .cache/variant/watch.log while watch is running, and dir is relative to the variant root. A - marks what a variant does not have: a variant started with up has no uptime or log. A variant with db.multi is still one row; its schemas are printed by status and by list --verbose, and they are on the JSON and YAML record. Schemas whose worktree is gone are grouped by schemaPrefix: the slug is the text before the last separator, and the tenant is the final segment. PostgreSQL schemas named v_<slug>-<tenant> group the same way when db.multi is absent: hyphens in the slug are stored as underscores, and the tenant is the text after the last hyphen, so v_fix_entra_vbu_login-de99 and its siblings are one row, fix-entra-vbu-login.

bash
variant list

When PostgreSQL or MySQL cannot be contacted, list still prints variants known from state files and worktrees and writes one contact warning. Variants that exist only as schemas are left out. A missing SQLite file is not this case. status of a slug known that way succeeds; a slug known only from the database fails with the same warning.

With --verbose every variant is printed as variant status prints it, with all its meta information, instead of the table. --verbose is not a log level; -v is.

bash
variant list --verbose
variant list --json   # the records, without the runtime object
variant list --verbose --json

variant status ​

Show everything known about one variant: the facts list shows plus .cache/variant/runtime.yaml: mode, the worktree directory, the database settings (the password is shown as ***), and for every watch its port, pid, URL, whether the process is alive, and its uptime. It also shows the path of that file and the log file of a running watch. VARIANT_<KEY>_* overrides do not apply. It fails when nothing is known about the slug.

bash
variant status -s feature-forty-two
variant status -s feature-forty-two --json

Lifecycle commands ​

These commands move a variant through the flow of steps.

variant create ​

Create the git worktree and the state for a slug. This does not create a database schema or file; that is provision. Creating the same variant again is safe. If PostgreSQL or MySQL cannot be contacted, create fails with the contact warning and does not create the worktree.

--from is a commit, tag, or branch, and it has no short flag. A new branch starts there. Omit it and the branch starts at variant.baseBranch. An existing worktree for the slug, or a branch that already uses any configured prefix, is checked out as it is; --from does not move it. implode still requires a merge into variant.baseBranch. provision, up, and watch take the same flag, because each of them creates the worktree when it is missing.

--pull-ff has no short flag. Before a new variant branch is created it fast-forwards the start branch: from when that names a local branch, otherwise variant.baseBranch. It does not pull the new branch. A tag, a commit, a remote-tracking name, or HEAD is used as given, with no fetch. A dry-run that predicts a conflict, divergence, a missing upstream, or another error leaves that checkout un-pulled. When the update fails after a clean dry-run, the checkout is restored and the error prints the command to run again. Omit the flag and nothing is fetched. An existing worktree, an existing prefixed branch, and slug main skip the network. provision, up, and watch take the same flag.

--mise-install has no short flag. The values are bg, sync, and no. Omit it on create and the value is bg on the library, the CLI, and MCP. Omit it on provision and watch and the value is sync. The install runs only when the worktree has a Mise config (mise.toml, .mise.toml, .config/mise/config.toml, mise/config.toml, or .tool-versions). up does not take it. There is no variants.yaml key. The run is mise -C <worktree> trust --all, then mise install in that worktree. bg returns immediately and replaces {worktree}/.cache/variant/mise-install.log with that run. sync waits and fails the command when Mise fails; the worktree stays. Slug main and a create that makes no worktree skip it.

bash
variant create -s feature-forty-two
variant create -s feature-forty-two --from feat/other
variant create -s feature-forty-two --pull-ff
variant create -s feature-forty-two --mise-install=sync

variant provision ​

Create the schema v_<slug>, or every schema of db.multi in one pass, and run the configured install, env file, up, step, and seed commands. This implies create, and it prepares the variant without leaving a supervised watch in the foreground.

A step named provision in variant.steps replaces the builtin schema creation and runs once, and the builtin creates nothing. That script creates the schemas and any extra role that uses them, and it handles every value of the db.multi list itself. The flow of steps shows where provision sits.

bash
variant provision -s feature-forty-two
variant provision -s feature-forty-two --from feat/other

--from starts a new branch at that commit. --pull-ff fast-forwards the start branch first. --mise-install installs Mise tools in the new worktree. See variant create.

variant up ​

Run the watches as containers. This implies seed, so the worktree, the schemas and the seed exist first. It does not drop an existing schema. One runtime exists per slug, so this stops recorded watch processes for that variant first.

bash
variant up -s feature-forty-two
variant up -s feature-forty-two --from feat/other

--from starts a new branch at that commit. --pull-ff fast-forwards the start branch first. See variant create.

variant watch ​

Run the watches as supervised host processes. This implies seed, so the worktree, the schemas and the seed exist before the processes start. It removes the variant's containers first, so up and watch do not both run.

bash
variant watch -s feature-forty-two
variant watch -s feature-forty-two --detach
variant watch -s feature-forty-two --reprovision
variant watch -s feature-forty-two --from feat/other

--from starts a new branch at that commit. --pull-ff fast-forwards the start branch first. --mise-install installs Mise tools in the new worktree. See variant create.

--reprovision runs deprovision before the provision phase, so the schemas are dropped and created again. Without it, watch does not drop a schema.

Inside a variant worktree that has its own variants.yaml, watch runs the commands of that file and keeps the environment it finds (PORT, VARIANT_SPA_PORT, VARIANT_API_PORT). Without --detach, the command stays attached. It exits 130 on interrupt, 1 when a watch ends or the worktree disappears, and 0 only when detached. The start summary, including the pids, is printed as soon as the processes are running. The exit code is printed when the watch ends. --detach starts the processes in the background and returns. Attached and detached, the output of all its processes goes to one log file, .cache/variant/watch.log in the worktree. The file is emptied when the watch starts. Each process is announced as [name] command, and each later line is prefixed [name] . Attached, stdout stays on stdout and stderr stays on stderr, with the same prefix, and the file is written without waiting for that write. output.mode: tty gives that process a pseudo-terminal, so color is in the log; the terminal mixes stderr into those stdout lines. Otherwise the watch runs with pipes and a warning. A line that contains an ANSI escape gets a reset before the newline, and the log starts with [watch] {args} mode=tty # set to 'no-tty' likely suppresses ansi escape sequences, where {args} is the invocation flags such as --detach. no-tty keeps the pipes. Omit output.mode and the editor uses tty when an enabled extension's description contains both log and ansi, otherwise no-tty. The CLI does not see extensions, so an omitted mode stays no-tty. The file grows while the processes run, so tail -f follows it. list and status show its path. down removes log from state and keeps the file. up writes no log and records no log. The first probe of a watch that sets ready writes [watch] {name} URL try {url} to stderr and, when watch is writing the log, to that file. The first status 200 writes [watch] {name} URL 200 {url} once. On a terminal, once every ready watch has returned 200, stderr gains [watch] Interactive: 1 restart 2 detach 3 quit (press number + ⏎). The numbers are bold cyan, the words are yellow, and the parenthetical is dark gray. 1 restarts the processes, 2 leaves them running and returns, and 3 sends Ctrl+C to every watch and waits. A second Ctrl+C at least 1 second later sends SIGTERM and returns. Any other line is written to each watch's stdin. Ctrl+C before 3 stops the processes. That hint is not written to the log. A second watch while those processes are still running leaves them running. It prints [watch] # already running: reattached, showing last 50 lines (the # clause in comment gray), the last 50 lines of the log, [watch] {name} URL 200 {url} for each ready watch that answers 200, and the same command line. With --detach it then returns. Without --detach it then follows new lines of the log. 1, 2, and 3 work as on the first run, and any other line is written to the watches' stdin. An interrupt exits 130 and leaves the processes running. A later poll does not repeat either line. Status 204 does not count. {url} is the rendered watch URL joined with ready, or http://127.0.0.1:<port><ready> when the watch has no URL template. Detach writes no try line and opens nothing. State is written to .cache/variant/state.yaml and .cache/variant/runtime.yaml.

variant down ​

Stop the processes and containers of a variant and keep its data, database, and worktree.

bash
variant down -s feature-forty-two

variant deprovision ​

Stop the watches, then drop the schema v_<slug>. With db.multi, drop every schema under db.multi.schemaPrefix, including one whose value has left the list. A step named deprovision in variant.steps replaces that drop and runs once; the builtin drops nothing. The script removes the schemas and anything else, such as a role, and it handles every tenant itself. VARIANT_STEP_DEPROVISION=no skips the step and does not fall back to the builtin drop. The worktree, the storage directory and the state stay. It refuses main.

bash
variant deprovision -s feature-forty-two

variant implode ​

Stop the variant, drop its schemas and storage, clear its state, remove its worktree, and then remove its local branch. This implies deprovision. It refuses main, and it refuses work that is not merged into variant.baseBranch unless --force is set. --branch-rm=yes|no chooses the branch step. The default is yes. --branch-rm=no keeps the branch. true and false are rejected. With --log-level=debug, stderr names the branch and whether it was removed or kept. The default log threshold hides that line. The report it prints colors added diff hunks green and removed diff hunks red; command traces stay yellow, and git's own color stays off. A worktree directory that is already gone does not block the drop: the schemas still go, and a later implode of the same slug succeeds. The drop uses the real schema names of that row, including v_<slug>-<tenant> leftovers. .cache/variant/state.yaml and runtime.yaml are removed.

bash
variant implode -s feature-forty-two
variant implode -s feature-forty-two --branch-rm=no
variant implode -s feature-forty-two --force

Released under the MIT License.