Shipping rate shop

From tinh2/skills-hub-registry · View interactive version

Shipping rate shop is an AI agent skill from the GitHub repository tinh2/skills-hub-registry. Multi-carrier shipping rate comparison and label-generation pipeline — real-time quotes from USPS, UPS, FedEx, DHL via direct carrier APIs OR aggregators (Shippo / EasyPost / ShipStation / Pirate Ship)..

How to use this skill

Skill file

Multi-Carrier Shipping Rate Shop

You generate a complete multi-carrier shipping pipeline. The 2026 rate landscape rewards rate-shopping: FedEx/UPS/DHL each took +5.9% general rate increases, USPS implemented service-specific changes Jan 18, 2026 plus a temporary 8% surcharge from Apr 26, 2026 through Jan 17, 2027. Static carrier choice leaves money on the table.

Carrier strength heuristics that hold in 2026:

============================================================

=== PRE-FLIGHT ===

============================================================

Verify:

Recovery:

============================================================

=== PHASE 1: RATE SHOP CORE ===

============================================================

Generate rate_shop.py (Python) or rateShop.ts (Node):

def rate_shop(parcel, from_addr, to_addr, options={}):
    """
    Returns sorted list of carrier+service+rate quotes.
    parcel: {weight_oz, length_in, width_in, height_in}
    from_addr / to_addr: {name, street1, city, state, zip, country}
    options: {residential, signature_required, insurance_amount, saturday_delivery}
    """
    quotes = []
    for carrier_client in active_carriers():
        try:
            carrier_quotes = carrier_client.get_rates(parcel, from_addr, to_addr, options)
            quotes.extend(carrier_quotes)
        except RateRequestError as e:
            log.warning(f"{carrier_client.name} rates unavailable: {e}")
    return sorted(quotes, key=lambda q: (q['rate_usd'], q['delivery_days']))

Each quote has: carrier, service, service_code, rate_usd, delivery_days, est_delivery_date, rate_id (for label purchase later).

VALIDATION: Rate shop returns ≥ 2 carrier quotes for a sample 1-lb domestic shipment. If only 1 returns, surface the others' errors clearly.

============================================================

=== PHASE 2: DIMENSIONAL WEIGHT CALCULATION ===

============================================================

Dim weight catches teams off-guard. Each carrier has its own divisor:

| Carrier | Domestic divisor | International divisor |

| ------- | ---------------- | --------------------- |

| UPS | 139 | 139 |

| FedEx | 139 | 139 |

| USPS | 166 (Priority) | 166 |

| DHL | 139 | 139 |

billable_weight = max(actual_weight_lb, ceil((L × W × H) / divisor))

Always compute and surface dim weight in the quote response so the user knows their effective billing weight, not just actual.

VALIDATION: Dim weight calc matches each carrier's published worksheet for a 14×10×6 box at 2 lb actual.

============================================================

=== PHASE 3: ADDRESS VALIDATION ===

============================================================

Bad addresses → returned packages → real cost. Run address validation before quoting:

Output: corrected address, residential/commercial flag, deliverability score. Residential flag matters — UPS Ground residential adds ~$5.50/package vs commercial.

VALIDATION: A known-bad address (e.g., "123 Fake St, San Francisco CA") returns deliverability="undeliverable" not silently accepted.

============================================================

=== PHASE 4: CARRIER-SPECIFIC SERVICES ===

============================================================

Pre-populate the service list per carrier with 2026-current codes:

USPS: Priority Mail, Priority Mail Express, Ground Advantage (replaced Retail Ground + First-Class Package in 2023), Media Mail.

UPS: UPS Ground, 3 Day Select, 2nd Day Air, Next Day Air, Next Day Air Saver, SurePost (USPS final-mile), Worldwide Express/Expedited/Saver/Standard.

FedEx: FedEx Ground, Home Delivery, Express Saver, 2Day, Standard Overnight, Priority Overnight, First Overnight, International Economy/Priority.

DHL eCommerce: SmartMail Parcel Expedited, SmartMail Parcel Plus Expedited, Parcel International Standard/Direct, Express Worldwide.

Each service has cutoff times by zone — show the latest "drop-off by X to ship today" in the quote.

VALIDATION: Service list matches each carrier's 2026 published codes. Cutoff times zone-aware.

============================================================

=== PHASE 5: LABEL PURCHASE + TRACKING ===

============================================================

Once a quote is selected, generate purchase_label.py:

  1. Buy label via carrier API or aggregator (POST /shipments/{rate_id}/buy).
  2. Receive label PDF/PNG/ZPL (thermal label) + tracking number.
  3. Persist to DB: tracking_number, carrier, service, rate_paid, purchased_at, from_addr, to_addr.
  4. Subscribe to tracking webhook (EasyPost Track endpoint, Shippo Tracker).
  5. On status change, push to order DB (label_created, picked_up, in_transit, out_for_delivery, delivered, exception, returned).

For high-volume shippers, support manifest creation (end-of-day batch close) — required for USPS and reduces per-package fee.

VALIDATION: Buy-and-track round trip works against the carrier sandbox. Status webhook updates the DB within 60s.

============================================================

=== PHASE 6: SMART CARRIER ROUTING ===

============================================================

Pre-route the user to the right carrier based on package signal:

def recommend_carrier(parcel, dest, urgency):
    """Heuristic-first, rate-shop-validated."""
    if parcel.weight_oz < 16 and dest.country == 'US' and urgency >= 3:
        candidates = ['USPS_Ground_Advantage', 'UPS_SurePost']
    elif parcel.weight_lb > 10 and dest.country == 'US':
        candidates = ['UPS_Ground', 'FedEx_Ground']
    elif dest.country != 'US' and parcel.weight_lb < 4.4:
        candidates = ['DHL_eCommerce', 'USPS_Priority_Intl']
    elif urgency == 1:  # next day
        candidates = ['UPS_Next_Day_Air_Saver', 'FedEx_Standard_Overnight', 'USPS_Priority_Mail_Express']
    else:
        candidates = ['ALL']
    return rate_shop_filtered(candidates)

Pair heuristics with rate-shop validation — heuristics narrow the field, real rates make the call.

VALIDATION: Recommendations match published carrier-strength patterns within 90% of test fixtures.

============================================================

=== PHASE 7: COST MONITORING ===

============================================================

Generate cost_dashboard.sql (or BigQuery / Snowflake equivalent) that reports weekly:

This is where the rate-shop ROI compounds. Without monitoring, savings drift.

VALIDATION: Dashboard query runs against the user's shipping data warehouse and surfaces ≥ 3 actionable findings.

============================================================

=== SELF-REVIEW ===

============================================================

Score 1–5:

Common gap: failing to compute dim weight → quote looks cheap but actual charge is 2-3× higher. Always surface billable weight.

============================================================

=== LEARNINGS CAPTURE ===

============================================================

Append to ~/.claude/skills/shipping-rate-shop/LEARNINGS.md:

<YYYY-MM-DD> — <vendor stack, volume, lane mix>

============================================================

=== STRICT RULES ===

============================================================

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.