diff --git a/README.md b/README.md index 8c83357a54..8f8333dd29 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,13 @@ # Shopify CLI + Twitter Followers License ![badge](https://github.com/Shopify/cli/actions/workflows/shopify-cli.yml/badge.svg) With the Shopify command line interface (Shopify CLI 3.0), you can: + - initialize, build, dev, and deploy Shopify apps, extensions, functions and themes - build custom storefronts and manage their hosting @@ -24,6 +26,7 @@ Install the latest version of [Node.js](https://nodejs.org/en/download/) and [n When you’re building a Shopify app, you can initialize your project using your preferred package manager. A single command will install all the dependencies you need β€” including Shopify CLI itself. Initialize your project using one of the following commands: + - `npm init @shopify/app@latest` (installed by default with Node) - `pnpm create @shopify/create-app@latest` - `yarn create @shopify/app` @@ -47,12 +50,35 @@ Learn more in the docs: [Shopify CLI for themes](https://shopify.dev/docs/storef ## Developing Hydrogen custom storefronts with Shopify CLI ## -The Hydrogen code lives here: https://github.com/Shopify/hydrogen/tree/main/packages/cli +The Hydrogen code lives here: Learn more in the docs: [Shopify CLI for Hydrogen storefronts](https://shopify.dev/docs/custom-storefronts/hydrogen/cli)

 

+## Agent Skill + +The repo includes an [Agent Skill](https://agentskills.io) at `skills/shopify-cli/` that injects Shopify CLI knowledge directly into the agent's context. This follows the open [Agent Skills format](https://agentskills.io/specification) and works with any compatible agent β€” Claude Code, Cursor, Gemini CLI, VS Code, and others. + +The skill is auto-discovered based on task context (e.g. when the user mentions Shopify themes or apps). It works with or without the MCP server: + +- **With the MCP server:** The agent uses MCP tools for execution (structured responses, auto-parsed JSON, auth detection) +- **Without the MCP server:** The agent runs `shopify` commands directly via shell + +Install the skill with the [skills CLI](https://skills.sh): + +```sh +npx skills add Shopify/cli --skill shopify-cli +``` + +Or using the full path: + +```sh +npx skills add https://github.com/Shopify/cli/tree/main/skills/shopify-cli +``` + +

 

+ ## Help πŸ– If you encounter issues using the CLI or have feedback you'd like to share with us, below are some options: diff --git a/skills/shopify-cli/SKILL.md b/skills/shopify-cli/SKILL.md new file mode 100644 index 0000000000..6f1490996c --- /dev/null +++ b/skills/shopify-cli/SKILL.md @@ -0,0 +1,124 @@ +--- +name: shopify-cli +description: Runs Shopify CLI commands for theme and app development. Handles theme push, pull, dev, check, publish, and app dev, deploy, build. Use when the user mentions Shopify themes, Shopify apps, Liquid templates, storefronts, or needs to interact with a Shopify store. +metadata: + author: shopify + version: "1.0" +--- + +# Shopify CLI + +Runs [Shopify CLI](https://shopify.dev/docs/api/shopify-cli) commands for theme and app development workflows. + +## Non-interactive execution + +The CLI is designed for interactive terminal use. For AI-assisted execution, always apply these flags: + +- `--force` or `-f` to skip confirmation prompts +- `--no-color` to disable ANSI escape codes +- `--json` when available for structured, parseable output +- `theme check` uses `--output json` instead of `--json` + +## Store resolution + +Before running any store-scoped command, determine the target store: + +1. Check if the user specified a store in their request +2. Look for `shopify.theme.toml` or `shopify.app.toml` in the project +3. Check if `SHOPIFY_FLAG_STORE` env var is set +4. If none found, ask the user + +## Authentication + +If a command fails with an auth error ("not logged in", "session expired"): + +1. Run `shopify auth login --store ` (allow ~2 minutes for browser OAuth) +2. Retry the original command after login succeeds + +## Command reference + +### Theme commands + +| Task | Command | Notes | +|------|---------|-------| +| List themes | `shopify theme list --json` | Returns theme IDs, names, roles | +| Theme info | `shopify theme info --json` | Details about a theme | +| Push | `shopify theme push --force --json` | Upload local to remote | +| Pull | `shopify theme pull --force` | Download remote to local | +| Check quality | `shopify theme check --output json` | Theme Check linting | +| Dev server | `shopify theme dev` | Long-running β€” start in separate terminal | +| Publish | `shopify theme publish --force` | Make a theme live | +| Delete | `shopify theme delete --force` | Remove a theme | +| Rename | `shopify theme rename --name ` | Rename a theme | +| Duplicate | `shopify theme duplicate --force --json` | Copy a theme | +| Init | `shopify theme init ` | Scaffold from starter theme | +| Package | `shopify theme package` | Create .zip for distribution | +| Share | `shopify theme share` | Create shareable preview link | +| Profile | `shopify theme profile --json` | Liquid performance profiling | +| Metafields | `shopify theme metafields pull --force` | Download metafield definitions | + +### App commands + +| Task | Command | Notes | +|------|---------|-------| +| Dev server | `shopify app dev` | Long-running β€” start in separate terminal | +| Deploy | `shopify app deploy --force` | Deploy app to Shopify | +| Build | `shopify app build` | Build the app | +| Generate extension | `shopify app generate extension` | Scaffold a new extension | +| App info | `shopify app info --json` | App configuration details | +| Function run | `shopify app function run` | Run a function locally | +| Release | `shopify app release --version ` | Release an app version | +| Versions list | `shopify app versions list --json` | List deployed versions | + +### Auth commands + +| Task | Command | +|------|---------| +| Log in | `shopify auth login --store ` | +| Log out | `shopify auth logout` | + +## Key flags + +- `--store ` / `-s` β€” target store (e.g. `my-store.myshopify.com`) +- `--theme ` / `-t` β€” target theme +- `--path ` β€” project directory (default: cwd) +- `--json` β€” structured output +- `--force` / `-f` β€” skip confirmation prompts +- `--no-color` β€” disable ANSI colors +- `--only ` / `--ignore ` β€” filter files for push/pull +- `--development` / `-d` β€” target the development theme +- `--live` / `-l` β€” target the live theme + +## Workflows + +See [references/workflows.md](references/workflows.md) for common multi-step workflows including: +- Creating a new theme +- Iterating on an existing theme +- Creating and deploying an app + +## Discovery + +Run `shopify --help` or `shopify --help` to discover commands and flags not listed above. + +## Output handling + +- Parse `--json` output as structured data and summarize for the user +- For non-JSON output, present the relevant portions +- Long-running commands (`theme dev`, `app dev`) should be started in a separate terminal, not through an MCP server or automated tool + +## Interactive commands + +Some commands prompt for input that `--force` cannot suppress. These may hang when run non-interactively: +- `app init` β€” prompts for template and app name +- `app generate extension` β€” prompts for extension type and name (use `--template` and `--name` to pre-fill) +- `theme dev` / `app dev` β€” long-running server processes (start in a separate terminal) + +If a command appears to hang, it is likely waiting for interactive input. Cancel it and check `--help` for flags that provide the needed values. + +## Destructive commands + +Before running commands that delete, publish, or deploy, always confirm with the user first: +- `theme delete` β€” permanently removes a theme +- `theme publish` β€” makes a theme live (replaces the current live theme) +- `app deploy` β€” deploys to production +- `app release` β€” releases an app version to users diff --git a/skills/shopify-cli/references/workflows.md b/skills/shopify-cli/references/workflows.md new file mode 100644 index 0000000000..d6bdc322cb --- /dev/null +++ b/skills/shopify-cli/references/workflows.md @@ -0,0 +1,105 @@ +# Shopify CLI Workflows + +Common multi-step workflows for theme and app development. + +## Create a new theme + +```bash +shopify theme init my-theme +cd my-theme +shopify theme dev --store +``` + +The `init` command clones the Skeleton starter theme. Use `--clone-url ` to start from a different repo, or `--latest` to pin to the latest release tag. + +## Iterate on an existing theme + +```bash +# Pull the latest version of a theme to work on locally +shopify theme pull --theme --force + +# Or pull the live theme +shopify theme pull --live --force + +# Start the dev server for live preview while editing +shopify theme dev --store + +# Make edits to Liquid, CSS, JSON files as needed... + +# Check for errors before pushing +shopify theme check --output json + +# Push changes back to the store +shopify theme push --force --json +``` + +Use `--development` / `-d` with push/pull to target the development theme specifically. Use `--only` and `--ignore` to limit which files are synced (e.g. `--only "sections/*"` or `--ignore "config/settings_data.json"`). + +## Create a new app + +```bash +# Interactive β€” prompts for template and name +shopify app init +cd + +# Start local dev server (long-running β€” run in separate terminal) +shopify app dev +``` + +Note: `app init` is interactive and will prompt for a template and app name. It cannot be fully automated with flags. + +## Add an extension to an app + +```bash +# Interactive β€” prompts for extension type and name +shopify app generate extension +``` + +Note: `app generate extension` is interactive. Use `--template ` and `--name ` to pre-fill values, but the CLI may still prompt for additional configuration. + +## Build, deploy, and release an app + +```bash +# Build the app +shopify app build + +# Deploy to Shopify (creates a new version) +shopify app deploy --force + +# Release a specific version to users +shopify app release --version + +# Check app info and configuration +shopify app info --json + +# List deployed versions +shopify app versions list --json +``` + +## App function development + +```bash +# Run a function locally +shopify app function run --path + +# Generate function types +shopify app function typegen --path +``` + +## Check and push (theme quality gate) + +```bash +shopify theme check --output json +# If no errors: +shopify theme push --force --json +``` + +## List and inspect themes + +```bash +# List all themes +shopify theme list --json + +# Get details about a specific theme +shopify theme info --theme --json +```