$npx -y skills add 40RTY-ai/shopify-admin-skills --skill shopify-admin-discount-ab-analysisCompare redemption rates and revenue performance across two or more discount codes over a specified date range.
| 1 | ## Purpose |
| 2 | Compares how different discount codes perform against each other by redemption count and revenue generated. Useful for A/B testing promotional offers without a dedicated analytics app — provide two or more codes and a date range, and the skill queries Shopify for discount metadata and order revenue, then produces a side-by-side comparison table. Read-only: no mutations are executed. |
| 3 | |
| 4 | ## Prerequisites |
| 5 | - Authenticated Shopify CLI session: `shopify auth login --store <domain>` |
| 6 | - API scopes: `read_discounts`, `read_orders` |
| 7 | |
| 8 | ## Parameters |
| 9 | |
| 10 | | Parameter | Type | Required | Default | Description | |
| 11 | |-----------|------|----------|---------|-------------| |
| 12 | | store | string | yes | — | Store domain (e.g., mystore.myshopify.com) | |
| 13 | | format | string | no | human | Output format: `human` or `json` | |
| 14 | | dry_run | bool | no | false | Preview operations without executing mutations | |
| 15 | | discount_codes | array | yes | — | Array of 2 or more discount code strings to compare (e.g., `["SAVE10", "WELCOME15"]`) | |
| 16 | | date_range_start | string | yes | — | Start date in ISO 8601 (e.g., `2025-01-01`) | |
| 17 | | date_range_end | string | yes | — | End date in ISO 8601 (e.g., `2025-01-31`) | |
| 18 | |
| 19 | ## Workflow Steps |
| 20 | |
| 21 | 1. **OPERATION:** `discountNodes` — query |
| 22 | **Inputs:** `first: 50`, `query: "code:<code>"` (one query per code in `discount_codes`) |
| 23 | **Expected output:** Discount metadata: title, code strings, `asyncUsageCount`, status, `startsAt`, `endsAt` per code |
| 24 | |
| 25 | 2. **OPERATION:** `orders` — query (one paginated query per discount code) |
| 26 | **Inputs:** `first: 250`, `query: "discount_code:<code> created_at:>='<date_range_start>' created_at:<='<date_range_end>'"`, pagination cursor |
| 27 | **Expected output:** Orders containing the discount code with `totalPriceSet`; paginate until `hasNextPage: false`; aggregate: count, sum revenue, compute avg order value |
| 28 | |
| 29 | ## GraphQL Operations |
| 30 | |
| 31 | ```graphql |
| 32 | # discountNodes:query — validated against api_version 2025-01 |
| 33 | query DiscountNodes($first: Int!, $query: String) { |
| 34 | discountNodes(first: $first, query: $query) { |
| 35 | edges { |
| 36 | node { |
| 37 | id |
| 38 | discount { |
| 39 | ... on DiscountCodeBasic { |
| 40 | title |
| 41 | codes(first: 10) { |
| 42 | edges { |
| 43 | node { |
| 44 | code |
| 45 | asyncUsageCount |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | usageLimit |
| 50 | status |
| 51 | startsAt |
| 52 | endsAt |
| 53 | } |
| 54 | ... on DiscountCodeBxgy { |
| 55 | title |
| 56 | codes(first: 10) { |
| 57 | edges { |
| 58 | node { |
| 59 | code |
| 60 | asyncUsageCount |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | status |
| 65 | } |
| 66 | ... on DiscountCodeFreeShipping { |
| 67 | title |
| 68 | codes(first: 10) { |
| 69 | edges { |
| 70 | node { |
| 71 | code |
| 72 | asyncUsageCount |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | status |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | ``` |
| 84 | |
| 85 | ```graphql |
| 86 | # orders:query (by discount code) — validated against api_version 2025-01 |
| 87 | query OrdersByDiscountCode($first: Int!, $after: String, $query: String) { |
| 88 | orders(first: $first, after: $after, query: $query) { |
| 89 | edges { |
| 90 | node { |
| 91 | id |
| 92 | createdAt |
| 93 | totalPriceSet { |
| 94 | shopMoney { amount currencyCode } |
| 95 | } |
| 96 | discountCodes |
| 97 | } |
| 98 | } |
| 99 | pageInfo { |
| 100 | hasNextPage |
| 101 | endCursor |
| 102 | } |
| 103 | } |
| 104 | } |
| 105 | ``` |
| 106 | |
| 107 | ## Session Tracking |
| 108 | |
| 109 | **Claude MUST emit the following output at each stage. This is mandatory.** |
| 110 | |
| 111 | **On start**, emit: |
| 112 | ``` |
| 113 | ╔══════════════════════════════════════════════╗ |
| 114 | ║ SKILL: discount-ab-analysis ║ |
| 115 | ║ Store: <store domain> ║ |
| 116 | ║ Started: <YYYY-MM-DD HH:MM UTC> ║ |
| 117 | ╚══════════════════════════════════════════════╝ |
| 118 | ``` |
| 119 | |
| 120 | **After each step**, emit: |
| 121 | ``` |
| 122 | [N/TOTAL] <QUERY|MUTATION> <OperationName> |
| 123 | → Params: <brief summary of key inputs> |
| 124 | → Result: <count or outcome> |
| 125 | ``` |
| 126 | |
| 127 | **On completion**, emit: |
| 128 | |
| 129 | For `format: human` (default): |
| 130 | ``` |
| 131 | ══════════════════════════════════════════════ |
| 132 | OUTCOME SUMMARY |
| 133 | Codes analyzed: <n> |
| 134 | Date range: <start> to <end> |
| 135 | Errors: 0 |
| 136 | Output: none |
| 137 | ══════════════════════════════════════════════ |
| 138 | ``` |
| 139 | |
| 140 | For `format: json`, emit: |
| 141 | ```json |
| 142 | { |
| 143 | "skill": "discount-ab-analysis", |
| 144 | "store": "<domain>", |
| 145 | "started_at": "<ISO8601>", |
| 146 | "completed_at": "<ISO8601>", |
| 147 | "dry_run": false, |
| 148 | "steps": [ |
| 149 | { "step": 1, "operation": "DiscountNodes", "type": "query", "params_summary": "<n> codes queried", "result_summary": " |