$npx -y skills add 40RTY-ai/shopify-admin-skills --skill shopify-admin-delivery-time-analysisRead-only: calculates average time from fulfillment creation to delivery by carrier using fulfillment and order data.
| 1 | ## Purpose |
| 2 | Analyzes fulfilled orders to calculate average transit time (fulfillment created → delivered) broken down by carrier. Surfaces which carriers are consistently slow or missing delivery confirmations. 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 | 30 | Lookback window for fulfilled orders | |
| 14 | | min_orders | integer | no | 5 | Minimum orders per carrier to include in averages | |
| 15 | | location_id | string | no | — | Filter by fulfillment location (optional) | |
| 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. |
| 21 | |
| 22 | ## Workflow Steps |
| 23 | |
| 24 | 1. **OPERATION:** `orders` — query |
| 25 | **Inputs:** `query: "fulfillment_status:shipped created_at:>='<NOW - days_back days>'"`, `first: 250`, pagination cursor |
| 26 | **Expected output:** Orders with `fulfillments { createdAt, updatedAt, deliveredAt, trackingInfo { company } }`; paginate until `hasNextPage: false` |
| 27 | |
| 28 | 2. Calculate transit times per carrier: `deliveredAt - createdAt` (skip orders where `deliveredAt` is null) |
| 29 | |
| 30 | 3. **OPERATION:** `fulfillmentOrders` — query (optional, for location breakdown) |
| 31 | **Inputs:** `assignedLocationId: <location_id>`, `status: CLOSED`, `first: 250` |
| 32 | **Expected output:** Fulfilled orders per location for location-level segmentation |
| 33 | |
| 34 | ## GraphQL Operations |
| 35 | |
| 36 | ```graphql |
| 37 | # orders:query — validated against api_version 2025-01 |
| 38 | query FulfilledOrders($query: String!, $after: String) { |
| 39 | orders(first: 250, after: $after, query: $query) { |
| 40 | edges { |
| 41 | node { |
| 42 | id |
| 43 | name |
| 44 | createdAt |
| 45 | fulfillments { |
| 46 | id |
| 47 | createdAt |
| 48 | updatedAt |
| 49 | deliveredAt |
| 50 | status |
| 51 | trackingInfo { |
| 52 | company |
| 53 | number |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 | } |
| 58 | pageInfo { |
| 59 | hasNextPage |
| 60 | endCursor |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | ``` |
| 65 | |
| 66 | ```graphql |
| 67 | # fulfillmentOrders:query — validated against api_version 2025-01 |
| 68 | query FulfillmentOrdersByLocation($locationId: ID!, $after: String) { |
| 69 | fulfillmentOrders( |
| 70 | assignedLocationId: $locationId |
| 71 | first: 250 |
| 72 | after: $after |
| 73 | query: "status:closed" |
| 74 | ) { |
| 75 | edges { |
| 76 | node { |
| 77 | id |
| 78 | assignedLocation { |
| 79 | location { |
| 80 | id |
| 81 | name |
| 82 | } |
| 83 | } |
| 84 | order { |
| 85 | id |
| 86 | name |
| 87 | } |
| 88 | } |
| 89 | } |
| 90 | pageInfo { |
| 91 | hasNextPage |
| 92 | endCursor |
| 93 | } |
| 94 | } |
| 95 | } |
| 96 | ``` |
| 97 | |
| 98 | ## Session Tracking |
| 99 | |
| 100 | **Claude MUST emit the following output at each stage. This is mandatory.** |
| 101 | |
| 102 | **On start**, emit: |
| 103 | ``` |
| 104 | ╔══════════════════════════════════════════════╗ |
| 105 | ║ SKILL: Delivery Time Analysis ║ |
| 106 | ║ Store: <store domain> ║ |
| 107 | ║ Started: <YYYY-MM-DD HH:MM UTC> ║ |
| 108 | ╚══════════════════════════════════════════════╝ |
| 109 | ``` |
| 110 | |
| 111 | **After each step**, emit: |
| 112 | ``` |
| 113 | [N/TOTAL] <QUERY|MUTATION> <OperationName> |
| 114 | → Params: <brief summary of key inputs> |
| 115 | → Result: <count or outcome> |
| 116 | ``` |
| 117 | |
| 118 | **On completion**, emit: |
| 119 | |
| 120 | For `format: human` (default): |
| 121 | ``` |
| 122 | ══════════════════════════════════════════════ |
| 123 | DELIVERY TIME ANALYSIS (<days_back> days) |
| 124 | Orders analyzed: <n> |
| 125 | With delivery data: <n> |
| 126 | |
| 127 | Carrier Orders Avg Days Min Max |
| 128 | ───────────────────────────────────────────── |
| 129 | UPS <n> <d> <d> <d> |
| 130 | USPS <n> <d> <d> <d> |
| 131 | FedEx <n> <d> <d> <d> |
| 132 | (carriers below min_orders threshold excluded) |
| 133 | Output: delivery_analysis_<date>.csv |
| 134 | ══════════════════════════════════════════════ |
| 135 | ``` |
| 136 | |
| 137 | For `format: json`, emit: |
| 138 | ```json |
| 139 | { |
| 140 | "skill": "delivery-time-analysis", |
| 141 | "store": "<domain>", |
| 142 | "period_days": 30, |
| 143 | "carriers": [ |
| 144 | { "name": "UPS", "orders": 0, "avg_days": 0, "min_days": 0, "max_days": 0 } |
| 145 | ], |
| 146 | "output_file": "delivery_analysis_<date>.csv" |
| 147 | } |
| 148 | ``` |
| 149 | |
| 150 | ## Output Format |
| 151 | CSV file `delivery_analysis_<YYYY-MM-DD>.csv` with columns: |
| 152 | `order_name`, `fulfillment_id`, `carrier`, `fulfilled_at`, `delivered_at`, `transit_days` |
| 153 | |
| 154 | ## Error Handling |
| 155 | | Error | Cause | Recovery | |
| 156 | |-------|-------|----------| |
| 157 | | `THROTTLED` | API rate limit exceeded | Wait 2 seconds, retry up to 3 times | |
| 158 | | `deliveredAt` is null | Carrier hasn't confirmed delivery | Exclude from averages, count as "in trans |