shopify-admin-duplicate-sku-barcode-detector
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePurpose
用途
Scans all product variants and identifies duplicate SKUs or barcodes — two or more variants sharing the same identifier. Duplicate SKUs cause inventory sync failures, incorrect order routing, and accounting mismatches. Read-only — no mutations.
扫描所有商品变体,识别重复的SKU或条形码——即两个或多个变体共用同一个标识符。重复的SKU会导致库存同步失败、订单路由错误以及账目不匹配。本工具为只读模式,不会执行任何变更操作。
Prerequisites
前置要求
- Authenticated Shopify CLI session:
shopify store auth --store <domain> --scopes read_products - API scopes:
read_products
- 已完成身份认证的Shopify CLI会话:
shopify store auth --store <domain> --scopes read_products - API权限范围:
read_products
Parameters
参数
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| store | string | yes | — | Store domain (e.g., mystore.myshopify.com) |
| check_skus | bool | no | true | Check for duplicate SKUs |
| check_barcodes | bool | no | true | Check for duplicate barcodes |
| include_blank | bool | no | false | Flag variants with blank/null SKU |
| format | string | no | human | Output format: |
| 参数 | 类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
| store | string | 是 | — | 商店域名(例如:mystore.myshopify.com) |
| check_skus | bool | 否 | true | 是否检查重复SKU |
| check_barcodes | bool | 否 | true | 是否检查重复条形码 |
| include_blank | bool | 否 | false | 标记SKU为空/ null的变体 |
| format | string | 否 | human | 输出格式: |
Safety
安全性
ℹ️ Read-only skill — no mutations are executed. Safe to run at any time.
ℹ️ 只读skill —— 不会执行任何变更操作,任何时间运行都安全。
Workflow Steps
工作流步骤
-
OPERATION:— query Inputs:
productVariants, selectfirst: 250,sku,barcode, pagination cursor Expected output: All variants with SKU and barcode values; paginate untilproduct { title }hasNextPage: false -
Build in-memory map ofand
sku → [variants]barcode → [variants] -
Report all keys with more than one variant (duplicates)
-
If: additionally flag variants where
include_blankis null or empty stringsku
-
操作:— 查询 输入:
productVariants,选择first: 250、sku、barcode、分页游标 预期输出: 所有带SKU和条形码值的变体;分页直到product { title }hasNextPage: false -
在内存中构建和
sku → [variants]的映射表barcode → [variants] -
上报所有对应变体数量大于1的键(即重复项)
-
如果开启:额外标记
include_blank为null或空字符串的变体sku
GraphQL Operations
GraphQL Operations
graphql
undefinedgraphql
undefinedproductVariants:query — validated against api_version 2025-01
productVariants:query — validated against api_version 2025-01
query VariantIdentifiers($after: String) {
productVariants(first: 250, after: $after) {
edges {
node {
id
sku
barcode
title
product {
id
title
handle
status
}
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
undefinedquery VariantIdentifiers($after: String) {
productVariants(first: 250, after: $after) {
edges {
node {
id
sku
barcode
title
product {
id
title
handle
status
}
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
undefinedSession Tracking
会话跟踪
Claude MUST emit the following output at each stage. This is mandatory.
On start, emit:
╔══════════════════════════════════════════════╗
║ SKILL: Duplicate SKU/Barcode Detector ║
║ Store: <store domain> ║
║ Started: <YYYY-MM-DD HH:MM UTC> ║
╚══════════════════════════════════════════════╝After each step, emit:
[N/TOTAL] <QUERY|MUTATION> <OperationName>
→ Params: <brief summary of key inputs>
→ Result: <count or outcome>On completion, emit:
For (default):
format: human══════════════════════════════════════════════
DUPLICATE SKU / BARCODE REPORT
Variants scanned: <n>
Duplicate SKUs found: <n> groups
Duplicate barcodes: <n> groups
Blank SKUs: <n>
Duplicate SKU groups:
SKU "ABC-123" — used by 2 variants:
Product A / Blue / L
Product B / Navy / XL
Output: duplicates_<date>.csv
══════════════════════════════════════════════For , emit:
format: jsonjson
{
"skill": "duplicate-sku-barcode-detector",
"store": "<domain>",
"variants_scanned": 0,
"duplicate_sku_groups": 0,
"duplicate_barcode_groups": 0,
"blank_skus": 0,
"output_file": "duplicates_<date>.csv"
}Claude必须在每个阶段输出以下内容,这是强制要求。
启动时,输出:
╔══════════════════════════════════════════════╗
║ SKILL: Duplicate SKU/Barcode Detector ║
║ Store: <store domain> ║
║ Started: <YYYY-MM-DD HH:MM UTC> ║
╚══════════════════════════════════════════════╝每步完成后,输出:
[N/TOTAL] <QUERY|MUTATION> <OperationName>
→ Params: <brief summary of key inputs>
→ Result: <count or outcome>运行完成时,输出:
当(默认)时:
format: human══════════════════════════════════════════════
DUPLICATE SKU / BARCODE REPORT
Variants scanned: <n>
Duplicate SKUs found: <n> groups
Duplicate barcodes: <n> groups
Blank SKUs: <n>
Duplicate SKU groups:
SKU "ABC-123" — used by 2 variants:
Product A / Blue / L
Product B / Navy / XL
Output: duplicates_<date>.csv
══════════════════════════════════════════════当时,输出:
format: jsonjson
{
"skill": "duplicate-sku-barcode-detector",
"store": "<domain>",
"variants_scanned": 0,
"duplicate_sku_groups": 0,
"duplicate_barcode_groups": 0,
"blank_skus": 0,
"output_file": "duplicates_<date>.csv"
}Output Format
输出格式
CSV file with columns:
, , , , , ,
duplicates_<YYYY-MM-DD>.csvissue_typeduplicate_valuevariant_idproduct_titlevariant_titleskubarcodeCSV文件,包含以下列:
, , , , , ,
duplicates_<YYYY-MM-DD>.csvissue_typeduplicate_valuevariant_idproduct_titlevariant_titleskubarcodeError Handling
错误处理
| Error | Cause | Recovery |
|---|---|---|
| API rate limit exceeded | Wait 2 seconds, retry up to 3 times |
| No duplicates found | Clean catalog | Exit with ✅ no issues found |
| 错误 | 原因 | 解决方案 |
|---|---|---|
| API速率限制超出 | 等待2秒,最多重试3次 |
| 未找到重复项 | 目录数据干净 | 返回✅未发现问题后退出 |
Best Practices
最佳实践
- Run this skill after every bulk product import — imports are the most common source of duplicate SKUs.
- A shared SKU across products is only valid if you intentionally use the same SKU for reprints or variants — most cases are data errors.
- Blank SKUs are not duplicates but can cause problems with 3PLs and fulfillment systems that require a SKU for every variant — use to surface them.
include_blank: true - After identifying duplicates, use the Shopify Admin UI or the mutation to correct SKU values.
productVariantsBulkUpdate
- 每次批量导入商品后运行本skill——导入操作是重复SKU最常见的来源。
- 只有当你有意为再版商品或变体使用相同SKU时,跨商品共享SKU才是合理的,绝大多数此类情况都是数据错误。
- 空SKU不属于重复项,但会给要求每个变体都有SKU的第三方物流和履约系统带来问题——可使用来找出这类SKU。
include_blank: true - 识别到重复项后,可使用Shopify管理后台UI或mutation修正SKU值。
productVariantsBulkUpdate