$npx -y skills add 40RTY-ai/shopify-admin-skills --skill shopify-admin-carrier-performance-comparisonRead-only: compares delivery times and shipping costs across carriers used in fulfillments to inform carrier mix and contract decisions.
| 1 | ## Purpose |
| 2 | Aggregates fulfillments across recent orders, joins them to the shipping line on each order, and compares carriers head-to-head on (a) average transit days, (b) on-time rate (delivered before/at the customer-facing estimate), and (c) shipping cost per order. Surfaces which carrier is the right default per zone, route, or weight class. Read-only — no mutations. |
| 3 | |
| 4 | ## Prerequisites |
| 5 | - Authenticated Shopify CLI session: `shopify store auth --store <domain> --scopes read_orders` |
| 6 | - API scopes: `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 | | days_back | integer | no | 60 | Lookback window for fulfilled orders | |
| 14 | | min_orders | integer | no | 10 | Minimum orders per carrier to include in comparison | |
| 15 | | segment_by | string | no | — | Optional segmentation: `country`, `weight`, or `none` | |
| 16 | | format | string | no | human | Output format: `human` or `json` | |
| 17 | |
| 18 | ## Safety |
| 19 | |
| 20 | > ℹ️ Read-only skill — no mutations are executed. Safe to run at any time. Cost data uses the shipping line price the customer paid, not your negotiated carrier rate; if you want true cost variance you must overlay carrier invoices yourself. |
| 21 | |
| 22 | ## Workflow Steps |
| 23 | |
| 24 | 1. **OPERATION:** `orders` — query |
| 25 | **Inputs:** `query: "fulfillment_status:shipped created_at:>='<NOW - days_back days>'"`, `first: 250`, select `fulfillments { trackingInfo, createdAt, deliveredAt, inTransitAt }`, `shippingLine { carrierIdentifier, originalPriceSet, title }`, `totalWeight`, `shippingAddress`, pagination cursor |
| 26 | **Expected output:** Fulfilled orders with shipping line and fulfillment timing; paginate until `hasNextPage: false` |
| 27 | |
| 28 | 2. **OPERATION:** `fulfillments` — query (per fulfillment ID for any order missing inline data) |
| 29 | **Inputs:** `id: <fulfillmentGid>` |
| 30 | **Expected output:** Detailed `events`, `deliveredAt`, `estimatedDeliveryAt` |
| 31 | |
| 32 | 3. Group by carrier (use `shippingLine.carrierIdentifier` if present, else parse `trackingInfo.company`). For each carrier compute: avg transit days, p90 transit days, on-time rate (`deliveredAt <= estimatedDeliveryAt`), avg shipping price, order count. |
| 33 | |
| 34 | 4. If `segment_by` is set, repeat the group within each segment (e.g., per `shippingAddress.countryCode`). |
| 35 | |
| 36 | 5. Filter out carriers below `min_orders` and sort by avg transit days ascending. |
| 37 | |
| 38 | ## GraphQL Operations |
| 39 | |
| 40 | ```graphql |
| 41 | # orders:query — validated against api_version 2025-01 |
| 42 | query OrdersForCarrierComparison($query: String!, $after: String) { |
| 43 | orders(first: 250, after: $after, query: $query) { |
| 44 | edges { |
| 45 | node { |
| 46 | id |
| 47 | name |
| 48 | createdAt |
| 49 | totalWeight |
| 50 | shippingAddress { |
| 51 | countryCode |
| 52 | provinceCode |
| 53 | zip |
| 54 | } |
| 55 | shippingLine { |
| 56 | carrierIdentifier |
| 57 | title |
| 58 | code |
| 59 | originalPriceSet { |
| 60 | shopMoney { |
| 61 | amount |
| 62 | currencyCode |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | fulfillments { |
| 67 | id |
| 68 | createdAt |
| 69 | inTransitAt |
| 70 | deliveredAt |
| 71 | estimatedDeliveryAt |
| 72 | status |
| 73 | trackingInfo { |
| 74 | company |
| 75 | number |
| 76 | } |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | pageInfo { |
| 81 | hasNextPage |
| 82 | endCursor |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | ``` |
| 87 | |
| 88 | ```graphql |
| 89 | # fulfillments:query — validated against api_version 2025-01 |
| 90 | query FulfillmentDetail($id: ID!) { |
| 91 | fulfillment(id: $id) { |
| 92 | id |
| 93 | status |
| 94 | createdAt |
| 95 | inTransitAt |
| 96 | deliveredAt |
| 97 | estimatedDeliveryAt |
| 98 | trackingInfo { |
| 99 | company |
| 100 | number |
| 101 | url |
| 102 | } |
| 103 | events(first: 50) { |
| 104 | edges { |
| 105 | node { |
| 106 | status |
| 107 | happenedAt |
| 108 | message |
| 109 | } |
| 110 | } |
| 111 | } |
| 112 | } |
| 113 | } |
| 114 | ``` |
| 115 | |
| 116 | ## Session Tracking |
| 117 | |
| 118 | **Claude MUST emit the following output at each stage. This is mandatory.** |
| 119 | |
| 120 | **On start**, emit: |
| 121 | ``` |
| 122 | ╔══════════════════════════════════════════════╗ |
| 123 | ║ SKILL: Carrier Performance Comparison ║ |
| 124 | ║ Store: <store domain> ║ |
| 125 | ║ Started: <YYYY-MM-DD HH:MM UTC> ║ |
| 126 | ╚══════════════════════════════════════════════╝ |
| 127 | ``` |
| 128 | |
| 129 | **After each step**, emit: |
| 130 | ``` |
| 131 | [N/TOTAL] <QUERY|MUTATION> <OperationName> |
| 132 | → Params: <brief summary of key inputs> |
| 133 | → Result: <count or outcome> |
| 134 | ``` |
| 135 | |
| 136 | **On completion**, emit: |
| 137 | |
| 138 | For `format: human` (default): |
| 139 | ``` |
| 140 | ══════════════════════════════════════════════ |
| 141 | CARRIER PERFORMANCE (<days_back> days) |
| 142 | Orders analyzed: <n> |
| 143 | With delivery data: <n> |
| 144 | |
| 145 | Carrier Orders Avg Days P90 |