Shopify CLI
$ shopify 官方出品 中风险Shopify CLI 可自动化脚手架创建、Hydrogen 店面开发、Shopify Functions 构建以及面向测试或线上商店的 Liquid 主题同步。通过 --store 与浏览器 OAuth 约束操作范围,但本地开发服务与监听命令属于长驻交互流程。
brew install shopify-cli 主题推送、App 构建与扩展部署需使用 shopify CLI;若 Agent 仅需查询 Admin GraphQL Schema 或文档,可配合 Shopify Dev MCP。
Agent 友好度体检单
当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。
FCRS-1.0 六维评分拆解
theme list、app info 等查看命令支持 --json,但开发调试命令会打开浏览器并阻塞终端。
--jsonflag available on read and theme list commandsshopify app devandshopify theme devrun interactive watchers
需显式指定 --store,支持 --unpublished 隔离草稿主题及受限的 --password 主题访问令牌。
- Theme Access App tokens scope permissions away from full admin OAuth
--unpublishedprevents overwriting the live theme
可通过 npm 与 Homebrew 跨平台安装,依赖 Node.js 环境。
- Published on npm as
@shopify/cliand Homebrew
集成了 theme check 静态分析、打包与扩展部署,是 Shopify 生态不可或缺的工程工具。
- Bundles Theme Check static analysis directly inside the CLI
由 Shopify 官方仓库(Shopify/cli)以 MIT 协议高频迭代维护。
- Actively maintained by Shopify engineering
Shopify Dev 官方文档提供详尽的子命令与参数说明。
- Official docs at shopify.dev/docs/api/shopify-cli
安全边界、鉴权与放权指南
将 OAuth 会话令牌保存在系统配置目录,或通过 SHOPIFY_CLI_PARTNERS_TOKEN 与 --password 传入主题访问密码。
CLI 开源免费(MIT);Shopify Partner 开发商店免费,正式商用商店需订阅 Shopify 套餐。
# Shopify CLI Agent Rules - Always target a development store or `--unpublished` theme; NEVER pass `--live` on `shopify theme push` without human approval. - Run `shopify theme check` before pushing any Liquid or JSON template edits. - Do not invoke `shopify app dev` or `shopify theme dev` synchronously without a background timeout.
Agent 高频安全命令配方
只读查询(安全推荐)
shopify theme list --store example.myshopify.com --json
以结构化 JSON 读取目标商店已安装的主题与角色状态。
shopify theme check --fail-level error
在本地运行 Shopify Theme Check 静态校验模板,不触碰远程商店。
受控写入与预演
shopify theme push --store example.myshopify.com --unpublished --theme agent-preview --json
将本地主题更改上传为未发布草稿主题,确保线上店面不受影响。
核心优势
- + 内置
shopify theme check,可在上传前于本地捕获 Liquid 与 Schema 错误。 - + 支持
--unpublished草稿主题隔离与--json结构化读取。 - + Theme Access 令牌相比完整管理员 OAuth 显著收敛了权限爆炸半径。
注意事项与踩坑点
- !
shopify app dev与shopify theme dev会启动常驻进程和交互提示。 - ! 首次 OAuth 登录通常依赖本地浏览器,除非配置了
SHOPIFY_CLI_PARTNERS_TOKEN或主题密码。