$npx -y skills add 40RTY-ai/shopify-admin-skills --skill shopify-admin-chargeback-watchlist-taggerIdentifies customers with disputed or charged-back orders and tags their customer record for proactive review on future orders.
| 1 | ## Purpose |
| 2 | Scans historical orders for any associated chargeback or dispute, then tags the customer record with `chargeback-history` (configurable). Future orders from these customers can be filtered or held for manual review by ops. Reduces repeated chargeback losses without blocking customers outright. Defaults to `dry_run: true`. |
| 3 | |
| 4 | ## Prerequisites |
| 5 | - Authenticated Shopify CLI session: `shopify store auth --store <domain> --scopes read_orders,read_customers,write_customers` |
| 6 | - API scopes: `read_orders`, `read_customers`, `write_customers` |
| 7 | |
| 8 | ## Parameters |
| 9 | |
| 10 | | Parameter | Type | Required | Default | Description | |
| 11 | |-----------|------|----------|---------|-------------| |
| 12 | | store | string | yes | — | Store domain (e.g., mystore.myshopify.com) | |
| 13 | | days_back | integer | no | 730 | Historical window to scan for disputes (2 years default) | |
| 14 | | watchlist_tag | string | no | chargeback-history | Tag applied to flagged customers | |
| 15 | | include_won_disputes | bool | no | false | If false, only tag customers whose disputes were lost or are open | |
| 16 | | dry_run | bool | no | true | Preview without applying tags | |
| 17 | | format | string | no | human | Output format: `human` or `json` | |
| 18 | |
| 19 | ## Safety |
| 20 | |
| 21 | > ⚠️ `customerUpdate` modifies customer tags that are visible to staff and may drive segmentation rules. Tag a customer incorrectly and you may downgrade their experience or block their orders. Run with `dry_run: true` first and review the list before committing. Won disputes (where the merchant won) are excluded by default to avoid false positives. |
| 22 | |
| 23 | ## Workflow Steps |
| 24 | |
| 25 | 1. **OPERATION:** `orders` — query |
| 26 | **Inputs:** `query: "created_at:>='<NOW - days_back days>' chargeback_status:*"` (any chargeback state), `first: 250`, select `disputes { id, status, initiatedAs, finalizedOn }`, `customer { id, displayName, tags, defaultEmailAddress { emailAddress } }`, `totalPriceSet`, pagination cursor |
| 27 | **Expected output:** All orders that have at least one dispute in the window |
| 28 | |
| 29 | 2. Group disputes by customer. For each customer: |
| 30 | - Skip if every dispute has status `WON` and `include_won_disputes: false` |
| 31 | - Skip if customer already carries `watchlist_tag` |
| 32 | - Otherwise add to tagging queue |
| 33 | |
| 34 | 3. **OPERATION:** `customerUpdate` — mutation |
| 35 | **Inputs:** `input: { id, tags: [<existing tags>, watchlist_tag] }` for each queued customer |
| 36 | **Expected output:** Updated customer with new tag list; `userErrors` |
| 37 | |
| 38 | 4. If `dry_run: true`, do not call mutation — just report the queue. |
| 39 | |
| 40 | ## GraphQL Operations |
| 41 | |
| 42 | ```graphql |
| 43 | # orders:query — validated against api_version 2025-01 |
| 44 | query OrdersWithDisputes($query: String!, $after: String) { |
| 45 | orders(first: 250, after: $after, query: $query) { |
| 46 | edges { |
| 47 | node { |
| 48 | id |
| 49 | name |
| 50 | createdAt |
| 51 | totalPriceSet { |
| 52 | shopMoney { |
| 53 | amount |
| 54 | currencyCode |
| 55 | } |
| 56 | } |
| 57 | disputes { |
| 58 | id |
| 59 | status |
| 60 | initiatedAs |
| 61 | finalizedOn |
| 62 | } |
| 63 | customer { |
| 64 | id |
| 65 | displayName |
| 66 | defaultEmailAddress { |
| 67 | emailAddress |
| 68 | } |
| 69 | numberOfOrders |
| 70 | amountSpent { |
| 71 | amount |
| 72 | currencyCode |
| 73 | } |
| 74 | tags |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | pageInfo { |
| 79 | hasNextPage |
| 80 | endCursor |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | ``` |
| 85 | |
| 86 | ```graphql |
| 87 | # customerUpdate:mutation — validated against api_version 2025-01 |
| 88 | mutation TagChargebackCustomer($input: CustomerInput!) { |
| 89 | customerUpdate(input: $input) { |
| 90 | customer { |
| 91 | id |
| 92 | tags |
| 93 | } |
| 94 | userErrors { |
| 95 | field |
| 96 | message |
| 97 | } |
| 98 | } |
| 99 | } |
| 100 | ``` |
| 101 | |
| 102 | ## Session Tracking |
| 103 | |
| 104 | **Claude MUST emit the following output at each stage. This is mandatory.** |
| 105 | |
| 106 | **On start**, emit: |
| 107 | ``` |
| 108 | ╔══════════════════════════════════════════════╗ |
| 109 | ║ SKILL: Chargeback Watchlist Tagger ║ |
| 110 | ║ Store: <store domain> ║ |
| 111 | ║ Started: <YYYY-MM-DD HH:MM UTC> ║ |
| 112 | ╚══════════════════════════════════════════════╝ |
| 113 | ``` |
| 114 | |
| 115 | **After each step**, emit: |
| 116 | ``` |
| 117 | [N/TOTAL] <QUERY|MUTATION> <OperationName> |
| 118 | → Params: <brief summary of key inputs> |
| 119 | → Result: <count or outcome> |
| 120 | ``` |
| 121 | |
| 122 | If `dry_run: true`, prefix every mutation step with `[DRY RUN]` and do not execute it. |
| 123 | |
| 124 | **On completion**, emit: |
| 125 | |
| 126 | For `format: human` (default): |
| 127 | ``` |
| 128 | ══════════════════════════════════════════════ |
| 129 | CHARGEBACK WATCHLIST (<days_back> days) |
| 130 | Orders with disputes: <n> |
| 131 | Unique customers: <n> |
| 132 | Disputes lost/open: <n> |
| 133 | Disputes won (excluded): <n> |
| 134 | Already tagged: <n> |
| 135 | ───────────────────────────── |
| 136 | Customers to tag: <n> |
| 137 | Tags applied: |