---
title: "Packwright: Label compliance checker | James Littlefield"
description: "Packaging labels checked against regulation, with the rule cited for every finding."
canonical_url: "https://jameslittlefield.net/projects/packwright"
meta:
  "og:description": "Packaging labels checked against regulation, with the rule cited for every finding."
  "og:image": "https://jameslittlefield.net/_og/s/o_b7bc0b5c894761e8.png"
  "og:image:height": "630"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "Packwright: Label compliance checker | James Littlefield"
  "twitter:image": "https://jameslittlefield.net/_og/s/o_b7bc0b5c894761e8.png"
---

> Index of every page on this site: [llms.txt](https://jameslittlefield.net/llms.txt)

Label compliance checker

# Packwright

Packaging labels checked against regulation, with the rule cited for every finding.

- [Live demo view](https://packwright.jameslittlefield.net)
- Video watch
- [Code GitHub](https://github.com/musicteachj/packwright)

Packwright

![Packwright GHS chemical label editor. The compliance panel lists two warnings citing EU Regulation 1272/2008.](https://jameslittlefield.net/_ipx/f_png&s_1800x1125/images/projects/packwright-ghs-editor.png)

## 01Overview

A packaging label generator that checks labels against regulation (GS1 retail barcodes, GHS chemical hazard labels, and US FDA food labels) and cites the rule behind every finding. Claude reads photos of existing labels; a deterministic rule engine does the judging. It also runs an MCP server so AI assistants can check labels directly, using the same rules.

## 02Key features

- Label editor with a live preview that matches the exported PDF exactly
- 36 rules across GS1, GHS, and US food labeling, each finding linked to its regulation
- Click a finding to highlight the part of the label it refers to
- Photo audit: Claude vision reads an existing chemical label into typed fields; a person confirms each one
- Public MCP server at `/mcp` with 4 read-only tools ( `check_label`, `list_rules`, `ghs_statement_text`, `check_gtin`)

## 03How the AI works

"The LLM reads. The rule engine judges." No verdict or citation comes from a model.

- Claude Opus 5.5 reads a label photo into a Zod-validated schema with a confidence score per field.
- Hazard codes are checked against verified tables, and a person confirms each field.
- Only then do the deterministic rules run.
- The MCP tools let assistants like Claude check labels with the same rules.

## 04Tech stack

<dl>

<dt>AI</dt>
<dd>Claude Opus 5.5 (vision, structured output), Anthropic SDK, MCP TypeScript SDK</dd>

<dt>Frontend</dt>
<dd>Vue 3, TypeScript, Vite, Pinia, Tailwind CSS v4</dd>

<dt>Backend</dt>
<dd>Node.js, Express 5, Zod 4, PDFKit, bwip-js (barcodes)</dd>

<dt>Data</dt>
<dd>MongoDB Atlas, Mongoose</dd>

<dt>Infra</dt>
<dd>Docker, AWS ECS on EC2, GitHub Actions, Vitest, Playwright</dd></dl>

## 05Architecture

Label editor

1. **Label form**
2. **Layout engine**Shared core package
3. **SVG preview and PDF export**Both from the same layout
4. **36 rules**Run on the resolved geometry
5. **Findings**Each with its citation

Photo audit

1. **Upload**
2. **Rate limits**
3. **Claude vision**Typed fields with confidence
4. **Schema validation**Zod
5. **Person confirms**Then the same rules run

## 06Results and evals

| Measure | Without tools | With tools |
| --- | --- | --- |
| Sonnet: defects caught, of 30 | 27 | 30 |
| Sonnet: false clearances | 2 | 0 |
| Sonnet: answers with a wrong citation, of 36 | 33 | 20 |
| Haiku: defects caught, of 30 | 5 | 21 |
| Haiku: answers with a wrong citation, of 36 | 36 | 7 |

12 labels with planted defects, 144 conversations, $5.28. Later fixes brought Haiku with tools to 35 of 36. A photo read takes about 5 s and costs at most $0.11. 3,054 unit and 95 browser tests.

## 07Decisions and lessons

- **Guardrail in the schema.** Moving a guardrail from the prompt into the tool schema removed false clearances the prompt fix couldn't.
- **Judging its own drawing.** The engine once assumed a default label size. It now declines checks on values nobody stated.
- **Withhold the pass.** A pass is withheld when a figure can't be verified.
- **Security fix.** A worst-case check went from 308 s to under 1 s.

## 08Screenshots

Packwright

![Packwright GS1 retail label editor with a barcode preview and every compliance check passed.](https://jameslittlefield.net/_ipx/f_png&s_1800x1126/images/projects/packwright-gs1-editor.png)

*GS1 editor: barcode preview with dimensions; all 6 checks pass.*

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://jameslittlefield.net/#website","@type":"WebSite","name":"James Littlefield","url":"https://jameslittlefield.net/","publisher":{"@id":"https://jameslittlefield.net/#identity"}},{"@id":"https://jameslittlefield.net/projects/packwright#webpage","@type":"WebPage","description":"Packaging labels checked against regulation, with the rule cited for every finding.","name":"Packwright: Label compliance checker","url":"https://jameslittlefield.net/projects/packwright","breadcrumb":{"@id":"https://jameslittlefield.net/projects/packwright#breadcrumb"},"isPartOf":{"@id":"https://jameslittlefield.net/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://jameslittlefield.net/projects/packwright"]}]},{"@id":"https://jameslittlefield.net/#identity","@type":"Person","jobTitle":"AI Engineer","name":"James Littlefield","url":"https://jameslittlefield.net/","image":{"@id":"https://jameslittlefield.net/#/schema/image/1"},"sameAs":["https://github.com/musicteachj","https://www.linkedin.com/in/james-littlefield-93037713b/"]},{"@id":"https://jameslittlefield.net/projects/packwright#creativework","@type":"CreativeWork","description":"Packaging labels checked against regulation, with the rule cited for every finding.","name":"Packwright","url":"https://jameslittlefield.net/projects/packwright","author":{"@id":"https://jameslittlefield.net/#identity"},"image":{"@id":"https://jameslittlefield.net/#/schema/image/2"}},{"@id":"https://jameslittlefield.net/projects/packwright#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"James Littlefield","item":"https://jameslittlefield.net/","position":1},{"@type":"ListItem","name":"Packwright","item":"https://jameslittlefield.net/projects/packwright","position":2}]},{"@id":"https://jameslittlefield.net/#/schema/image/1","@type":"ImageObject","contentUrl":"https://jameslittlefield.net/images/james.jpg","inLanguage":"en","url":"https://jameslittlefield.net/images/james.jpg"},{"@id":"https://jameslittlefield.net/#/schema/image/2","@type":"ImageObject","contentUrl":"https://jameslittlefield.net/images/projects/packwright-ghs-editor.png","inLanguage":"en","url":"https://jameslittlefield.net/images/projects/packwright-ghs-editor.png"}]}
```