$npx -y skills add 40RTY-ai/shopify-admin-skills --skill shopify-admin-average-order-value-trendsRead-only: tracks AOV over time buckets and segments by new vs. returning customers.
| 1 | ## Purpose |
| 2 | Calculates Average Order Value (AOV) over configurable time buckets (daily, weekly, monthly) and segments results by new vs. returning customers. Tracks AOV trends to measure the impact of upsell programs, bundle offers, or free shipping thresholds. Read-only — no mutations. |
| 3 | |
| 4 | ## Prerequisites |
| 5 | - Authenticated Shopify CLI session: `shopify store auth --store <domain> --scopes read_orders,read_customers` |
| 6 | - API scopes: `read_orders`, `read_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 | 90 | Total lookback window | |
| 14 | | bucket | string | no | week | Time bucket: `day`, `week`, or `month` | |
| 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:** `orders` — query |
| 24 | **Inputs:** `query: "created_at:>='<NOW - days_back days>'"`, `first: 250`, select `totalPriceSet`, `customer { id, numberOfOrders }`, `createdAt`, pagination cursor |
| 25 | **Expected output:** All orders in window; paginate until `hasNextPage: false` |
| 26 | |
| 27 | 2. Classify each order: if `customer.numberOfOrders == 1` → new customer order; else → returning |
| 28 | |
| 29 | 3. **OPERATION:** `customers` — query (optional enrichment for cohort context) |
| 30 | **Inputs:** Recent customers for new vs. repeat segmentation validation |
| 31 | |
| 32 | 4. Group orders by time bucket; calculate AOV per bucket and per customer segment |
| 33 | |
| 34 | ## GraphQL Operations |
| 35 | |
| 36 | ```graphql |
| 37 | # orders:query — validated against api_version 2025-01 |
| 38 | query AOVData($query: String!, $after: String) { |
| 39 | orders(first: 250, after: $after, query: $query) { |
| 40 | edges { |
| 41 | node { |
| 42 | id |
| 43 | name |
| 44 | createdAt |
| 45 | totalPriceSet { |
| 46 | shopMoney { |
| 47 | amount |
| 48 | currencyCode |
| 49 | } |
| 50 | } |
| 51 | customer { |
| 52 | id |
| 53 | numberOfOrders |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 | pageInfo { |
| 58 | hasNextPage |
| 59 | endCursor |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | ``` |
| 64 | |
| 65 | ```graphql |
| 66 | # customers:query — validated against api_version 2025-01 |
| 67 | query NewVsReturningCustomers($query: String!, $after: String) { |
| 68 | customers(first: 250, after: $after, query: $query) { |
| 69 | edges { |
| 70 | node { |
| 71 | id |
| 72 | numberOfOrders |
| 73 | createdAt |
| 74 | } |
| 75 | } |
| 76 | pageInfo { |
| 77 | hasNextPage |
| 78 | endCursor |
| 79 | } |
| 80 | } |
| 81 | } |
| 82 | ``` |
| 83 | |
| 84 | ## Session Tracking |
| 85 | |
| 86 | **Claude MUST emit the following output at each stage. This is mandatory.** |
| 87 | |
| 88 | **On start**, emit: |
| 89 | ``` |
| 90 | ╔══════════════════════════════════════════════╗ |
| 91 | ║ SKILL: Average Order Value Trends ║ |
| 92 | ║ Store: <store domain> ║ |
| 93 | ║ Started: <YYYY-MM-DD HH:MM UTC> ║ |
| 94 | ╚══════════════════════════════════════════════╝ |
| 95 | ``` |
| 96 | |
| 97 | **After each step**, emit: |
| 98 | ``` |
| 99 | [N/TOTAL] <QUERY|MUTATION> <OperationName> |
| 100 | → Params: <brief summary of key inputs> |
| 101 | → Result: <count or outcome> |
| 102 | ``` |
| 103 | |
| 104 | **On completion**, emit: |
| 105 | |
| 106 | For `format: human` (default): |
| 107 | ``` |
| 108 | ══════════════════════════════════════════════ |
| 109 | AOV TRENDS (<days_back> days, bucket: <bucket>) |
| 110 | Orders analyzed: <n> |
| 111 | Overall AOV: $<amount> |
| 112 | New customer AOV: $<amount> |
| 113 | Returning AOV: $<amount> |
| 114 | |
| 115 | Period Orders AOV New AOV Returning AOV |
| 116 | ──────────────────────────────────────────────────── |
| 117 | 2026-W14 <n> $<n> $<n> $<n> |
| 118 | Output: aov_trends_<date>.csv |
| 119 | ══════════════════════════════════════════════ |
| 120 | ``` |
| 121 | |
| 122 | For `format: json`, emit: |
| 123 | ```json |
| 124 | { |
| 125 | "skill": "average-order-value-trends", |
| 126 | "store": "<domain>", |
| 127 | "period_days": 90, |
| 128 | "overall_aov": 0, |
| 129 | "new_customer_aov": 0, |
| 130 | "returning_customer_aov": 0, |
| 131 | "by_period": [], |
| 132 | "output_file": "aov_trends_<date>.csv" |
| 133 | } |
| 134 | ``` |
| 135 | |
| 136 | ## Output Format |
| 137 | CSV file `aov_trends_<YYYY-MM-DD>.csv` with columns: |
| 138 | `period`, `order_count`, `aov`, `new_customer_orders`, `new_customer_aov`, `returning_orders`, `returning_aov`, `currency` |
| 139 | |
| 140 | ## Error Handling |
| 141 | | Error | Cause | Recovery | |
| 142 | |-------|-------|----------| |
| 143 | | `THROTTLED` | API rate limit exceeded | Wait 2 seconds, retry up to 3 times | |
| 144 | | Guest checkout orders | No customer record | Count in totals but exclude from new/returning segmentation | |
| 145 | | No orders in window | New store or quiet period | Exit with 0 AOV | |
| 146 | |
| 147 | ## Best Practices |
| 148 | - A free shipping threshold increase or bundle introduction should show up as an AOV lift in the week/month it launched — use this report to measure the impact. |
| 149 | - Returning customer AOV is typically higher than new — a shrinking gap may indicate loyalty erosion. |
| 150 | - `bucket: week` is best for campaign measurem |