Skip to the lesson
CivOps AI Academy · M13Warehouse (WMS): Scan-Verified Moves Posted to the Ledger
0%

Chapter 1 · Sessions 1–2

What the old WMS holds, and the tables that replace it

A stock ledger knows how many units of which lot sit in which location. A warehouse management system (WMS) adds what has to happen and who did it: it directs every physical move, checks it by scan, and posts the result to the ledger. Session 1 finds out what your WMS does and costs, from its own reports and bills. Session 2 adds the fifteen wms_ tables, the rules, a worked example, a made-up seed and the GS1 label parser, with the one rule above all others: the warehouse keeps no stock quantity of its own.

30 minAbout 7 hours hands-on across six sessionsSessions 1–2: 6 steps15 tables, 0 quantities of its own

By the end of this chapter you can

  • Inventory the WMS you pay for from its own reports and bill, and take four baseline measures.
  • Map the module onto your spine and the M12 ledger, then have Claude Code write the tables, views, rules, tests, the worked example and the seed.
  • Build the GS1-128 label parser with its test labels, and try the tables on the development project yourself.

What a WMS adds to the ledger

Module M13 directs and verifies every physical warehouse move by scan: receiving against advance ship notices (ASNs, the supplier's message saying what is on the truck), quality quarantine, directed put-away, replenishment, picking, packing, shipping and cycle counting. It replaces tools such as Manhattan Active WM, Blue Yonder WMS, SAP EWM, Oracle WMS Cloud, Infios, Infor WMS and Made4net, and for smaller businesses Fishbowl, NetSuite WMS, Logiwa and Extensiv [1][2].

Think of two books. The M12 ledger is the book of how much: item, lot, location and status, one row per movement. The warehouse module is the book of what has to happen and who did it. The second book never copies a quantity from the first.

The edge of the warehouse moduleInside: location profiles, handling units and labels, ASNs and receipts, directed tasks, waves with packing and shipping, cycle counting and replenishment to pick faces and, by kanban, to line-side. Outside, each with its owner: valuation and purchasing in M12, transportation planning in catalogue Wave 4, labour standards and slotting in best-in-class extensions, and the pull signal a production system sends for line-side demand, which the course does not build. INSIDE THE WAREHOUSE MODULE (M13)Location profilesHandling units, labelsASNs and receiptsDirected tasksWaves and shippingwith packingCycle countingReplenishmentpick face, line-sideOUTSIDE, WITH ITS OWNERValuation and purchasingowned by M12Transportation planningcatalogue Wave 4Labour standards, slottingBIC extensionsProduction pull signalline-side demand; not built
The edge of the module. Inside: locations, handling units and labels, ASNs and receipts, directed tasks, waves, packing and shipping, counting and replenishment. Outside: valuation and purchasing (M12), transportation planning, labour standards and slotting.
The seven warehouse jobsReceiving, put-away, replenishment and picking in a row, then packing, loading and shipping, with cycle counting apart. Each stock move posts one ledger row: po_receipt, transfer_in, shipment or cycle_count. Packing posts no row itself. Receivingledger: po_receiptPut-awayledger: transfer_inReplenishmentledger: transfer_inPickingledger: transfer_inPackingno ledger row;creates load tasksLoading, shippingledger: shipmentCycle countingledger: cycle_countEvery box that moves stock posts one row to the M12 ledger; counting posts only the variance.
Seven jobs, one ledger. Receiving, put-away, replenishment and picking each post one receipt or transfer. Packing posts nothing itself. Loading posts the shipment. Counting posts only the variance.
One task, one ledger transactionA scan on the phone is checked again by the route, which calls inventory-post. That writes one ledger row and moves the balance. The ledger row id is written back to the task's inventory_txn_ref in the same database transaction. Scan on the phonelocation and unitWMS routechecks the scan againinventory-postthe only door to M12Ledger rowinv_inventory_transactionTask is doneinventory_txn_ref setBalance rowinv_inventory_balancesame databasetransactionledger row id written backledger moves itNo code outside inventory-post writes the balance table, and a unique index lets one ledger row belong to only one task.
One task, one transaction. The phone scan is checked again by the route, which calls inventory-post; the ledger row's id is written back to the task in the same database transaction.
Step 1

Session 1: Map the warehouse and the WMS you pay for, from its own reports and bill

35 minutes

Why

The module must replace real things, not guesses. A number read from the tool's own report or invoice can be checked by anyone; a number from memory is the first thing finance knocks down, and the saving in Session 6 rests on this bill. The map in the repository gives Claude Code your zones, labels and rules instead of letting it invent them.

Do this

Walk the building from inbound dock to outbound dock with the supervisor. Photograph labels and locations, never people, and only with permission. Then:

Terminal or PowerShell
cd ~/code/acme-platform && git switch main && git pull && claude
Paste into Claude Code
On a new branch wms/map, create docs/wms-map.md for Acme Bottling as a form I will fill in from the old WMS's own reports and invoices. Do not invent any number, name or price: where I have not given one, write "not known: ask <role>".

Sections:
1. Zones (receiving, reserve, forward pick, quarantine or hold, staging, shipping, line-side, returns): number of locations, how they are named, how a person finds stock.
2. Handling units and labels: pallets, cases, totes, cartons; whether license plates are used, who prints them; which GS1 application identifiers the inbound and outbound labels carry (00 SSCC, 01 GTIN, 10 lot, 17 expiry, 21 serial) or "own text only"; whether we hold a GS1 company prefix (from our own GS1 account).
3. Tools: the WMS, scanners, label printers, spreadsheets, paper pick lists, the ASN inbox: owner, users, the invoice amount and what it covers, renewal date, notice period, leased devices as their own line, and which exports it gives (locations, on-hand by license plate, open ASNs and orders, history, users).
4. The seven jobs (receiving, put-away, replenishment, picking, packing, shipping, cycle counting): who, which shifts, confirmed by scan, paper or memory. EDI messages exchanged (X12 856, 940, 945, EDIFACT DESADV), recorded only.
5. Four baselines for the latest month, each with its source: dock-to-stock time (ten receipts), pick accuracy, order cycle time (ten orders), inventory record accuracy with the tolerance used. "not recorded" where nobody records it.
6. Workarounds, in the users' own words, and where scanners lose their connection.
7. Special rules: lots and expiry, quality holds, temperature, serial tracing (DSCSA or "not applicable"), customer label requirements.
8. The pilot area: one flow from receiving to shipping, an item family of at least two items, one with lots and expiry, and a named supervisor.

Then ask me for each section in turn and write my answers in. Open a pull request titled "Warehouse map" when I say it is complete.

You will see recreated screen

claude — acme-platform
⏺ Bash(git switch -c wms/map)
⎿ Switched to a new branch 'wms/map'
⏺ Write(docs/wms-map.md)
+## 3. Tools
+| Tool | Owner | Users | Invoice amount | Covers | Renewal | Notice | Exports |
+| not known: ask finance | | | not known | | | | |
1
⏺ Write(docs/wms-map.md)
+## 5. Baselines
+| Measure | Value | Source |
+| Inventory record accuracy | not recorded | |
2
⏺ The form is ready. Section 1: which zones did you pass on the walk, and how many locations does each have?
Claude Code writes the form, then asks section by section. Gaps stay visible.
  1. Prices start as "not known".
  2. "Not recorded" is a finding, not a gap to fill with an estimate.

Check it worked

docs/wms-map.md has every section filled from a report, an invoice or a named person, each number with its source.

Fastest path

Take one test export of the location list and on-hand by license plate into a private folder now, and count the rows: Session 5 needs to know what the export really holds.

If it goes wrong

Claude Code fills in a price or a location count I never gave it

Say: Remove every number I did not give you and write "not known: ask <role>". Every number in this file must name its source.

The supervisor wants the test export in the repository "for convenience"

No: it holds item and customer data. Keep it in a private company folder; only the column headers go anywhere Claude Code can read.

Step 2

Session 1: Take four baselines, hear the workarounds, choose the pilot

25 minutes

Why

Session 6 decides whether to cancel the old tool by comparing the new module against these numbers. A baseline taken from records now, with its definition written beside it, is the only fair comparison; and the workarounds pickers and receivers describe are exactly the moves the scan-verified tasks must catch.

Do this

From your own records for the latest month: dock-to-stock time for ten receipts, pick accuracy from complaints, returns and pack-check records, order cycle time for ten orders, and inventory record accuracy from the latest counts with the tolerance used. Ask pickers and receivers, not only the supervisor, what they do to get round the system.

Paste into Claude Code, after replacing the <paste> parts
Add what I give you below to docs/wms-map.md (sections 5, 6 and 8), each number with its source and definition. Then open the pull request "Warehouse map", wait for the checks, and tell me the result in plain words.

Baselines: <paste>
Workarounds: <paste>
Pilot area and why: <paste>

Have the supervisor read the pilot area; owner two approves and it merges.

You will see recreated screen

github.com/acme-ops/acme-platform/pull/81/files
ConversationCommitsFiles changed
docs/wms-map.md
1
MeasureValueSource
Dock-to-stockmedian 6.5 h10 receipts, Oct
Pick accuracy98.1%pack-check log
Order cycle timemedian 21 h10 orders
Record accuracynot recorded
Pilot: aisle A finished goods, FG-10 (lots, expiry) and FG-20Read by the warehouse supervisor2
The map on GitHub. Session 6 compares against these four lines.
  1. Each number with its source and definition.
  2. A pilot with a shelf-life item, so earliest-expiry-first can be shown.

Check it worked

docs/wms-map.md is merged with four baselines (or "not recorded"), the workarounds in the users' words, a bill and renewal date for each paid tool, and a pilot area read by the supervisor.

If it goes wrong

Claude Code says the checks passed but the pull request shows a red check

Say: The check is red. Run gh pr checks, read the failed log, fix it and wait for green before you report. We trust the check on GitHub, never the summary.

Fifteen tables, two views, one label

Every table has the standard columns id, site_id (the specification's tenant_id, so each table keeps one simple access rule), created_at, created_by, updated_at, updated_by, row_version, archived_at and ext. The module keeps no location, item, lot or people list of its own: it points at the spine tables the library calls core_storage_location, core_item, core_item_class, core_lot, core_uom, core_party, core_address and core_person. A qty is stored as numeric(18,6), never floating point. Five columns are soft links (plain uuid, no foreign key) to M12: po_ref, sales_order_ref and the three inventory_txn_ref, each of the last three unique where set, so one ledger row belongs to one task, receipt or count line [3].

The fifteen wms_ tablesFifteen tables in five groups: places and units (2), inbound (3), counting (2), rules and work (4) and outbound (4). A sixth panel lists the M12 tables reached by soft link: inv_inventory_transaction, inv_purchase_order and inv_sales_order. A strip below lists the spine tables they point at. PLACES AND UNITSwms_location_profilewms_handling_unitINBOUNDwms_inbound_shipmentwms_inbound_linewms_receiptCOUNTINGwms_cycle_countwms_cycle_count_lineRULES AND WORKwms_putaway_rulewms_replenishment_rulewms_wavewms_taskOUTBOUNDwms_outbound_orderwms_outbound_linewms_shipmentwms_packageSOFT LINKS TO M12inv_inventory_transactioninv_purchase_orderinv_sales_orderSpine tables they point at:core_storage_location, core_item, core_lot, core_party, core_person, core_uom
The fifteen tables. Places and units, inbound, counting, rules and work, outbound; at the lower right the M12 tables reached by soft link.
TableHoldsColumns
wms_location_profileWMS attributes on a spine storage locationstorage_location_id → core_storage_location req, unique; zone_type text req: receiving, reserve, forward_pick, staging, shipping, quarantine, line_side or returns; max_volume_l num; max_weight_kg num; max_pallets int; pick_sequence int; putaway_sequence int; temperature_class text: ambient, cool, frozen or controlled; mixed_items_allowed bool; mixed_lots_allowed bool; pickable bool req
wms_handling_unitA license plate: pallet, case, tote, container or carton, with an optional SSCClpn text req, unique; hu_type text req: pallet, case, tote, container or carton; sscc text; parent_hu_id → wms_handling_unit; storage_location_id → core_storage_location; status text req: open, closed, in_transit, shipped or consumed; weight_kg num
wms_inbound_shipmentAn expected receipt (the ASN)asn_no text req, unique; supplier_party_id → core_party; carrier_party_id → core_party; po_ref uuid (soft link to inv_purchase_order); expected_at ts; dock_door text; status text req: expected, arrived, receiving, received or closed
wms_inbound_lineOne line of the ASNinbound_shipment_id → wms_inbound_shipment req; item_id → core_item req; qty_expected qty req; qty_received qty; uom_id → core_uom req; lot_no text; expiry_date date
wms_receiptA scanned receipt into a handling unitinbound_line_id → wms_inbound_line; item_id → core_item req; qty qty req; uom_id → core_uom req; lot_id → core_lot; handling_unit_id → wms_handling_unit; received_by → core_person req; received_at ts req; qc_required bool req; damage bool; inventory_txn_ref uuid (soft link to inv_inventory_transaction)
wms_putaway_ruleA directed put-away rulepriority int req; item_class_id → core_item_class; zone_type text; strategy text req: fixed, nearest_empty, consolidate, velocity or fefo_zone; params json; active bool req
wms_replenishment_rulePick-face or line-side replenishmentstorage_location_id → core_storage_location req; item_id → core_item req; min_qty qty req; max_qty qty req; trigger text req: min_max, kanban or demand; source_zone text; active bool req
wms_waveA group of order lines released for pickingwave_no text req, unique; wave_type text req: wave, batch, zone, cluster or discrete; status text req: planned, released, picking, picked or closed; released_at ts; planned_ship_at ts
wms_taskA directed warehouse tasktask_no text req, unique; task_type text req: putaway, pick, replenish, move, count, load or unload; status text req: open, assigned, in_progress, done, short or cancelled; priority int; item_id → core_item; lot_id → core_lot; qty qty; uom_id → core_uom; from_location_id → core_storage_location; to_location_id → core_storage_location; handling_unit_id → wms_handling_unit; wave_id → wms_wave; order_line_ref uuid; assigned_to → core_person; created_at_task ts; completed_at ts; inventory_txn_ref uuid (soft link to inv_inventory_transaction)
wms_outbound_orderAn order to shiporder_no text req, unique; order_type text req: customer, transfer, line_side or vendor_return; customer_party_id → core_party; sales_order_ref uuid (soft link to inv_sales_order); ship_by ts; carrier_party_id → core_party; service_level text; ship_to_address_id → core_address; status text req: new, allocated, released, picking, packed, shipped or cancelled
wms_outbound_lineA line to pickoutbound_order_id → wms_outbound_order req; item_id → core_item req; qty_ordered qty req; qty_allocated qty; qty_picked qty; qty_shipped qty; uom_id → core_uom req; lot_requirement text
wms_shipmentA shipment with its carrier documentsshipment_no text req, unique; carrier_party_id → core_party; tracking_no text; bol_no text; shipped_at ts; total_weight_kg num; package_count int; status text req: open, loaded, shipped or delivered
wms_packageA packed carton or pallet in a shipmentshipment_id → wms_shipment req; handling_unit_id → wms_handling_unit; outbound_order_id → wms_outbound_order; length_cm num; width_cm num; height_cm num; weight_kg num; label_zpl text
wms_cycle_countOne instance of a count programmecount_no text req, unique; method text req: abc, location, item, ad_hoc or wall_to_wall; status text req: planned, counting, review or posted; scheduled_at date; blind bool req
wms_cycle_count_lineA counted location and item, with its variancecycle_count_id → wms_cycle_count req; storage_location_id → core_storage_location req; item_id → core_item; lot_id → core_lot; system_qty qty; counted_qty qty; variance qty; counted_by → core_person; recount bool; approved_by → core_person; inventory_txn_ref uuid (soft link to inv_inventory_transaction)

A handling unit holds one item and one lot, and no quantity: a view, wms_hu_lot, names its item and lot. A second view, wms_allocatable, is the only stock an order may take: pickable, active reserve or forward-pick locations, released lots, less open pick and replenish tasks. Both are created with security_invoker so they apply the reader's rights [4]. Held and quarantined stock is not in the view, so it can never be offered.

LocationZone typePickablePick seq.Put-away seq.Max pallets
DOCK-INreceivingno6
QUAR-1quarantineno2
RES-A1reserveyes20104
RES-A2reserveyes30204
PICK-B1forward_pickyes10
STAGE-OUTstagingno6
The six locations of the seedDOCK-IN receiving feeds RES-A1 and RES-A2 reserve and QUAR-1 quarantine by put-away. RES-A1 replenishes the PICK-B1 forward pick face. Picks go from PICK-B1, RES-A1 and RES-A2 to STAGE-OUT. A released quarantine lot is moved on to reserve, to RES-A2 in the worked example because RES-A1 is full. DOCK-INreceiving · 6 palletsRES-A1reserve · 4 palletsput-away seq 10QUAR-1quarantine · 2 palletsRES-A2reserve · 4 palletsput-away seq 20PICK-B1forward pick · min 45STAGE-OUTstaging6 palletsput-awayreplenishpickpick from reservepick from reservereleased: move to RES-A2
The seed's six locations, four kinds of move. Put-away from DOCK-IN to reserve or quarantine; replenishment from RES-A1 to PICK-B1; picks to STAGE-OUT.

GS1 labels

GS1 publishes the identification keys suppliers, carriers and warehouses share [5]. A GTIN identifies a kind of item; an SSCC identifies one pallet. A GS1-128 label holds data fields, each started by an application identifier (AI): 00 SSCC (18 digits), 01 GTIN (14), 10 lot (up to 20), 17 expiry (YYMMDD, read as 20YY), 21 serial (up to 20). The last digit of an SSCC or GTIN is a check digit: from the right, multiply alternately by 3 and 1, add, and the check digit brings the sum to the next multiple of ten [6].

A GS1-128 label decodedThe label string (00)076543210000001012(01)11234567000104(17)270331(10)L-5001 split into four fields: AI 00 SSCC of 18 digits, AI 01 GTIN of 14 digits, AI 17 expiry in YYMMDD form, here 2027-03-31, and AI 10 lot, here L-5001. (00)076543210000001012(01)11234567000104(17)270331(10)L-500100 · SSCC07654321000000101218 digits, fixedthis pallet01 · GTIN1123456700010414 digits, fixedthe item17 · Expiry270331YYMMDD, fixed2027-03-3110 · LotL-5001up to 20 characterslast, so no separatorA field of variable length (10 lot, 21 serial) ends with character 29 (FNC1) unless it is last.A raw scan may start with the symbology identifier ]C1; the human form puts each identifier in brackets.
One label, four fields. 00 is the pallet's SSCC, 01 the item's GTIN, 17 the expiry and 10 the lot.
A check digit worked by handThe thirteen digits 1 1 2 3 4 5 6 7 0 0 0 1 0 with weights 3 and 1 alternating from the right give products 3 1 6 3 12 5 18 7 0 0 0 1 0, a sum of 56, and so a check digit of 4. Weights run from the right: the digit next to the check digit is multiplied by 3, the next by 1, and so on.digitweightproduct133111236313431251563187170300100301110304check= 56Sum 56. The next multiple of ten is 60, and 60 minus 56 is 4.So the check digit is 4 and the full GTIN-14 is 11234567000104. A scan with any other last digit is refused.
A check digit by hand. Thirteen digits, weights 3 and 1 from the right, products add to 56; the next multiple of ten is 60, so the check digit is 4.
Step 3

Session 2: Map the module onto your spine and the M12 ledger, before any table

15 minutes

Why

The module posts every move to M12's ledger and points at spine tables your Foundation may already hold under its own names. Building them blind is how a plant ends up with two location lists and a second stock book. A written map makes Claude Code extend what exists, create only what is missing, and stop if the ledger it must post to is not there.

Do this

Paste into Claude Code
Read docs/SCHEMA-PLAN.md, docs/naming-standard.md, docs/matrix.json and every file in supabase/migrations. Do not write any SQL yet.

On a new branch wms/spine, add a section "## M13 Warehouse (WMS)" to docs/spine-map.md, the one spine map every module shares (if it does not exist yet, create it with the heading "# Spine map" first; never a separate map file for this module). Put in the section, under "### Tables", exactly the text between the lines below. Then, under "### Map":
- For each spine table or function the module needs (core_site, core_uom, core_item, core_item_class, core_storage_location, core_lot, core_party, core_person, core_job_role, core_address, core_reason_code, core_number_sequence, core_comment, core_event_outbox, core_audit_log with core_audit_row(), core_touch_row(), core_current_tenant()): "we have it as <our table>, missing columns: ..." or "missing". Never plan a second table for something we have.
- For M12: whether inv_inventory_transaction, inv_inventory_balance, inv_available, inv_balance_from_ledger, the inventory-post route and scripts/check-balances.mjs exist. If any is missing, STOP and tell me: this module adds no inv_ table and changes none.
- Module tables carry site_id in place of the specification's tenant_id, so each keeps one simple access rule.
End the section with "Questions for me". Then write one spine migration (npx supabase migration new wms_spine) adding only what is missing, with row-level security on and no policies, and pgTAP tests that each new table exists with RLS on. Open "WMS spine map", wait for the schema check, and report.

----- tables for docs/spine-map.md -----
# The module's fifteen tables (from module library M13)
Standard columns on every table: id, site_id (in place of tenant_id), created_at, created_by, updated_at, updated_by, row_version, archived_at, ext.
Types: text, int, num (decimal), qty (numeric(18,6)), bool, date, ts (timestamptz), uuid, json (jsonb). "req" = not null. A list after a colon = the only allowed values. "→" = foreign key. Soft links are uuid with no foreign key.

## wms_location_profile
WMS attributes on a spine storage location.
- storage_location_id → core_storage_location req, unique
- zone_type text req: receiving, reserve, forward_pick, staging, shipping, quarantine, line_side or returns
- max_volume_l num
- max_weight_kg num
- max_pallets int
- pick_sequence int
- putaway_sequence int
- temperature_class text: ambient, cool, frozen or controlled
- mixed_items_allowed bool
- mixed_lots_allowed bool
- pickable bool req

## wms_handling_unit
A license plate: pallet, case, tote, container or carton, with an optional SSCC.
- lpn text req, unique
- hu_type text req: pallet, case, tote, container or carton
- sscc text
- parent_hu_id → wms_handling_unit
- storage_location_id → core_storage_location
- status text req: open, closed, in_transit, shipped or consumed
- weight_kg num

## wms_inbound_shipment
An expected receipt (the ASN).
- asn_no text req, unique
- supplier_party_id → core_party
- carrier_party_id → core_party
- po_ref uuid (soft link to inv_purchase_order)
- expected_at ts
- dock_door text
- status text req: expected, arrived, receiving, received or closed

## wms_inbound_line
One line of the ASN.
- inbound_shipment_id → wms_inbound_shipment req
- item_id → core_item req
- qty_expected qty req
- qty_received qty
- uom_id → core_uom req
- lot_no text
- expiry_date date

## wms_receipt
A scanned receipt into a handling unit.
- inbound_line_id → wms_inbound_line
- item_id → core_item req
- qty qty req
- uom_id → core_uom req
- lot_id → core_lot
- handling_unit_id → wms_handling_unit
- received_by → core_person req
- received_at ts req
- qc_required bool req
- damage bool
- inventory_txn_ref uuid (soft link to inv_inventory_transaction)

## wms_putaway_rule
A directed put-away rule.
- priority int req
- item_class_id → core_item_class
- zone_type text
- strategy text req: fixed, nearest_empty, consolidate, velocity or fefo_zone
- params json
- active bool req

## wms_replenishment_rule
Pick-face or line-side replenishment.
- storage_location_id → core_storage_location req
- item_id → core_item req
- min_qty qty req
- max_qty qty req
- trigger text req: min_max, kanban or demand
- source_zone text
- active bool req

## wms_wave
A group of order lines released for picking.
- wave_no text req, unique
- wave_type text req: wave, batch, zone, cluster or discrete
- status text req: planned, released, picking, picked or closed
- released_at ts
- planned_ship_at ts

## wms_task
A directed warehouse task.
- task_no text req, unique
- task_type text req: putaway, pick, replenish, move, count, load or unload
- status text req: open, assigned, in_progress, done, short or cancelled
- priority int
- item_id → core_item
- lot_id → core_lot
- qty qty
- uom_id → core_uom
- from_location_id → core_storage_location
- to_location_id → core_storage_location
- handling_unit_id → wms_handling_unit
- wave_id → wms_wave
- order_line_ref uuid
- assigned_to → core_person
- created_at_task ts
- completed_at ts
- inventory_txn_ref uuid (soft link to inv_inventory_transaction)

## wms_outbound_order
An order to ship.
- order_no text req, unique
- order_type text req: customer, transfer, line_side or vendor_return
- customer_party_id → core_party
- sales_order_ref uuid (soft link to inv_sales_order)
- ship_by ts
- carrier_party_id → core_party
- service_level text
- ship_to_address_id → core_address
- status text req: new, allocated, released, picking, packed, shipped or cancelled

## wms_outbound_line
A line to pick.
- outbound_order_id → wms_outbound_order req
- item_id → core_item req
- qty_ordered qty req
- qty_allocated qty
- qty_picked qty
- qty_shipped qty
- uom_id → core_uom req
- lot_requirement text

## wms_shipment
A shipment with its carrier documents.
- shipment_no text req, unique
- carrier_party_id → core_party
- tracking_no text
- bol_no text
- shipped_at ts
- total_weight_kg num
- package_count int
- status text req: open, loaded, shipped or delivered

## wms_package
A packed carton or pallet in a shipment.
- shipment_id → wms_shipment req
- handling_unit_id → wms_handling_unit
- outbound_order_id → wms_outbound_order
- length_cm num
- width_cm num
- height_cm num
- weight_kg num
- label_zpl text

## wms_cycle_count
One instance of a count programme.
- count_no text req, unique
- method text req: abc, location, item, ad_hoc or wall_to_wall
- status text req: planned, counting, review or posted
- scheduled_at date
- blind bool req

## wms_cycle_count_line
A counted location and item, with its variance.
- cycle_count_id → wms_cycle_count req
- storage_location_id → core_storage_location req
- item_id → core_item
- lot_id → core_lot
- system_qty qty
- counted_qty qty
- variance qty
- counted_by → core_person
- recount bool
- approved_by → core_person
- inventory_txn_ref uuid (soft link to inv_inventory_transaction)
----- end -----

You will see recreated screen

claude — acme-platform
⏺ Write(docs/spine-map.md)
+## M13 Warehouse (WMS)
+| Spine / M12 | Ours | Action |
+| core_storage_location | (from M12) | none |
+| core_item_class | (none) | create |
+| inventory-post | app/api/inventory-post | present |
1
⏺ Bash(gh pr checks --watch)
⎿ schema / test pass 1m49s
⏺ Pull request #82 is green. M12's ledger, views, posting route and balance check are all present. It creates 2 spine tables we did not have (core_item_class, core_address), with row-level security on and no policies.
The map, including the check that M12's ledger is there to post to.
  1. If M12 is missing, Claude Code stops: build M12 Sessions 2–4 first.

Check it worked

Pull request WMS spine map is green, the M13 section of docs/spine-map.md has no open questions, M12's ledger is confirmed present, and no new table duplicates one you had.

If it goes wrong

The map says M12's ledger is missing

Stop here and build M12 Sessions 2 to 4 first. Never let Claude Code create an inv_ table in this module: two modules would then own the same book.

CI fails with: column does not exist, on a fresh database

A column has no migration. Say: Rebuild from nothing using only supabase/migrations, run supabase db diff, and write any missing change as a new migration. We hit this: ten columns merged with no migration.

Step 4

Session 2: One prompt: the tables, the views, the rules page, the tests, the worked example and the seed

30 minutes

Why

The rules that keep the book honest (no quantity outside the ledger, one ledger row per task, held stock never offered) must exist in the database and in one readable page before any route exists. The worked example is fixed and small, kept as a test fixture so that Session 4 can be worked by hand to the unit; the seed gives the development project the same rows shifted onto today.

Do this

After the spine pull request has merged:

Paste into Claude Code
Read the M13 section of docs/spine-map.md and docs/naming-standard.md. Use our table names from the map wherever the library says core_...

On a new branch wms/tables:
1. npx supabase migration new wms_tables: the fifteen tables exactly as the M13 section of docs/spine-map.md lists them, with site_id in place of tenant_id (allowed values as check constraints, qty as numeric(18,6), soft links plain uuid). Every table: index on its scope column, row-level security on with no policies, touch and audit triggers. Unique indexes on each inventory_txn_ref where not null. Checks: receipt qty > 0; task qty > 0 when set; counted_qty >= 0; qty_allocated <= qty_ordered, qty_picked <= qty_allocated, qty_shipped <= qty_picked. Not wms_dock_appointment (yard management, an extension).
2. Views with security_invoker: wms_hu_lot (each unit's item and lot from its receipt, its opening ledger row, or ext when loaded in check mode) and wms_allocatable (inv_available in locations with pickable true, zone reserve or forward_pick, status active, for released lots, less open, assigned or in-progress pick and replenish tasks).
3. docs/wms-rules.md, one page: a unit holds one item and one lot; quantities live only in the ledger; a move is one transfer_in with both locations and both statuses set to the stock's current status; a receipt is a po_receipt; a pick changes available to allocated; shipment from allocated; FEFO then pick_sequence then lowest LPN, undated lots last by FIFO, only from wms_allocatable; every post carries ref_type, ref_id and client_ref; count variances post one cycle_count per line, zero variance posts nothing; no costs, no reversals; config/wms.json receipt_over_pct 0, recount_tolerance_units 1; the five events (wms.receipt.posted, wms.receipt.qc_required, wms.task.completed, wms.shipment.shipped, wms.count.variance) written to the outbox in the same transaction.
4. pgTAP tests: the database refuses a duplicate lpn, a zone_type outside the list, a task status outside the list, a receipt of quantity zero, a line with qty_picked above qty_allocated; and a test that fails if any function or route other than inventory-post writes inv_inventory_balance.
5. The worked example, exactly as I give it in the next message, in two places: tests/fixtures/wms-worked.json with its fixed dates, which the seed test loads into the test database and checks against the counts; and supabase/seeds/wms.sql, listed under [db.seed] sql_paths in supabase/config.toml, holding the same rows shifted onto today (every date moved by the same whole number of weeks, so week 1 starts this Monday), marked SYNTHETIC, and safe to run twice. Never appended to supabase/seed.sql, never in a migration; the deploy workflow never seeds production.
Do not connect to or change any live project. Then wait for my next message.
Paste into Claude Code
The worked example for the warehouse module. Fixed dates, as written here, go into tests/fixtures/wms-worked.json; week 1 starts Monday 2026-11-02. supabase/seeds/wms.sql holds the same rows shifted onto today. Every row is made up, marked SYNTHETIC, and carries ext synthetic true and a seed_key; rows M12's seed already made (unit EA, Supplier One, Customer One, reason codes OPENING and COUNT-VAR) are looked up by code or name and reused, never duplicated. The GTINs and SSCCs are made up with valid check digits; never print them on real goods.

Spine: site WH1 (warehouse); parties Supplier One, Carrier One, Customer One; item classes STD-FG and INSPECT; items FG-10 (STD-FG, GTIN 11234567000104) and FG-20 (INSPECT, GTIN 11234567000272), finished_good, lot-controlled, EA; reason codes OPENING, COUNT-VAR, QC-RELEASE; sequences LPN- (next 101), T-, W-, SHP-, BOL-, CNT- (next 1) and OUT- (next 2002), padding 4.
Locations (ambient) with profiles (zone, pickable, pick seq, put-away seq, max pallets, mixed items, mixed lots): DOCK-IN receiving no - - 6 yes yes; QUAR-1 quarantine no - - 2 yes yes; RES-A1 reserve yes 20 10 4 no yes; RES-A2 reserve yes 30 20 4 no yes; PICK-B1 forward_pick yes 10 - - no yes; STAGE-OUT staging no - - 6 yes yes.
Put-away rules: 10 class INSPECT zone quarantine fixed QUAR-1; 20 class STD-FG zone reserve consolidate; 90 any class zone reserve nearest_empty. Replenishment: PICK-B1 FG-10 min 45 max 100 min_max from reserve.
Lots: L-4001 FG-10 released exp 2027-01-31; L-4002 released exp 2026-12-31; L-4003 on_hold exp 2026-11-30. Units: LPN-0001 tote at PICK-B1; LPN-0002 pallet at RES-A1, SSCC 012345670000000022; LPN-0003 pallet at RES-A1, SSCC 012345670000000039; all closed. Opening ledger through inventory-post, three adjustments reason OPENING at 2026-11-02 06:00, ref_type wms_handling_unit: 50 L-4001 at PICK-B1 on LPN-0001 available; 30 L-4002 at RES-A1 on LPN-0002 available; 20 L-4003 at RES-A1 on LPN-0003 hold.
Inbound ASN-1001 from Supplier One by Carrier One, door D1, expected 2026-11-03 08:00, status expected: line 1 FG-10 100 EA lot L-5001 exp 2027-03-31; line 2 FG-20 24 EA lot L-6001 exp 2027-06-30. Outbound OUT-2001 for Customer One, customer, Carrier One, ship by 2026-11-06 17:00, new, no address: line 1 FG-10 40; line 2 FG-20 12.

The seed test, on the fixture and again on the shifted seed, must prove: 19 wms_ rows (6 profiles, 3 units, 1 ASN, 2 ASN lines, 3 put-away rules, 1 replenishment rule, 1 order, 2 order lines); 3 opening ledger rows at WH1's locations; wms_hu_lot gives 3 units; wms_allocatable gives 50 of L-4001 at PICK-B1 and 30 of L-4002 at RES-A1 (80) and never the 20 on hold; a second seed run adds nothing; scripts/check-balances.mjs passes.

Now push, open a pull request titled "WMS tables", wait for every check, and tell me the result in plain words. If a check fails, fix it and wait again before reporting.

You will see recreated screen

claude — acme-platform
⏺ Bash(npx supabase migration new wms_tables)
⎿ Created new migration at supabase/migrations/20261103121500_wms_tables.sql
1
⏺ Write(supabase/migrations/20261103121500_wms_tables.sql)
+create view public.wms_allocatable with (security_invoker = true) as
+select a.* from public.inv_available a
+ join public.wms_location_profile p on p.storage_location_id = a.location_id
+ join public.core_lot l on l.id = a.lot_id
+ where p.pickable and p.zone_type in ('reserve', 'forward_pick') and l.status = 'released' ...
2
⏺ Bash(gh pr checks --watch)
⎿ schema / test pass 2m37s
⏺ Pull request #83 is green. 15 tables, 2 views, docs/wms-rules.md. 44 tests passed, including the 5 refused inserts and the test that only inventory-post may write balances. The seed loads twice without a duplicate; wms_allocatable shows 80 of FG-10 and not the 20 on hold; check-balances passes.3
Claude Code writes the tables, the views, the rules page and the seed, then waits for GitHub.
  1. Production gets this file from the deploy pipeline on merge, never by hand.
  2. Held stock cannot be offered because it is not in this view.
  3. The numbers Session 4 starts from.

Check it worked

Pull request WMS tables is green with the five refusals, the balance-write test, the seed run twice without duplicates, and wms_allocatable at 80 without the held 20.

Fastest path

Two messages sent one after the other replace a dozen exchanges: the rules first, then the worked example and the counts the test must prove.

If it goes wrong

The seed adds a second Supplier One or a second OPENING reason

M12's seed made them without a seed_key. Say: Look up rows M12's seed made by code or name and reuse them; use seed_key only for rows this seed creates.

Claude Code adds a quantity column to wms_handling_unit "to make screens faster"

Refuse: Quantities live only in the ledger. Read them from inv_available or wms_allocatable. That shortcut is the module's first pitfall.

A later step expects a count the seed does not give

Say: List every count a later step or test expects and show the seed line that creates it. Fix the seed, not the check.

Step 5

Session 2: The GS1-128 label parser, proven with test labels

20 minutes

Why

Receiving believes what a label says only after the server has decoded it and recomputed its check digits. A parser written and tested before any route uses it, with labels that must decode and labels that must be refused, means a misread digit or an impossible expiry is caught at the dock rather than found in a customer's warehouse.

Do this

Paste into Claude Code
On a new branch wms/gs1, write lib/gs1.ts: parse a GS1-128 string in the bracketed human form and in the raw form (character 29 after variable fields, optional leading ]C1). Decode 00 (SSCC, 18 digits), 01 (GTIN, 14), 10 (lot, up to 20), 17 (expiry YYMMDD read as 20YY), 21 (serial, up to 20). Recompute the check digits of 00 and 01 and refuse a mismatch; refuse an impossible date (including day 00), a lot over 20 characters and an unknown AI. Tests that must decode:
(00)076543210000001012(01)11234567000104(17)270331(10)L-5001
(00)076543210000001029(01)11234567000104(17)270331(10)L-5001
(00)076543210000001036(01)11234567000272(17)270630(10)L-6001
(01)11234567000104(21)SN-0007 then character 29 then (10)L-5001
(00)012345670000000022
Must be refused: (01)11234567000105 (check digit) and (17)270231 (31 February).
Show each test failing with the check-digit rule removed, then passing. Open "GS1 label parser", wait for checks, report.

Before you read the result, work the first label by hand: split it, check the SSCC's 18th digit and the GTIN's 14th, read the expiry. Your page should agree with the parser field by field.

You will see recreated screen

claude — acme-platform
⏺ Bash(npm test -- gs1)
⎿ ✗ refuses (01)11234567000105 (check-digit rule removed)
1
⏺ Bash(npm test -- gs1)
⎿ ✓ 5 labels decode · ✓ 2 labels refused
⏺ Pull request #84 is green. lib/gs1.ts decodes the five test labels and refuses the wrong check digit and 31 February. It needs no database; Session 4's receiving route calls it on the server for every scan.2
The parser, proven red first.
  1. A test that cannot fail proves nothing.
  2. The phone may show what it read; only the server's reading is believed.

Check it worked

Pull request GS1 label parser is merged; the five labels decode and the two bad ones are refused; your hand-worked label agrees.

If it goes wrong

The parser accepts (17)270231

Say: Validate the date as a real calendar date; add 270229 (not a leap year) and 270100 to the refused tests.

A real supplier label fails to decode

Read the raw scan: suppliers often end a variable field with character 29. Add the label (with made-up numbers in the same shape) as a test before changing the parser.

Step 6

Session 2: Try it on the development project yourself

15 minutes

Why

CI proves the files build a database from nothing; the development project proves they apply on top of your real Foundation and M12. You run it, in your own terminal, because changing a database is kept for a person; production then gets the same migrations from the deploy pipeline on merge.

Do this

In a terminal, not inside Claude Code. The password is in the password manager under Supabase: acme-platform-dev database password:

Terminal or PowerShell
cd ~/code/acme-platform && git fetch && git switch wms/tables
Terminal or PowerShell
npx supabase link --project-ref tsrqponmlkjihgfedcba
Terminal (Mac or Git Bash on Windows)
cat supabase/.temp/project-ref

It must print tsrqponmlkjihgfedcba. If it prints abcdefghijklmnopqrst, stop: that is production. Then push the migrations and load the new seed file the first time (after that, reload the made-up rows with npm run seed:dev):

Terminal or PowerShell
npx supabase db push --include-seed
Open

https://supabase.com/dashboard/project/tsrqponmlkjihgfedcba/sql/new

The development project's SQL editor. Paste the query below and press Run.

Supabase SQL Editor, development project
select l.code as location, lot.lot_no, a.qty
from wms_allocatable a
join core_storage_location l on l.id = a.location_id
join core_lot lot on lot.id = a.lot_id
order by lot.expires_at;

Owner two approves and the pull request merges; the deploy pipeline applies it to production.

You will see recreated screen

Terminal
$ cat supabase/.temp/project-ref
tsrqponmlkjihgfedcba1
$ npx supabase db push --include-seed
Do you want to push these migrations to the remote database? • 20261102161000_wms_spine.sql • 20261103121500_wms_tables.sql [Y/n] y
Seeding data from supabase/seeds/wms.sql...
Finished supabase db push.
db push applies the new migrations and the seed, after asking.
  1. The development project. Check every time.

You will see recreated screen

supabase.com/dashboard/project/tsrqponmlkjihgfedcba/sql/new
SQL Editor · acme-platform-dev
1
locationlot_noqty
RES-A1L-400230
PICK-B1L-400150
Only released stock in pickable locations is offered.
  1. 80 in all. L-4003 expires first but is on hold, so it is not here.

Check it worked

The query shows 30 of L-4002 and 50 of L-4001 and no L-4003; the pull request is merged and the deploy pipeline run is green on the Actions tab.

If it goes wrong

db push says: Remote migration versions not found in local migrations directory

The development project has a migration your branch does not. Do not force anything. In Claude Code: List which versions differ and which branch each came from, without changing any project.

The migration changed in review after I pushed it to the development project

Never reset the database. Say: Write the change as a new migration, never by editing one already pushed. Push it to the development project yourself, then reload the made-up rows with npm run seed:dev; the seed is safe to run twice.

Knowledge check

Where does the warehouse module keep how many units of a lot are in a location?

Knowledge check

A scan decodes as (01)11234567000105. What must the parser do?

References

  1. Made4net: which is the best WMS for business (core and extended capabilities). https://made4net.com/knowledge-center/which-is-the-best-wms-for-business/
  2. Infios: Leader in the 2025 Gartner Magic Quadrant for WMS (core capability list). https://www.infios.com/en/knowledge-center/news/infios-leader-in-2025-gartner-magic-quadrant-wms
  3. PostgreSQL documentation: Unique indexes. https://www.postgresql.org/docs/current/indexes-unique.html
  4. PostgreSQL documentation: CREATE VIEW (the security_invoker option). https://www.postgresql.org/docs/current/sql-createview.html
  5. GS1: GS1 General Specifications. https://www.gs1.org/standards/barcodes-epcrfid-id-keys/gs1-general-specifications
  6. GS1: how to calculate a check digit manually. https://www.gs1.org/services/how-calculate-check-digit-manually

Chapter 2 · Session 3

Who may do what, and the screens

Five roles, an insert-only loader and a read-only checker go into docs/matrix.json, with four rules that take rights away on purpose: nobody approves their own count, nobody releases what they received, a blind count stays blind, and the loader writes only marked rows. Then Claude Code builds the phone screens for gloves and glare, and the desk screens.

20 minSession 3: 2 steps5 roles, 2 identities9 routes, 9 screens

By the end of this chapter you can

  • Add the roles, identities, tables, routes and screens to docs/matrix.json with the four restrictive rules, and regenerate the access rules.
  • Walk Sessions 4 to 6 against the matrix so no later step is refused.
  • Have Claude Code build the scan screens and the desk screens and test them signed out, per role and at phone width.
RoleDoesMay not
wh_receiverReceives against ASNs, puts away, completes movesRelease stock they received from quarantine
wh_pickerPicks, replenishes, moves, counts (blind)Read system_qty or variance on count lines; approve a count
wh_packerPacks cartons, loads themShip (the supervisor ships)
wh_supervisorEnters orders and ASNs, allocates, releases waves, assigns tasks, ships, approves countsApprove a line they counted
inventory_controlOwns locations and rules, releases from quarantine, plans and approves countsRelease what they received; approve a line they counted
wms_loader (identity)Inserts locations, profiles, units and opening rows marked imported, only through import-wms.yml (Sessions 5–6)Update or delete anything; sign in after cut-over (set NOLOGIN)
wms_check (identity)Reads tasks, receipts, units, counts and the ledger for the checksWrite anything
Roles and the jobs they holdFive roles against nine jobs. Receiver: receive and put away. Picker: pick and count. Packer: pack and load. Supervisor: ship and approve counts. Inventory control: approve counts and release stock from quarantine. ReceivePut awayPickPackLoadShipCountApproveReleasewh_receiverwh_pickerwh_packerwh_supervisorinventory_controlThe supervisor also enters orders and ASNs, allocates and releases waves; inventory control owns locations and rules and plans counts.Two rules bind everyone: the counter cannot approve their own line, and the receiver of a lot cannot release it.
Five roles, nine jobs. A large dot means the role holds the job.

A restrictive policy can only remove rights: a row must pass it as well as the policy that grants the right, so no other grant gets round it [1]. In Postgres an update finds rows only through the role's read rule, and the changed row must still pass it, so a read limited to "status is open" would refuse the update that sets it to done [2]: write reads broad and put narrow conditions in the route.

RouteCalled byPosts to the ledger
wms-orderswh_supervisornothing
wms-receivewh_receiverpo_receipt
wms-taskreceiver, picker, supervisor, inventory controltransfer_in
wms-allocatewh_supervisornothing
wms-wavewh_supervisornothing
wms-packwh_packernothing
wms-shipwh_packer loads; wh_supervisor shipsshipment
wms-releaseinventory_controlstatus_change
wms-countinventory control plans; picker counts; supervisor or inventory control approvescycle_count
Key or secretWhat it unlocksWhere it livesWho holds itNever
wms_loader passwordLets .github/workflows/import-wms.yml sign in as wms_loader, which may only insert locations, units and opening stock marked importedGitHub Actions secret WMS_LOADER_PASSWORD, typed by a person; password manager; named in docs/KEYS.mdpat@acme.comIn Vercel, the repository or a chat; the account is set NOLOGIN at cut-over
wms_check passwordLets scripts/check-wms.mjs read as wms_checkWMS_CHECK_PASSWORD in Vercel (Preview, Production), typed by a person; password manager; named in docs/KEYS.mdpat@acme.com and sam@acme.comGiven write rights of any kind
Step 7

Session 3: The roles, identities and restrictive rules into the matrix

35 minutes

Why

Access decided once in the matrix and generated everywhere cannot drift. The four restrictive rules are the module's separation of duties, and the walk through every later step is what stops Session 4 failing halfway through a wave, or a confirm that reports success and changes nothing because the role could not read the row.

Do this

Paste into Claude Code, after replacing the last line
Read docs/matrix.json, the M13 section of docs/spine-map.md, docs/wms-rules.md, scripts/gen-policies.mjs and docs/access-review.md.

On a new branch wms/access, add to docs/matrix.json, starting every cell blank and adding only what the job needs (scope: own site): the roles wh_receiver, wh_picker, wh_packer, wh_supervisor, inventory_control, and the identities wms_loader (insert-only) and wms_check (read-only), each its own sign-in with a password a person sets and names in docs/KEYS.md, never the service key, with exactly the rights in element M13 chapter 2's table, which I paste below; the routes wms-orders, receive, task, allocate, wave, pack, ship, release, count (the load is a workflow, not a route); and the screens /warehouse/receive, /warehouse/tasks, /warehouse/pack, /warehouse/load, /warehouse/count (phone), /warehouse/orders, /warehouse/shipping, /warehouse/control (desk), /warehouse/kpis (manager). No delete for anyone.
Four restrictive policies: the person who counted a line cannot approve it; the person who received a lot cannot release it from quarantine; the loader inserts only rows with ext imported; the picker cannot read system_qty or variance (a column right).
Then write docs/access-walk.md: one line per step of Sessions 4, 5 and 6 in element M13 (I paste the list below): role or identity, table, action, the cell that allows it. Mark and add any missing cell.
Run scripts/gen-policies.mjs (Session 8) and scripts/gen-routes.mjs, which writes lib/access/routes.ts (Session 9). Add tests for each restrictive rule, that wms_check can write nothing, that nobody can delete, a cross-site test, and for each role that updates a table, that the row really changed. In the WMS seed file only (never a migration, never a page or switch in the app), add public.dev_act_as(email text, person_code text), refusing any person without ext synthetic true. Push, open "WMS access", wait for every check, report.

<paste the role table and the step list>

You will see recreated screen

claude — acme-platform
⏺ Write(docs/matrix.json)
+"wms_cycle_count_line": {
+ "wh_picker": { "read": "site", "columns_hidden": ["system_qty", "variance"], "update": ["counted_qty", "counted_by"] },
+ "wh_supervisor": { "read": "site", "update": ["approved_by"], "restrict": "counted_by <> me" }
+}
1
⏺ Bash(gh pr checks --watch)
⎿ access / test pass 3m02s
⏺ Pull request #85 is green. 7 roles and identities, 15 tables, 9 routes, 9 screens. The walk found 2 missing cells (the picker reads open replenish tasks; inventory control updates core_lot status through the release); both are added. 171 access tests passed, including the four restrictive rules.2
The matrix grows by rows; the restrictive rules arrive with their tests.
  1. A blind count stays blind: the picker's role cannot read the system quantity at all.
  2. Two refusals found now instead of in the middle of a wave.

Check it worked

Pull request WMS access is green; docs/access-walk.md has a cell for every line; the four restrictive-rule tests and the really-changed tests are in supabase/tests/access.test.sql.

If it goes wrong

A confirm reports success but the task is still open

The role can update rows it cannot read, so the update matched nothing. Say: Check the read policy covers the row before and after, and add a test that performs the change and checks the row really changed. We met this in three modules.

Claude Code proposes the service_role key for the load

Refuse: wms_loader is its own insert-only sign-in with only its matrix rights. Never service_role.

Claude Code put dev_act_as in a migration or added an "act as" switch

Say: Remove it. It lives only in the seed, which never runs in production. A demo switch once made every visitor an administrator in production.

Step 8

Session 3: The screens: scan on the phone, plan at the desk

40 minutes

Why

Warehouse floors have glare and people wear gloves. A scan screen with one task at a time, large targets and a confirm that stays disabled until the scans match is what makes pick accuracy measured instead of assumed; and refusing to confirm with no connection stops a queued confirm posting stock into a location frozen in the meantime.

Do this

Paste into Claude Code
Read node_modules/next/dist/docs/ first: this version of Next.js differs from what you know, and request checks live in proxy.ts. Then read docs/matrix.json, lib/access/routes.ts, docs/wms-rules.md and the screens from Foundation Sessions 12 to 15.

On a new branch wms/screens, build the nine screens. Phone screens (/warehouse/receive, tasks, pack, load, count): one task at a time in large type, the location to go to and the unit to scan; scan by the phone camera with a barcode library in the page (Code 128), or a handheld scanner typing into the focused box; confirm disabled until the scans match the task; refuse to confirm with no connection, saying so, rather than queueing. Desk screens (/warehouse/orders, shipping, control) and /warehouse/kpis (read only, "No data" where there is none, never 0).
The server takes the person from the signed-in session, never from the page, and sets every time from its own clock. Tests: every screen and route signed out lands on sign-in; each role sees only its screens; the phone screens pass at 360 and 390 px with 44 px targets and 16 px fields; a scan recorded by the receiver names the receiver whoever the page claims. Push, open "WMS screens", wait for every check including the preview, and report with the preview link.
Open

https://supabase.com/dashboard/project/tsrqponmlkjihgfedcba/sql/new

Run select public.dev_act_as('pat@acme.com', '<person>'); in the development project's SQL editor to act as a receiver, picker, packer, supervisor or inventory control.

Give a receiver and a picker a phone with the preview, gloves on. Do not explain. Write down every place they stop, and give the list to Claude Code.

You will see recreated screen

acme-platform-git-wms-screens-acme-ops.vercel.app/warehouse/tasks
Pick 10 × FG-10 · lot L-4001
Go toPICK-B1
Scan locationPICK-B1 ✓
Scan unitwaiting…
Confirm2
The task screen on a phone, as a picker on the preview (development project, made-up data).
  1. Made-up data says so. If a preview shows real stock, stop.
  2. Disabled until the location and the unit both match. The server checks again.

Check it worked

Pull request WMS screens is green; each role sees only its screens; the phone screens pass at 360 and 390 px; confirm stays disabled until the scans match; you have notes from a receiver and a picker.

If it goes wrong

The camera does not open on the preview

Camera access needs a secure page (https) and the person's permission in the browser; previews are https. Check the browser's site settings before changing code.

The KPI screen shows 100% pick accuracy before anything was picked

Say: Show "No data" when there is none, never a number, and add a test per widget rendered empty. A chart once graded twelve hard-coded points "In control" on 87 screens.

A page answers without sign-in

Stop. Say: Call every /warehouse page and wms- route signed out and show me each status code. A prior build had 376 of 449 route handlers with no guard.

Knowledge check

A picker counted a line 2 short. Who may approve it?

Knowledge check

A receiver scanned in lot L-6001, which is in quarantine. Who may release it?

References

  1. PostgreSQL documentation: Row security policies (including restrictive policies). https://www.postgresql.org/docs/current/ddl-rowsecurity.html
  2. Supabase Docs: Row Level Security. https://supabase.com/docs/guides/database/postgres/row-level-security
  3. W3C: Understanding WCAG 2.2, Target Size (Enhanced). https://www.w3.org/WAI/WCAG22/Understanding/target-size-enhanced.html

Chapter 3 · Session 4

The workflow: every move scanned and posted once

The seed's ASN-1001 goes through the building on the preview: received and decoded from its labels, one item to quarantine, every pallet put away by rule, stock allocated earliest-expiry first, a wave released, picks confirmed by scan, a replenishment, packing, shipping and a blind count whose variance someone else approves. Every completed task posts exactly one ledger row, and two scripts prove it.

30 minSession 4: 5 steps, two sittings11 tasks, 19 ledger rowsFG-10 ends at 158

By the end of this chapter you can

  • Have Claude Code build the nine routes on inventory-post, with the refusal tests.
  • Work ASN-1001 and OUT-2001 end to end on a phone and check each ledger row.
  • Prove the book with check-wms and check-balances, each shown failing on a planted fault.
A scan-verified moveFive screen steps: the task is shown, the location is scanned, the unit is scanned, a quantity is keyed where needed, and confirm is enabled when the scans match. The server then checks every scan again: a match posts one ledger row, a mismatch writes a SCAN-REFUSED comment and posts nothing. 1 · Task shownone at a time,in large type2 · Locationscan the labelon shelf or floor3 · Unitscan the pallet orcarton plate4 · Quantitykeyed only wherethe task needs it5 · Confirmenabled whenthe scans matchSCAN-REFUSEDcomment on the task;nothing is postedServer checks againwhatever the screen didLedger row postedone per task,same transactionno matchmatchThe confirm button is a convenience; the server's check is the rule.
The phone guides; the server decides. Confirm is enabled only when the scans match; the server checks every scan again. A match posts one ledger row; a mismatch writes a SCAN-REFUSED comment and posts nothing.
Task statusA task moves open, assigned, in progress, done. From open it can be cancelled when its order is cancelled; from in progress it can end short when fewer were found than asked; the quantity found is still posted to the ledger. opencreated by a route;a picker may claim itassigneda supervisor nameda personin_progressthe person isscanningdoneevery scan matched;ledger row id keptcancelledorder cancelled whilenew or allocatedshortfewer found than asked;the line stays openorder cancelledfewer foundA task is the unit of work and of proof: each completed task points at its own ledger row.
Task status. Open, assigned, in progress, done; cancelled when its order is cancelled early; short when fewer were found, with the found quantity still posted.
Put-away rules in priority orderThree rules: priority 10, class INSPECT, fixed to QUAR-1; priority 20, class STD-FG, consolidate into the reserve location already holding the item; priority 90, any class, nearest empty reserve location. The first rule that finds a qualifying location wins. Rules are tried in priority order; the first one that finds a location wins.10 · class INSPECTzone quarantinefixedalways the location in params: QUAR-1no location found: next rule20 · class STD-FGzone reserveconsolidatethe reserve location that already holds the item,lowest put-away sequence, with pallet room leftno location found: next rule90 · any other classzone reservenearest_emptythe reserve location with no unit in it,lowest put-away sequenceA location qualifies only if it is active, has room under max_pallets and accepts the mixing.
Three seed rules, first match wins. Priority 10 sends class INSPECT to QUAR-1; 20 consolidates STD-FG into the reserve already holding the item; 90 takes the nearest empty reserve.
First expired, first outBars to scale for FG-10: lot L-4003, 20 units, expires 2026-11-30 and is on hold; lot L-4002, 30 units, expires 2026-12-31; lot L-4001, 50 units, expires 2027-01-31. An order for 40 takes 30 from L-4002 and 10 from L-4001 and never touches the held lot. Stock of FG-10 by earliest expiry, bar length to scale (units)01020304050L-4003 · expires 2026-11-3020 · on hold, never offeredL-4002 · expires 2026-12-3130 · RES-A1, availableL-4001 · expires 2027-01-3150 · PICK-B1, availableOUT-2001 line 1: 40 EA30 from L-4002, then 10 from L-4001L-4003 expires first but is on hold, so it is never offered; the order takes the earliest expiry among released lots.
FEFO on the seed, to scale. An order for 40 of FG-10 takes 30 from L-4002, then 10 from L-4001. L-4003 expires first but is on hold, so it is never offered.
StepLedger transactionStatus
Receivepo_receipt into DOCK-INavailable (quarantine for class INSPECT)
Put-away, move, replenishtransfer_in, both locations and both statuses setunchanged
Release from quarantinestatus_change at QUAR-1quarantine to available
Allocatenonenone
Picktransfer_in to STAGE-OUT (a short pick posts what was found)available to allocated
Loadshipment from STAGE-OUTfrom allocated
Count variancecycle_count out of (or into) the locationfrom the line's balance_status
Step 9

Session 4: One prompt for the routes on inventory-post, with the refusal tests

30 minutes

Why

Every route calls inventory-post inside its own database transaction with a client_ref built from the task, so the ledger row and the warehouse rows are saved together or not at all, and the same request sent twice changes the data once. Writing the refusals as tests in the same pull request proves the server, not the screen, decides.

Do this

Paste into Claude Code
Read docs/wms-rules.md, docs/matrix.json and lib/gs1.ts. On a new branch wms/workflow, build the nine routes in this order, each on inventory-post inside its own database transaction, with client_ref from the task, receipt or count line, the transaction id written back to inventory_txn_ref, and the event written to the outbox in the same transaction:
wms-receive (decode every label with lib/gs1.ts on the server; match GTIN to item and lot and expiry to the ASN line; create the lot once (quarantine for class INSPECT, else released), the unit with the SSCC and the next LPN, the receipt, a po_receipt into DOCK-IN; refuse above the ASN quantity, a lot that differs from the line, a scan matching no line; keep arrived_at in ext);
wms-task (put-away by the first active rule that finds an active location with pallet room and acceptable mixing; complete any task by scanning location and unit, checked again on the server; a refused scan writes a SCAN-REFUSED comment; short picks post what was found; min/max replenishment after a pick; a kanban card scan at a line_side location creates one replenish task for max_qty);
wms-allocate (FEFO from wms_allocatable only), wms-wave, wms-pack (the server sets package_count and total_weight_kg, ignoring the browser), wms-ship, wms-release (refuses the receiver), wms-count (blind; recount beyond tolerance; approval by someone else; one cycle_count per line with a variance, from the line's balance_status), wms-orders.
Tests in tests/wms-workflow.test.mjs against a database the test sets up and rolls back: wrong location scan refused with SCAN-REFUSED; a fifth pallet for RES-A1 goes to RES-A2; put-away into a blocked location refused; an order for 200 of FG-10 allocates 180 and never the 20 on hold; a short pick of 8 against 10 posts 8 and leaves the line open; the same task completed twice posts one row; cancelling a released order refused; the kanban card at a test LINE-1 creates exactly one replenish task for 20. Show each failing with its rule removed first. Push, open "WMS workflow", wait for every check and report.

You will see recreated screen

claude — acme-platform
⏺ Write(app/api/wms-task/route.ts)
+if (scan.location !== task.from_location_code || scan.lpn !== task.lpn) {
+ await addComment(task.id, 'SCAN-REFUSED', scan);
+ return refuse(409, 'Scanned ' + scan.location + ', expected ' + task.from_location_code);
+}
1
⏺ Bash(npm test -- wms-workflow)
⎿ ✗ same task twice posts one row (client_ref removed) · then ✓ 14 of 14
⏺ Bash(gh pr checks --watch)
⎿ test pass 4m11s
⏺ Pull request #86 is green. 9 routes, all posting through inventory-post. 14 workflow tests, each shown failing first; the balance-write test still passes, so no route writes inv_inventory_balance.
Nine routes, every one on inventory-post, and the refusals proven red first.
  1. The server checks the scan again, whatever the screen did, and keeps a record of the refusal.

Check it worked

Pull request WMS workflow is green with each refusal test shown red first, and the test that only inventory-post writes balances still passes.

Fastest path

"Build them in this order" means each route can be read before the next uses it; one prompt with the order and the tests replaces ten rounds of "now add the next route".

If it goes wrong

Two pickers confirm the same task at once and both succeed

Say: Include the task's row_version in the update's WHERE clause so the second confirm is refused, and add a test with two confirms from the same copy. Two saves from one starting copy is how a record gets lost.

A test only checks that inventory-post is mentioned in the route

Say: Rewrite it to call the route and check the ledger row and the task's inventory_txn_ref. A test of a word is not a test of behaviour.

Claude Code goes round in circles on the same failing test

After the second identical failure: Stop. Quote the error, what you tried, whether the cause is in our code or outside it, and what you need from me.

Step 10

Session 4, first sitting: receive ASN-1001, quarantine FG-20, put every pallet away

20 minutes

Why

Receiving is where a label becomes stock. Watching the server decode each label, the INSPECT item go to quarantine, and the put-away rules choose each destination is how you learn to trust (or question) every later number.

Do this

On the preview of WMS workflow, as the receiver (switch with dev_act_as): mark ASN-1001 arrived; scan DOCK-IN, then each supplier label, keying 60, 40 and 24:

The three made-up pallet labels (print them as Code 128 or type them)
(00)076543210000001012(01)11234567000104(17)270331(10)L-5001
(00)076543210000001029(01)11234567000104(17)270331(10)L-5001
(00)076543210000001036(01)11234567000272(17)270630(10)L-6001

Then complete the three put-away tasks by scanning each destination and pallet. Expect LPN-0101 and LPN-0102 to RES-A1 (consolidate), LPN-0103 to QUAR-1 (fixed).

Paste into Claude Code
Read-only, on the development project as inventory control: the balance rows at DOCK-IN, RES-A1 and QUAR-1 by lot and status; the six ledger rows for ASN-1001 with their types and statuses; and the dock-to-stock hours of each receipt.

You will see recreated screen

acme-platform-git-wms-workflow-acme-ops.vercel.app/warehouse/receive
ASN-1001 · line 2 · FG-20
SSCC076543210000001036
Lot · expiryL-6001 · 2027-06-30
Quantity24
License plateLPN-0103
Receiving: the server's reading of the label, not the phone's.
  1. Quarantined stock is never in wms_allocatable, so no order can take it.

You will see recreated screen

claude — acme-platform
⏺ RES-A1: L-4002 30 available, L-4003 20 hold, L-5001 100 available (LPN-0101 60, LPN-0102 40). QUAR-1: L-6001 24 quarantine. Ledger: 3 po_receipt into DOCK-IN, 3 transfer_in out of it (statuses unchanged). Dock-to-stock 0.6, 0.7 and 0.8 hours.1
Checkpoint A, read back.
  1. Six rows for six completed actions; RES-A1 now holds 4 of its 4 pallets.

Check it worked

Checkpoint A: ASN-1001 received with three labels decoded on the server, L-6001 in quarantine at QUAR-1, three put-aways each with one transfer_in, and the refusal tests still green.

If it goes wrong

The put-away of the quarantined pallet is refused for a balance below zero

The transfer_in left the statuses empty, which M12 reads as available. Say: Set from_status and to_status both to the status the stock is in now (quarantine).

The preview shows real stock

Stop. Previews must use the development project (Session 11). Ask Claude Code which project the Preview variables name (names only) and fix it in Vercel yourself.

Step 11

Session 4, second sitting: allocate, release quarantine, wave, pick and replenish

20 minutes

Why

Allocation is where held stock would do damage if it were offered. Seeing FEFO skip the held lot, the quarantined line wait until inventory control releases it, and the first pick trigger exactly one replenishment shows the book and the rules agreeing under real moves.

Do this

  • As the supervisor: allocate OUT-2001. Expect line 1: 30 from L-4002 (RES-A1, LPN-0002), 10 from L-4001 (PICK-B1, LPN-0001); line 2: nothing, L-6001 is in quarantine.
  • As inventory control (not the receiver): release L-6001 with reason QC-RELEASE and the quality result as a comment. As the receiver, complete a move of LPN-0103 from QUAR-1 to RES-A2. Allocate again: line 2 takes 12 from RES-A2.
  • As the supervisor: create and release a wave holding OUT-2001; assign the first task to Picker One.
  • As the picker: pick 10 of L-4001 (not empty), 30 of L-4002 (empty: the unit becomes consumed), 12 of L-6001. After the first pick, complete the one replenish task for 60 of L-5001 from LPN-0101 to PICK-B1.
Paste into Claude Code
Read-only, on the development project as the supervisor: OUT-2001's lines (allocated, picked), the pick and replenish tasks with their status and ledger rows, and FG-10 by lot, location and status. Confirm L-4003 was never offered.

You will see recreated screen

acme-platform-git-wms-workflow-acme-ops.vercel.app/warehouse/orders
OUT-2001 · allocation
1
LineLotExpiryFromQty
FG-10L-40022026-12-31RES-A130
FG-10L-40012027-01-31PICK-B110
FG-200 (quarantine)
FEFO, as the supervisor sees it.
  1. Earliest expiry among released lots first.
  2. Held stock is not in the view, so it cannot be offered.

Check it worked

FEFO took 30 from L-4002 then 10 from L-4001 and never L-4003; line 2 waited until the release, then took 12 from RES-A2; three picks and one replenishment each posted one transfer_in.

If it goes wrong

The receiver could release L-6001

The restrictive rule is missing or the route skips it. Add the failing test first, then the rule; never release it by editing the lot's status.

Two replenish tasks appeared for PICK-B1

The route did not count open replenish tasks. Say: Create a replenish task only when none is open for the location and item; add a test with two picks in a row.

Step 12

Session 4, second sitting: pack, load, ship, and a blind count

20 minutes

Why

Shipping is where stock leaves the book, and counting is where the book meets the shelf. A server that sets the carton weights itself, and a count that is blind, recounted and approved by someone else, are the two cheapest controls in the module.

Do this

  • As the packer: pack into three cartons (LPN-0104 to -0106): 30 of L-4002 (40 × 30 × 30 cm, 12.5 kg), 10 of L-4001 (30 × 20 × 20, 4.2 kg), 12 of L-6001 (30 × 20 × 20, 5.0 kg). Choose the lot from the order's done picks. Load each carton by scanning STAGE-OUT and the carton.
  • As the supervisor: ship SHP-0001 with a made-up tracking number; the route sets BOL-0001. Close ASN-1001.
  • As inventory control: plan CNT-0001, method location, blind, for PICK-B1. As the picker: count 38 (L-4001) and 60 (L-5001); recount the first (beyond tolerance 1): 38 again. As the supervisor: approve both lines.
Paste into Claude Code
Read-only, on the development project as the supervisor: SHP-0001 (package_count, total_weight_kg, bol_no, status), the three shipment ledger rows, CNT-0001's lines (system, counted, variance, approver) and its one cycle_count row, and inventory record accuracy for the count.

You will see recreated screen

acme-platform-git-wms-workflow-acme-ops.vercel.app/warehouse/count
CNT-0001 · PICK-B1 · blind
FG-10 · L-400138
FG-10 · L-500160
Submit count
The blind count: the picker never sees the system quantity.
  1. The difference is beyond the tolerance, so it is counted again before anyone approves it.

You will see recreated screen

claude — acme-platform
⏺ SHP-0001: 3 packages, 21.7 kg (set by the server), BOL-0001, shipped. CNT-0001: L-4001 system 40, counted 38, variance -2, approved by SYNTHETIC · Supervisor (not the counter), one cycle_count of 2 out of PICK-B1. L-5001 exact, nothing posted. Record accuracy 1 of 2 lines, 50%.1
Shipping and the count, read back.
  1. A zero variance posts nothing: a ledger quantity must be above zero.

Check it worked

SHP-0001 shipped with BOL-0001 and 21.7 kg; CNT-0001 posted one variance of 2, approved by someone other than the counter; inventory record accuracy for the count is 50%.

If it goes wrong

The shipment total is whatever the browser sent

Say: The server sums package_count and total_weight_kg from the packages and ignores any total the browser sends; add a test that sends a wrong total.

The picker could approve their own count line

The restrictive rule is missing. Add the failing test, then the rule.

Step 13

Session 4: Prove the book, and see each check fail on a planted fault

15 minutes

Why

Two scripts prove the module agrees with the ledger: every complete task has exactly one ledger row, and balances recomputed from the ledger equal the stored ones. A check you have never seen fail proves nothing, so each is shown failing on a fault planted in a copy that is thrown away.

Do this

Paste into Claude Code
On wms/workflow, write scripts/check-wms.mjs, run as wms_check (password WMS_CHECK_PASSWORD from the environment, never printed): every complete task (done, or short with qty above zero) has exactly one non-reversal ledger row with ref_type wms_task equal to its inventory_txn_ref; no ledger row names a task that is not complete; every receipt and every approved non-zero count line has its row. Add a CI test that runs check-wms.mjs and M12's check-balances.mjs on the seeded, worked database, then, inside a transaction it rolls back, edits one balance by hand (check-balances must fail) and clears one done task's inventory_txn_ref (check-wms must fail). Push, wait for checks, and give me the command to run check-wms on the development project myself.

Set the wms_check account's password yourself (make it with the command below, keep it in the password manager, name it in docs/KEYS.md), add it as WMS_CHECK_PASSWORD for Preview in Vercel, then run the check yourself:

Terminal or PowerShell
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
Terminal or PowerShell
npx vercel env pull .env.local --environment=preview && node --env-file=.env.local scripts/check-wms.mjs

You will see recreated screen

Terminal
$ node --env-file=.env.local scripts/check-wms.mjs
WH1: 19 ledger rows (3 opening, 3 receipts, 3 put-aways, 1 release, 1 move, 3 picks, 1 replenishment, 3 loads, 1 count)1
11 tasks done, 11 task rows; 0 rows naming an incomplete task
FG-10 on hand 158 (138 available, 20 hold); FG-20 12 at RES-A22
The book proved on the development project.
  1. Only rows at WH1's six locations; M12's own rows are left out.
  2. 38 + 60 at PICK-B1, 40 at RES-A1, and the 20 on hold.

Check it worked

check-wms and check-balances pass on the development project; the CI test shows each failing on its planted fault; FG-10 stands at 158 with 138 available. Owner two approves and the workflow pull request merges.

Fastest path

Planting the faults inside a rolled-back transaction in CI means you never break the development project to see a check fail.

If it goes wrong

check-wms reports 12 task rows for 11 tasks

A task posted twice. Find which: its client_ref was not set or not unique. Fix the route and add the twice-completed test for that task type.

The check ran green on an empty database

It could never fail. Say: Make the check refuse to report "pass" when it finds no tasks at all; that is "could not measure".

Knowledge check

OUT-2001 asks for 40 of FG-10. L-4003 expires first but is on hold. What does allocation take first?

Knowledge check

A counted line is 2 units short with recount_tolerance_units 1. What happens next?

References

  1. GS1: reference list of GS1 application identifiers. https://ref.gs1.org/ai/
  2. PostgreSQL documentation: Constraints. https://www.postgresql.org/docs/current/ddl-constraints.html
  3. W3C: Understanding WCAG 2.2, Contrast (Minimum). https://www.w3.org/WAI/WCAG22/Understanding/contrast-minimum.html

Chapter 4 · Sessions 5–6

Load the stock, count it, switch the old WMS off

The specification's migration rule is short: load the location master, then opening balances by license plate as ledger transactions, and run a wall-to-wall count at cut-over. You rehearse the load on the development project with a copy IT approved, load production through a workflow a person starts from main with an export owner two approved, run side by side for a week, count wall to wall, close the loader, cut over and cancel with the saving from invoices.

25 minSessions 5–6: 4 stepsLoad twice, add nothingEnds with the module gate

By the end of this chapter you can

  • Map the export and dry-run the loader in post or check mode, refusing mixed units.
  • Rehearse on the development project and reconcile on-hand three ways.
  • Load production through import-wms.yml with an approved export, run side by side, count wall to wall, close the loader and cancel.
Loading the warehouseFive steps in order: items and units loaded first by M12's import, then locations (reused when M12 already loaded them, otherwise created) with parents before children, then handling units, then opening rows as adjustment transactions with reason OPENING, then a three-way reconciliation. The loader runs as a dry run by default, in post mode or in check mode. Items, unitsloaded first byM12's importLocationsreuse or create;parents firstHandling unitsone item, one lot;pallets firstOpening rowsadjustments withreason OPENINGReconcileold report, exportand ledger agreeThree ways to run the loader (as wms_loader, through import-wms.yml)Dry run (the default)reports, changes nothingPost modeone OPENING row per unitCheck modecompares, posts nothing
Order of loading. Items and units first (M12), then locations parents before children, then units, then opening rows, then a reconciliation. Dry run by default; post mode or check mode.
A cycle count from plan to postSix steps: plan the count, count blind, recount when the variance is beyond the tolerance, review, approve by a person who did not count the line, and post one cycle_count transaction for each line with a variance. 1 · Planinventory control: method,blind true, locations2 · Count blindthe picker counts; thesystem quantity is hidden3 · Recounta variance beyond tolerance(1 unit) forces a recount4 · Reviewcounts side by side;status review5 · Approvea person who did notcount the line6 · Postone cycle_count row perline with a varianceCNT-0001, PICK-B1: lot L-4001 system 40, counted 38 twice, variance minus 2; lot L-5001 system 60, counted 60.Only the first line posts. Inventory record accuracy: 1 of 2 lines within tolerance, 50 percent.
A count from plan to post. Plan, count blind, recount, review, approve by someone else, post.
The ledger rows of the workflow at site WH1Bars to scale, counting only rows whose from or to location is one of the six WH1 locations, so M12's own rows are left out: opening balances 3, receipts 3, put-aways 3, quality release 1, move 1, picks 3, replenishment 1, loads 3 and count variance 1, which makes 19 rows. Eleven of them, one for each done task, are put-aways, the move, picks, the replenishment and loads. Ledger rows at site WH1 after the Session 4 workflow, bar length to scaleOpening balances3Receipts (po_receipt)3Put-aways3Quality release1Move1Picks3Replenishment1Loads (shipment)3Count variance119 rows at WH111 green: one per done task8 cyan: receipts, the openingload, a release and a count
19 ledger rows at WH1 after the Session 4 workflow, to scale. The 11 green rows are one for each done task.
FG-10 on hand, to scaleA bar of 158 units drawn to scale: 38 of lot L-4001 and 60 of lot L-5001 at PICK-B1, 40 of lot L-5001 at RES-A1, all available, and 20 of lot L-4003 at RES-A1 on hold. 138 are available. A second short bar on the same scale shows FG-20: 12 units at RES-A2. FG-10 on hand after the workflow: 158 units, drawn to scale38PICK-B1 · L-4001available60PICK-B1 · L-5001available40RES-A1 · L-5001available20RES-A1 · L-4003on hold138 available20 on holdFG-20 on hand, same scale: 12 units12 · RES-A2
FG-10 on hand at the end, to scale. 158 units: 138 available and the 20 of L-4003 on hold.
KPIDefinitionHow the module measures it
Dock-to-stock timeHours from arrival to put-away confirmedPut-away completed_at minus the ASN's arrived_at
Pick accuracyLines picked correctly ÷ lines pickedDone picks with no SCAN-REFUSED ÷ done plus short picks
Order cycle timeRelease to ship hoursWave released_at to shipment shipped_at
Inventory record accuracyCount lines within tolerance ÷ count linesFrom wms_cycle_count_line

The two pick-accuracy figures are not the same measure: the module counts refused scans and short picks, the old tool usually counts mistakes found at pack check or by customers. Say so beside the comparison [1].

Step 14

Session 5: Map the export and dry-run the loader

30 minutes

Why

A load that cannot account for every row is not finished, and a unit with mixed contents loaded as if it held one lot puts a wrong number in the book for good. A mapping written first, a loader that refuses what it cannot place, and a dry run that writes nothing catch that before any ledger row exists.

Do this

Take the export again from the old tool's own export page just before the load; keep it in a private company folder, never in the repository. Items and units must already be loaded by M12's import.

Paste into Claude Code, after replacing the last line
I will describe the old WMS export's files and column headers below (no data). On a new branch wms/import:
1. docs/wms-mapping.md: old location to storage location and profile (parents before children; closed locations load blocked or inactive); old zone names to the eight zone types; unit types to hu_type; stock statuses to a balance status (available, quarantine, hold, damaged) and a lot status; my real line-side locations and kanban rules from docs/wms-map.md.
2. scripts/load-wms.mjs, dry run by default, writing only with --post or --check: post mode posts one adjustment (reason OPENING, ref_type wms_handling_unit, dated at the cut-off, with the old status) per accepted unit, signed in as wms_loader, through inventory-post's posting code; check mode, used when M12 already posted opening stock, adds profiles and units (item and lot in the unit's ext) and compares quantities, posting nothing. Refuse and list a unit with mixed items or lots. client_ref from LPN, item, lot and status. Never write inv_inventory_balance.
3. .github/workflows/import-wms.yml, run only by hand (workflow_dispatch) from main, refusing any other branch, with inputs target (dev or production), mode (post or check) and dry_run (default true). It downloads the export from the private Storage bucket imports of the target project; refuses it unless every file's sha256 and expected counts are listed in docs/imports/wms-approved.md on main; signs in as wms_loader with the password in that target's Actions secret (never the service key); runs scripts/load-wms.mjs; and fails on any count that differs from the approved file. Counts go to the job summary. No GitHub environment with required reviewers: the reviewed pull request that merges the approved file is the approval. A migration creates wms_loader as a database role with NOLOGIN, insert-only (no update, no delete); a person turns its login on with a password they set. Every row ext imported with the old id.
4. Tests on a made-up export (marked synthetic) with a mixed unit, an unknown location and a closed location; read = loaded + refused per file; a second run adds nothing; a file whose sha256 is not approved is refused; a count mismatch fails; wms_loader cannot update or delete.
Push, open "WMS load", wait for every check and report.

<paste the file names and column headers, no data>
Terminal or PowerShell (you, not Claude Code): a dry run, writes nothing
node scripts/load-wms.mjs --from ~/private/wms-export

You will see recreated screen

Terminal
$ node scripts/load-wms.mjs --from ~/private/wms-export
mode: dry run (nothing written) · choose --post or --check
locations.csv read 412 would load 410 refuse 2
A-07-03: parent A-07 not found (load parents first)1
onhand.csv read 1,906 would load 1,903 refuse 3
LPN 88213: two lots on one unit (split it before loading)2
The dry run says what it would load and what it refuses.
  1. Fix the mapping or the order, never the data.
  2. A mixed unit is split in the old tool or on the floor, then loaded.

Check it worked

The dry run explains every refused row; read = would-load + refused per file; the mode (post or check) and the reason are written in docs/wms-mapping.md; the pull request is merged.

If it goes wrong

Claude Code asks to read the export to check the format

Give it the column headers and made-up rows of the same shape, never the real file.

Items are missing

Items and units belong to M12's import. Load them there first; the warehouse loader creates neither.

Step 15

Session 5: Rehearse on the development project and reconcile three ways

40 minutes

Why

The first load of real stock should never be the one into production. A rehearsal through the same workflow, with a copy IT approved in writing, shows the counts, the second run adding nothing, and on-hand by location agreeing three ways (the old tool's report, the export, the ledger), and the copy is removed the same day.

Do this

Get IT's written approval to load a copy into acme-platform-dev for one rehearsal, redacted where it holds personal data (user names in the history). In the development project's SQL editor, turn on wms_loader's login with a password you make (alter role wms_loader login password '…'); keep it in the password manager, type it into the Actions secret WMS_LOADER_PASSWORD_DEV and name it in docs/KEYS.md. Create a private Storage bucket imports in the development project and upload the copy.

Open

https://supabase.com/dashboard/project/tsrqponmlkjihgfedcba/storage/buckets

Development project Storage: a private bucket named imports; upload the approved copy.

Terminal (Mac or Git Bash on Windows), in the export folder
shasum -a 256 *.csv
Paste into Claude Code, after replacing the last line
On a new branch wms/import-approval, write docs/imports/wms-approved.md with a section "Rehearsal (development project only)": each file's name, sha256 and expected row count (I paste them below), the date the copy was taken, what was redacted, the mode (post or check), and IT's written approval (date and role). Open a pull request titled "WMS: approve rehearsal export".

<paste the shasum lines and row counts>

Owner two reviews and approves; merge. Run the workflow with target dev, dry run first, then for real, then a second time.

Open

https://github.com/acme-ops/acme-platform/actions/workflows/import-wms.yml

Run workflow from main: target dev, dry_run true; read the counts; then dry_run false, twice.

Paste into Claude Code, after replacing <paste>
Read-only, on the development project as inventory control: opening rows loaded against docs/imports/wms-approved.md, and whether the second load added any; then on-hand by location, item, lot and status from inv_balance_from_ledger beside the old tool's report I paste below, with the difference on each row; and confirm held and quarantined stock is absent from wms_allocatable. Then run check-balances.mjs. Old report: <paste>

Explain every difference with a cause you can open. Then remove the copy from the development project the same day (ask Claude Code for a statement that removes only rows with ext imported, which you run yourself in the SQL editor), delete the file from the bucket, and write the date of removal in docs/imports/wms-approved.md.

You will see recreated screen

github.com/acme-ops/acme-platform/actions/workflows/import-wms.yml
import-wms · target dev · mode post · dry_run false
FileReadLoadedRefused
locations.csv4124102 (listed)
onhand.csv1,9061,9033 (listed)
The rehearsal on the development project: the approved fingerprints checked first.
  1. Only an export owner two approved can be loaded, and only from main.

You will see recreated screen

claude — acme-platform
⏺ 1,903 opening rows for 1,903 accepted units; the second load added 0. check-balances passes.1
⏺ On-hand agrees for 409 of 410 locations. B-02-01: old report 120, ledger 96. Cause: a move of 24 entered in the old tool after the export was taken (its own history shows 10:42). Held and quarantined stock: 3 lots, none in wms_allocatable.2
The rehearsal's reconciliation.
  1. Safe to run twice: the client_ref makes it so.
  2. A difference with a cause you can open, not a rounding to accept.

Check it worked

The rehearsal ran through import-wms.yml with the approved copy, loaded every accepted row once, the second run added nothing, on-hand agreed three ways or every difference has a proven cause, and the copy was removed from the development project the same day, with the date recorded.

If it goes wrong

The workflow refuses: sha256 not approved

The file changed since you recorded it (often opened and saved in a spreadsheet, which rewrites it). Upload the approved file again, or record the new fingerprint through a pull request owner two approves.

A difference has no cause you can find

You are not ready. Write "not ready" and who looks next; never adjust the ledger to make it match.

Held stock shows in wms_allocatable

A status was mapped wrongly. Fix the mapping (hold, quarantine) and reload; a held lot must never be offered.

Step 16

Session 6: Load production through the workflow, and reconcile

30 minutes

Why

Production gets the stock the way the rehearsal proved: a person starts import-wms.yml from main, it reads an export whose fingerprint and counts owner two approved in a reviewed pull request, and it signs in as the insert-only wms_loader. Nobody runs SQL against the live database and no upload page exists in the app. Freezing the pilot area for the load means no move happens between the export and the first ledger row.

Do this

Agree a cut-off with the supervisor; take the final export; block every location in the pilot area (a blocked location refuses moves but allows counting). Upload the export to a private Storage bucket imports in production. Turn on wms_loader's login in production with a new password you make, keep it in the password manager, type it into the Actions secret WMS_LOADER_PASSWORD and name it in docs/KEYS.md.

Open

https://supabase.com/dashboard/project/abcdefghijklmnopqrst/storage/buckets

Production Storage: a private bucket named imports; upload the final export.

Paste into Claude Code, after replacing the last line
On a new branch wms/import-production, add a section "Production" to docs/imports/wms-approved.md: each file's name, sha256 and expected counts (read, to load, refused, from the dry run I paste below), the mode and the cut-off time. Open a pull request titled "WMS: approve production export".

<paste the shasum lines and the dry run's counts>

Owner two reviews and approves; merge. Run the workflow from main with target production, dry run first, then for real.

Open

https://github.com/acme-ops/acme-platform/actions/workflows/import-wms.yml

Run workflow from main: target production, dry_run true; check the counts equal the approved file; then dry_run false.

Paste into Claude Code, after replacing <paste>
Read-only, through the app as inventory control on production: the same reconciliation as the rehearsal, against docs/imports/wms-approved.md and the old tool's on-hand report I paste below; write the results into docs/cutover.md on a new branch wms/cutover. Do not change any data. Old report: <paste>

You will see recreated screen

github.com/acme-ops/acme-platform/actions/workflows/import-wms.yml
import-wms · target production · mode post · dry_run false
2
FileReadLoadedRefused
locations.csv4124120
onhand.csv1,9061,9060 (3 split since)
The production load: the approved file checked first, then the load with the same numbers.
  1. Same fingerprints and counts as the approved file, or the run stops.
  2. Read = loaded + refused, file by file.

Check it worked

The production run's summary matches docs/imports/wms-approved.md; docs/cutover.md shows every row of the final export accounted for and on-hand agreeing three ways (or each difference proven), on production.

If it goes wrong

The run fails: counts differ from the approved file

Stop. Find why (a move after the cut-off, a re-export), and approve the right file through a new pull request. Never edit the counts to fit.

Someone suggests a GitHub environment with required reviewers

Not available on the Team plan for private repositories. The reviewed pull request that merges docs/imports/wms-approved.md is the approval.

Production reports a table or column missing

The pipeline did not apply a migration. Open the deploy run on GitHub's Actions tab; do not apply anything by hand.

Someone suggests typing the opening balances straight into the balance table

No. Opening stock is ledger history posted through inventory-post by import-wms.yml, so check-balances can prove it.

Step 17

Session 6: A week side by side, a wall-to-wall count, close the loader, cut over, cancel

60 minutes, after a week

Why

A week with every move entered in both systems, the four measures compared against the Session 1 baselines, and a blind wall-to-wall count approved by someone who did not count, is the evidence that the new book matches the shelf. Removing the loader and cancelling only after the final export is stored keep the book closed and the history safe.

Do this

For one week every receipt, put-away, pick, pack, shipment and count in the pilot area is entered in both systems by the same people. Then count wall to wall: block the pilot area, plan a count of method wall_to_wall, count blind in pick-sequence order, recount, approve by someone who did not count, unblock.

Paste into Claude Code, after replacing the last line
On branch wms/cutover, add to docs/cutover.md from numbers I give and read-only queries as inventory control on production:
1. Each day of the week: on-hand by location, open orders and open ASNs compared, every difference with its cause.
2. The four measures for the week, old tool against module, beside the Session 1 baselines, with the note that the two pick-accuracy figures measure different things.
3. The module checks: check-wms and check-balances pass; a held lot is not offered; the GS1 tests pass; the access tests pass, including that a counter cannot approve their own line.
4. The wall-to-wall count: lines counted, recounted, posted, and who approved.
5. The cut-over date, the rollback plan, the last transaction time in the old tool, who tells the floor, and where the final export of locations, on-hand, history, users and reports is stored.
6. The saving: the old annual cost from the invoice I paste, minus what the module costs on services we already pay for, plus any scanners or printers bought, arithmetic shown; leased devices as their own line.
Then a migration that sets wms_loader NOLOGIN at cut-over, its rights removed from docs/matrix.json and regenerated, and a test that wms_loader can no longer sign in or insert. Open "WMS cut-over", wait for every check, report.

<paste the week's numbers and the invoice lines>

Delete the WMS_LOADER_PASSWORD secrets from GitHub Actions and note the date in docs/KEYS.md. On the cut-over date make the old WMS read-only and watch the first day. Cancel on the vendor's own account page within its notice period, only after the final export is stored and you have checked it opens.

You will see recreated screen

github.com/acme-ops/acme-platform/pull/94/files
ConversationCommitsFiles changed
docs/cutover.md
1
MeasureBaselineOld tool (week)Module (week)
Dock-to-stock6.5 h6.1 h2.4 h
Pick accuracy98.1%98.4%99.6% (refused scans counted)
Record accuracynot recorded97.8%
Loader closedwms_loader set NOLOGIN; sign-in and insert refused (test)2
The cut-over record on GitHub.
  1. Each measure beside its Session 1 baseline, with what it measures.
  2. The book cannot be loaded again by accident.

Check it worked

docs/cutover.md is merged with the daily comparison, the four measures, the module checks, the wall-to-wall count, the cut-over plan and the saving from invoices; wms_loader is set NOLOGIN with a test proving it; the loader secrets are deleted; the old WMS is read-only or cancelled after the export was stored.

If it goes wrong

The module's pick accuracy is lower than the old tool's

Look at the SCAN-REFUSED comments: the module counts mistakes the old tool never saw. Explain each miss before deciding; a difference you cannot explain means you are not ready.

Finance asks for the saving before the export is stored

Cancel last. Once the subscription ends, history may be unreachable; store the export in the company's storage and check it opens first.

Before you go on · The module is done whenTick each one

Knowledge check

The loader is run twice by mistake. Why does it not double the stock?

Knowledge check

Where does real stock data go first?

References

  1. Solutions Review: 2023 Magic Quadrant for WMS, key takeaways. https://solutionsreview.com/enterprise-resource-planning/?p=5624
  2. Supabase Docs: Database migrations. https://supabase.com/docs/guides/deployment/database-migrations
  3. GitHub Docs: Manually running a workflow. https://docs.github.com/en/actions/managing-workflow-runs-and-deployments/managing-workflow-runs/manually-running-a-workflow

Chapter 5 · 12 questions · 80% passes

Final assessment

Twelve questions across the element. Score 80% (10 of 12) to pass. Your LMS records your score and each answer; you can review the chapters and try again.

15 min12 questions≈ 15 minutesRetake allowed

Choose one answer for each question, then submit. You will see the right answer and why for every question.

1. Where does the warehouse module keep the quantity of a lot in a location?
2. What confirms a pick in the module?
3. How many ledger transactions does each completed task produce?
4. Where does the wms_loader account's password live, and for how long?
5. The first thirteen digits of a GTIN-14 are 1123456700010. What is its check digit?
6. Under the seed's put-away rules, where does the pallet of FG-20 (class INSPECT) go?
7. OUT-2001 asks for 40 of FG-10. Lot L-4003 expires first but is on hold. What does allocation take?
8. A receiver scanned in lot L-6001, which is in quarantine. Who may release it?
9. A blind count of PICK-B1 finds lot L-4001 at 38 against a system quantity of 40, with a tolerance of 1. What happens?
10. How does the loader bring in opening stock?
11. Where does real stock data go first?
12. When may the old warehouse system's subscription be cancelled?