agentleFS
sadrmaneshsadrmanesh/commerce-agent-skills/skills/inventory-and-multi-warehouse/SKILL.md

inventory-and-multi-warehouse

Skill1 starsChanged 18 days agoMITView on GitHub

Track stock per location with on-hand, reserved, and available quantities, reserve at checkout, and allocate orders across warehouses without overselling. Use when adding warehouses or stores as stock locations, reservations, transfers, or order routing.

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Keep separate quantities: on_hand (physically there), reserved (held for unpaid or unshipped orders), and available = on_hand - reserved - …

    line 18
  2. Distinctive:

    Only locations that can ship to the destination and are active.

    line 28
  3. Very specific:

    Run node scripts/allocate-stock.mjs order.json stock.json to test a policy on sample data.

    line 33

≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Inventory and multi-warehouse

A single stock number per product stops working once there are two places that ship, or a checkout that holds stock while the shopper pays. Model quantities per location and per state, and change them only through movements. Platform notes are in the platform notes.

Procedure

  1. Key stock by purchasable unit (SKU or variation) and location. A product with sizes has one row per size per location.
  2. Keep separate quantities: on_hand (physically there), reserved (held for unpaid or unshipped orders), and available = on_hand - reserved - safety_stock. Sell only from available.
  3. Change stock only by writing a movement row: receipt, sale reservation, release, shipment, return, adjustment, or transfer. The current quantity is the sum of movements, or a cached total updated in the same transaction.
  4. Reserve at order creation with a conditional update, such as UPDATE stock SET reserved = reserved + :qty WHERE sku = :sku AND location = :loc AND on_hand - reserved - safety_stock >= :qty. Zero rows updated means not enough stock.
  5. Give each reservation an expiry. Release it when payment fails or the hold expires. Convert it to a shipment when the order ships.
  6. Allocate an order to locations with an explicit policy, then reserve at those locations. Store the allocation on the order lines.

Allocation

A common policy, in order:

  1. Only locations that can ship to the destination and are active.
  2. One location that can fill every line, the closest or cheapest first.
  3. Otherwise split by line across the fewest locations.
  4. Otherwise back-order or reject the line, as the store policy says. Never reserve more than available.

Run node scripts/allocate-stock.mjs order.json stock.json to test a policy on sample data. It returns the allocation per line and any shortfall, and never allocates more than a location has available.

Transfers

A transfer is two movements: out of the source when it ships, and into the destination when it is received. Stock in transit is in neither available figure. Record incoming at the destination if buyers need to see it.

Counts and adjustments

A stock count writes an adjustment movement for the difference, with a reason and the user. Do not overwrite on_hand directly, or the history and any reservations made during the count are lost.

Gotchas

  • Reading available stock and then writing it in a second statement oversells under load. Check and reserve in one conditional update or a row lock.
  • Decrementing on_hand at checkout and again at shipment counts the sale twice. Reserve at checkout, then move reserved to shipped.
  • A parent product's total is not a sellable quantity. Sell from the variation's row.
  • Safety stock that is not subtracted from available lets the last units sell online while the store floor still shows them.
  • Returns go back into stock only after inspection. Use a separate location or state such as quality_control until then.

Verification

  • Two concurrent checkouts for the last unit: one reserves, the other is refused.
  • An expired unpaid reservation returns its quantity to available.
  • An order for two lines that one warehouse can fill is not split.
  • A transfer in transit does not appear as available at either location.
  • The movement log sums to the current on_hand for every SKU and location.

Evaluation

Worked examples and the checks they must satisfy are in evals/tasks.json.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.