| name | integration-guard |
| description | Use when writing or modifying code that interacts with REX (Retail Express), Shopify, or any external integration/sync system. Triggers on work involving SOAP calls, REX API, Shopify API, inventory sync, order sync, product sync, fulfillment sync, or any code in services/retailExpress/, services/shopify*, or queue workers. Use before writing any integration code to avoid known pitfalls. |
Integration Guard
Overview
A pre-code checklist and reference for external integration work. REX and Shopify integrations have accumulated many gotchas from production incidents. This skill codifies those lessons so you don't repeat them.
When to Use
- Before writing ANY code that touches REX or Shopify APIs
- Before modifying sync workers or queue processors
- When debugging integration failures
- When adding new sync flows
Specialized Skills (invoke for deeper guidance)
For detailed domain knowledge, invoke the specialized skill FIRST:
| Domain | Skill | When |
|---|
| REX SOAP API | /rex-soap-protocol | Any SOAP envelope, REX API call, fulfillment sync, error handling |
| Queue/sync workers | /sync-worker | Any queue worker, retry logic, checkpoint, echo detection, backoff |
| Shopify API/webhooks | /shopify-integration | Any webhook handler, API call, pagination, inventory push |
This integration-guard provides a general checklist. The specialized skills above provide the deep patterns.
Pre-Code Checklist
Run through ALL of these before writing integration code:
1. Data Type Safety
2. SOAP Protocol (invoke /rex-soap-protocol for full details)
3. Multi-Tenant Safety
4. Queue & Sync Patterns (invoke /sync-worker for full details)
5. Inventory Specifics
6. Order Specifics
7. PO (Purchase Order) Specifics
Environment Reference
- REX environment:
testhuntthenight.retailexpress.com.au is LIVE — treat as production
- Shopify: Check
.env for store URL and API keys
- Sync checkpoint: Don't create death spirals —
shouldAdvance requires entitiesSynced > 0
Quick Reference: File Locations
| Component | Path |
|---|
| REX sync services | apps/api/src/services/retailExpress/ |
| Shopify services | apps/api/src/services/shopify*/ |
| Queue workers | apps/api/src/workers/ |
| Sync checkpoints | apps/api/src/services/syncCheckpoint* |
| Inventory sync | apps/api/src/services/inventory*/ |
Common Mistakes From Production
| Incident | Root Cause | Prevention |
|---|
| Order sync losing IDs | BigInt precision loss | Cast to String |
| Silent SOAP failures | SOAP 1.2 used instead of 1.1 | Always SOAP 1.1 |
| Inventory wrong on Shopify | Math.max(0, qty) clamping | Never clamp negatives |
| Queue items stuck forever | No stale lock recovery | 5-min lock timeout sweep |
| Products not linking | Wrong SKU field used | supplier_sku → sku mapping |
| Sync checkpoint spiral | shouldAdvance with 0 entities | Require entitiesSynced > 0 |
| PO submission 500 error | No try/catch on rex_incomplete | Always wrap SOAP calls |