bmrc-domain

Defines inventory stock math, location model, and data invariants for the BMRC logistics app.

2|Updated Dec 24, 2025
One-click install
npx skills add https://github.com/iv-zhang/BMRC-Logistics --skill bmrc-domain-iv-zhang
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: bmrc-domain
Source: https://github.com/iv-zhang/BMRC-Logistics/tree/main/.claude/skills/bmrc-domain
Command: npx skills add https://github.com/iv-zhang/BMRC-Logistics --skill bmrc-domain-iv-zhang

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Medical supply inventory bugs are dangerous: wrong stock math means a crew opens a bag in the field and the medication is missing or expired. This Skill encodes the BMRC Logistics app's data model, stock computation rules, and hard invariants so any code change touching inventory, batches, locations, or Firestore documents stays consistent and safe. ## Core Features & Use Cases - Single sources of truth: Routes all stock counts, status chips, and location display through canonical helpers like computeBagStock(), getItemStatus(), and displayLocation() in app/lib/item-status.ts. - Two stock models plus two pools: Documents bag/lot-tracked vs. box-tracked items, the physical vs. available distinction, and the back-reserve vs. front-shelf split including refillShelf() transfer semantics. - Invariant contract: Enforces twelve tested invariants (INV-1 to INV-12) covering FEFO draws, expiration exclusion, recall quarantine, and location move validation, verified via npm run test:invariants. - Use Case: Before fixing a bug where an expired lot still shows as available, consult this Skill to learn that availableItems (not totalItems) drives readiness decisions and that status precedence is expired > out > low > expiring > ok. ## Quick Start Ask the AI to review a planned change to inventory stock calculation code and confirm it follows the BMRC domain invariants before implementing it.

Frequently Asked Questions about bmrc-domain

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I compute available stock for an inventory item?▼

Call computeBagStock() from app/lib/item-status.ts and use its availableItems value, which excludes expired and quarantined lots. Never use totalItems for readiness, low-stock, or buy-list decisions, and never re-implement the math elsewhere.

What is the difference between totalItems and availableItems?▼

totalItems is physical on-hand stock including expired and quarantined lots, used by inventory and audit views. availableItems is deployable stock that excludes expired and quarantined batches and drives every readiness, reorder, and pack-fill decision.

How do I move an item to a new storage location in Firestore?▼

Use moveItemLocation() or moveItemsBulk() from app/lib/audit-actions.ts, which resolve the destination zone and sync the legacy location, room, and currentLocation mirror fields. Writing storageLocation with a raw updateDoc breaks legacy filters and is rejected for unknown zones.

Why does an item with stock on the shelf still show as out?▼

Status is driven only by the back-reserve pool, not the front shelf shelfQuantity. The shelf is a deployed, uncounted pool re-anchored by periodic physical checks, so an empty reserve correctly reads out even when the shelf looks full.

How are expired lots handled in status calculation?▼

getItemStatus() flags expired only when a batch with actual stock has a past expirationDate, using precedence expired > out > low > expiring > ok. Zero-stock tombstone batches never flag an item expired, and expired lots are excluded from availableItems per INV-6.

What tests must pass before shipping a data-touching change?▼

Run npm run test:invariants to verify the INV-1 through INV-12 contract covering over-consumption, FEFO, recalls, and location moves. If you touched computeBagStock or getItemStatus, also run npm run test:properties.