Install
$ agentstack add skill-40rty-ai-shopify-admin-skills-shopify-admin-customer-merge ✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
About
Purpose
Resolves duplicate customer records identified by duplicate-customer-finder. Where the Shopify Admin API exposes customerMerge (a native merge that moves orders, addresses, subscriptions, and metafields onto a winner record), this skill calls it directly. When customerMerge is unavailable or fails for the given account pair, the skill falls back to consolidating searchable metadata — tags, notes, marketing consent — onto the winner via customerUpdate, then writes a clear annotation to the loser record so staff can complete the merge manually in Shopify Admin.
Prerequisites
- Authenticated Shopify CLI session:
shopify store auth --store --scopes read_customers,write_customers - API scopes:
read_customers,write_customers
Parameters
| Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | store | string | yes | — | Store domain (e.g., mystore.myshopify.com) | | format | string | no | human | Output format: human or json | | dryrun | bool | no | true | Preview merge plan without executing mutations | | customerwinnerid | string | yes | — | GID of the customer record to keep (e.g., gid://shopify/Customer/12345) | | customerloserid | string | yes | — | GID of the customer record to merge into the winner | | usenativemerge | bool | no | true | Try customerMerge first; if it fails or is unavailable, fall back to consolidation via customerUpdate | | mergetags | bool | no | true | Union the loser's tags onto the winner | | mergenote | bool | no | true | Append the loser's note to the winner (with timestamp prefix) | | annotateloser | bool | no | true | Write a note on the loser record pointing to the winner GID for manual cleanup |
Safety
> ⚠️ Steps 2–4 execute mutations that modify customer records. customerMerge is irreversible — once orders and addresses are moved to the winner, the loser record is closed and cannot be split back. Run with dry_run: true first to confirm winner/loser GIDs and the merge plan. The default is dry_run: true. Always verify both records belong to the same human (matching email, phone, name) using duplicate-customer-finder output before committing. Do not merge a customer with active subscriptions or unfulfilled orders without confirming downstream systems will follow the new owner GID.
Workflow Steps
- OPERATION:
customer— query (called twice: winner and loser)
Inputs: id: , select id, displayName, firstName, lastName, defaultEmailAddress { emailAddress }, phone, tags, note, numberOfOrders, amountSpent, emailMarketingConsent { marketingState }, smsMarketingConsent { marketingState }, addresses(first: 25) { id }, createdAt Expected output: Both records' full identity payload — abort if either GID does not resolve
- OPERATION:
customerMerge— mutation (only ifuse_native_merge: trueand notdry_run)
Inputs: customerOneId: , customerTwoId: , overrideFields: prefer winner's name/email/phone/locale/marketing-consent Expected output: job.id (merge runs asynchronously), userErrors. If userErrors indicates merge is not supported for this pair (B2B, gift card holder, subscriber, etc.), proceed to step 3 fallback.
- OPERATION:
customerUpdate— mutation (winner) — fallback path or whenuse_native_merge: false
Inputs: input.id: , input.tags: (only if merge_tags), input.note: :\n" + loser.note> (only if merge_note) Expected output: customer.id, customer.tags, customer.note, userErrors
- OPERATION:
customerUpdate— mutation (loser) — only ifannotate_loser: true
Inputs: input.id: , input.note: "\n[YYYY-MM-DD] DUPLICATE — merge target: . Manually close in Shopify Admin once orders are reviewed.", input.tags: Expected output: customer.id, customer.tags, customer.note, userErrors
GraphQL Operations
# customer:query — validated against api_version 2025-01
query CustomerForMerge($id: ID!) {
customer(id: $id) {
id
displayName
firstName
lastName
defaultEmailAddress { emailAddress }
phone
tags
note
numberOfOrders
amountSpent { amount currencyCode }
emailMarketingConsent { marketingState marketingOptInLevel consentUpdatedAt }
smsMarketingConsent { marketingState marketingOptInLevel consentUpdatedAt }
addresses(first: 25) { id address1 city provinceCode countryCodeV2 zip }
createdAt
}
}
# customerMerge:mutation — validated against api_version 2025-01
mutation CustomerMerge(
$customerOneId: ID!
$customerTwoId: ID!
$overrideFields: CustomerMergeOverrideFields
) {
customerMerge(
customerOneId: $customerOneId
customerTwoId: $customerTwoId
overrideFields: $overrideFields
) {
job { id done }
resultingCustomerId
userErrors { field message code }
}
}
# customerUpdate:mutation — validated against api_version 2025-01
mutation CustomerConsolidate($input: CustomerInput!) {
customerUpdate(input: $input) {
customer { id displayName tags note }
userErrors { field message }
}
}
Session Tracking
Claude MUST emit the following output at each stage. This is mandatory.
On start, emit:
╔══════════════════════════════════════════════╗
║ SKILL: Customer Merge ║
║ Store: ║
║ Started: ║
╚══════════════════════════════════════════════╝
After each step, emit:
[N/TOTAL]
→ Params:
→ Result:
If dry_run: true, prefix every mutation step with [DRY RUN] and do not execute it.
On completion, emit:
For format: human (default):
══════════════════════════════════════════════
CUSTOMER MERGE OUTCOME
Winner: () Orders: Spent: $
Loser: () Orders: Spent: $
Path used:
Merge job:
Tags consolidated:
Note appended:
Loser annotated:
Errors:
Output: none
══════════════════════════════════════════════
For format: json, emit:
{
"skill": "customer-merge",
"store": "",
"started_at": "",
"completed_at": "",
"dry_run": true,
"winner_id": "",
"loser_id": "",
"outcome": {
"path": "native|fallback",
"merge_job_id": "",
"resulting_customer_id": "",
"tags_consolidated": 0,
"note_appended": false,
"loser_annotated": false,
"errors": 0,
"output_file": null
}
}
Output Format
No CSV output. The session summary reports the merge job ID, the resulting customer GID, and which path was taken. For batch merges, run this skill once per pair and capture the JSON output.
Error Handling
| Error | Cause | Recovery | |-------|-------|----------| | THROTTLED | API rate limit exceeded | Wait 2 seconds, retry up to 3 times | | customerMerge userError: customer has subscriptions | Active subscription on loser | Cancel subscription before merge or use fallback path | | customerMerge userError: B2B customer | Company-affiliated record | Use fallback path; manual merge in Shopify Admin | | customerMerge userError: gift card holder | Loser owns gift card balance | Transfer gift card or use fallback path | | Either GID not found | Wrong ID or deleted customer | Re-run duplicate-customer-finder | | Merge job pending | Async merge not yet complete | Re-query Job(id) to confirm done: true |
Best Practices
- Always run
duplicate-customer-finderfirst to confirm the pair is genuinely duplicate. Manual misclassifications are unrecoverable. - Pick the winner deliberately: typically the record with more orders, the verified email, or the older
createdAt. Avoid making the marketing-consenting record the loser. - Run
dry_run: truefirst; the preview shows both records' order counts and spend so you can sanity-check before committing. - For large dedup runs, write a wrapper script that calls this skill once per pair and feeds it from
duplicate-customer-finder's CSV output — never batch merges in a single call. - After native merge, the
job.done: falseresponse is normal — Shopify processes merges asynchronously. Re-query the job ID until completion before assuming the loser is closed. - The fallback path (
customerUpdateconsolidation only) does not move orders. It preserves searchability via tags/notes so a human can finish the merge in Shopify Admin (Customers → Merge).
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: 40RTY-ai
- Source: 40RTY-ai/shopify-admin-skills
- License: MIT
- Homepage: http://skills.40rty.ai
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet — be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.