HNZ Rad Tools · Workshop, 13 and 14 October 2026
Building Community Triage
How the national referral criteria PDF became a working triage app for PCRLs and GPs in two days, built in conversation with Claude Code.
Use ← → or the bar above to move between slides.
Starting point
What was already in place
Community Triage is the sixth app on an existing platform. Two days was possible because none of this had to be built first.
Claude Code, set up for this repo
Project rules in CLAUDE.md, a memory of earlier decisions, and skills. Opus plans and reviews while Sonnet sub-agents build.
CLAUDE.md · memory · skills
GitHub and automatic deploys
A push to develop sends the app to beta and applies its database migrations. Production is promoted separately, per app.
GitHub Actions · develop · *-prod
Cloudflare, reachable by Claude
The Cloudflare MCP servers and wrangler let Claude create databases, sites, domains and secrets from the terminal.
MCP · wrangler · hnzradtools.nz
HNZ identity hub
One sign-in, with roles, across every HNZ Rad Tools app. A new app is a registration, not a new login system.
id.hnzradtools.nz
HNZ branding and style guide
Palette, Poppins and Open Sans, and layout rules written down once, so new screens match the other tools with no design work.
docs/hnz-design-system.md
The hospital triage tool
A working pattern to copy: browse the guidance, assess a referral with AI, review screens, shared code packages.
apps/triage
Prompt 1 of 85 · 22:43, 13 October
The first prompt
Typed as plain language, typos included. No code and no specification: an input, the users, three goals in order, and a request to research and plan before building.
Claude came back with a plan and four questions
- Separate app or part of triage?"separate"
- Can we get real referrals with PCRL decisions on them?"we will be able to"
- Who uses the AI assessment, PCRLs only or GPs too?"PCRLs initially then open to GPs as a pre-referral check tool"
- Has Health NZ asked for the headless API?"proposal (but it will be)"
The core input
From PDF to database
The criteria are 105 pages of Word tables. Pick a step to see what went in, what happened and what came out.
In
National Community Referral Criteria for Imaging, Part I, version 2.0. 105 pages, one four-column table per exam.
What happened
A Python script (PyMuPDF) pulled out the text layer, every hyperlink, the PDF's tagged table structure, and a picture of every page at 160 dpi.
Out
pages.json, links.json, structure.json and 105 page images.
scripts/extract_pdf_pages.py
In
The page images and the text layer, plus a written rules file any agent could follow.
What happened
The text layer gets the words right but scrambles structure, so agents read the page images for which tier a bullet belongs to and copied wording from the text. Opus ran a pilot; Sonnet agents then did the exam groups in parallel.
Out
Structured exams: tiers, criteria, nested items, footnotes, guidance boxes and sources.
docs/criteria-extraction.md
In
The agents' output, with ids assigned by a script.
What happened
A clinician checked the pilot exams one to one against the PDF before the rest were extracted. Unclear spots were marked with review notes rather than guessed.
Out
38 exam files, 935 items including footnotes and guidance, 111 flagged where a named clinician's advice is needed. Appendix 1 was an image and was transcribed separately.
data/criteria/v2.0/exams/*.json
In
The JSON and the scanned source files.
What happened
Code compared every word against the PDF text layer and checked ids, links and item counts against the PDF's own tags.
Out
0 failures and 25 warnings, each one explained. An HTML preview for clinical review.
scripts/validate-criteria.ts
In
The checked JSON, kept in git as the source.
What happened
A script generated SQL migrations: one for the schema, one to load version 2.0. They ship through the normal deploy, so beta and production get the same data. A fix to the criteria ships as a new migration.
Out
Queryable criteria in Cloudflare D1 with full-text search, the same way the hospital triage tool keeps its scenarios.
worker/migrations/0001, 0002
The one rule: the dataset is an exact copy of a national clinical document. Text is copied verbatim, including the source's own typos. Nothing is paraphrased, summarised, corrected or merged.
Infrastructure
Cloudflare: what Claude set up
Created from the terminal through the Cloudflare MCP servers and wrangler in the first hour. Every deploy after that went through GitHub.
Set up by Claude
- Two D1 databases, production and preview, in Oceania
- A Pages project for the screens
- A Worker for the API, in production and preview
- Four custom domains on hnzradtools.nz
- A Turnstile bot check for the public GP page
- A rate limit of 5 checks a minute per connection
- Secrets: Anthropic key, hub signing key, Turnstile key
- Registration in the identity hub as a new app
- Workers Logs on every request
- A deploy workflow that applies migrations first
Sequence
The build, step by step
Each step ended with a commit, a deploy to beta and an updated plan page. Open any step on the timeline to read the prompts behind it.
Inside the app
How a referral check works
One step is the AI model. Everything around it is ordinary code that can be tested. Select a step to see what it does.
Two days of prompts
Where the iteration happened
Every prompt typed into Claude Code, by what it was about. Hover a marker to read it, or click to open it below. Drag to pan; pinch, or scroll with Ctrl or ⌘, to zoom.
prompts, up to 08:52 on day two, were about the interface. They went on the plan, Cloudflare and getting the criteria exactly right.
prompts, from 12:30 on day two, were interface and workflow changes: short, specific corrections to what GPs and PCRLs see.
Measured from the session logs
What it took
The build ran on a Claude subscription. These are the costs the same work would have run up on the Anthropic API.
| Who did the work | Model | Calls | Tokens | Est. cost |
|---|---|---|---|---|
| Main session: research, design, specs, review | Opus 5.5 | 698 | 225 M | US$74 |
| Sub-agents: building and criteria extraction | Sonnet 5.5 | 485 | 90 M | US$30 |
| Sub-agents: reading the existing code | Opus 5.5 | 48 | 4 M | US$2 |
| Total | 1,231 | 318 M | US$106 |
To take away
What made two days possible
A clinician made the decisions
Most of the 85 prompts were decisions or corrections: what goes in the database, who signs in, what a GP sees, what is never stored.
The data came first
The plan, Cloudflare and exact criteria came before any screen. Once the data was right, screens took minutes to change.
Code checks the AI
The model cites criteria and quotes the referral. Code confirms both and works out the priority itself.
The platform was already built
Claude Code set up for the repo, GitHub deploys, the Cloudflare MCPs, the identity hub and the HNZ style guide.
Next: test against real referrals with PCRL decisions, then production
Community Triage build · 13 and 14 October 2026 · times are NZ time