Many sites with WP-CLI

The WP-CLI commands of Leitvia Studio for work across many client sites: token sets, patterns, content models, audits, change packages and recipes, with the same checks as the admin.

For agencies and developers · Leitvia Studio · Checked with Leitvia Studio 1.3.65 and Leitvia Pro 0.8.55

How the commands work

WP-CLI is the command line of WordPress. The commands of Leitvia Studio start with wp leitvia.

  • Add --user. Most commands act as a WordPress user, for example --user=admin. Without it they stop with “This command acts as a user; run with –user=<agent or admin>.” before anything happens. The table below says which commands need it.
  • Every write runs through the same abilities as REST and MCP, with their checks, a snapshot and a change package.
  • Lists take --format=table|json|yaml.
  • A rejection exits with 1; with --format=json it prints code, message and data.

Commands

CommandDoes--user
wp leitvia tokens listLists the token setsNo
wp leitvia tokens export <id>Prints a token set as JSON: { "title", "document" }, the document in DTCG formatYes
wp leitvia tokens import <file>Creates a token set from such an export, with the contrast checkYes
wp leitvia tokens activate <id> [--base-hash=<hash>]Activates a token setYes
wp leitvia patterns list [--status=<status>]Lists the patterns of the theme and StudioNo
wp leitvia patterns export [<slug>…]Prints patterns with markup, all without a slugNo
wp leitvia patterns import <file>Creates Lab patterns from a JSON list of title and contentYes
wp leitvia model getPrints the content modelNo
wp leitvia model apply <file> [--dry-run] [--base-hash=<hash>]Adds or replaces content model entries; --dry-run only checksYes, not for --dry-run
wp leitvia audit [--after=<cursor>] [--limit=<n>]Audits the published content page by page and sums the findings per checkYes
wp leitvia package list [--state=<state>] [--page=<n>]Lists change packages, 100 per pageYes
wp leitvia package show|reject|rollback <id>Shows, rejects or rolls back a change packageYes
wp leitvia package apply <id> [--ops=<ids>]Applies the open steps, or only the listed onesYes
wp leitvia package export <id>Prints a package with the hashes of its targets and its mediaYes
wp leitvia package import <file>Imports a package as an open package; refuses when a target changedYes
wp leitvia recipe listLists the recipes, with Pro also the kits, such as leitvia-pro/saasNo
wp leitvia recipe apply <name>Applies a recipeYes

A hash is a fingerprint of the current state. With --base-hash a write is refused if someone changed the target in the meantime. --after and --limit page through a long audit; without them the audit runs to the end, 20 posts per step.

Examples for many sites

Copy a token set to every site of a multisite network:

wp --user=admin leitvia tokens export 12 > brand.json
wp site list --field=url | xargs -I{} sh -c \
  'wp --url={} --user=admin leitvia tokens import brand.json'

The import creates the token set on each site; activate it there with tokens activate or in the admin. For releases with one site first, the network screen is easier.

Audit a list of client sites over SSH aliases and keep the results:

for site in @tidepost @larkspoon @kestrelgate; do
  wp $site --user=admin leitvia audit --format=json > "audit-${site#@}.json"
done

Move a reviewed change from a stage to live as a file:

wp @stage --user=admin leitvia package export 34 > change.json
wp @live --user=admin leitvia package import change.json
wp @live --user=admin leitvia package apply 51

The import prints the number of the new package (here 51). Apply that one.

MCP over WP-CLI

With the plugin MCP Adapter active, an AI agent on the same machine can talk to the site over standard input and output, without HTTP. Its default server finds and runs the Leitvia abilities with the same checks; the MCP server leitvia of Studio itself runs over HTTP only.

wp mcp-adapter serve --server=mcp-adapter-default-server --user=admin