skills/catalog-inventory/inventory-tracking/SKILL.md
Track stock levels in real time across your platform with inventory reservation to prevent overselling and support for backorders
npx skillsauth add finsilabs/awesome-ecommerce-skills inventory-trackingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Real-time inventory tracking prevents overselling by reserving stock when customers add items to their cart and decrementing it on order fulfillment. Every major e-commerce platform has this built in. Platform-native inventory tracking is almost always the right starting point — only build custom inventory logic if you have requirements that platforms cannot meet (complex multi-warehouse routing, custom reservation windows, or external WMS integration).
| Platform | Built-in Inventory | Recommended Extension | |----------|-------------------|----------------------| | Shopify | Native per-variant inventory tracking with location support | Stocky (free, by Shopify) for purchase orders and demand forecasting | | WooCommerce | Native stock management with backorder support | ATUM Inventory Management for advanced multi-warehouse and supplier POs | | BigCommerce | Native per-SKU inventory tracking with low-stock alerts | Multi-Location Inventory app for warehouse routing | | Custom / Headless | Build atomic reservation with optimistic locking | Required for custom platforms without native inventory management |
Shopify tracks inventory per variant, per location, natively.
Enable inventory tracking:
Set up locations:
Backorders:
Oversell prevention during high traffic:
Shopify's checkout system holds inventory during the checkout process to prevent two customers from purchasing the last item simultaneously. For flash sales, use Shopify Scripts (Plus) or the Inventory Planner app to set purchase limits.
Inventory sync with physical locations:
WooCommerce has built-in stock management.
Enable inventory tracking:
Per-product settings:
Advanced inventory management with ATUM:
BigCommerce tracks inventory per SKU natively.
Enable inventory tracking:
Multi-location inventory:
Backorders:
For custom platforms, implement atomic inventory reservation using optimistic concurrency control to prevent overselling under high load:
// lib/inventory.ts
const MAX_RETRIES = 3;
// Reserve inventory atomically — handles concurrent requests safely
export async function reserveInventory({
variantId, locationId, quantity, referenceId
}: { variantId: string; locationId: string; quantity: number; referenceId: string }) {
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
const level = await db.inventoryLevels.findUnique({
where: { variantId_locationId: { variantId, locationId } },
});
if (!level) throw new Error(`Inventory not found: ${variantId}`);
const available = level.onHand - level.reserved;
if (available < quantity && !level.backorderAllowed) {
throw new Error(`Insufficient stock: ${available} available, ${quantity} requested`);
}
// Optimistic update — only succeeds if version hasn't changed (no concurrent modifications)
const updated = await db.inventoryLevels.updateMany({
where: { variantId_locationId: { variantId, locationId }, version: level.version },
data: { reserved: level.reserved + quantity, version: level.version + 1 },
});
if (updated.count === 0) {
// Another process modified inventory concurrently; retry
await new Promise(r => setTimeout(r, 50 * (attempt + 1)));
continue;
}
// Log the transaction for audit trail
await db.inventoryTransactions.create({
data: { variantId, locationId, type: 'reserve', quantity: -quantity, referenceId },
});
return { success: true, remaining: available - quantity };
}
throw new Error(`Failed to reserve inventory after ${MAX_RETRIES} retries`);
}
// Release reservation when cart expires or order is cancelled
export async function releaseReservation({
variantId, locationId, quantity, referenceId
}: { variantId: string; locationId: string; quantity: number; referenceId: string }) {
// Idempotency check — don't release twice
const existing = await db.inventoryTransactions.findFirst({
where: { type: 'release', referenceId, variantId },
});
if (existing) return;
await db.$transaction([
db.inventoryLevels.update({
where: { variantId_locationId: { variantId, locationId } },
data: { reserved: { decrement: quantity } },
}),
db.inventoryTransactions.create({
data: { variantId, locationId, type: 'release', quantity: +quantity, referenceId },
}),
]);
}
// Expire stale cart reservations — run every 5-10 minutes via cron
export async function expireStaleCartReservations() {
const TTL_MINUTES = 30;
const cutoff = new Date(Date.now() - TTL_MINUTES * 60 * 1000);
const staleCarts = await db.carts.findMany({
where: { status: 'active', updatedAt: { lt: cutoff }, reservedAt: { not: null } },
include: { items: true },
});
for (const cart of staleCarts) {
for (const item of cart.items) {
await releaseReservation({ variantId: item.variantId, locationId: item.locationId, quantity: item.quantity, referenceId: cart.id });
}
}
}
Backorders allow customers to purchase even when stock is at zero, with a clear expectation of a delayed delivery.
When to allow backorders:
When to block backorders:
Communication best practices:
Pair inventory tracking with low-stock alerts — see the @low-stock-alerts skill for full setup. Quick summary:
inventory_transactions table is essential for diagnosing discrepancies| Problem | Solution |
|---------|----------|
| Overselling during flash sales on Shopify | Shopify's checkout holds inventory during the checkout flow; for very high-concurrency launches, set purchase limits using Shopify Scripts (Plus) or use a waitlist app |
| WooCommerce inventory not decremented after order | Check that stock management is enabled on the product AND globally in WooCommerce settings; both must be on |
| Inventory released immediately when order is cancelled before fulfillment | This is correct behavior for physical goods — released inventory becomes available for other customers; only delay release for backordered items |
| Negative inventory after manual adjustment | Add validation in WooCommerce (ATUM) or set a DB check constraint on custom builds; reserved >= 0 and on_hand >= 0 |
| Shopify location not receiving inventory updates from POS | Ensure POS is connected to the correct Shopify location in Settings → Locations → POS channel |
tools
Let shoppers save products to a wishlist, share it with friends, and get notified when saved items come back in stock or drop in price
development
Build a themeable storefront with design tokens and CSS custom properties that supports white-labeling, multi-brand variants, and dark mode
development
Speed up product discovery with instant search suggestions, fuzzy typo matching, and category-aware results powered by Algolia or Elasticsearch
development
Build a mobile-first storefront with thumb-friendly navigation, sticky add-to-cart buttons, and touch-optimized components for high mobile conversion