@ref_digital/shopify-theme-cli
v1.0.2
Published
A safety-first convenience layer around the Shopify Theme CLI: store picker, pull before push, theme copies, Vite + Cloudflare tunnel dev server.
Readme
@ref_digital/shopify-theme-cli
A safety-first convenience layer around the Shopify Theme CLI, for Vite-powered themes.
yarn dev # pick a store → pull (optional) → tunnel → Vite + shopify theme dev
yarn deploy # commit check → pull → review → build → pick theme → push → publish (optional)What it adds on top of shopify theme:
- 🛍️ Store picker. It reads your stores from
shopify.config.ts. Production is tagged and sandboxes are grouped. - ☁️ Pull before push. A deploy pulls first, so edits made in the visual editor aren't overwritten. It also refuses to push DATA you haven't pulled.
- 👯♀️ New themes are copies. "A new theme" duplicates an existing one. Shopify's blank theme would lose every translation edited in the editor.
- ☂️ Live theme guards. Pushing to the live theme asks a second time, publishing is opt-in, and dev never touches the live theme.
- ⚡ Vite +
theme devtogether.theme devonly starts once Vite is ready, so hot reload works from the first page. - 🔗 Cloudflare tunnel. The visual editor and preview links can load your local CSS/JS. By default it is a free, random URL; you can also set up a stable one.
- 🌱 Noob mode.
--noobexplains every step before it happens, with its risk.
It never replaces your tooling: Vite runs from your project (--vite-command, --build-command), and any flag it doesn't own is forwarded to the Shopify CLI.
Contents
- @ref_digital/shopify-theme-cli
Requirements
- Node.js 24 or later, on macOS or Linux.
- Shopify CLI 4.x or 5.x, logged in to your stores. No tokens are stored: the CLI reuses its own login.
cloudflaredfor the tunnel:brew install cloudflared, or see Cloudflare's downloads. It's optional: dev works on localhost without it.- Vite with
vite-plugin-shopify5 (on GitHub).init --completesets both up. Not using Vite?init --agnosticsets the project up without it: the theme folder is uploaded as it is, or built by your own tooling.
Get Started
1. Init, from the project's folder. An empty folder works: init creates the package.json, then installs @ref_digital/shopify-theme-cli into the project along with the rest. It asks for the package manager (Yarn or pnpm), the setup and your store, then writes shopify.config.ts, adds the scripts below and offers a README.md.
npx @ref_digital/shopify-theme-cli@latest init # the stable release (without @latest, npx may run an older one it has cached)
npx @ref_digital/shopify-theme-cli@next init # a release channel: next, beta, alphaThe project gets the version that ran: @beta installs ^1.5.0-beta.1, as yarn add --dev @ref_digital/shopify-theme-cli@beta would. yarn dlx and pnpm dlx work too, and don't ask for the package manager. In a project that already has the CLI, run yarn theme-cli init:
yarn theme-cli init # asks: minimal, complete or agnostic, then addons
yarn theme-cli init --complete # also Vite, vite-plugin-shopify, TypeScript, Biome, entry points, theme folder
yarn theme-cli init --agnostic # no Vite: config and scripts, bring your own tooling (or none)In a project already set up, init offers add, remove, init again (to switch setups), update-readme or reset instead.
2. Scripts. init adds them, and you only need flags when a default doesn't fit:
"scripts": {
"dev": "theme-cli dev", // runs `vite dev`
"deploy": "theme-cli deploy", // runs `vite build` before pushing
"download": "theme-cli download",
"console": "theme-cli console",
"theme": "theme-cli theme"
}Some variations:
"dev": "theme-cli dev --vite-command 'vite dev --mode staging' --concurrently 'yarn watch:icons'",
"deploy": "theme-cli deploy --build-command 'yarn build:prod'",3. Run. Every question has a default (press enter), and every prompt can be skipped with a flag.
yarn dev
yarn dev --noob # first time, or showing someone aroundTip: working with Claude Code? Install Claude in Chrome so Claude can open the theme
devserves and check its UI work. See Claude Code.
Configuration
Every command reads shopify.config.ts. It's found in the current folder or the closest parent folder, and commands run from that folder (the project root). --config <path> points to another file. .mts, .js and .mjs work too.
// shopify.config.ts
import type { Config } from "@ref_digital/shopify-theme-cli";
export default {
themeRoot: "shopify",
viteTag: "vite-tag",
stores: {
default: { name: "Main", store: "my-shop", privateModePassword: "hunter2" },
sandboxes: [
{ name: "Staging", store: "my-shop-staging", description: "Shared staging store" },
{ name: "QA", store: "my-shop-qa", environment: "qa" },
],
},
ignore: {
download: ["templates/page.app-generated.json"],
},
} satisfies Config;The type import is erased at runtime: Node loads this file directly, and no build step is involved. Without "type": "module" in package.json, Node prints a warning on every run. init offers to add it, or writes shopify.config.mts instead.
Options
| Key | Type | Default | What it is |
| ----------- | -------------------------------------- | ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------- |
| stores | { default, sandboxes? } | required | Stores offered by the picker and matched by --store. See Stores. |
| themeRoot | string | "shopify" | Theme folder, relative to the config. Passed to the Shopify CLI as --path. |
| viteTag | string | "vite-tag" | The snippet vite-plugin-shopify writes (its snippetFile, without .liquid). dev waits for it before starting theme dev. |
| vite | boolean | true | false: no Vite (the Agnostic setup of init). See Without Vite. |
| ignore | { dev?, deploy?, download? } | {} | Extra --ignore globs, added to the built-in ones. See Ignore rules. |
| css | { breakpoints?, fluid?, container? } | see addons | Breakpoints and fluid ranges of the CSS helpers (css and tailwind-plus addons). Media queries always get rem. |
What changes from one run to the next is a flag rather than a config key: --vite-command, --vite-port, --build-command and --concurrently (see commands).
Without Vite
vite: false is what init --agnostic writes. It's for projects whose theme folder is uploaded as it is, or that bring their own tooling:
devrunsshopify theme devalone (no Vite, no tunnel). Watchers go in--concurrently, which starts once the theme is served.deployruns thebuildscript ofpackage.jsonbefore pushing, when there is one (or--build-command).addonly offers the addons that work without Vite (claude,editor), andCLAUDE.md, the skill and the editor settings leave Vite and TypeScript out.
To let theme-cli run Vite, switch the setup with init --minimal or init --complete (see changing the setup) rather than just removing the line: that also adds what the new setup brings.
Stores
type StoreConfig = {
name: string; // Required. Display name; what people pick, and what --store matches (case-insensitive)
store: string; // Required. The *.myshopify.com handle, passed as --store to the Shopify CLI
description?: string; // Shown under the option in the picker
privateModePassword?: string; // Storefront password, see below
[flag: string]: string | undefined; // Any other key is passed as `--<key> <value>`
};- The picker. With no sandboxes there is no prompt, and
defaultis used. One sandbox is offered directly; several are grouped under "Sandbox". Production is tagged, in orange when the command can change the store. - The store flag.
--storeaccepts thenameor thestorehandle, case-insensitive:--store main,--store MAINand--store my-shopall work. - Extra keys become Shopify CLI flags. Every key except
name,descriptionandprivateModePasswordis passed to every Shopify CLI call for that store.store: "my-shop"becomes--store my-shop, andenvironment: "qa"becomes--environment qa. - Storefront password.
privateModePasswordis the storefront password (/admin/online_store/preferences), not your account password, so it's fine to commit. It is sent as--store-password, only to the commands that render the storefront (dev,console). If you'd rather not commit it, read it from the environment:privateModePassword: process.env.STOREFRONT_PASSWORD. - Legacy array. An array of stores is still accepted. Index 0 is
default, and the rest aresandboxes.
CODE and DATA
Pulls and pushes are split into:
- DATA: content edited on the store (settings, section content, translations). That is
config/*.json,locales/*.json,blocks/*.json,sections/*.json,snippets/*.jsonandtemplates/*.json. - CODE: everything else.
This split is built in.
| Selection | theme pull | theme push |
| ----------- | ---------------------------- | ------------------------------------- |
| CODE + DATA | --ignore <download> | --ignore <deploy> |
| CODE only | --ignore <download> + DATA | --ignore <deploy> + --ignore DATA |
| DATA only | --only DATA | --only DATA |
Ignore rules
Globs are relative to themeRoot. The built-in rules keep Vite output out of the way. Your ignore rules are added to them.
| Key | Used by | Built in |
| ---------- | ------------------------------------------------------------- | ----------------------------------------------------- |
| dev | dev (theme dev) | assets/.vite/* |
| deploy | deploy, theme push | assets/.vite/* |
| download | download, theme pull, the pull step of dev and deploy | assets/.vite/*, assets/vite-*, **/vite-*.liquid |
Vite output (vite-*) is generated locally, so a pull must never overwrite it with the remote copy. A file an app keeps rewriting is also a good candidate for ignore.
Environment variables
| Variable | Effect |
| --------------------------- | -------------------------------------------------------------------------------------------------------- |
| CLOUDFLARE_TUNNEL_TOKEN | With CLOUDFLARE_TUNNEL_URL, dev uses this named tunnel instead of a quick one. |
| CLOUDFLARE_TUNNEL_URL | Public URL of that named tunnel. |
| THEME_CLI_DEBUG=1 | Prints every command (and its working folder) before it runs, plus stack traces. |
| TUNNEL_URL, TUNNEL_PORT | Set by dev for the Vite process, when the tunnel is up. Read by the Vite plugin. |
.env in the project root is loaded on start, if it exists. It's only needed for the tunnel token, which is a secret, so keep .env out of git (init --complete adds it to .gitignore).
Stable tunnel URL
By default dev opens a free quick tunnel: a random *.trycloudflare.com URL with no account, which changes on every run. For the same URL every time:
In Cloudflare Zero Trust, create a tunnel with a public hostname that points to
http://localhost:5173(or your--vite-port).Put its token and URL in
.env:CLOUDFLARE_TUNNEL_TOKEN=eyJh… CLOUDFLARE_TUNNEL_URL=https://dev-yourname.example.com
Local state
The CLI keeps a little state in node_modules/.cache/shopify-theme-cli/. It is never committed, and deleting it is harmless.
last-pull.json: when the last pull happened, and whether it covered CODE and/or DATA.deployreads it to allow skipping a fresh pull and to only push what was pulled.preferences.json: the noob level and run counts, per git user (see noob mode).
Coming from copied scripts/cli
Projects that copied the CLI before it was a package have a shopify.config.mjs with named exports. The CLI detects it and stops with a conversion guide. To convert it:
// before: export const STORES = …; export const IGNORE_RULES = …; export const DATA_RULES = …;
import type { Config } from "@ref_digital/shopify-theme-cli";
export default {
stores: STORES, // same shape
ignore: { download: ["**/page.app-generated.json"] }, // only your own rules: Vite output is built in
} satisfies Config;
// DATA_RULES is built in: delete it.Then replace the node scripts/cli/theme-*.mjs scripts with theme-cli <command>. --build-command keeps working. Delete kill:TUNNEL, since dev runs it on every start (and theme-cli kill-tunnel does it on demand).
Commands
Run theme-cli <command> --help for every flag in your terminal.
| Command | What it does |
| ------------------------- | -------------------------------------------------------------------------------------------- |
| theme-cli dev | Vite + shopify theme dev on your private preview theme, plus the optional tunnel |
| theme-cli deploy | Builds, then pushes CODE and/or DATA to a new or existing theme. Publishing is opt-in |
| theme-cli download | Pulls CODE, DATA and/or metafield definitions |
| theme-cli console | Liquid console on real store data |
| theme-cli theme <sub> | Any shopify theme command on a configured store (push gets the theme picker of deploy) |
| theme-cli init | Sets up a project, then asks for addons |
| theme-cli add | Adds addons: fonts, icons, Preact, CSS or Tailwind, generator, Claude Code |
| theme-cli remove | Removes addons, their files, settings and dependencies |
| theme-cli reset | Undoes init (every addon and .theme-cli.json), then offers to run it again |
| theme-cli update-readme | Writes README.md from what's set up: getting started, scripts, files |
| theme-cli new | Creates a section, block, snippet or component with its CSS entry (generator addon) |
| theme-cli kill-tunnel | Stops leftover tunnels and clears the Vite cache |
| theme-cli setup | Installs the see-links VS Code extension, run by postinstall (generator addon) |
Flag model
Each command owns a small set of flags. Everything else is forwarded untouched, in order, to the underlying shopify theme … command. No shell quoting is needed. Put -- before anything that must be forwarded even if its name matches one of ours.
Flags shared by dev, deploy, download, console and theme:
| Flag | Effect |
| -------------------------------- | -------------------------------------------------------------- |
| --store <name> | Store name or handle from the config. Skips the store picker |
| --noob[=0\|1\|2\|off\|disable] | Noob mode |
| --verbose | Forwarded to the Shopify CLI |
| --config <path> | Use this config file (any command) |
Every prompt has a flag, so the same commands work in scripts. Without a terminal (CI, pipes), noob mode never asks anything.
→ dev
Asks every question up front: store, pull, tunnel, browser. Then it runs Vite, shopify theme dev and your --concurrently commands side by side. Nothing prompts once they run, and keyboard input goes to theme dev, so its shortcuts keep working.
| Flag | Effect |
| ------------------------ | -------------------------------------------------------------------------------------------------- |
| --vite-command "<cmd>" | Starts Vite. Default: vite dev. Runs in a shell from the project root, node_modules/.bin first |
| --vite-port <port> | Where the tunnel points, also passed to Vite as TUNNEL_PORT. Default: 5173 |
| --concurrently "<cmd>" | Also runs this, once Vite and Shopify are ready. Repeatable |
| --open | Opens the browser without asking |
| --events-inspector | Starts with --standard-events-inspector without asking |
| --dangerously | Syncs onto a real theme instead of a private one. See dangerous mode |
| --theme <id\|name> | With --dangerously: the theme to sync onto (no picker) |
| anything else | Forwarded to shopify theme dev (e.g. --port 9393, --host 0.0.0.0, --live-reload off) |
It always passes --theme-editor-sync and --reconciliation-strategy=keep-local.
Start order. theme dev starts once Vite has written the Vite tag for this session (see How it works). --concurrently commands start once Vite is ready and theme dev serves its first page. Only Vite or Shopify stopping ends the session: a --concurrently command can exit, or fail, without stopping the others.
Without Vite (vite: false in the config, the Agnostic setup of init), dev runs shopify theme dev alone. The --concurrently commands start once it serves, and are the place for your own watchers. There's no tunnel question, since the tunnel only exposes Vite, and --vite-command / --vite-port are refused.
theme-cli dev --store Main --open
theme-cli dev --vite-command "vite dev --mode staging" --vite-port 5174
theme-cli dev --concurrently "yarn watch:icons" --concurrently "yarn storybook"
theme-cli dev --dangerously --theme my-branch→ deploy
These steps run in order:
- Commit check
- Pull (recommended)
- Review of what the pull changed
- Build
- CODE / DATA
- Theme
- Push
- Publish (optional)
See How it works for why each step exists.
| Flag | Effect |
| ---------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| --build-command "<cmd>" | Runs before pushing, in a shell from the project root. Default: vite build (without Vite: the build script, if any) |
| --theme <id\|name> | Pushes to this existing theme, with no picker |
| --live + --allow-live | Pushes to the live theme, with no picker and no live confirmation |
| --development | Pushes to your development theme |
| --deploy-method existing\|new | Skips the "Push to" question |
| --from-theme <id\|name\|scratch> | Source of the new theme (implies new) |
| --theme-name <name> | Name of the new theme (implies new). Fails if the name is taken |
| anything else | Forwarded to shopify theme push |
Without Vite (vite: false), the build step runs the project's build script when package.json has one, and is skipped otherwise.
--unpublished is ignored on purpose (see new themes are copies).
theme-cli deploy --store Main --theme 1234567890
theme-cli deploy --deploy-method new --from-theme 1234567890 --theme-name feature/x
theme-cli deploy --build-command "yarn build:prod && yarn size-check"→ download
Pulls CODE, DATA and/or metafield definitions. Metafield definitions are only used for editor autocompletion. It records what was pulled, and when, for deploy.
| Flag | Effect |
| -------------------- | ------------------------------------------------------------- |
| --theme <id\|name> | Pulls from this theme, without Shopify's picker |
| --data-opt-in | DATA starts unticked |
| anything else | Forwarded to shopify theme pull and theme metafields pull |
→ console
Opens a Liquid REPL on real store data. --url /products/foo sets the page context without asking. Everything else goes to shopify theme console.
→ theme <subcommand>
A pass-through: it adds the store, --path and the ignore rules, for example theme-cli theme list --json or theme-cli theme pull --only templates/index.json.
dev,deploy,consoleanddownloadare refused. Use the dedicated commands, which do the extra setup.pushis the exception: theme selection goes through the same picker asdeploy, including--theme,--live,--allow-liveand--development.pushgets thedeployignore rules, andpullgets thedownloadones.theme-cli theme --helpshows this help.theme-cli theme push --helpshows Shopify's.
→ init
Sets up the project you run it in. It never overwrites a file without asking, and asks nothing without a terminal.
It runs without being installed: npx @ref_digital/shopify-theme-cli@latest init (or @next, @beta, @alpha, or yarn dlx / pnpm dlx). The project then gets the version that ran, ^1.5.0-beta.1 for @beta, in the same install as the addons' dependencies. A folder without package.json gets one (named after the folder, private, ESM), asked first. Without a terminal, it's only created when no parent folder has one: that hints at init run from a subfolder by mistake.
In a project already set up (it has a .theme-cli.json), it stops there and asks what you meant instead: add, remove, init again (to change the setup), update-readme or reset (to start over), and runs the one you pick. Without a terminal, it exits with an error listing them.
- Package manager: the project's (lockfile,
packageManager, the one runninginit), else Yarn or pnpm, asked. Run through npx, it's always asked, with the project's preselected: npm isn't offered (--package-manager npmstill works). It's written topackageManager(.yarnrc.ymlgetsnodeLinker: node-moduleswith Yarn 2+). Corepack, which Node 25+ no longer ships, is offered when Yarn needs it. - The setup:
- Minimal: config, scripts and TypeScript. You bring Vite with
vite-plugin-shopify;devanddeployrun it. - Complete: Minimal plus Vite,
vite-plugin-shopify, entry points, the theme folder, Biome and VS Code settings. - Agnostic: config and scripts only, and
vite: falseinshopify.config.ts. There's no Vite and no TypeScript, and the theme folder is uploaded as it is.devrunsshopify theme devalone anddeployruns yourbuildscript, if there is one. Bring your own tooling (a CLI, Vite withoutvite-plugin-shopify, scripts) through--concurrentlyand abuildscript, or use none. Only the addons that work without Vite are offered (claude,editor); the others are hidden. The README it writes explains all of this.
- Minimal: config, scripts and TypeScript. You bring Vite with
- Addons, preselected for the setup.
- The store, then
shopify.config.ts, the theme folder, everything the addons write, and one install. - The README (
README.md, see update-readme): getting started, the scripts and the files that were set up. Created when there's none; an existing one can be replaced, added to (at its start or end) or kept. Without a terminal, only a missing one is written.
| Flag | Effect |
| -------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| --agnostic | Config and scripts only, vite: false: no Vite, no TypeScript, only the addons that work without Vite |
| --minimal | Config, scripts, TypeScript and a requirements check |
| --complete | Also: Vite, vite-plugin-shopify, vite.config.ts, entry points, theme folder, Biome, VS Code settings, .theme-check.yml, .gitignore, .env.example, .editorconfig |
| --addons <a,b> | Addons to add, without asking ("" for none). See addons |
| --store <handle> | The *.myshopify.com handle (required without a terminal) |
| --name <name> | Display name of that store. Default: Main |
| --password <password> | Storefront password, if the store has one |
| --theme-root <dir> | Theme folder. Default: shopify |
| --theme-source pull\|skeleton\|empty | When Vite is set up and the theme folder is empty: pull the live theme, Shopify's Skeleton theme, or empty folders |
| --package-manager yarn\|pnpm\|npm | When the project doesn't show one, or through npx (required there without a terminal, unless the project shows Yarn or pnpm) |
| --readme replace\|start\|end\|skip | An existing README.md: replace it, add to its start or end, or keep it. A missing one is created unless skip |
Changing the setup
Running init again switches a project to another setup: pick init from the menu, or pass --agnostic, --minimal or --complete. It works like add and remove combined:
- The installed addons that still fit stay. When asked interactively, any of them can be unticked. Addons that need Vite are removed when you switch to Agnostic.
- What the old setup brought and the new one doesn't (Vite, TypeScript, entry points…) is removed. Edited files are kept unless you say so.
- A kept
shopify.config.tsonly has itsvite: falseline added or removed.
theme-cli init --minimal # Agnostic → Minimal: you bring Vite, theme-cli runs it
theme-cli init --complete # → Complete: theme-cli sets Vite up
theme-cli init --agnostic # → Agnostic: back to no ViteWith Vite, layout/theme.liquid (and layout/password.liquid) render snippets/theme-head.liquid before </head>, which loads theme.css and theme.ts (and, with fonts, snippets/theme-preload.liquid after <head>, for the preloads). The Skeleton theme's own .git, docs, license and dotfiles are removed: the project has its own, and .theme-check.yml lives at the project root.
→ add / remove
Add or remove addons: fonts, icons, Preact, styling, the generator, the Claude Code setup…
| Flag | Effect |
| -------------- | ---------------------------------------------------------------------------------- |
| [addon...] | By name; without names, a list to pick from |
| --yes | Don't ask: edited files are kept. add --yes alone refreshes the installed addons |
| --no-layers | add css: no cascade layers |
| --no-install | Update package.json without installing |
theme-cli add icons fonts
theme-cli remove css && theme-cli add tailwind-plus→ update-readme
Writes README.md from what the project has when it runs: getting started (with its package manager and store), the theme-cli scripts in package.json (the project's own are left out) and the main files and folders. Run it again after add or remove. It's also the last step of init.
With no README.md, it offers to create one. With one, it asks: replace it, add to its start, add to its end, or keep it as is.
| Flag | Effect |
| ------------------------------------ | ---------------------------------------------------------------------------------------- |
| --readme replace\|start\|end\|skip | An existing README.md: replace it, add to its start or end, or keep it, without asking |
→ reset
Undoes init, to start over: every addon goes, core included (their files, settings, managed blocks and dependencies, as remove does), then .theme-cli.json. Edited files are kept unless you say so. The theme folder, README.md, .gitignore and what init set in package.json (type, packageManager) stay. It asks before deleting shopify.config.ts, then offers to run init again.
| Flag | Effect |
| -------------- | ------------------------------------------------------------------------------------------- |
| --yes | Don't ask (required without a terminal): edited files and the config stay, init isn't run |
| --no-install | Update package.json without uninstalling |
→ new
With the generator addon. Creates a section, block, snippet or component: the Liquid file, its CSS entry (rendered at the top of the Liquid file), an optional custom element, and @see links between them.
| Flag | Effect |
| -------------------------------------- | ------------------------------------------------------------- |
| [section\|block\|snippet\|component] | Asked when missing |
| [name] | kebab-case. A custom element needs a dash |
| --js | A custom element as the root (frontend/components/<type>s/) |
| --preact | The custom element is a Preact component (preact addon) |
| --private | Block: _name.liquid, only usable from code |
The CSS follows the styling addon: @layer components with cascade layers, @reference "../theme.css" with Tailwind.
→ kill-tunnel
Stops leftover cloudflared tunnel processes, deletes the cloudflared binary that vite-plugin-shopify brings along, and clears Vite's dependency cache. dev does it on every start. Note that it stops every cloudflared tunnel of your user, including other projects'.
→ setup
The postinstall script of the generator addon, so it runs on every install. It installs the see-links VS Code extension, which makes the @see [file](path) links written by the new command Cmd/Ctrl+clickable.
- Editors: VS Code, VS Code Insiders, Cursor and Windsurf, through their CLI on the
PATH(on macOS, also found in/Applicationswhen the CLI isn't on thePATH). - Skipped in CI (
CIset), for editors that already have this version, and for editors without a CLI. - Never fails the install: when an editor refuses the extension, it prints the path of the VSIX (in
node_modules/.cache/shopify-theme-cli/) to install by hand (Command Palette → "Extensions: Install from VSIX…").
Run it again with yarn postinstall (or theme-cli setup), then reload the editor window.
→ hook
hook guard|format are the Claude Code hooks of the claude addon, run for you.
Noob mode
Noob mode adds explanations around the regular prompts, with each step's risk. It never changes what a command does.
| Level | Shows |
| ---------------- | -------------------------------------------------------- |
| 0 beginner | Overview, every step explained, plus jargon and tips |
| 1 intermediate | Overview, every step explained |
| 2 expert noob | The list of steps, then one line per step (title + risk) |
| not a noob | Nothing extra |
Where the level comes from (first match wins):
| Source | Saved? | Notes |
| --------------------- | ------ | --------------------------------------------------------------------------------------- |
| --noob=0\|1\|2\|off | No | This run only (false works like off) |
| --noob=disable | Yes | Noob mode off for good, with no more noob questions |
| --noob | Yes | Always asks "What kind of noob are you?" |
| Saved preference | n/a | Asked on the very first run. While you're a noob, every run starts with "Still a noob?" |
While the saved level is a noob level, a check-in replaces "Still a noob?" every 20 deploys and every 80 dev sessions: "Are you still a noob, want to upgrade?".
Every step shows a risk, always in the same color:
| Risk | Color | Meaning |
| ------- | ------ | ----------------------------------------- |
| none | green | Nothing is changed |
| local | yellow | Changes files on your computer |
| store | orange | Changes the store, customers don't see it |
| live | red | Customers see the result |
Steps worth reading before going on, like "Start Vite + Shopify", end with "I understand, continue?". The level is saved per git user in node_modules/.cache/shopify-theme-cli/preferences.json.
Vite
theme-cli doesn't bundle anything itself. Your project runs its own Vite: dev starts it with --vite-command (default vite dev), and deploy builds with --build-command (default vite build). For this to work, Vite needs vite-plugin-shopify (on GitHub), which writes the snippet that loads your assets in the theme.
There are two ways to set it up.
With the plugin (recommended)
yarn add --dev vite vite-plugin-shopify// vite.config.ts
import shopify from "@ref_digital/shopify-theme-cli/vite";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [shopify()],
});shopify():
- Sets up the Shopify plugin. It gives
vite-plugin-shopifythethemeRootandsnippetFilefromshopify.config.ts, so the CLI and Vite always agree on them. - Wires in the tunnel. When
devstarts it,TUNNEL_URLbecomes the plugin'stunnel, and the dev server listens on exactlyTUNNEL_PORT, the port the tunnel points to. CORS is opened so theme previews on a custom domain can load the scripts. - Names the build output. Files are named
vite-[name].[hash], which the built-in ignore rules rely on to keep Vite output out of pulls. - Keeps the assets folder clean. Theme and app files also live in
assets/, so it isn't emptied. Instead, after each build, thevite-files the build didn't produce are removed. - Targets your browsers.
build.targetcomes from package.json'sbrowserslist(JS syntax, CSS prefixes and lowering), and the modulepreload polyfill is left out. - Inlines early scripts.
frontend/inline/<name>.tsbecomessnippets/vite-inline-<name>.liquid, a minified<script>for what must run before first paint. - Runs the addons' features turned on by its options (
fonts,icons,preact,tailwind,postcss,visualizer): see features and addons. - Restarts on config changes.
devrestarts whenshopify.config.tschanges (breakpoints included).
It takes the other vite-plugin-shopify options (sourceCodeDir, entrypointsDir, additionalEntrypoints, versionNumbers, …) and config (the path of shopify.config):
shopify({ entrypointsDir: "src/entrypoints", versionNumbers: true });Features
Each feature is off by default and takes true (on, with the defaults), false, or an object (on, with these options). Start with true; switch to an object when you need more:
import postcssNesting from "postcss-nesting";
shopify({
fonts: true,
// @preact/preset-vite's options, plus the React Compiler.
preact: { compiler: true, devToolsEnabled: false },
// The helpers, then your own plugins.
postcss: { plugins: [postcssNesting()] },
visualizer: { template: "sunburst" },
});| Option | Object |
| --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| fonts | (no options) |
| icons | (no options) |
| inlineScripts | (no options, default true) |
| preact | @preact/preset-vite's options, plus compiler: true or the React Compiler options |
| tailwind | @tailwindcss/vite's options (optimize defaults to off with postcss, see below) |
| postcss | plugins: more PostCSS plugins, run after the helpers. mixinsFiles: the postcss-mixins definitions (default frontend/styles/mixins/*.{css,js,mjs}) |
| visualizer | rollup-plugin-visualizer's options, over the defaults (report in node_modules/.cache, gzip and brotli sizes, opened) |
With postcss, the plugin sets Vite's css.postcss, so a postcss.config.js is ignored: list its plugins in postcss.plugins instead. With tailwind and postcss together, Tailwind runs first and leaves minifying to Vite (its Lightning CSS pass would reject @media (--md) before the helpers resolve it).
React Compiler
Opt-in: install oxc-transform-react (on npm) with yarn add --dev oxc-transform-react, then set preact: { compiler: true }. It runs the React Compiler on your components and hooks before JSX is compiled: values, callbacks and JSX are memoized at build time, so useMemo, useCallback and memo() aren't needed by hand. oxc-transform-react is Oxc's Rust port of the compiler, still experimental: review the output before relying on it. It uses the React 18 target: its small runtime is served on preact/hooks, so nothing from React ships.
- Only your code is compiled (
node_modulesis skipped). - Opt a function out with the
"use no memo"directive at the top of its body. - Options go to the compiler, e.g. only functions marked
"use memo":compiler: { compilationMode: "annotation" }.reportDiagnostics: trueprints why a function was skipped. - The compiler expects the Rules of React (no mutation of props or state, hooks called unconditionally). Code that breaks them may misbehave once memoized: turn the compiler off (
preact: true) to check.
The global entry points render in snippets/theme-head.liquid (end of <head>), and each section, block or snippet loads its own CSS at the top of its file:
{%- liquid
render 'vite-tag', entry: 'theme.css', preload_stylesheet: true
render 'vite-tag', entry: 'theme.ts'
-%}{%- # sections/featured-collection.liquid -%}
{%- render 'vite-tag', entry: 'sections/featured-collection.css' -%}Components load by tag, from theme.ts:
import { autoload } from "@ref_digital/shopify-theme-cli/client";
// frontend/components/<tag>.ts is imported the first time <tag> is on the page.
autoload(import.meta.glob("../components/**/*.{ts,tsx}"));Why this split: see addons.
Without the plugin
Use vite-plugin-shopify directly, and keep these in line with shopify.config.ts:
// vite.config.ts
import { defineConfig, loadEnv } from "vite";
import shopify from "vite-plugin-shopify";
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), "");
return {
plugins: [
shopify({
themeRoot: "shopify", // = themeRoot
snippetFile: "vite-tag.liquid", // = viteTag + ".liquid"
tunnel: env.TUNNEL_URL || false, // set by `theme-cli dev`
}),
],
server: env.TUNNEL_PORT
? { port: Number(env.TUNNEL_PORT), strictPort: true, cors: { origin: true } }
: undefined,
build: {
emptyOutDir: false,
rolldownOptions: {
output: {
// `vite-` prefix: the built-in ignore rules keep these files out of pulls.
entryFileNames: "vite-[name].[hash].js",
chunkFileNames: "vite-[name].[hash].js",
assetFileNames: "vite-[name].[hash][extname]",
},
},
},
};
});Without the cleanup the plugin does, stale vite-* files pile up in assets/. @driver-digital/vite-plugin-shopify-clean (on npm) handles that.
Not using Vite's dev server?
dev always waits for the Vite tag snippet to point at a dev server (the snippet must contain /@vite/client, plus the tunnel URL when there is one). If your setup names the snippet differently, set viteTag in shopify.config.ts.
Addons
Addons are tooling shipped with this package (Vite plugins, CSS helpers, a generator, the Claude Code setup…) and wired into a project by theme-cli add. init asks for them right after the setup (Agnostic, Minimal or Complete).
theme-cli add # pick from a list
theme-cli add icons fonts # by name
theme-cli remove visualizer # files, settings and dependencies go away
theme-cli add --yes # refresh: untouched files follow this version's templatesWhat each addon adds
| Addon | Adds |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| claude | Always on. CLAUDE.md (a managed block), the theme-cli skill, plugins, permissions, hooks. See Claude Code |
| editor | Biome, Theme Check, .editorconfig, VS Code settings and extensions. Comes with Complete. See Editor and linting |
| fonts | frontend/fonts/, frontend/styles/fonts.css, and vite-font-preload to preload hashed font files from snippets/theme-preload.liquid (start of <head>) |
| icons | frontend/icons/**/*.svg → snippets/vite-icon-<name>.liquid, optimized by SVGO, single-color icons in currentColor |
| preact | Preact components used as custom elements (preact-custom-element), loaded by tag like any component |
| css | Pure CSS + PostCSS helpers, optional cascade layers, stylelint |
| tailwind | Tailwind CSS v4 |
| tailwind-plus | Tailwind v4 + a toolkit (utilities, variants), one breakpoints list, the PostCSS helpers |
| generator | new: sections, blocks, snippets, components with their CSS entry, plus the see-links VS Code extension |
| visualizer | build:visualize: a treemap of the bundles (rollup-plugin-visualizer) |
init preselects claude for Minimal, claude and editor for Agnostic, and claude, fonts, icons, generator and visualizer for Complete. Preact is left to you, and styling (one of css, tailwind, tailwind-plus, or none) is its own question after the list. Before the list, init prints what the mode sets up. Without a terminal: init --addons a,b and add a b --yes.
Most addons need Vite: picking one in Minimal sets Vite up too (as Complete does), so the theme folder question comes up. The Agnostic setup (vite: false in shopify.config.ts) has no Vite, so those addons don't show up there at all: only claude and editor do. add refuses the others by name. Switching to Minimal or Complete (init --minimal, init --complete, see changing the setup) brings them back.
Every project with Vite also gets, whatever it picks (Minimal gets the TypeScript part):
- TypeScript,
tsconfig.json(with Vite's@/alias) andfrontend/types/theme.d.ts(window.Shopify, theme editor events). - Inline scripts.
frontend/inline/<name>.ts→snippets/vite-inline-<name>.liquid, a minified<script>for the little code that must run before first paint. - A build target. It comes from
browserslistin package.json: JS syntax and CSS (Lightning CSS) are lowered for those browsers only, and the modulepreload polyfill is left out.
How CSS and JS reach the page
The aim: no single big CSS and JS file. Pages only load what they render.
Global:
snippets/theme-head.liquid, rendered at the end of<head>bylayout/theme.liquid, loadstheme.css(preloaded) andtheme.ts. Keep them small. Withfonts,snippets/theme-preload.liquidis rendered at the start of<head>, before any stylesheet, for the preloads (fonts, the image above the fold): they're requested first. Something only a template needs can be rendered there conditionally:{%- if template.name == 'product' -%} {%- render 'vite-tag', entry: 'product.ts' -%} {%- endif -%}CSS per section, block or snippet:
frontend/entrypoints/sections/<name>.css, rendered first thing in the section, so it's only requested where the section is:{%- render 'vite-tag', entry: 'sections/<name>.css' -%}JS by tag:
theme.tsrunsautoload(import.meta.glob("../components/**/*.{ts,tsx}"))(from@ref_digital/shopify-theme-cli/client).frontend/components/<tag>.tsis imported the first time<tag>is on the page, sections added later included (theme editor, Section Rendering API).This rather than a
vite-tagper section for JS: each entry adds a branch to the generatedvite-tagsnippet, a section rendered twice would load its script twice, and a section injected by the theme editor wouldn't run it.
Styling
One styling addon at a time: theme-cli remove css && theme-cli add tailwind-plus switches.
PostCSS helpers (css, tailwind-plus)
| Write | Get |
| ----------------------------- | ------------------------------------------------------------------------------------ |
| --rem(16 24) | 1rem 1.5rem (px or unitless; 0, auto, var(), % kept) |
| --fluid(16, 40) | clamp(1rem, … + …vw, 2.5rem), from 16px to 40px across the fluid range |
| --fluid(16, 40, md, 1440px) | the same between two breakpoints or lengths |
| --fluid-cq(16, 40) | against the container's width (cqi), 320px → 768px by default |
| @media (--md) | (width >= md), and (--below-md), (--hover), (--motion), (--reduced-motion) |
They come from css in shopify.config.ts (init writes it; without it, these defaults apply):
export default {
// …
css: {
// @media (--md) / (--below-md), and Tailwind's md: (tailwind-plus). Media queries get rem.
breakpoints: { sm: "640px", md: "768px", lg: "1024px", xl: "1280px", "2xl": "1536px" },
// --fluid(min, max) goes from min to max between these (names or px).
fluid: ["sm", "xl"],
},
} satisfies Config;Values are px (or rem), and a value can name another breakpoint (tablet: "md"). Media queries always get rem: @media (--md) is (width >= 48rem), and so is Tailwind's md:.
The @custom-media are generated into node_modules/.cache/shopify-theme-cli/media.css (every CSS file sees them), and changing shopify.config.ts restarts dev. Mixins (postcss-mixins) can go in frontend/styles/mixins/.
Pure CSS (css)
Native CSS with nesting, the helpers above, and stylelint: stylelint.config.mjs extends stylelint-config-standard and the package's preset, @ref_digital/shopify-theme-cli/stylelint (the helpers allowed, BEM class names, rem() flagged for --rem()), and overrides go in its rules. frontend/styles/ holds tokens.css and base.css.
With cascade layers (asked, on by default), theme.css starts with @layer theme, base, components, utilities; (Tailwind's order) and new wraps a section's CSS in @layer components. Unlayered CSS (apps, the theme editor) beats every layer: that's the point, and the reason to say no if you rely on overriding app styles.
Tailwind (tailwind, tailwind-plus)
Tailwind v4 through @tailwindcss/vite. Classes in Liquid are detected automatically. A section's own CSS starts with @reference "../theme.css"; (Tailwind's theme and @apply without a second copy of Tailwind).
tailwind-plus adds:
- One breakpoints list.
@plugin "@ref_digital/shopify-theme-cli/tailwind"sets Tailwind's breakpoints fromcss.breakpoints:md:and@media (--md)always match. - The toolkit, from
@import "@ref_digital/shopify-theme-cli/tailwind.css":section-py-*/section-my-*: vertical rhythmsection-x-*: content width with a gutterauto-fill-*/auto-fit-*: gridsoverflow-inset*,box-trim,masked-*,icon-fill-*/icon-stroke-*
- Variants (
@plugin "@ref_digital/shopify-theme-cli/tailwind"):pseudo:,if-exists-[…]:,follows-[…]:,precedes-[…]:,if-child-data-[…]:. - The PostCSS helpers, after Tailwind: usable in
@themeand arbitrary values (p-[--fluid(16,40)]). Tailwind can't compute with them (--spacing(--rem(4))doesn't work). Tailwind's own optimization is off, Vite's minifier does it after PostCSS.
Editor and linting
editor (part of Complete, and an option in the other setups) sets up Biome (extending the @ref_digital/shopify-theme-cli/biome preset), Theme Check, .editorconfig and VS Code. The VS Code side follows the styling:
| Styling | Recommended extensions | Settings |
| ---------------- | -------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| Tailwind | bradlc.vscode-tailwindcss | Tailwind IntelliSense in Liquid (class: '…', {% capture …_class %}) |
| Pure CSS or none | stylelint.vscode-stylelint, vunguyentuan.vscode-css-variables, Zignd.html-css-class-completion, pranaygp.vscode-css-peek | A global Tailwind IntelliSense turned off |
yarn check runs typecheck, lint (Biome, plus stylelint with css) and lint:theme (Theme Check, with .theme-check.yml at the project root ignoring Vite's output).
Without Vite (Agnostic), it's Biome, Theme Check and the editor basics only: there's no TypeScript or CSS tooling to configure, the recommended extensions are Biome, Theme Check and td-snippets, and check runs lint and lint:theme. Biome leaves the theme folder out in every setup (files.includes in biome.jsonc).
Claude Code
claude is always installed, and generic: it describes the tooling, not the project.
- The CLAUDE.md block: in
CLAUDE.md, between<!-- theme-cli:claude -->markers (addons, commands, what never to do). The rest of the file is yours. - The skill, named
theme-cli(.claude/skills/theme-cli/): where code goes, how assets load, the commands, and one reference per installed addon. Copied into the project (agents don't searchnode_modules) and refreshed byadd/remove. - Settings, in
.claude/settings.json: theshopify-ai-toolkit,claude-md-managementandfrontend-designplugins; permissions (build/lint/check allowed, deploy and pushes asked, delete/publish and.envdenied); hooks. - Without Vite (Agnostic),
CLAUDE.mdand the skill describe a theme folder uploaded as it is, the permissions only list the scripts the project has, and there's noguardhook. - Hooks, through the installed package (
theme-cli hook):guardrefuses edits to Vite's output (thevite-files),formatruns Biome on edited files (the.editorconfigbasics on Liquid and Markdown). Beforeinstallthey do nothing, and a session-start hook tells the agent dependencies are missing.
Checking UI work. For Claude to see what it changed, we recommend Claude in Chrome: it lets Claude open the theme dev serves (http://127.0.0.1:9292) in your browser and look at the result.
How add, remove and refresh work
.theme-cli.json (commit it) lists the addons and a hash of each file they wrote. Every run compares what the previous selection wanted with what the new one wants:
- Files are created when missing, follow the template while untouched, and are kept once you edit them. When an addon would now write something else in an edited file (switching styling rewrites
theme.css), you're asked first; with--yesit's kept, and a note says what changed. - Settings (
package.jsonscripts,tsconfig.json,.vscode/*.json,biome.jsonc,.claude/settings.json) are merged value by value: comments and your own values stay, a value you changed is kept.package.jsonscripts are then grouped under_____STORE_____,_____BUILD_____,_____CHECKS_____… header keys, after your own scripts. - Managed blocks (
CLAUDE.md,snippets/theme-head.liquid,snippets/theme-preload.liquid, therender 'theme-head'/render 'theme-preload'in the layouts) are rewritten between their markers only. - Dependencies are installed in one pass, and removed with the last addon needing them.
remove deletes untouched files, and asks about edited ones. A settings file left with only empty objects and arrays, or a block file with only its header, is deleted too; .gitignore lines stay. reset does the same for every addon, core included. Updating the package and running theme-cli add --yes brings untouched files to the new templates.
The Vite plugin
The addons' Vite features are options of shopify() (@ref_digital/shopify-theme-cli/vite), listed in vite.config.ts. theme-cli add / remove keep the list up to date while the file is untouched; once you've edited it, they ask (or tell you which option to set). Turning a feature off is one line:
export default defineConfig({
plugins: [
shopify({
fonts: true,
icons: false, // snippets aren't generated anymore
postcss: true,
}),
],
});| Option | Addon | Does |
| --------------- | --------------------------- | ---------------------------------------- |
| fonts | fonts | vite-font-preload snippet |
| icons | icons | vite-icon-* snippets |
| preact | preact | @preact/preset-vite |
| tailwind | tailwind, tailwind-plus | @tailwindcss/vite |
| postcss | css, tailwind-plus | The PostCSS helpers |
| visualizer | visualizer | With vite build --mode visualize |
| inlineScripts | (always, default true) | frontend/inline/*.ts → vite-inline-* |
Each option also takes an object: the feature on, with options (PostCSS plugins of your own, @preact/preset-vite's options…). With preact: { compiler: true }, the React Compiler memoizes components (opt-in). See Features for every option.
How it works
Why each safeguard exists, and what it does.
Pull before push
The store can hold changes that are not in git, usually content edited in the visual editor. A push would erase them, so deploy always offers to pull first.
- The pull is blocked until the theme folder has no uncommitted changes, so it can't overwrite local work. Uncommitted changes elsewhere only trigger a warning, since they end up in the build.
- If the pull changes files, the deploy waits until you review and commit them. What is committed is what gets pushed.
- You can decline the pull only if the last one is under 2 minutes old.
- The CODE / DATA you push is limited to what was just pulled. Pushing DATA you didn't pull is disabled, because you would be overwriting content you never looked at.
New themes are copies
Translations edited in the visual editor live on the theme, not in locales/*.json. A blank theme (Shopify's --unpublished, or "create a new theme") silently loses them.
So "A new theme" runs shopify theme duplicate on a source theme, waits until Shopify reports the copy finished (processing: false), then pushes onto the copy. Waiting matters because an early push can be overwritten by the background copy. "Empty theme" is still offered, with a warning.
- A new theme needs CODE and DATA, otherwise it would be incomplete.
- The name defaults to the
