Skip to the lesson
CivOps AI Academy · M10Laboratory (LIMS): Samples, Specifications, Results, OOS and Certificates of Analysis
0%

Chapter 1 · Sessions 1–2

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

A laboratory information management system (LIMS) records every sample from collection to an approved result and a certificate of analysis. Session 1 finds out what yours holds and costs, from its own reports and bills. Session 2 adds the fourteen lims_ tables to your Foundation platform, with the two rules that keep results honest written into the database from the start: a result is never overwritten, and every sample is judged against the specification version pinned to it.

30 minAbout 7 hours hands-on across six sessionsSessions 1–2: 5 steps14 tables

By the end of this chapter you can

  • Inventory the LIMS you pay for today from its own reports and bill, and run three baseline tests on it.
  • Map the module onto your Foundation spine so it keeps no second item, lot or people list.
  • Have Claude Code write the fourteen tables, the result and pin rules, the tests, a fixture of hand-worked values and a made-up seed, and try them on the development project yourself.

What a LIMS does

A laboratory tests samples and reports results that other people act on: release a lot, reject a delivery, change a process. A LIMS holds the whole path. A sample is registered and labelled, received, stored, assigned to an analyst and an instrument, tested, judged against a specification, reviewed, approved, and reported on a certificate of analysis (CoA). Every step names the person and the time [1][2]. ISO/IEC 17025:2017 sets the general requirements for a laboratory's competence, including how results are recorded and reported [3]. Tools in this class include LabWare, LabVantage, STARLIMS, Thermo Fisher SampleManager, LabLynx, QBench and Labguru.

From sample to certificateEight steps in two rows: register, receive, assign, enter result, review, approve, disposition and certificate of analysis. Registernumber given,spec version pinnedReceivecustody andstorage recordedAssignworklist andinstrument chosenEnter resultflags set bythe database ruleReviewfirst signatureApprovesecond signatureDispositionpass, fail orconditionalCertificatesigned PDFfor the lotEvery arrow is a status change, and every status change is a recorded step.
The workflow in eight steps. Register, receive, assign, enter the result, review, approve, set the disposition, issue the certificate. The specification version is fixed at the first step.
Scope of the moduleTwo panels: inside M10 are samples, methods and specifications, worklists, evaluation, investigations, stability, environment and reagents; outside are calibration, training, the chromatography data system, deviations and CAPA, and controlled SOPs. Inside M10Samples, labels and chain of custodyMethods and versioned specificationsWorklists and result captureEvaluation: in spec, OOS, OOTOOS investigations, review, certificateStability, environment, reagentsCalibration executionM05 · the LIMS checks statusAnalyst training recordsM07 · the LIMS checks qualificationChromatography data systemintegrate it, do not replace itDeviation and CAPAquality module · OOS Phase IIControlled SOPsdocument module · soft linkOutside M10: each has an owner
Inside and outside M10. Calibration execution belongs to M05 and training records to M07; M10 checks their status before a test is released, or records a manual check where they are not installed. A chromatography data system is integrated, not replaced.
StandardUsed in this module for
ASTM E1578-18; LIMSpecLaboratory informatics requirements
ISO/IEC 17025:2017Competence of testing and calibration laboratories
21 CFR 211.160–211.194; 21 CFR Part 11; EU Annex 11Laboratory controls and records; electronic records and signatures
FDA guidance on investigating OOS results (rev. 2022)Phase I laboratory and Phase II full-scale investigations
ICH Q1A(R2); ICH Q2(R2)Stability testing; validation of analytical procedures
ISPE GAMP 5 (2nd ed.)Risk-based computerised system validation

Samples, statuses and custody

A sample has a type (raw, in_process, finished, stability, environmental, water, retain, complaint or investigation), a priority (routine, rush or stat), a number issued by the system, and links to the item, lot, sampling point and specification. The chain of custody is the unbroken record of who held it and where: each hand-over is a row with one of seven actions, added and never changed. A chain is complete when it begins with collected, includes received and stored, runs in time order, and each from-person equals the previous to-person.

Sample statusesSix statuses left to right: planned, collected, received, in_testing, in_review, approved. From in_review a sample can be rejected; approved and rejected samples end as disposed. plannedcollectedreceivedin_testingin_reviewapprovedrejecteddisposedApproval and rejection wait until every OOS investigation on the sample is closed.The disposition (pending, pass, fail, conditional) is a second column on the same sample.
A sample's statuses. Forward from planned to approved; rejected from review; approved and rejected samples are finally disposed. Disposition (pending, pass, fail, conditional) is recorded separately.
Chain of custody for one sampleA time line from 07:00 to 10:00 drawn to scale with four custody events: collected at 07:30, received at 09:00, stored at 09:10 and retrieved at 09:40. 07:0008:0009:0010:00collected07:30to requesterreceived09:00requester to analyststored09:10to analyst, LAB-FR-01retrieved09:40to analystSMP-2026-0001 on 2026-06-10: four events in time order, each from-person the previous to-person.
Custody of one sample, to scale. SMP-2026-0001 is collected at 07:30, received at 09:00, stored ten minutes later and retrieved at 09:40. Four events, no gaps.
Step 1

Session 1: Inventory the LIMS you pay for, from its own reports and bill

35 minutes

Why

The module must replace something real, not a guess. A number you read from the tool's own report or invoice can be checked by anyone; a number from memory is the first thing finance or an auditor knocks down, and the saving in Session 6 rests on this bill. The inventory in the repository also gives Claude Code the facts it needs in Session 2 instead of inventing them.

Do this

Gather first: one finished sample's full record with its custody and results, one specification printout with its version, the tool's turnaround or backlog report if it has one, and its account or billing page. Ask the laboratory lead before you copy anything; leave customer names and sample descriptions out of what you save.

Terminal or PowerShell
cd ~/code/acme-platform && git switch main && git pull && claude
Paste into Claude Code
On a new branch lims/inventory, create docs/lims-inventory.md for Acme Bottling, site Cleveland (cle), as a form I will fill in from the old LIMS'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. Sample types, sampling points and how samples are labelled and numbered today.
2. Methods and specifications: counts, how versions are kept, how a change is approved, and whether old results stay tied to the version they were judged by.
3. Instruments, and how calibration status and analyst training are checked before a test (and by whom).
4. Users by role (requester, analyst, reviewer, approver, manager) and how they sign in and sign.
5. Paid tools: name, owner, named users, the amount and what it covers as printed on the invoice, renewal date, notice period, which exports it gives (methods, specifications, samples, results, audit trail) and how long history stays readable after cancelling.
6. Counts, each with its report: samples a month by type, tests a month, open samples, OOS results last year.
7. The four numbers as the tool reports them (turnaround, backlog, OOS rate, right-first-time) with each definition it uses.
8. Three tests (I will run them).
9. Workarounds, in the users' own words: trending in spreadsheets, paper custody forms, certificates typed by hand.
10. The first slice: one sample type, one item and its specification, one laboratory, and why.

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

You will see recreated screen

claude — acme-platform
⏺ Bash(git switch -c lims/inventory)
⎿ Switched to a new branch 'lims/inventory'
⏺ Write(docs/lims-inventory.md)
+## 5. Paid tools
+| Tool | Owner | Users | Invoice amount | Covers | Renewal | Notice | Exports |
+| not known: ask finance | | | not known | | | | |
1
⏺ Write(docs/lims-inventory.md)
+## 7. The four numbers as the tool reports them
+| Number | Tool's figure | Tool's definition | Report |
2
⏺ The form is ready. Section 1: which sample types does the laboratory receive, and where is each one drawn?
Claude Code writes the form, then asks section by section. Gaps stay visible.
  1. Nothing is invented: a gap you can see beats a figure nobody can trace.
  2. Each number with the definition the tool uses: Session 6 compares like with like.

Check it worked

docs/lims-inventory.md has every section filled from a report, an invoice or a named person, and each number says where it came from.

Fastest path

Fill sections 5 to 7 from the vendor's account page and the tool's standard reports in one sitting with the right login: they are where most "not known" answers come from.

If it goes wrong

Claude Code fills in a price or a sample 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 tool cannot export its audit trail

Write that down as a finding: Session 5 will keep the old tool's full export as the archive, and the people who decide (quality, IT) need to know before you cancel.

Step 2

Session 1: Run three tests on today's system, and choose the first slice

25 minutes

Why

The module's definition of done is three tests: a corrected result can still be retrieved with its reason and signer, a result is judged against the specification version pinned at login, and the chain of custody is complete. Running the same three on today's system gives the baseline the new way must beat, and shows the laboratory what the change is for.

Do this

Correction test. Find one result that was corrected. Can the tool show the original value, who changed it, when and why? Time it.

Pin test. Find one sample tested under an older specification version. Does the tool still judge it against that version, or against today's?

Custody test. Pick three samples from last month. Is every hand-over recorded, in order, with no gap? Count the gaps.

Paste into Claude Code, after replacing the <paste> parts
Add the three test results I give you below to section 8 of docs/lims-inventory.md, as facts with their source, and the first slice to section 10. Then open the pull request "LIMS inventory", wait for the checks, and tell me the result in plain words.

Correction test: <paste>
Pin test: <paste>
Custody test: <paste>
First slice and why: <paste>

Have the laboratory lead and the approver read the slice in the pull request; owner two approves and it merges.

You will see recreated screen

github.com/acme-ops/acme-platform/pull/61/files
ConversationCommitsFiles changed
docs/lims-inventory.md
1
TestTodaySource
Original of a corrected assayNot shown; value editedAudit report empty
Old sample against its versionRe-judged against today'sSample screen
Custody, 3 samples2 gaps (paper form missing)Custody log
Slice: finished-product release testing of P-100, main laboratoryRead by the laboratory lead and the approver2
The inventory on GitHub. The three tests are the baseline Session 6 compares against.
  1. Each a fact with a source. These are the three things the module must fix.
  2. The slice names people who have read it.

Check it worked

docs/lims-inventory.md is merged with the three tests, a bill and renewal date for each paid tool, and the first slice read by the laboratory lead and the approver.

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.

Fourteen tables on your spine

The module keeps no item list, lot list, people table or signature store of its own. It points at the spine tables the module library calls core_item, core_lot, core_person, core_equipment, core_storage_location, core_party, core_uom, core_attachment and core_e_signature; some already exist in your Foundation under another name (your parts and lots tables). Step 3 writes that map. Every table also has the standard columns id, site_id, created_at, created_by, updated_at, updated_by, row_version, archived_at and ext: the specification's tenant_id becomes site_id, so each table keeps the one simple access rule your Foundation already uses. Types: text, int, num (decimal, never a float, which would store 99.1 as an approximation), bool, date, ts, uuid, json; req means required; a list after a colon is the allowed values.

The fourteen lims_ tablesFour groups of tables: methods and specifications, samples, testing, and stability and release. Specifications have limits; samples point at one specification, have custody events and tests; tests have results; results have OOS investigations. Methods and specstest_methodspec_limitspecificationSamplessampling_pointsamplecustody_eventTestingworklisttestresultoos_investigationStability, releasestability_studystability_pullreagentcoaArrows run from the one side to the many side. Names drop the lims_ prefix. The amber arrow is the pin:a sample points at one specification version. The dashed cyan arrow: a stability pull creates a sample.
The fourteen tables. A specification has many limits, each tied to a method. A sample points at one specification, has custody events and tests; a test has results; a result can have an OOS investigation.
TableHoldsColumns
lims_test_methodA versioned analytical methodcode text req; version text req; name text req; technique text; sop_doc_ref uuid (soft link to document control); analytes json req; calculations json; status text req: draft, active or retired
lims_specificationOne version of a specification for an item, stage and customerspec_no text req; version text req; item_id → core_item req; stage text req: raw, in_process, release, stability, customer or environmental; customer_party_id → core_party; status text req: draft, approved, effective or superseded; effective_at ts; approved_signature_id → core_e_signature
lims_spec_limitThe limit for one analyte of a specificationspecification_id → lims_specification req; test_method_id → lims_test_method req; analyte text req; lsl num; usl num; target num; uom_id → core_uom; text_spec text; reportable bool req; oot_rule json
lims_sampling_pointWhere samples are drawncode text req, unique; name text req; equipment_id → core_equipment; storage_location_id → core_storage_location; point_type text req: process, raw_receipt, finished, environmental, utility_water, air or surface; schedule_rrule text; active bool req
lims_sampleA laboratory samplesample_no text req, unique; sample_type text req: raw, in_process, finished, stability, environmental, water, retain, complaint or investigation; item_id → core_item; lot_id → core_lot; sampling_point_id → lims_sampling_point; specification_id → lims_specification; production_order_ref uuid (soft link to MES); parent_sample_id → lims_sample; collected_at ts; collected_by → core_person; received_at ts; received_by → core_person; status text req: planned, collected, received, in_testing, in_review, approved, rejected or disposed; priority text req: routine, rush or stat; storage_location_id → core_storage_location; disposition text: pending, pass, fail or conditional
lims_custody_eventOne step in the chain of custodysample_id → lims_sample req; action text req: collected, transferred, received, stored, retrieved, consumed or disposed; from_person_id → core_person; to_person_id → core_person; storage_location_id → core_storage_location; at ts req
lims_worklistA batch of tests for one analyst and instrument runworklist_no text req, unique; instrument_equipment_id → core_equipment; analyst_id → core_person; status text req: open, running, complete or cancelled; created_at_run ts
lims_testOne method applied to one samplesample_id → lims_sample req; test_method_id → lims_test_method req; worklist_id → lims_worklist; analyst_id → core_person; instrument_equipment_id → core_equipment; status text req: pending, assigned, in_progress, complete, reviewed, approved, cancelled or retest; started_at ts; completed_at ts
lims_resultOne analyte's result, its flags and its approvalstest_id → lims_test req; analyte text req; value_num num; value_text text; uom_id → core_uom; source text req: manual, instrument or calculated; raw_attachment_id → core_attachment; entered_by → core_person req; entered_at ts req; in_spec bool; oos bool; oot bool; reviewed_by → core_person; reviewed_at ts; approved_by → core_person; approved_at ts; review_signature_id → core_e_signature; approval_signature_id → core_e_signature; superseded_by_id → lims_result
lims_oos_investigationA phased investigation of an OOS resultinvestigation_no text req, unique; result_id → lims_result req; phase text req: phase_1_lab or phase_2_full; hypothesis text; assignable_cause bool; conclusion text; retest_plan text; quality_event_ref uuid (soft link to quality); status text req: open, phase_1_closed, escalated or closed
lims_stability_studyA stability protocol being runstudy_no text req, unique; item_id → core_item req; lot_id → core_lot; protocol_doc_ref uuid (soft link to document control); conditions json req; timepoints_months json req; start_at date req; status text req: planned, active, complete or cancelled
lims_stability_pullA scheduled pull point that creates a samplestudy_id → lims_stability_study req; condition text req; timepoint_months num req; scheduled_at date req; sample_id → lims_sample; status text req: scheduled, pulled, tested or missed
lims_reagentA reagent, standard or prepared solutionname text req; grade text; lot_no text; supplier_party_id → core_party; received_at date; opened_at date; prepared_from json; expires_at date req; storage_location_id → core_storage_location; status text req: available, quarantine, expired or consumed
lims_coaA certificate of analysis for a lotcoa_no text req, unique; lot_id → core_lot req; specification_id → lims_specification req; customer_party_id → core_party; generated_at ts req; attachment_id → core_attachment; signature_id → core_e_signature

Versions, and the pin

A method or specification is never edited once in force: a change is a new version. A specification's status only moves forward: draft, approved (signed), effective (from its date), superseded. Pinning means a sample stores the id of the specification version in force when it was logged in, and that id never changes. Every flag is computed against that version, whatever is published later.

AnalyteSPEC-P100 version 1 (from 1 Jan 2026)Version 2 (from 1 Jul 2026)
Assay (ASSAY-01)98.0 to 102.0 % (method version 1)98.5 to 101.5 % (method version 2)
pH (PH-01)6.5 to 7.56.5 to 7.5
Specification versions and the samples pinned to themA time line from 1 June to 1 August 2026 drawn to scale. Version 1 of the specification runs to 1 July, version 2 from 1 July. Sample 0001, collected on 10 June, is pinned to version 1; samples 0002 to 0006, collected from 8 July, are pinned to version 2. 1 June1 July1 AugustVersion 1 · from 1 Januaryassay 98.0 to 102.0 %Version 2 · from 1 Julyassay 98.5 to 101.5 %000100020003000400050006Samples SMP-2026-0001 to -0006 by collection date. Amber is pinned to version 1, green to version 2.
Two versions of SPEC-P100 and the samples pinned to them, to scale. Sample 0001 was collected on 10 June under version 1; samples 0002 to 0006 on or after 8 July under version 2.
One result against two specification versionsA number line from 97.5 to 102.5 percent. Version 1 allows 98.0 to 102.0 and version 2 allows 98.5 to 101.5. The result 98.2 is inside version 1 and below version 2. 98.2 % · SMP-2026-0001Version 198.0 to 102.0 %Version 298.5 to 101.5 %in specOOS9899100101102The sample is pinned to version 1, so its stored result says in specification, and stays so.
One result, two verdicts. 98.2 % is inside version 1 and below version 2. Because sample 0001 is pinned to version 1, its stored result is in specification.
Step 3

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

15 minutes

Why

The module library names spine tables your Foundation may already hold under its own names, or may not have yet. Building them blind is how a plant ends up with two item lists and two lot tables that drift apart. A written map makes Claude Code extend what exists and create only what is missing, in a separate spine migration that merges first.

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 lims/spine, add a section "## M10 Laboratory (LIMS)" 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_item, core_lot, core_person, core_job_role, core_equipment, core_storage_location, core_party, core_uom, core_attachment with a sha256 checksum, core_e_signature with signer_id, meaning, record_type, record_id, record_hash, signed_at, auth_method, printed_name and comment, core_number_sequence, core_action_item, core_event_outbox, core_audit_log with core_audit_row(), core_block_mutation(), core_touch_row(), core_current_tenant()), say "we have it as <our table>, missing columns: ..." or "missing". Never plan a second table for something we already have (our parts table may be core_item, our lots table core_lot); add missing columns instead. 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". Open a pull request titled "LIMS spine map".

----- tables for docs/spine-map.md -----
# The module's fourteen tables (from module library M10)
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 (numeric, never float), 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.

## lims_test_method
A versioned analytical method.
- code text req
- version text req
- name text req
- technique text
- sop_doc_ref uuid (soft link to document control)
- analytes json req
- calculations json
- status text req: draft, active or retired

## lims_specification
One version of a specification for an item, stage and customer.
- spec_no text req
- version text req
- item_id → core_item req
- stage text req: raw, in_process, release, stability, customer or environmental
- customer_party_id → core_party
- status text req: draft, approved, effective or superseded
- effective_at ts
- approved_signature_id → core_e_signature

## lims_spec_limit
The limit for one analyte of a specification.
- specification_id → lims_specification req
- test_method_id → lims_test_method req
- analyte text req
- lsl num
- usl num
- target num
- uom_id → core_uom
- text_spec text
- reportable bool req
- oot_rule json

## lims_sampling_point
Where samples are drawn.
- code text req, unique
- name text req
- equipment_id → core_equipment
- storage_location_id → core_storage_location
- point_type text req: process, raw_receipt, finished, environmental, utility_water, air or surface
- schedule_rrule text
- active bool req

## lims_sample
A laboratory sample.
- sample_no text req, unique
- sample_type text req: raw, in_process, finished, stability, environmental, water, retain, complaint or investigation
- item_id → core_item
- lot_id → core_lot
- sampling_point_id → lims_sampling_point
- specification_id → lims_specification
- production_order_ref uuid (soft link to MES)
- parent_sample_id → lims_sample
- collected_at ts
- collected_by → core_person
- received_at ts
- received_by → core_person
- status text req: planned, collected, received, in_testing, in_review, approved, rejected or disposed
- priority text req: routine, rush or stat
- storage_location_id → core_storage_location
- disposition text: pending, pass, fail or conditional

## lims_custody_event
One step in the chain of custody.
- sample_id → lims_sample req
- action text req: collected, transferred, received, stored, retrieved, consumed or disposed
- from_person_id → core_person
- to_person_id → core_person
- storage_location_id → core_storage_location
- at ts req

## lims_worklist
A batch of tests for one analyst and instrument run.
- worklist_no text req, unique
- instrument_equipment_id → core_equipment
- analyst_id → core_person
- status text req: open, running, complete or cancelled
- created_at_run ts

## lims_test
One method applied to one sample.
- sample_id → lims_sample req
- test_method_id → lims_test_method req
- worklist_id → lims_worklist
- analyst_id → core_person
- instrument_equipment_id → core_equipment
- status text req: pending, assigned, in_progress, complete, reviewed, approved, cancelled or retest
- started_at ts
- completed_at ts

## lims_result
One analyte's result, its flags and its approvals.
- test_id → lims_test req
- analyte text req
- value_num num
- value_text text
- uom_id → core_uom
- source text req: manual, instrument or calculated
- raw_attachment_id → core_attachment
- entered_by → core_person req
- entered_at ts req
- in_spec bool
- oos bool
- oot bool
- reviewed_by → core_person
- reviewed_at ts
- approved_by → core_person
- approved_at ts
- review_signature_id → core_e_signature
- approval_signature_id → core_e_signature
- superseded_by_id → lims_result

## lims_oos_investigation
A phased investigation of an OOS result.
- investigation_no text req, unique
- result_id → lims_result req
- phase text req: phase_1_lab or phase_2_full
- hypothesis text
- assignable_cause bool
- conclusion text
- retest_plan text
- quality_event_ref uuid (soft link to quality)
- status text req: open, phase_1_closed, escalated or closed

## lims_stability_study
A stability protocol being run.
- study_no text req, unique
- item_id → core_item req
- lot_id → core_lot
- protocol_doc_ref uuid (soft link to document control)
- conditions json req
- timepoints_months json req
- start_at date req
- status text req: planned, active, complete or cancelled

## lims_stability_pull
A scheduled pull point that creates a sample.
- study_id → lims_stability_study req
- condition text req
- timepoint_months num req
- scheduled_at date req
- sample_id → lims_sample
- status text req: scheduled, pulled, tested or missed

## lims_reagent
A reagent, standard or prepared solution.
- name text req
- grade text
- lot_no text
- supplier_party_id → core_party
- received_at date
- opened_at date
- prepared_from json
- expires_at date req
- storage_location_id → core_storage_location
- status text req: available, quarantine, expired or consumed

## lims_coa
A certificate of analysis for a lot.
- coa_no text req, unique
- lot_id → core_lot req
- specification_id → lims_specification req
- customer_party_id → core_party
- generated_at ts req
- attachment_id → core_attachment
- signature_id → core_e_signature
----- end -----
Paste into Claude Code, after replacing <paste>
My answers to the questions in the M10 section of docs/spine-map.md: <paste>.

Now write ONE spine migration on this branch (npx supabase migration new lims_spine) that adds only what the map says is missing, with create table if not exists for missing core_ tables. Row-level security on for every new table, no policies (they come from docs/matrix.json in Session 3). pgTAP tests that each new table exists with RLS on. Push, wait for the schema check, and tell me the result in plain words.

You will see recreated screen

claude — acme-platform
⏺ Write(docs/spine-map.md)
+## M10 Laboratory (LIMS)
+| Spine table | Ours | Action |
+| core_item | parts | add item_type, lot_controlled, base_uom_id |
+| core_lot | lots | add status quarantine/released |
+| core_e_signature | (none) | create |
+| core_number_sequence | (none) | create |
1
⏺ Write(docs/spine-map.md)
+### Questions for me
+1. Are customers already a table (for certificates), or is core_party new?
2
⏺ Bash(gh pr checks --watch)
⎿ schema / test pass 1m58s
⏺ Pull request #62 is green. It adds 4 columns to parts and lots and creates 7 spine tables we did not have, with row-level security on and no policies.
The map: what you have, what is missing, and the questions only you can answer.
  1. Extend, do not duplicate.
  2. Questions about meaning are yours to answer.

Check it worked

Pull request LIMS spine map is green, the M10 section of docs/spine-map.md has no open questions, and no new table duplicates one you had.

Fastest path

The table list goes into the shared spine map in the same prompt, so Claude Code reads the columns from a file instead of from memory.

If it goes wrong

The map plans core_item as a new table although we have parts

Say: Our parts table is core_item. Add the missing columns to parts instead.

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

A column the code uses has no migration. Say: Rebuild from nothing using only supabase/migrations, run supabase db diff, and write any missing change as a new migration, never by editing an old one. We hit this: a merged change added ten columns with no migration.

Step 4

Session 2: One prompt: the fourteen tables, the honest-result rules, the tests, the worked example and the seed

30 minutes

Why

The rules that keep results honest must be in the database before any screen exists, so no screen, import or agent can skip them: a result's value never changes, a sample's specification never changes, custody is never rewritten, and nobody types a flag. The worked example is small and fixed, kept as a test fixture so Session 4 can check every flag and count against numbers you worked out by hand; the seed gives the development project the same rows shifted onto today, so the screens show recent work.

Do this

After the spine pull request has merged:

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

On a new branch lims/tables:
1. npx supabase migration new lims_tables. Create the fourteen lims_ tables exactly as the M10 section of docs/spine-map.md lists them, with site_id in place of tenant_id: every column, type, required flag and allowed value (check constraints). Results and limits numeric, never float. Soft links plain uuid with a comment naming the table they will point to. Every table: an index on its scope column, row-level security on with no policies, the touch trigger and the audit trigger. Numbers (sample_no, worklist_no, investigation_no, study_no, coa_no) unique and issued from core_number_sequence. Unique (code, version) on methods and (spec_no, version) on specifications.
2. Checks: lsl <= usl; a limit has at least one of lsl, usl, text_spec; a result has value_num or value_text.
3. Triggers: (a) lims_result: delete refused; update may change only reviewed_by, reviewed_at, review_signature_id, approved_by, approved_at, approval_signature_id and superseded_by_id. (b) lims_sample: item_id never changes; specification_id never changes once set; a sample that is not planned needs a specification; the specification must be of the same item, not draft or approved, and effective no later than collected_at. (c) lims_specification: status only moves forward; approved or effective needs approved_signature_id; limits change only while draft. (d) lims_custody_event and lims_coa append-only with core_block_mutation(). (e) lims_evaluate(specification_id, test_method_id, analyte, value, before) returning in_spec, oos, oot, called by a before-insert trigger on lims_result that fills the flags from the sample's PINNED specification: in spec when at least lsl and at most usl, whichever are given, otherwise OOS; OOT only when in spec, the limit's oot_rule is {"rule":"run","points":3}, and this and the two latest earlier non-superseded results of the same item and analyte, by entered_at, all rise or all fall.
4. pgTAP tests in supabase/tests/lims_schema.test.sql that the database refuses: a sample with status shipped, lsl above usl, an update of a result's value, a delete of a result, a change of a sample's specification_id, a sample with no specification, an update of a custody event.
5. The worked example, exactly as I give it in the next message, in two places: tests/fixtures/lims-worked.json with its fixed dates, which the seed test loads into the test database and checks against the counts and flags; and supabase/seeds/lims.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 days, so the latest approval falls yesterday), marked SYNTHETIC, and safe to run twice (fixed ids, on conflict do nothing). 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 LIMS module. Fixed dates in UTC, as written here, go into tests/fixtures/lims-worked.json: Session 4 checks exact numbers against them. supabase/seeds/lims.sql holds the same rows shifted onto today. Every row is made up, marked SYNTHETIC and carries ext synthetic true. No real names, customers or readings. Insert each sample at collected and walk it forward with updates in the order a person would, and results in entered_at order, so the fixture and the seed pass every rule.

Spine: units kg, %, pH; item P-100 (finished_good, kg, lot-controlled); lots L-001 to L-005 released, L-006 to L-008 quarantine; customer "SYNTHETIC · Customer A"; storage LAB-FR-01 (lab); instruments TIT-01 (titrator) and PH-01 (pH meter) at site cle; four people: a requester, an analyst, a reviewer, an approver (display names start "SYNTHETIC · "). Sequences: lims_sample SMP-2026- next 7 (4 digits); lims_worklist WL-2026- next 3; lims_oos_investigation OOS-2026- next 1; lims_coa COA-2026- next 1.
Methods: ASSAY-01 v1 (retired), ASSAY-01 v2 (active), PH-01 v1 (active).
Specifications (insert draft, add limits, then move forward with the approver's signature): SPEC-P100 v1, stage release, effective 2026-01-01, superseded; v2, effective 2026-07-01, effective. Limits: v1 assay 98.0–102.0 % by ASSAY-01 v1, pH 6.5–7.5 by PH-01 v1; v2 assay 98.5–101.5 % by ASSAY-01 v2, pH 6.5–7.5 by PH-01 v1. All reportable; both assay limits carry the run-of-three oot_rule.
Sampling points SP-FIN-01 (finished) and SP-WAT-01 (utility_water). Reagents: titrant TIT-L1 available to 2028-12-31; pH 7 buffer BUF-L2 available to 2028-12-31; older buffer BUF-L1 expired 2026-06-30.
Six samples, finished, routine, P-100, SP-FIN-01 (number, lot, collected, received, version, final status): 0001 L-001 2026-06-10 07:30, 09:00, v1, approved; 0002 L-002 2026-07-08 07:30, 09:00, v2, approved; 0003 L-003 2026-07-15 08:30, 10:00, v2, approved; 0004 L-004 2026-07-22 07:30, 09:00, v2, approved; 0005 L-005 2026-07-29 07:30, 09:00, v2, approved; 0006 L-006 2026-07-30 07:30, 09:00, v2, in_testing. The first five disposition pass.
Custody, four per sample (24): collected (to requester), received (requester to analyst), stored (LAB-FR-01, +10 min), retrieved (+40 min).
Worklists WL-2026-0001 (TIT-01) and WL-2026-0002 (PH-01), open, holding sample 0006's tests. Twelve tests: one assay and one pH per sample; the first ten approved (0001's assay by ASSAY-01 v1, other assays v2), 0006's two assigned.
Ten results, entered 13:00 (assay) and 13:30 (pH) on the day of receipt: assay 98.2, 99.0, 98.8, 99.1, 99.5; pH 7.0, 7.1, 7.2, 7.0, 7.4. Each reviewed (two hours before approval) and approved, with a signature each (20, plus 2 on the specifications = 22). Approvals: 2026-06-11 15:00, 07-09 09:00, 07-16 16:00, 07-23 21:00, 07-31 09:00.

The seed test, on the fixture and again on the shifted seed run twice, must prove: 6 samples, 24 custody events, 12 tests, 10 results (10 in spec, 0 OOS, exactly 1 OOT: the assay of 0005), 22 signatures.

Now push, open a pull request titled "LIMS 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 lims_tables)
⎿ Created new migration at supabase/migrations/20261103111500_lims_tables.sql
1
⏺ Write(supabase/migrations/20261103111500_lims_tables.sql)
+create trigger lims_result_guard before update on public.lims_result
+ for each row execute function public.lims_result_only_review_columns();
+-- value_num, analyte, test_id, entered_by, entered_at can never change
2
⏺ Bash(gh pr checks --watch)
⎿ schema / test pass 2m22s
⏺ Pull request #63 is green: 14 tables, row-level security on, no policies. 47 tests passed, 7 of them try bad changes and are refused. The fixture and the seed (loaded twice, nothing doubled) each give: 6 samples, 24 custody events, 12 tests, 10 results (10 in spec, 0 OOS, 1 OOT on the assay of SMP-2026-0005), 22 signatures.3
Claude Code writes the migration, the tests and the seed, then waits for GitHub before reporting.
  1. Dated migration: production gets it from the deploy pipeline on merge (Session 11), never by hand.
  2. The honest-result rule, in the table itself.
  3. The counts you will hand-check, proven in CI.

Check it worked

Pull request LIMS tables is green and its summary gives the seed counts: 6 samples, 24 custody events, 12 tests, 10 results with exactly one OOT, 22 signatures.

Fastest path

Two messages sent one after the other replace a dozen exchanges: the first sets every rule, the second gives the worked example and the counts the test must prove.

If it goes wrong

The seed fails on the pin trigger

The seed inserts a sample before its specification is effective, or with a version effective after collection. Say: Insert each specification as draft, add its limits, then move it forward with its signature, before the samples that pin it. Fix the seed, not the trigger.

A later step expects a count the seed does not give

Say: List every count any later step or test expects and show the seed line that creates each. Fix the seed, not the check. Reviews of five Academy modules found this fault.

Claude Code proposes to drop a rule to get green

Say: Never edit, skip or loosen a test or a rule to make something pass. Explain why you think it is wrong and stop.

Step 5

Session 2: Try it on the development project yourself, then predict the flags

20 minutes

Why

CI proves the files build a database from nothing; the development project proves they apply on top of your real, already-migrated Foundation. 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. Predicting the flags by hand first makes the checks honest.

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 lims/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 count(*) filter (where in_spec) as in_spec, count(*) filter (where oos) as oos,
       count(*) filter (where oot) as oot, count(*) as results
from lims_result;

Before you look, write docs/lims-seed.md by hand: which of the ten results are in spec, OOS or OOT and why, and what 98.2 would be against version 2. Commit it; owner two approves and the pull request merges.

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? • 20261102151000_lims_spine.sql • 20261103111500_lims_tables.sql [Y/n] y
Applying migration 20261103111500_lims_tables.sql...
Seeding data from supabase/seeds/lims.sql...
Finished supabase db push.2
db push lists exactly the new migrations and seed files, and asks first.
  1. The development project. Check every time.
  2. Production gets these files from the deploy pipeline when the pull request merges.

You will see recreated screen

supabase.com/dashboard/project/tsrqponmlkjihgfedcba/sql/new
SQL Editor · acme-platform-dev
1
in_specoosootresults
100110
The flags were computed by the trigger, not typed.
  1. Your hand prediction should say the same: ten in spec, the fifth assay OOT.

Check it worked

The query shows 10 in spec, 0 OOS, 1 OOT of 10 results on acme-platform-dev; docs/lims-seed.md holds your predictions; 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.

A page later fails on the live site with "column does not exist"

Production did not get the migration. Open the deploy run on GitHub's Actions tab. Our live database once fell nine migrations behind main; the Session 11 pipeline and its daily check exist so that never happens silently.

Knowledge check

Version 2 of a specification becomes effective on 1 July. A sample collected on 20 June is still being tested on 3 July. Which version judges it?

Knowledge check

Where are the module's migrations first applied, and by whom?

References

  1. LIMSwiki: LIMSpec primary laboratory workflow (mapped to ASTM E1578-18). https://limswiki.org/index.php/LII:LIMSpec/Primary_Laboratory_Workflow
  2. LIMSwiki: LIMSpec sample management. https://limswiki.org/index.php/Template:LIMSpec/Sample_management
  3. ISO/IEC 17025:2017 General requirements for the competence of testing and calibration laboratories. https://www.iso.org/standard/66912.html
  4. Supabase CLI reference: supabase db push. https://supabase.com/docs/reference/cli/supabase-db-push

Chapter 2 · Session 3

Who may do what, and the screens

A result is not final until a second and a third person have looked at it. Session 3 writes who may request, test, review and approve into docs/matrix.json, generates the access rules from it, and builds the laboratory's screens: the requester's form, the analyst's bench, the review and approval queues, investigations, methods and the manager's board.

20 minSession 3: 2 steps4 roles and a reader, 1 machine account7 screens

By the end of this chapter you can

  • Add the module's roles, the importer account, tables, screens and routes to docs/matrix.json and regenerate the access rules.
  • Walk Sessions 4 to 6 against the matrix so no later step is refused.
  • Have Claude Code build the seven screens and test them signed out, per role and at phone width.

Three different people

Review and approval are separate steps by separate people. The reviewer checks the result against the raw data and the method; the approver, usually the laboratory lead, accepts it for release. Each signs, and the database refuses the shortcuts. An electronic signature records who signed, what it meant (authored, reviewed, approved, released or rejected), the record, a hash of its text, when and how they authenticated; Part 11 expects a signed record to show the printed name, date and time, and meaning [1].

Two-level review with signaturesThree lanes. The analyst enters the result and is named in entered_by; a signed author statement is added only when a result corrects another. The reviewer and the approver each sign their own level, and the certificate is released with a further signature. No person signs for another level of the same result. AnalystReviewerApproverEnter resultentered_by and entered_atReviewsigns as reviewerApprovesigns as approverCertificatereleased signatureentered_by is not reviewed_by is not approved_byA reviewer cannot also approve.Approval waits for every OOS investigation to close.
Three lanes. The analyst enters; the reviewer and the approver each sign their own level; the certificate is released with a further signature. Approval waits for every OOS investigation to close.
RoleScopeMayMay not
RequesterOwn samplesRegister a sample (collected) and its first custody event; see own samples and their approved results and certificatesUpdate a sample once registered; see others' samples
AnalystSiteReceive, store, assign, test, enter results, open investigations, sign (authored)Review or approve own results; change a value
ReviewerSiteReview results (first level, signed); close investigations they did not openReview a result they entered; approve
ApproverSiteApprove results and samples; own methods and specifications; release certificatesApprove a result they entered or reviewed
ManagerSiteRead the board: samples by status and age, the four numbersChange anything
Importer (machine)SiteInsert methods, specifications, open samples and history with ext imported_from, only through import-lims.yml (Sessions 5–6)Update, delete, sign, review or approve; write the outbox; sign in after cut-over (set NOLOGIN)

Two facts about row-level security shape the cells [2]: an update finds rows only through the role's read rule, so a role that updates must also read the row before and after the change; and an insert that returns its row needs read too, so routes make their own ids with crypto.randomUUID(). The flag trigger reads earlier results for the trend, so the analyst must read every result.

Key or secretWhat it unlocksWhere it livesWho holds itNever
lims_importer passwordLets .github/workflows/import-lims.yml sign in as lims_importer, which may only insert methods, specifications and samples with imported_fromGitHub Actions secret LIMS_IMPORTER_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
Step 6

Session 3: The roles and rights into the matrix

35 minutes

Why

Access decided once in the matrix and generated everywhere cannot drift: the database, the routes and the menus all say the same thing. Walking every later step against the matrix now is what stops Session 4 failing halfway through a review, or an approval 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 M10 section of docs/spine-map.md, scripts/gen-policies.mjs and docs/access-review.md.

On a new branch lims/access, add to docs/matrix.json, starting every cell blank and adding only what the job needs: the roles requester (own samples), analyst, reviewer, approver and the existing manager (read the board only), and the machine account importer (lims_importer: its own sign-in with a password a person sets, insert-only, never the service key), with exactly the rights in element M10 chapter 2's table, which I paste below; the seven screens /lims/request, /lims/bench, /lims/review, /lims/approve, /lims/investigations, /lims/methods, /lims/board and the routes /api/lims/register, receive, test, result, investigation, review, approve, coa and spec, each with the roles that may use it (the import is a workflow, not a route). No delete for anyone. Every role that updates a table also reads it, before and after the change; the analyst reads every result (the trend needs it).

Then write docs/access-walk.md: one line per step of Sessions 4, 5 and 6 in element M10 (I paste the list below): role, 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: a requester sees no other requester's samples and cannot update a sample; an analyst cannot review own result; a reviewer cannot approve; the manager can change nothing; the importer cannot sign; nobody can delete from any lims_ table; and for each role that updates a table, the row really changed afterwards. Also, in the LIMS seed file only (never a migration, never a page or switch in the app), add public.dev_act_as(email text, person_code text) that links that sign-in to the made-up person, refusing any person without ext synthetic true. Push, open "LIMS 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)
+"lims_result": {
+ "analyst": { "read": "site", "insert": "site" },
+ "reviewer": { "read": "site", "update": ["reviewed_by", "reviewed_at", "review_signature_id"] },
+ "approver": { "read": "site", "update": ["approved_by", "approved_at", "approval_signature_id"] }
+}
1
⏺ Write(docs/access-walk.md)
+| S4 step 10 | reviewer | lims_oos_investigation | update status | added: reviewer read + update |
2
⏺ Bash(gh pr checks --watch)
⎿ access / test pass 2m51s
⏺ Pull request #64 is green. 6 roles and accounts, 14 tables, 7 screens, 9 routes. The walk found one missing cell (the reviewer closes investigations); it is added. 142 access tests passed.
The matrix grows by rows; the generators do the rest. The walk names a cell for every step.
  1. Each signer may set only the columns of their own level.
  2. The walk catches the refusal before the session that would hit it.

Check it worked

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

If it goes wrong

An approval reports success but the result is not approved

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

Claude Code proposes the service_role key for the import route

Refuse: The importer is its own sign-in with only its matrix rights. Never service_role in a route. It skips every policy.

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 7

Session 3: The screens, built and tried by the people who will use them

40 minutes

Why

Analysts judge the module by the bench screen, gloved, at a fume hood; requesters by how fast a sample is logged. Building the screens against the seed, then testing every one signed out, per role and at phone width, catches the wrong person recorded as the author or a page that answers without sign-in before anyone relies on it.

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 and the screens from Foundation Sessions 12 to 15.

On a new branch lims/screens, build:
- /lims/request: register a sample at a sampling point; the route takes the number from the sequence and pins the latest specification version effective at the collection time for the stage that fits the point; print a label with the number as a barcode, item, lot, point and time. The version is shown beside the sample everywhere.
- /lims/bench: receive, store, retrieve; worklists; enter a result (value, unit, source, raw-data file stored with its sha256), with the limits shown and the flags as the database set them.
- /lims/review and /lims/approve: queues with the raw data beside each result; signing asks for the password again.
- /lims/investigations, /lims/methods (versions, never edits), /lims/board (samples by status and age, the four numbers, "No data" where there is none).
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; a result entered by the analyst records the analyst whoever the page claims; the screen-size check at 360 and 390 px. Push, open "LIMS 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 the requester, analyst, reviewer or approver.

Sit a requester at /lims/request and an analyst at /lims/bench. Do not explain. Write down every place each one stopped, and give the list to Claude Code.

You will see recreated screen

acme-platform-git-lims-screens-acme-ops.vercel.app/lims/bench
Bench · WL-2026-0002 · PH-01
SMP-2026-0006 · P-100 · L-006SPEC-P100 version 2 · pH 6.5 to 7.52
pH7.2
Enter result
The bench on a tablet, signed in as the analyst on the preview (development project, made-up data).
  1. Made-up data says so. If a preview shows real data, stop.
  2. The pinned version beside the sample, on every screen.

Check it worked

Pull request LIMS screens is green; on the preview each role sees only its screens; every screen passes at 360 and 390 px; you have notes from a requester and an analyst.

If it goes wrong

Every result says it was entered by the same person

The page sent a name and the server trusted it. Say: Take the person from the signed-in session on the server and ignore what the page sends; add a test with two users.

The board shows 0 hours turnaround for a type with no approved samples

Say: Show "No data" where there is none, never 0, 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 /lims page and /api/lims route signed out and show me each status code. A prior build had 376 of 449 route handlers with no guard.

Knowledge check

An analyst enters a result. Who may review it?

Knowledge check

An approval reports success but the result is still unapproved. The likeliest cause?

References

  1. eCFR: 21 CFR Part 11, Electronic Records; Electronic Signatures. https://www.ecfr.gov/current/title-21/chapter-I/subchapter-A/part-11
  2. Supabase Docs: Row Level Security. https://supabase.com/docs/guides/database/postgres/row-level-security
  3. PostgreSQL Documentation: Row Security Policies. https://www.postgresql.org/docs/current/ddl-rowsecurity.html

Chapter 3 · Session 4

The workflow: from sample to certificate

Two new samples go through the laboratory on the preview: one shows a typing error corrected by superseding, never overwriting; the other a genuine out-of-specification result that blocks approval until its investigation is closed in two phases. Then you prove the pin and hand-count the whole dataset.

30 minSession 4: 5 steps3 flags, 2 phases0 results overwritten

By the end of this chapter you can

  • Have Claude Code write the remaining rules and their tests, each shown failing first.
  • Run a correction and a genuine OOS end to end, with custody, two signatures and a certificate.
  • Prove the pin and match a hand count of the dataset.

Flags, corrections and OOS

When a result is inserted, the trigger fills in_spec, oos and oot from the sample's pinned specification. Nobody types them.

How a result is flaggedA number line from 90 to 104 percent with the in-specification band from 98.5 to 101.5 and two out-of-specification regions. The value 91.9 is OOS; 99.1 and 100.2 are in specification. below 98.5: OOS98.5 to 101.5 %above 101.5OOS91.9 · OOS99.1 · in spec100.2 · in spec9092949610010498.5101.5The database sets in_spec and oos from the specification pinned to the sample. Nobody types a flag.
Judging an assay against 98.5 to 101.5 %. 91.9 is OOS; 99.1 and 100.2 are in specification; the limits themselves are in specification.
The out-of-trend run ruleA chart of five assay results: 98.2, 99.0, 98.8, 99.1 and 99.5. The last three are three results in a row, each higher than the one before, so the fifth result is flagged out of trend although it is inside its limits. rising run of three: OOT98991001010001000200030004000598.299.098.899.199.5 · OOTAssay (%) by sample SMP-2026-, in the order entered. Green ticks are each sample's own pinned limits.
Five assays in the order entered. 98.8, 99.1, 99.5 rise three in a row, so the fifth is OOT although every value is inside its limits.

A wrong result is never overwritten. Part 11 expects audit trails that do not obscure previously recorded information [1], and the FDA's data integrity guidance sets the same expectation for original data [2]. A correction is a new result on the same test and analyte with a signed, non-empty reason; the old one gets superseded_by_id and stays on file. An OOS result opens an investigation: Phase I looks for an assignable cause in the laboratory, shown from the raw data; if none, Phase II escalates to the quality module [3]. While any investigation on a sample is open, nothing on it can be approved, and the person who opened it may not close it.

Correcting a result by superseding itResult 1, assay 91.9, stays on file and points to result 2, assay 99.1, through superseded_by_id. Result 2 carries a signed reason; the investigation records the transcription error. One query returns the old value, reason, signer and new value. Result 1 · assay 91.9 %OOS, entered in errornever edited or deletedResult 2 · assay 99.1 %in specificationsupersedes result 1superseded_by_idInvestigation OOS-2026-0001Phase I: transcription errorshown from the raw-data fileSigned reasonmeaning: authoredreason text is requiredOne query returnsold value 91.9, the reason, the signer's printed name and the new value 99.1
A digit-swap corrected. The analyst typed 91.9; the raw data says 99.1. The new result carries a signed reason; the old one is linked to it.
Phases of an out-of-specification investigationAn OOS flag opens Phase I in the laboratory. If an assignable cause is shown from the raw data, Phase I is closed, the wrong result is superseded and a different person closes the investigation. If not, it escalates to a Phase II full-scale investigation with a quality event, and closes with a conclusion. Approval waits until the investigation is closed. OOS flaggedcomputed on pinned specan investigation opensPhase I · laboratoryhypothesis, raw data,instrument, reagent,calculation checksAssignable cause?shown from the raw data,never assumedyesnoLaboratory error shownsupersede wrong resultEscalate to Phase IIstatus escalatedFull-scale investigationa quality event opensInvestigation closedby a different personApproval can go aheadonly when all are closed
The two phases. Phase I looks for a laboratory cause shown from the raw data; if none, Phase II escalates. A different person closes it, and only then can approval go ahead.
Step 8

Session 4: The rules page, then one prompt for the remaining rules and their tests

25 minutes

Why

A rule you can read on one page is one the laboratory lead can check before anything is built, and the same page tells Claude Code exactly what to enforce. Each rule as a database trigger with a test that tries to break it means the refusal holds for every screen and import, and a later change that quietly removes it turns CI red.

Do this

Paste into Claude Code, after replacing <paste>
On a new branch lims/workflow, write docs/lims-rules.md, one page: the pin; the flags and the run-of-three rule; the rounding rule from our SOP (I paste it below); correction by superseding; the two investigation phases; who may review, approve and close; the custody completeness check; and the certificate rules. Stop and show me the page; the laboratory lead will read it.

Our rounding rule: <paste from your SOP>

When the laboratory lead has signed it off:

Paste into Claude Code
docs/lims-rules.md is signed off. Now, as new migrations on lims/workflow, add triggers that:
(a) refuse superseded_by_id unless the old result is not yet approved, the new result has the same test and analyte, and a signature for the new result by the person who entered it has a non-empty comment (the reason);
(b) refuse a review by the person who entered the result, an approval by the person who reviewed or entered it, a review without review_signature_id, and an approval without approval_signature_id or without a review;
(c1) refuse approval of a result, and a sample status approved or rejected, while any investigation on that sample's results is not closed; and refuse closing an investigation by the person who opened it;
(c2) refuse a sample status approved or rejected while any non-superseded result is not approved;
(d) refuse a lims_coa unless the lot's sample is approved on the same specification. A certificate is built only from approved, non-superseded results.
The signature's record_hash is SHA-256 of the test id, analyte, value, unit and entered_at.
Also a custody-check query (a sample is complete when its events begin with collected, include received and stored, run in time order, and each from_person_id equals the previous to_person_id).
Tests in supabase/tests/lims_workflow.test.sql, each in a transaction it rolls back, for every rule, each shown failing with its rule removed and passing with it back. Push, open "LIMS workflow", wait for every check and report.

You will see recreated screen

claude — acme-platform
⏺ Write(supabase/migrations/20261110103000_lims_review_rules.sql)
+if new.reviewed_by = old.entered_by then
+ raise exception 'You entered this result. Another reviewer must review it.';
+end if;
1
⏺ Bash(npx supabase test db)
⎿ lims_workflow.test.sql .. not ok 4: self-review refused (rule removed)
2
⏺ Bash(gh pr checks --watch)
⎿ schema / test pass 3m05s
⏺ Pull request #65 is green. 24 workflow tests, each shown failing with its rule removed first. The custody check lists no incomplete sample in the seed.
Every rule arrives with a test that tries to break it, red before green.
  1. The message names the rule in the laboratory's words.
  2. Red first: a test that cannot fail proves nothing.

Check it worked

docs/lims-rules.md is signed off by the laboratory lead; pull request LIMS workflow is green, with each test shown failing before it passed.

Fastest path

"Show it failing with the rule removed" in the prompt saves the day you find a test that was green all along because it could never fail.

If it goes wrong

A test checks that a word appears in a file, not that the database refuses

Say: For each test, tell me what behaviour it proves. Rewrite any that only looks for a name to perform the action and check the refusal.

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 9

Session 4: Register two samples, receive them, and assign the tests

15 minutes

Why

Registration is where the pin is made and the number is issued, and custody starts at the first hand-over. Trying the expired buffer and a change of specification here shows the database refusing the two mistakes that would make every later result indefensible.

Do this

On the preview of LIMS workflow, acting in turn with dev_act_as:

  • As the requester on /lims/request: SP-FIN-01, P-100, lot L-007, routine. It becomes SMP-2026-0007, pinned to SPEC-P100 version 2, with a custody event collected. Print the label. Register L-008 the same way (SMP-2026-0008).
  • As the analyst on /lims/bench: receive both (received, from the requester), store in LAB-FR-01, retrieve.
  • Assign: try buffer lot BUF-L1 (refused: expired), then BUF-L2. Check TIT-01 and PH-01 are in calibration and you are qualified (read from M05 and M07 where installed, otherwise a manual check recorded on the test). Create WL-2026-0003 (assay, TIT-01) and WL-2026-0004 (pH, PH-01).
Paste into Claude Code
Read-only, on the development project as the approver: try to change SMP-2026-0007's specification_id to version 1 inside a transaction you roll back, and show the refusal. Then show both new samples with their pinned version, custody events and tests, and run the custody check over all eight samples.

You will see recreated screen

acme-platform-git-lims-workflow-acme-ops.vercel.app/lims/request
Sample registered
SampleSMP-2026-00071
SpecificationSPEC-P100 version 2 (effective 1 Jul 2026)2
Custodycollected · 07:30 · requester
Print label
Registration pins the version and issues the number.
  1. From the sequence, never counted by a person.
  2. Pinned now, and never changed.

You will see recreated screen

claude — acme-platform
⏺ Changing SMP-2026-0007's specification was refused: "specification_id cannot change once set". Both samples are pinned to version 2, with collected, received, stored, retrieved. The custody check lists no incomplete sample among the eight.1
The refusal and the custody check.
  1. The pin holds against any writer, not only the screen.

Check it worked

SMP-2026-0007 and -0008 exist, pinned to version 2, each with four custody events; BUF-L1 was refused; 4 worklists and 16 tests exist; the custody check lists nothing.

If it goes wrong

The register route pinned version 1 to a July sample

It looked up the wrong version. Say: Pick, for the stage that fits the sampling point, the version with the latest effective_at not later than collected_at; add a test with a sample on each side of 1 July.

The preview shows real laboratory data

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

Step 10

Session 4: A typing error: OOS, Phase I, supersede, two signatures, a certificate

20 minutes

Why

This is the module's first definition-of-done test: the wrong value stays on file with its reason and signer, and the certificate never shows it. It also shows the honest order of events: the flag opens an investigation, the cause is shown from the raw data, a new result supersedes the old, and only then do two other people sign.

Do this

  • As the analyst: attach raw-0007-assay.txt (the line "assay 99.1 %"). Enter the assay as 91.9 (the digits swapped) and the pH as 7.3. The trigger flags the assay OOS and the route opens OOS-2026-0001.
  • Phase I on /lims/investigations: hypothesis "transcription error"; compare with the raw data; assignable cause yes; conclusion; status phase_1_closed. Do not retest.
  • Enter the assay as 99.1 and sign it with the reason "Digits transposed on entry; raw data shows 99.1; see OOS-2026-0001". Supersede the 91.9.
  • As the reviewer: close OOS-2026-0001; review both current results. As the approver: approve them, approve the sample (pass), generate the certificate for L-007.
Paste into Claude Code
Read-only, on the development project: return the superseded result of SMP-2026-0007 with its value, the reason, the signer's printed name and the value that replaced it; then the lines of the certificate for lot L-007.

You will see recreated screen

acme-platform-git-lims-workflow-acme-ops.vercel.app/lims/bench
SMP-2026-0007 · assay
Entered91.9 %
The flag the trigger set, and the investigation it opened.
  1. Nobody typed the flag, and approval of this sample is now blocked.

You will see recreated screen

claude — acme-platform
⏺ Superseded: 91.9 %, entered by SYNTHETIC · Analyst. Reason: "Digits transposed on entry; raw data shows 99.1; see OOS-2026-0001", signed by SYNTHETIC · Analyst. Replaced by 99.1 %.1
⏺ COA-2026-0001 for L-007 against SPEC-P100 v2: assay 99.1 % (98.5–101.5), pH 7.3 (6.5–7.5). Two lines; 91.9 does not appear.2
The definition-of-done query.
  1. The old value, the reason and the signer: one row.
  2. The certificate is built only from approved, current results.

Check it worked

The query returns 91.9 with its reason, signer and the 99.1 that replaced it; the certificate has two lines and no 91.9; a self-review, done as SQL in a rolled-back transaction, is refused.

If it goes wrong

Claude Code offers to "fix" the 91.9 by updating it

Refuse: A result is never updated. Enter a new one with a signed reason and supersede the old. The trigger refuses the update anyway; the offer means CLAUDE.md should say so.

The certificate shows three lines

It included the superseded result. Say: Build certificate lines only from approved results whose superseded_by_id is empty; add a test.

Step 11

Session 4: A genuine OOS: Phase II, approval blocked, the lot rejected

15 minutes

Why

A real failure must stop the lot, and retesting must not make it disappear. Seeing approval refused while the investigation is open, and the certificate refused for the rejected lot, is the proof that the laboratory's decision reaches the plant only through the rules.

Do this

  • As the analyst: attach raw-0008.txt ("assay 100.2 %; pH 8.1"); enter both. The pH is OOS: OOS-2026-0002 opens.
  • Phase I: raw data agrees, instrument and buffer BUF-L2 in order: no assignable cause. Escalate: phase_2_full, status escalated, and an action item for the approver (or a quality event if M08 is installed).
  • As the reviewer: review both results (allowed while open). As the approver: try to approve (refused); close in Phase II with a conclusion and retest plan "none"; approve; reject the sample (fail, signed); try a certificate for L-008 (refused).
Paste into Claude Code
Read-only, on the development project: show OOS-2026-0002's phase, status and conclusion, SMP-2026-0008's status and disposition, and the lims. events in core_event_outbox for SMP-2026-0007 and -0008.

You will see recreated screen

acme-platform-git-lims-workflow-acme-ops.vercel.app/lims/approve
SMP-2026-0008 · pH 8.1 (OOS)
Open investigation
Approval waits for the investigation.
  1. The database refuses it, whatever screen or import tries.
  2. A rejected lot gets no certificate. The quality module acts on lims.lot.disposition.

Check it worked

OOS-2026-0002 is closed in Phase II, SMP-2026-0008 is rejected with disposition fail, and the certificate for L-008 was refused.

If it goes wrong

Someone asks to retest until it passes

The original result and every retest stay on record, and what may be retested is set by the investigation plan and the FDA guidance, not by the hope of a pass.

Step 12

Session 4: Prove the pin, and match a hand count of the whole dataset

15 minutes

Why

The second definition-of-done test is that a flag follows the pinned version, not today's. The hand count is the defence against a seed and a set of steps that disagree: if the queries and your paper count differ, one of them is wrong, and it is never the count you did by hand from the steps.

Do this

On paper first: samples 8 (5 approved, 1 in_testing, 1 disposed after the certificate, 1 rejected); results 15 (1 superseded, 2 OOS, 1 OOT, 13 in spec); investigations 2, closed; certificates 1 with 2 lines; worklists 4, tests 16.

Paste into Claude Code
Read-only, on the development project: run lims_evaluate for the assay of SMP-2026-0001 (98.2) against SPEC-P100 version 2 with the current time as before, and show the stored flags of that result. Then count, by query: samples by status, results (superseded, OOS, OOT, in spec), investigations by status, certificates and their lines, worklists, tests, custody events and signatures. Write both into docs/lims-rules.md on the branch, then wait for the checks and tell me when the pull request is ready for review.

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

You will see recreated screen

claude — acme-platform
⏺ lims_evaluate(98.2, SPEC-P100 v2): in_spec false, oos true. Stored on SMP-2026-0001: in_spec true, oos false, because it is pinned to version 1.1
⏺ Samples 8 (approved 5, in_testing 1, disposed 1, rejected 1). Results 15: superseded 1, OOS 2, OOT 1, in spec 13. Investigations 2 closed. Certificates 1 (2 lines). Worklists 4, tests 16. All match your count.2
The pin, and the counts against your paper.
  1. One value, two verdicts: the stored one follows the pin.
  2. If any count differs, fix the query or the step, not your count.

Check it worked

docs/lims-rules.md holds both lines of the pin proof and the counts, matching your paper count; the workflow pull request is merged with every check green.

If it goes wrong

The counts are one sample short

The aliquot practice was not rolled back, or a step was skipped. Find which, and fix the step, not the count.

Knowledge check

An analyst typed 91.9; the raw data says 99.1. What is the right correction?

Knowledge check

A result is in spec but the third of three rising values under a run-of-three rule. Its flags?

References

  1. eCFR: 21 CFR Part 11, Electronic Records; Electronic Signatures. https://www.ecfr.gov/current/title-21/chapter-I/subchapter-A/part-11
  2. FDA: Data Integrity and Compliance With Drug CGMP, Questions and Answers. https://www.fda.gov/regulatory-information/search-fda-guidance-documents/data-integrity-and-compliance-drug-cgmp-questions-and-answers
  3. FDA: Investigating Out-of-Specification (OOS) Test Results for Pharmaceutical Production. https://www.fda.gov/regulatory-information/search-fda-guidance-documents/investigating-out-specification-test-results-pharmaceutical-production

Chapter 4 · Sessions 5–6

Move the records, prove it, switch the old LIMS off

Methods, specifications and open samples come across; closed history stays in the old tool's export as the archive. You prove the specifications moved correctly by re-evaluating real historical results against them, rehearse on the development project with a copy IT approved, import into production through a workflow a person starts from main with an export owner two approved, run side by side for a week, cut over and cancel with the saving from invoices.

25 minSessions 5–6: 4 stepsRe-evaluate historyEnds with the module gate

By the end of this chapter you can

  • Map an export, load every specification version with the approver's line-by-line check, and dry-run the import.
  • Rehearse on the development project, re-evaluating history against the migrated specifications.
  • Import into production through import-lims.yml with an approved export, compare the four numbers side by side, cut over and cancel.
NumberDefinition (write it before comparing)
Turnaround timeMedian hours from received_at to approval, by sample type
BacklogSamples received and not yet approved, by age
OOS rateOOS results ÷ reportable results
Right-first-timeResults approved without retest or correction ÷ results entered (a superseded result and its correction both count as corrections)
Turnaround of five approved samplesFive horizontal bars drawn to scale: 30, 24, 30, 36 and 48 hours from receipt to approval, with the median of 30 hours marked. median 30 hSMP-2026-000130 hSMP-2026-000224 hSMP-2026-000330 hSMP-2026-000436 hSMP-2026-000548 h01020304050Sorted: 24, 30, 30, 36, 48. The middle value is 30 hours.Backlog at 2026-08-01 12:00 UTC: SMP-2026-0006, received 2026-07-30 09:00, 51 hours old.
Turnaround of the five approved seed samples, to scale: 24, 30, 30, 36 and 48 hours, so the median is 30. A different start time (collected instead of received) or working hours instead of calendar hours changes the number for no real reason.

The module library's plan is: export methods, specifications and historical results; load them; and validate by re-evaluating a sample of history against the migrated specifications. Validation should be risk-based: ISPE GAMP 5 (second edition) is the guide the library names [1], and EU Annex 11 sets expectations for computerised systems in regulated settings [2].

Step 13

Session 5: Read the export, map it, and dry-run the import

35 minutes

Why

A specification that moves with one limit wrong silently changes every verdict after cut-over. Mapping every value to an allowed one (never by guess), loading each version as draft and having the approver compare it line by line with the old printout before signing, and a dry run that writes nothing, catch that before any result depends on it.

Do this

Take the export yourself from the old tool's own export page; keep it in a private company folder, never in the repository. It may carry customer names and sample descriptions.

Paste into Claude Code, after replacing the last line
I will describe the old LIMS export's files and column headers below (no data). On a new branch lims/import:
1. Write docs/lims-migration-plan.md: counts per file (I will fill them in), what the export lacks (audit trail, signatures, custody), and the mapping of old sample types, statuses, stages and units to our allowed values, items to our items, lots to our lots (a missing lot is reported, never created), people and instruments to ours.
2. scripts/import-lims.mjs with --dry-run: reads the files from a path I give, applies the mapping, writes nothing, and reports per file rows read, rows it would import and every value it cannot match. Never maps by guess.
3. .github/workflows/import-lims.yml, run only by hand (workflow_dispatch) from main, refusing any other branch, with inputs target (dev or production) 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/lims-approved.md on main; signs in as lims_importer with the password in that target's Actions secret (never the service key); runs the same code as the script in one transaction; and fails, keeping nothing, 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 lims_importer as a database role with NOLOGIN, insert-only on the tables it loads (no update, no delete); a person turns its login on with a password they set. It loads: methods (each version a row: in use active, older retired); specifications loaded as draft with their limits, left for the approver to compare and sign; open samples with the old vial number, pinned to the version in force at their collected_at, with custody, tests and results so far (flags computed by the trigger). Every row has ext imported_from with the old tool's name and id and a batch id.
4. Three checks into docs/lims-migration-check.md, each must return no rows: an item and stage with samples but no effective specification, or two; a specification approved or effective without limits or signature; a limit of an approved or effective specification whose method is retired.
5. Tests on a made-up export (marked synthetic) with one bad row of each kind, and the count rule: read = imported + skipped, per file; a file whose sha256 is not in the approved file is refused; a count mismatch fails and keeps nothing; lims_importer cannot update or delete.
Push, open "LIMS import", wait for every check and report.

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

You will see recreated screen

Terminal
$ node scripts/import-lims.mjs --dry-run --from ~/private/lims-export
methods.csv read 41 would import 41 skip 0
specs.csv read 63 would import 62 skip 1
row 17: stage 'FG-REL' has no mapping (add it to docs/lims-migration-plan.md)1
samples.csv read 28 open would import 28; pinned version found for 28 of 282
The dry run writes nothing and says what it cannot match.
  1. Fix the mapping, never guess in the import.
  2. Every open sample has the version that was in force when it was collected.

Check it worked

The dry run maps every value or explains each skip; read = would-import + skipped per file; the three check queries are written; the pull request is green and 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.

The old tool's stage names do not fit ours

Map each one deliberately in docs/lims-migration-plan.md and have the approver agree; never let the script guess.

Step 14

Session 5: Rehearse on the development project and re-evaluate history

40 minutes

Why

Matching row counts proves nothing about limits. Re-evaluating real historical results with lims_evaluate against the migrated specifications, and comparing with the old tool's own verdicts, proves the specifications behave as the old ones did. Doing it first on the development project, with a copy IT approved in writing and removed the same day, rehearses the very workflow production will use, away from production.

Do this

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

Open

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

Development project Storage: a private bucket named imports; upload the redacted 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 lims/import-approval, write docs/imports/lims-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, and IT's written approval (date and role). Open a pull request titled "LIMS: 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. As the approver on the preview, compare each specification version in force with the old printout line by line, then sign it to approved and effective with its old date.

Open

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

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

Paste into Claude Code, after replacing <paste>
Read-only, on the development project: counts with ext imported_from per table beside docs/imports/lims-approved.md; the three checks in docs/lims-migration-check.md; then re-evaluate 50 historical results from the export (I give their values, analytes, items and collection dates below) with lims_evaluate against the specification version in force at each collection date, and compare with the old tool's verdict. List every difference with its likely cause. Results: <paste>

Then remove the copy from the development project the same day (ask Claude Code for a statement that deletes only rows with ext imported_from, which you run yourself in the SQL editor), delete the file from the bucket, and write the date of removal in docs/imports/lims-approved.md.

You will see recreated screen

github.com/acme-ops/acme-platform/actions/workflows/import-lims.yml
import-lims · target dev · dry_run false
FileReadImportedSkipped
methods.csv41410
specs.csv63630
samples.csv28280
The rehearsal on the development project: the approved fingerprints checked first, then the counts.
  1. Only an export owner two approved can be loaded, and only from main.

You will see recreated screen

claude — acme-platform
⏺ Counts match docs/imports/lims-approved.md for all 5 files. The three checks return no rows.1
⏺ 50 historical results re-evaluated: 49 agree with the old tool. 1 differs: a 2025 assay of 101.8 % is OOS against the migrated SPEC-P210 v3 (usl 101.5), but the old tool said in spec. The old printout of v3 says usl 102.0: the export rounded it. Fix the limit in the draft and re-sign.2
The rehearsal's evidence.
  1. Every number traced to the approved file.
  2. Exactly what this step is for: a limit that moved wrongly, found before any result depends on it.

Check it worked

The rehearsal ran through import-lims.yml with the approved copy; every specification in force is signed after a line-by-line check; the three checks return nothing; the re-evaluated history agrees with the old tool or every difference is explained and fixed; 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 re-evaluated result disagrees with the old tool

Do not change the result. Find the cause: a limit, a unit, a version date, a rounding rule. Fix the specification (a new draft if it was already signed) and re-evaluate.

An open sample has no specification in force at its collection date

Report it and decide with the approver; never pin a later version to make it fit.

Step 15

Session 6: Import into production through the workflow, and prove the counts

25 minutes

Why

Production gets the records the way the rehearsal proved: a person starts import-lims.yml from main, it reads an export whose fingerprint and counts owner two approved in a reviewed pull request, and it signs in as an insert-only account. Nobody runs SQL against the live database, no upload page exists in the app, and a count that differs stops the import with nothing kept.

Do this

Take the final export yourself from the old tool. Upload it to a private Storage bucket imports in production. Turn on lims_importer's login in production with a new password you make, keep it in the password manager, type it into the Actions secret LIMS_IMPORTER_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 lims/import-production, add a section "Production" to docs/imports/lims-approved.md: each file's name, sha256 and expected counts (read, to import, skipped, from the dry run I paste below), and the date taken. Open a pull request titled "LIMS: 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. The approver signs each specification in force after the same line-by-line check.

Open

https://github.com/acme-ops/acme-platform/actions/workflows/import-lims.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
Read-only, through the app as the approver on production: counts per table against docs/imports/lims-approved.md and the three checks; write the results into docs/cutover.md on a new branch lims/cutover. Do not change any data.

You will see recreated screen

github.com/acme-ops/acme-platform/actions/workflows/import-lims.yml
import-lims · target production · dry_run false
2
FileReadImportedSkipped
methods.csv41410
specs.csv63630
samples.csv31310
The production run: the approved file checked first, then the import with the same numbers.
  1. Same fingerprints and counts as the approved file, or the run stops.
  2. Read = imported + skipped, file by file.

Check it worked

The production run's summary matches docs/imports/lims-approved.md for every file; docs/cutover.md shows read = imported + skipped, the three checks returning nothing and every specification in force signed.

If it goes wrong

The run fails: counts differ from the approved file

Nothing was kept: the import runs in one transaction. Find why (a re-export, a filter in the old tool), 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/lims-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 running the import SQL straight against production

No. Records come only through import-lims.yml so every row has its imported_from mark, its audit entry and the importer's identity.

Step 16

Session 6: A week side by side, then cut over and cancel with the saving from invoices

60 minutes, after a week

Why

A week of the same samples through both systems, with the four numbers on the same definitions, is the evidence that the new way records what the old way did. Cancelling only after the cut-over works and the full export is stored, with the saving from real invoices, makes the figure one finance can sign.

Do this

For one week the same samples go through both systems; the old one stays the official record and the same people enter both. Then:

Paste into Claude Code, after replacing the last line
On branch lims/cutover, add to docs/cutover.md from numbers I give and read-only queries as the approver on production:
1. The four numbers for the week, old tool (with the report each came from) against platform, on the definitions in element M10 chapter 4; explain every difference.
2. Three samples of the week compared result by result: values, flags, specification version, reviewer and approver.
3. The three kept rules as queries with results: a superseded result is retrievable with reason and signer; for every result the stored flags equal lims_evaluate against the pinned version with its entered_at; custody complete for every sample of the week.
4. The cut-over date and rollback plan: who tells the laboratory and requesters, samples in flight on the day, when the old LIMS becomes read-only, where the export and its checksum are kept, the date after which a result entered only in the old tool is not accepted.
5. The saving: the old cost from the invoice I paste minus what the module costs on services we already pay for, arithmetic shown.
6. A migration that sets lims_importer NOLOGIN at cut-over; I will delete the LIMS_IMPORTER_PASSWORD secrets and note the date in docs/KEYS.md.
Mark each capability in docs/lims-inventory.md replaced, kept elsewhere or out of scope, with the date. Open "LIMS cut-over", wait for checks, report.

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

On the cut-over date, make the old LIMS read-only and put the request and bench screens where people looked for the old ones. Cancel on the vendor's own account page within its notice period, after the full export and its checksum are stored in the company's storage.

You will see recreated screen

github.com/acme-ops/acme-platform/pull/72/files
ConversationCommitsFiles changed
docs/cutover.md
1
NumberOld toolPlatformWhy different
Median turnaround26 h30 hOld counts working hours
Backlog44
OOS rate1 of 521 of 52
Right-first-timenot reported50 of 52Old tool cannot tell
SavingAnnual invoice line minus run cost, arithmetic shown2
The cut-over record on GitHub.
  1. Every difference has a cause written beside it.
  2. From invoices, never estimates.

Check it worked

docs/cutover.md is merged with the four numbers explained, three samples compared, the three kept rules, the cut-over date and rollback plan, lims_importer set NOLOGIN, and the cancellation (or end date) with the saving from invoices.

If it goes wrong

A difference cannot be explained

You are not ready. Keep both running, find the cause (a definition, a start time, a sample entered in one system only) and run another week if needed.

Your laboratory is accredited to ISO/IEC 17025

Keep this document, the Session 5 re-evaluation and the tests as the evidence that the system was checked before use, and ask your quality manager what your accreditation body expects.

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

Knowledge check

How is the migration of specifications validated?

Knowledge check

Five approved samples took 30, 24, 30, 36 and 48 hours. The median turnaround?

References

  1. ISPE: GAMP 5 Guide, 2nd Edition. https://ispe.org/publications/guidance-documents/gamp-5-guide-2nd-edition
  2. European Commission: EudraLex Volume 4, EU GMP guidelines (includes Annex 11, computerised systems). https://health.ec.europa.eu/medicinal-products/eudralex/eudralex-volume-4_en
  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 lims_importer account's password live?
2. Which of these does M10 leave to another module?
3. Where do real laboratory records go first?
4. Why is each sample pinned to one specification version when it is logged in?
5. SPEC-P100 version 1 allows an assay of 98.0 to 102.0 % and version 2 allows 98.5 to 101.5 %. A sample pinned to version 1 has a result of 98.2 %. What does its stored result say?
6. An analyst typed 91.9 for an assay; the raw-data file shows 99.1. How is it corrected?
7. Under a run-of-three rule, when is a result out of trend (OOT)?
8. Who may approve a result?
9. A result is flagged OOS. What should the Phase I investigation look for first?
10. What does a certificate of analysis for a lot show?
11. Five approved samples took 30, 24, 30, 36 and 48 hours from receipt to approval. What is the median turnaround?
12. How is a migration of specifications from the old LIMS validated?