$npx -y skills add 40RTY-ai/shopify-admin-skills --skill shopify-admin-discount-roi-calculatorRead-only: calculates the true ROI of each discount code and automatic discount by comparing incremental revenue against discount cost.
| 1 | ## Purpose |
| 2 | Evaluates the true return on investment for each discount code and automatic discount by measuring revenue generated, number of orders, average order value with vs. without discount, customer acquisition attributed to discounts, and whether discounted orders cannibalized full-price sales. Goes beyond `discount-hygiene-cleanup` (which finds broken/unused codes) to answer "was this discount worth it?" Read-only — no mutations. |
| 3 | |
| 4 | ## Prerequisites |
| 5 | - Authenticated Shopify CLI session: `shopify store auth --store <domain> --scopes read_orders,read_discounts` |
| 6 | - API scopes: `read_orders`, `read_discounts` |
| 7 | |
| 8 | ## Parameters |
| 9 | |
| 10 | | Parameter | Type | Required | Default | Description | |
| 11 | |-----------|------|----------|---------|-------------| |
| 12 | | store | string | yes | — | Store domain | |
| 13 | | days_back | integer | no | 90 | Lookback window | |
| 14 | | min_uses | integer | no | 3 | Minimum uses for a discount to be analyzed | |
| 15 | | format | string | no | human | Output format: `human` or `json` | |
| 16 | |
| 17 | ## Safety |
| 18 | |
| 19 | > ℹ️ Read-only skill — no mutations are executed. Safe to run at any time. |
| 20 | |
| 21 | ## Workflow Steps |
| 22 | |
| 23 | 1. **OPERATION:** `discountNodes` — query |
| 24 | **Inputs:** `first: 250`, select discount details (title, code, type, value, usageCount, startsAt, endsAt), pagination cursor |
| 25 | **Expected output:** All discount codes and automatic discounts |
| 26 | |
| 27 | 2. Filter to discounts with `usageCount >= min_uses` and active within lookback window |
| 28 | |
| 29 | 3. **OPERATION:** `orders` — query |
| 30 | **Inputs:** `query: "created_at:>='<NOW - days_back days>' discount_code:<code>"`, `first: 250` for each active discount code, select `totalPriceSet`, `totalDiscountsSet`, `subtotalPriceSet`, `customer { id, numberOfOrders }`, pagination cursor |
| 31 | **Expected output:** All orders using each discount |
| 32 | |
| 33 | 4. Also query orders WITHOUT any discount in same period for baseline AOV comparison |
| 34 | |
| 35 | 5. For each discount, calculate: |
| 36 | - **Total Discount Cost** = Σ(totalDiscountsSet for orders with this code) |
| 37 | - **Revenue Generated** = Σ(totalPriceSet for orders with this code) |
| 38 | - **Discounted AOV** = revenue / orders |
| 39 | - **Baseline AOV** = AOV of non-discounted orders in same period |
| 40 | - **AOV Lift/Drop** = discounted AOV - baseline AOV |
| 41 | - **New Customer %** = orders where customer.numberOfOrders == 1 / total |
| 42 | - **Gross ROI** = (revenue - discount_cost) / discount_cost × 100 |
| 43 | - **Cannibalization Risk** = high if discount AOV < baseline AOV and new customer % < 20% |
| 44 | |
| 45 | ## GraphQL Operations |
| 46 | |
| 47 | ```graphql |
| 48 | # discountNodes:query — validated against api_version 2025-01 |
| 49 | query AllDiscounts($after: String) { |
| 50 | discountNodes(first: 250, after: $after) { |
| 51 | edges { |
| 52 | node { |
| 53 | id |
| 54 | discount { |
| 55 | ... on DiscountCodeBasic { |
| 56 | title |
| 57 | codes(first: 1) { edges { node { code } } } |
| 58 | usageLimit |
| 59 | asyncUsageCount |
| 60 | startsAt |
| 61 | endsAt |
| 62 | customerGets { |
| 63 | value { |
| 64 | ... on DiscountPercentage { percentage } |
| 65 | ... on DiscountAmount { amount { amount currencyCode } } |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | ... on DiscountCodeFreeShipping { |
| 70 | title |
| 71 | codes(first: 1) { edges { node { code } } } |
| 72 | asyncUsageCount |
| 73 | startsAt |
| 74 | endsAt |
| 75 | } |
| 76 | ... on DiscountAutomaticBasic { |
| 77 | title |
| 78 | asyncUsageCount |
| 79 | startsAt |
| 80 | endsAt |
| 81 | customerGets { |
| 82 | value { |
| 83 | ... on DiscountPercentage { percentage } |
| 84 | ... on DiscountAmount { amount { amount currencyCode } } |
| 85 | } |
| 86 | } |
| 87 | } |
| 88 | } |
| 89 | } |
| 90 | } |
| 91 | pageInfo { hasNextPage endCursor } |
| 92 | } |
| 93 | } |
| 94 | ``` |
| 95 | |
| 96 | ```graphql |
| 97 | # orders:query — validated against api_version 2025-01 |
| 98 | query OrdersByDiscount($query: String!, $after: String) { |
| 99 | orders(first: 250, after: $after, query: $query) { |
| 100 | edges { |
| 101 | node { |
| 102 | id |
| 103 | name |
| 104 | createdAt |
| 105 | totalPriceSet { shopMoney { amount currencyCode } } |
| 106 | totalDiscountsSet { shopMoney { amount currencyCode } } |
| 107 | subtotalPriceSet { shopMoney { amount currencyCode } } |
| 108 | customer { |
| 109 | id |
| 110 | numberOfOrders |
| 111 | } |
| 112 | discountCodes |
| 113 | } |
| 114 | } |
| 115 | pageInfo { hasNextPage endCursor } |
| 116 | } |
| 117 | } |
| 118 | ``` |
| 119 | |
| 120 | ## Session Tracking |
| 121 | |
| 122 | **Claude MUST emit the following output at each stage. This is mandatory.** |
| 123 | |
| 124 | **On start**, emit: |
| 125 | ``` |
| 126 | ╔══════════════════════════════════════════════╗ |
| 127 | ║ SKILL: Discount ROI Calculator ║ |
| 128 | ║ Store: <store domain> ║ |
| 129 | ║ S |