Stacki CLI
The stacki command line — read and change a project's .stacki settings with dry-run plans, all-or-nothing writes, undo and JSON output.
stacki reads and changes everything in a project’s .stacki/ folder, with the rules the app itself enforces.
- Every write is a dry run until you add
--apply. Deletes also need--yes. - All files or none. Every file in a plan is checked by the app’s own parser before the first byte is written.
- No network, no secrets. It reads and writes only the listed
.stackisettings files (plus component files forcomponentscommands). - One table, two front doors. The same commands run in a shell and as MCP tools for AI agents.
Not on npm yet. The
stackicommand is not published and is not bundled inside the Desktop app. Build it from a checkout of the Stacki repository (below). It runs on its own after that: the bundle is one file.
Install
Needs Node 22.18 or later and git.
git clone https://github.com/flowtricks/stacki.git cd stacki npm install npm run build:cli - Output:
dist/cli/stacki.cjs, a single executable file (about 11 MB). - Put it on your
PATHwithnpm linkfrom the checkout, or call it by path:
npm link stacki --version node /path/to/stacki/dist/cli/stacki.cjs --version --versionprintsstacki 1: the version of the output contract, not the app version.
Usage
stacki <command> [arguments] [options] - Options go before or after the command.
stacki --json doctorandstacki doctor --jsonare the same. - Project:
--project <dir>, otherwise the nearest folder at or above the current one that holds.stacki/or anastro.config.{mjs,ts,js,mts}. - Text output by default, one JSON line with
--json. - Any argument can also be written as a flag:
stacki config get --file guide --path settingsworks.
Help
| Command | Prints |
|---|---|
stacki --help, or no arguments | Every command the role may run |
stacki <command> --help, stacki help <command> | That command’s usage line, every argument, whether it writes, its feature and MCP tool |
stacki <group> --help, stacki help <group> | The commands in a group, for example stacki roles --help |
- Add
--as-role <role>to see only what that role may run.
Options on every command
| Option | Does |
|---|---|
--project <dir> | The project folder. Default: found from the current folder |
--json | Print the JSON envelope instead of text |
--apply | Write the plan. Without it nothing is written |
--yes | Confirm a command that deletes. Needed with --apply on those commands |
--wait <seconds> | Wait for another CLI writer to finish, 0 to 120. Default 0 |
--as-role <role> | Act as a role from .stacki/roles.json. --role works too, except on commands with their own role argument |
--login <github-login> | Act as the role roles.json gives that login. Or set STACKI_LOGIN |
--help | Print help: the command list, or one command’s usage |
- Booleans can stand alone:
--visibleis--visible true.--visible falseworks too. --name=valueand--name valueare the same.- An unknown option is refused (exit 2), never ignored.
Commands
write = prints a plan, writes with --apply. deletes = also needs --yes.
Read
| Command | Does |
|---|---|
stacki schema [file] | Key reference of one .stacki file: types, bounds, defaults, the commands that set each key. No file: lists all files |
stacki list <what> | components, apps, guides, breakpoints, roles or folders, as the project has them |
stacki doctor | Checks every .stacki file against the app’s parser and the key reference. Exits 1 when the app refuses a file |
stacki config get <file> [path] | One key, or the whole file, with its type and description |
stacki apps commands | Commands installed apps add to the CLI, and why any are off |
Settings
| Command | Access | Does |
|---|---|---|
stacki config set <file> <path> <value> | write | Sets one key. value is JSON; bare text is a string |
stacki config unset <file> <path> | write | Removes an optional key so the app uses its default |
stacki config add <file> <path> <value> [--position n] | write | Appends to a list (or adds an entry to a map). --position inserts at an index |
stacki config remove <file> <path> [value] | deletes | Removes a list entry (by value or position) or a map entry (by key) |
stacki undo <id> | write | Puts back what an apply changed, if the files still hold what it wrote |
<file>is an id fromstacki schema(guide,roles,breakpoints, …) or its.stacki/path.<path>reads likesettings.visible,entries[0],components["src/Card.astro"].tag.
Column guide
| Command | Access | Flags |
|---|---|---|
stacki guides set | write | --visible --numbers --color --opacity --columns --margin --gutter --width-max |
stacki guides clear <margin|gutter|widthMax|all> | deletes | none |
--columns:automatic, a count 2–32, or a project variable such as--site-columns.--margin,--gutter,--width-max: a length (16px,3rem), a variable (--site-margin) ordefaultto clear.--opacity: 0.06 to 0.2.--color: a literal CSS colour.
Breakpoints
| Command | Access | Does |
|---|---|---|
stacki breakpoints set <id> [--value n] [--unit rem|px] [--name text] | write | Moves a boundary or renames. desktop is the desktop width. --name default clears the name |
stacki breakpoints add <name> --value n --unit rem|px | write | Adds a breakpoint. --value and --unit are required |
stacki breakpoints remove <id> | deletes | Removes a breakpoint. Built-in ones cannot go |
stacki breakpoints sync <id> --value n [--unit rem|px] [--from length] [--places checked|all] | write | Moves the boundary and every media query that holds the old one |
breakpoints setchanges.stacki/breakpoints.jsononly. Your CSS is not touched.breakpoints syncdoes what Settings > Breakpoints does: it rewrites the boundary in.stacki/breakpoints.jsonand in every@mediaquery holding the old one, in stylesheets and in<style>blocks of pages and components.--unit: default the breakpoint’s current unit. Rem projects get rem.--from 64rem: the boundary the media queries still hold, whenbreakpoints.jsonwas already changed. Default: the saved boundary.--places checked(default): the places the Settings dialog ticks first.--places all: every place found.- Running the same sync again is a success with no change (exit 0).
desktopis refused: usestacki breakpoints set desktop --value n.
Roles
All need the cli:roles feature, which only admin holds. A project needs .stacki/roles.json first: create it in Settings > Roles.
| Command | Access | Does |
|---|---|---|
stacki roles add <name> | write | Adds a custom role with only cli:read |
stacki roles remove <role> | deletes | Removes a custom role |
stacki roles members add <role> <login> | write | Adds a GitHub login (and takes it out of any other role) |
stacki roles members remove <role> <login> | deletes | Removes a login |
stacki roles access grant <role> <feature> | write | Grants one feature, for example panel:cms, cli:guides |
stacki roles access revoke <role> <feature> | deletes | Takes one feature away |
stacki roles components hide <role> <path> | write | Hides a component or folder from the role’s insert menu |
stacki roles components show <role> <path> | write | Shows it again |
- After the command,
--roleand--loginfill the command’s own<role>and<login>:stacki roles members add editor --login newbieisstacki roles members add editor newbie. To act as a role, use--as-role.
Folders
| Command | Access | Does |
|---|---|---|
stacki folders add <kind> <folder> | write | Adds a project folder to a kind |
stacki folders remove <kind> <folder> | deletes | Removes it |
stacki folders reset <kind> | deletes | Back to the app’s default folders |
<kind>:components,layouts,assets,stylesorvariables.
Components
These change .astro files as well as .stacki files, with the same planner as the Components panel.
| Command | Access | Does |
|---|---|---|
stacki components rename <path> <name> | write | Renames and updates every import, tag, recipe and role rule |
stacki components move <path> <folder> | write | Moves to another folder, same updates |
stacki components duplicate <path> | write | Copies a component or folder under the first free name (FooCopy, foo-copy) |
stacki components delete <path> | deletes | Deletes an unused component or folder and the recipes and rules that name it |
- Names are normalised like the Rename dialog:
"Accordion Cards"→AccordionCards.astro, oraccordion-cards.astroin a project whose components are dashed. - A name with a character that cannot be kept (
til/e, an emoji), starting with a digit, or reserved (Fragment,Astro) is refused. deleteis refused withused in N placeswhile anything still uses the component.- Deleted files do not go to the system Trash. They are kept in the undo journal;
stacki undo <id> --applywrites them back. - Mentions the planner cannot safely change (plain text, a namespace tag) are listed as notes, not changed.
Apps
| Command | Access | Feature | Does |
|---|---|---|---|
stacki apps add <folder-or-zip> | write | cli:apps | Installs from a local folder or .zip. URLs, github: and npm: are refused |
stacki apps remove <app> | deletes | cli:apps | Removes the app folder, lock entry and its non-secret settings |
stacki apps settings set <app> <setting> <value> | write | cli:apps | Sets one non-secret setting |
stacki apps enable <app> [--network] | write | cli:roles | Turns on the app’s CLI commands and records that you trust it |
stacki apps disable <app> | write | cli:roles | Turns them off |
- An app can add its own commands:
stacki <app-id> <command>. They stay off until an admin appliesapps enable, and go off again when the app changes. --networkapproves network use the app declares. Node cannot block a module handler’s sockets, so this is a declaration you accept, not a sandbox.
Examples
All run against a real project. Plans first, then the apply.
# Health check and the file list stacki doctor stacki schema stacki schema guide # What the project has stacki list components stacki list breakpoints --json # Read one key stacki config get guide settings.opacity # Plan, then write stacki guides set --visible --opacity 0.1 stacki guides set --visible --opacity 0.1 --apply # Undo it, with the id the apply printed stacki undo mwklj10q36cb0907 stacki undo mwklj10q36cb0907 --apply # Settings by key stacki config set guide settings.color red stacki config add styles keep '".hero"' stacki folders add components src/blocks # Breakpoints: settings only, then settings and CSS stacki breakpoints set laptop --value 62 stacki breakpoints add Wide --value 1600 --unit px stacki breakpoints sync laptop --value 60 stacki breakpoints sync laptop --value 60 --apply # Help for one command stacki breakpoints sync --help # A rename across the whole project, planned stacki components rename src/components/Button.astro "Big Button" # A delete needs both flags stacki guides clear all --apply --yes What a plan prints:
Set the column guide. modify .stacki/guide.json settings.visible: false -> true settings.opacity: 0.06 -> 0.1 This is a plan: nothing was written. Add --apply to write it. JSON output
--json prints one line: an envelope with schemaVersion: 1. The shape is pinned by tests; a change bumps the version.
A plan:
{ "schemaVersion": 1, "ok": true, "command": "guides set", "project": "/Users/you/my-site", "role": "admin", "notes": [], "summary": "Set the column guide.", "mode": "plan", "applied": false, "files": [ { "file": ".stacki/guide.json", "action": "modify", "beforeDigest": "c420a375…", "afterDigest": "f75ac25a…", "changes": [ { "path": "settings.visible", "before": false, "after": true }, { "path": "settings.opacity", "before": 0.06, "after": 0.1 } ] } ] } A refusal:
{ "schemaVersion": 1, "ok": false, "command": "config set", "error": { "code": "unknown-key", "message": ".stacki/guide.json: \"settings.opactiy\" is not a setting (known here: visible, numbers, color, opacity, columns, margin, gutter, widthMax, columnDefaultsVersion). Run \"stacki schema guide\" for the reference" } } | Field | When | Holds |
|---|---|---|
ok | always | true or false |
command | always | The command’s words, config set |
mode | ok: true | read, plan or apply |
applied | ok: true | true only when files were written |
project | ok: true | Absolute project path |
role | ok: true | The role the command ran as |
files[] | ok: true | file, action (create modify delete move), from for a move, digests, changes[] (path, before, after) |
result | reads | The answer of a read command. Also on a failed doctor, with the findings |
notes[] | ok: true | Things to know that did not stop the command |
undoId | apply | The id stacki undo takes |
summary | ok: true | One line for a person |
error.code | ok: false | A stable code, below |
error.message | ok: false | A sentence for a person |
- A file’s
changeslist stops at 200 entries.
Exit codes
| Exit | Meaning | Codes |
|---|---|---|
| 0 | ok | |
| 1 | refused by a rule, nothing written | unknown-key invalid-value invalid-file missing exists required refused confirmation-required apply-required planner-unavailable unsupported-file app-untrusted |
| 2 | usage | usage not-a-project unknown-file bad-path |
| 3 | busy, retry | locked conflict |
| 4 | write failed, everything rolled back | write-failed internal |
| 5 | the role may not run it | role-denied |
stacki doctorin CI: exits 1 (invalid-file) when the app refuses any settings file; warnings alone exit 0.--jsoncarries the findings inresult.
What it reads and writes
| Commands | Reads | Writes (with --apply) |
|---|---|---|
schema, list, doctor, config get, apps commands | .stacki/*.json, component folders | nothing |
breakpoints sync | .stacki/breakpoints.json, stylesheets, pages, components | .stacki/breakpoints.json, .stacki/breakpoint-sync.json, the files whose media queries move |
config, guides, breakpoints, roles, folders, apps settings, apps enable | the target .stacki file | that file |
components | every file that references the component | those files, .stacki/components.json, .stacki/roles.json |
apps add, apps remove | the source folder or .zip | .stacki/apps/<id>/, .stacki/apps/apps.json, .stacki/apps/settings.json, .stacki/cli.json |
| any apply | .stacki/io/cli-journal/<id>.json (undo), .stacki/io/cli-project.lock while it runs |
Settable files (stacki schema lists them):
| File | Set by |
|---|---|
.stacki/guide.json | guides, config |
.stacki/breakpoints.json | breakpoints, config |
.stacki/breakpoint-sync.json | breakpoints sync, breakpoints remove, config |
.stacki/roles.json | roles, config (admin only) |
.stacki/components.json | components, config |
.stacki/component-sources.json | config |
.stacki/folders.json | folders, config |
.stacki/pages.json | config |
.stacki/publish.json | config |
.stacki/styles.json | config |
.stacki/variables.json | config |
.stacki/audits.json | config |
.stacki/instructions.json | config |
.stacki/apps/apps.json | apps add, apps remove |
.stacki/apps/settings.json | apps settings set |
.stacki/cli.json | apps enable, apps disable (admin only) |
Never read, printed or written: .stacki/preview/, .stacki/canvas/, .stacki/io/ (except the CLI’s own journal and lock), .stacki/studio/, .stacki/studio-app-secrets/, .stacki/studio-media/, .stacki/studio-cms/, .stacki/studio-app-storage/, .stacki/app-data/, .stacki/cms.json, installed app code in .stacki/apps/<id>/ (only apps add and apps remove touch it), .env, .mcp.json.
Safety
- Nothing is written without
--apply. Commands that delete refuse--applyalone withconfirmation-required. - Unknown keys are refused (
unknown-key), so a typo cannot become dead data the app ignores. - A file the app would refuse is never written, and an existing file the app refuses is never overwritten.
- Conflict-safe. Apply re-checks that each file still holds what the plan read (
conflictotherwise) and takes the same per-file lock the app takes (lockedotherwise). Both exit 3, nothing written. - One CLI writer at a time per project. A lock older than 10 minutes, or whose process is gone, is taken over.
- Rollback. On the first failed write, every file already written is put back (exit 4).
- Undo. Each apply journals what it changed; the last 16 are kept.
stacki undo <id> --applyrestores them while the files still hold what the apply wrote. - Roles are a guardrail, not a lock. On your own machine anyone who can run the CLI can pick another role or edit
roles.json. Without a role or login the CLI acts as the project owner (admin). The Studio server is what enforces roles for a team. - Every write feature is admin only until granted in Settings > Roles;
cli:readis held by every role.
Related command lines
| Command | Where | Does |
|---|---|---|
create-stacki | npm | Adds Studio to an Astro project, in ./studio. See Install |
astro-studio check-project | the Studio in ./studio | Validates editor metadata and reports unused selectors. Exits 1 on an invalid file |
stacki mcp | this CLI | The MCP server for AI agents |
create-stacki options: --yes (no prompt), --agent (print a setup prompt, change no files), --help, --version.
create-stacki asks how people sign in to Studio: GitHub (the default), Cloudflare Access, Google, SSO (OpenID Connect) or passkeys. To skip the question, pass --auth github|access|google|oidc|passkey, plus --auth-client-id, --auth-issuer, --auth-name, --auth-allowed-domains, --auth-allowed-emails, --auth-team-domain, --auth-aud, --auth-custom-domain and --auth-admin where the type needs them. --yes without --auth keeps GitHub. It never takes a client secret: it prints the wrangler secret put command to run. The GitHub App is still needed in every mode, because publishing goes through it. Desktop asks the same question in Settings > Stacki Studio (Add to project, then Change). Details: studio/docs/auth-providers.md and studio/docs/cloudflare.md in the Stacki repository.
astro-studio check-project
cd studio npm run build node dist/cli.mjs check-project .. - Checks
.stacki/components.jsonrecipes against your components, plusguide.json,pages.json,publish.json,styles.json,folders.json,component-sources.json. - Run it after moving or renaming components outside Stacki.
- Reports, never fails, on unused selectors:
Project component defaults, guide, page order, publish, styles and folder settings are valid. Style selectors: 0 unused of 696; 264 could not be proven either way. Lock names to keep in .stacki/styles.json. stacki doctorruns the same parsers without the component scan.astro-studiowith no command,helpor--helpprints its commands (exit 0); an unknown command prints them to stderr and exits 2.
Troubleshooting
| You see | Do |
|---|---|
command not found: stacki | Run npm link in the checkout, or call node /path/to/stacki/dist/cli/stacki.cjs |
Unknown command … | Check the spelling with stacki --help |
| How do I call this command? | stacki <command> --help prints its usage and every argument |
not-a-project | Run inside the project, or pass --project <dir> |
This is a plan: nothing was written | Add --apply |
confirmation-required | The command deletes: add --apply --yes |
unknown-key | Check the key with stacki schema <file>; the message lists the keys that exist |
invalid-value: … must be between 0.06 and 0.2 | The value breaks a bound from the key reference; stacki schema <file> shows bounds |
locked or conflict (exit 3) | The app or another CLI is writing. Retry, or add --wait 30 |
role-denied (exit 5) | Ask an admin to grant the named feature in Settings > Roles |
There is no .stacki/roles.json, so the only role is "admin" | Drop --as-role, or create roles in Settings > Roles |
The project has no .stacki/roles.json yet on roles add | Create roles in Settings > Roles first; it names the first admin |
Cannot safely update links through symbolic link … on rename | A symlink in the project blocks a safe rename; move or remove it first |
There is no undo entry … | Only the last 16 applies are kept |
breakpoints sync says nothing to move | The boundary is already saved. If media queries hold an older one, add --from 64rem |
breakpoints sync desktop refused | Desktop is not a media query: use stacki breakpoints set desktop --value n |
doctor exits 1 (invalid-file) | A settings file is refused by the app; stacki doctor --json lists which in result |
apps add refuses a URL | Install downloads from the Apps panel; the CLI installs local folders and .zips only |