skills/vendix-inventory-stock/SKILL.md
Inventory stock management patterns: StockLevelManager, stock_levels source of truth, reservations, variant/base transitions, audit records, and denormalized stock sync. Trigger: When working with stock levels, inventory adjustments, stock transfers, reservations, or any operation that modifies product/variant quantities.
npx skillsauth add rzyfront/vendix vendix-inventory-stockInstall 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.
apps/backend/src/domains/store/inventory/shared/services/stock-level-manager.service.ts.stock_levels with unique (product_id, product_variant_id, location_id).products.stock_quantity and product_variants.stock_quantity are maintained by syncProductStock().stock_quantity mirrors quantity_available, not quantity_on_hand.| Field | Meaning |
| --- | --- |
| quantity_on_hand | Physical units in the location |
| quantity_reserved | Units locked by active reservations |
| quantity_available | Sellable units; on_hand - reserved |
Never sell from quantity_on_hand directly.
Use StockLevelManager for stock writes. Do not update stock_levels, products.stock_quantity, or product_variants.stock_quantity directly.
updateStock():
track_inventory = false and returns null stock/transaction values.getOrCreateStockLevel() for missing location rows.inventory_transactions record.inventory_movements record only when create_movement: true.syncProductStock() and emits stock.updated / stock.low as applicable.syncProductStock(product_id, variant_id?):
product_variants.stock_quantity for that variant.Call sync after any stock/reservation change unless the manager method already does it.
reserveStock() creates active stock_reservations, increments quantity_reserved, decrements quantity_available, then syncs.releaseReservation() marks active reservations as consumed and restores available stock.releaseReservationsByReference(..., 'consumed') consumes reserved units by reducing quantity_on_hand.releaseReservationsByReference(..., 'cancelled') restores available stock without reducing on-hand stock.releaseAllReservationsForProduct() and releaseAllActiveReservations() are bulk helpers for cleanup flows.Simple/base stock uses product_variant_id = null. Variant stock uses a variant id.
Simple to variant:
transferBaseStockToVariants(product_id, variant_ids, user_id, mode, tx).first, distribute, reset.enforceStockLevelsMode() removes base stock rows after variants exist.initializeVariantStockAtLocations().Variant to simple:
transferVariantStockToBase(product_id, variant_ids, user_id, tx) before deleting variants.StockLevelManager uses StorePrismaService. Some internals use _baseClient || prisma for nullable composite keys and cross-mode aggregation. Do not copy that bypass into request handlers; prefer scoped service access unless the stock manager already encapsulates it.
updateStock().stock_levels has cascade FKs; destructive product/location deletes can remove stock state. Use migration/data cleanup safeguards.vendix-prisma-scopesvendix-backendvendix-error-handlingdevelopment
Mobile app development rules for Vendix Expo/React Native project. Trigger: When editing, creating, or modifying any file under apps/mobile, or when developing mobile-specific features.
development
Feature gating by store subscription state: global store write guard, AI feature gate, Redis feature resolution, quota consumption, frontend paywall interceptor, banner, and subscription UI states. Trigger: When adding feature gates, paywalls, subscription-based access control, protecting store write operations, AI feature gates, or rollout flags.
testing
SaaS subscription billing for Vendix stores: plan pricing, invoices, Wompi platform payments, manual payments, partner commissions, payouts, proration, and dunning. Trigger: When creating SaaS invoices, working with partner rev-share, margin/surcharge pricing, invoice sequence allocation, partner payout batches, subscription payments, manual payments, or dunning flows.
development
Periodic quota counters with Redis, UTC period keys, Lua-based idempotent AI quota consumption, request-id deduplication, and post-success consumption. Trigger: When building quota counters, enforcing monthly/daily feature caps, or reusing AI quota patterns for uploads, emails, exports, or rate-limited features.