用途
该技能用于对流失客户进行分群:找出至少下过一笔订单、但在可配置时间窗口内未再次购买的客户,并为其打标签以便再营销。它只负责 Shopify 原生数据层;发送再营销邮件需要外部工具。
前置条件
已认证的 Shopify CLI 会话:shopify auth login --store <domain>
API 权限范围:read_customers、write_customers
参数
store(string,必填,无默认值):店铺域名
format(string,可选,默认 human):human 或 json
dry_run(bool,可选,默认 false):仅预览,不打标签
inactive_days(integer,可选,默认 90):距上次下单多少天视为流失
min_orders(integer,可选,默认 1):纳入所需的最低历史订单数
tag(string,可选,默认 win-back):应用于流失客户的标签
max_customers(integer,可选,默认 500):每次运行处理的最大客户数
工作流程步骤
OPERATION: customers — query 输入:filter last_order_date:<(NOW - inactive_days days), orders_count:>=(min_orders), first: 250, 分页 预期输出:客户对象列表,包含 id、defaultEmailAddress { emailAddress }、firstName、lastName、ordersCount、lastOrder.processedAt;分页直到 hasNextPage: false
OPERATION: tagsAdd — mutation 输入:客户 id、来自 tag 参数的标签字符串 预期输出:每个客户的确认;收集 userErrors
GraphQL 操作
customers:query — 已针对 api_version 2025-04 验证
query LapsedCustomers($first: Int!, $after: String, $query: String) { customers(first: $first, after: $after, query: $query) { edges { node { id defaultEmailAddress { emailAddress } firstName lastName ordersCount lastOrder { processedAt totalPriceSet { shopMoney { amount currencyCode } } } } } pageInfo { hasNextPage endCursor } } }
tagsAdd:mutation — 已针对 api_version 2025-01 验证
mutation TagsAdd($id: ID!, $tags: [String!]!) { tagsAdd(id: $id, tags: $tags) { node { id } userErrors { field message } } }
会话跟踪
Claude 必须在每个阶段输出以下内容。这是强制要求。
开始时输出:
╔══════════════════════════════════════════════╗ ║ SKILL: Customer Win-Back ║ ║ Store: <store domain> ║ ║ Started: <YYYY-MM-DD HH:MM UTC> ║ ╚══════════════════════════════════════════════╝
每个步骤后输出:
[N/TOTAL] <QUERY|MUTATION> <OperationName> → Params: <brief summary> → Result: <count or outcome>
如果 dry_run: true,则在 mutation 步骤前加 [DRY RUN] 前缀,且不执行。
完成时,对于 format: human:
══════════════════════════════════════════════ OUTCOME SUMMARY Lapsed customers found: <n> Customers tagged: <n> Errors: <n> Output: winback_<date>.csv ══════════════════════════════════════════════
对于 format: json,输出标准 JSON schema,结果键为:lapsed_found、customers_tagged、errors、output_file。
输出格式
CSV winback_<YYYY-MM-DD>.csv,列包括: customer_id, email, first_name, last_name, orders_count, last_order_date, tag_applied
错误处理
错误:THROTTLED 原因:速率限制 恢复:等待 2 秒,最多重试 3 次
错误:tagsAdd 上的 userErrors 原因:客户未找到或 ID 无效 恢复:记录、跳过、继续
最佳实践
使用带日期的标签(例如 win-back-2026-04),以便跟踪每月针对的是哪一批客户,并避免对已收到再营销活动的客户重复打标签。
设置 min_orders: 2,聚焦于有真实购买关系的客户,而非可能从未打算复购的一次性买家。
先以 dry_run: true 运行,在打标签前验证流失客户数量——该数量可帮助你判断再营销活动的规模。