All projects

Porter

Legacy CMS to Contentful: code converts the text, Claude proposes mappings and links, people approve. Evals included.

LLMRAGAgentsEvalsNext.jspgvectorOpen live Source
Preview of Porter

CI

Moves a legacy CMS export into Contentful. Code converts the text; Claude does the parts that need judgement; a person approves before anything is written.

Live demo: porter.vitaliipopov.dev. Walk the stages in order: Map → Link → Migrate → Evals. The public demo replays recorded model answers, so it costs nothing and behaves the same every time; the database (Neon) is real and shared, and each stage has a Reset.

Sample data is a fictional travel magazine's WordPress export (samples/). No real site or space is contacted unless you configure one.

At a glance

What A WordPress → Contentful migration where code converts the text and Claude only makes judgement calls. A learning project I built on my own, not client work.
Try it Live demo, no sign-up and no API keys: it replays recorded model answers. Locally: npm install && npm run dev.
Retrieval Hybrid search (Voyage embeddings in pgvector + Postgres full-text, Reciprocal Rank Fusion): 98% correct, 96% retrieval recall on 53 hand-labelled cases.
Agent Hand-written tool loop, 6 tools, max 10 turns and $0.40 per post, every tool input validated; anything uncertain goes to a human review queue. Recorded run: 9 posts, 3–4 turns each, about $0.013 per post.
Evals Linking and agent evals run in CI on recorded answers and fail the build below set floors; a separate Haiku judge scores the free text, checked against known-bad inputs.
Guardrails The model never writes article text; a word-level diff proves each body survived. Model-written fields are checked for names and numbers the source doesn't contain.
Honest limits Small eval sets (n=53 and 19), so metrics sit near their ceiling with wide intervals; the judge's agreement with human labels is still being measured.

Why the conversion isn't an agent: turning HTML into rich text has a right answer, so it's a deterministic workflow that can be proved word for word. The agent only gets the open-ended part (summaries, region, review notes), where judgement is the job.

Why it exists

I work with Contentful (the newsroom rich-text editor at Paris Match, Contentful Certified Professional) and I ship features with a coding agent every day. Porter is where I build the LLM side properly, in public: structured output, retrieval, a tool-using agent and evals, on a problem I know well.

It is not a rebuild of client work. Migrations like this one are a common Contentful job; the code and data here are written from scratch.

The rule that shapes everything

The model never writes article text. Bodies go through a deterministic HTML → Rich Text transform, and a separate check proves the migrated body has the same words, in the same order, as the old page. The model is used only where rules run out:

Stage What happens Who decides Status
01 Convert HTML → Contentful Rich Text, word-for-word check code built
02 Map Source fields → target fields, with transforms Claude proposes (structured output), you approve built
03 Link Authors and topics matched to entries that already exist retrieval (embeddings + keyword), Claude decides close calls built
04 Migrate An agent assembles each entry with tools, validates, retries agent, then a human review queue built
05 Measure Golden set, scorers, report per prompt version evals in CI on recorded responses built

Stage 01: convert

src/core is framework-free and fully tested:

Every sample post converts to a valid document with every word accounted for. That is a test, not a claim (src/core/core.test.ts).

Stage 02: map

Claude proposes which source field fills each target field, and how. It sees real sample values and every rule of the target type. A person reviews, edits and approves; code applies.

First live run (Claude Opus 5.5, prompt map-v1): 10/10 fields mapped with no errors from the checks, five questions for the editor, 4,030 in / 1,591 out tokens, $0.05, 17.6 s.

Stage 03: link (retrieval-augmented)

The new space already has 16 authors and 36 topics, some of them deliberate near-misses: Tom Brennan (former mountain guide) and Tomas Brenner (restaurant critic). Each WordPress author and term has to land on the right one, become a new entry, or be skipped.

  1. Index. Every existing entry is embedded (Voyage AI voyage-3.5-lite, 512 dimensions, called with fetch) and stored in Postgres with pgvector (HNSW index) next to a full-text column (GIN index, English stemming). The same schema runs on Neon and on PGlite.
  2. Hybrid retrieval. Each source item is searched two ways: nearest neighbours by cosine similarity, and full-text matches. The rankings are combined with Reciprocal Rank Fusion, which uses ranks rather than scores, so the two never need calibrating against each other.
  3. Rules first. Code settles the same name once accents and punctuation are ignored (Ana Lucia Ortega = Ana-Lucía Ortega), and WordPress's default category.
  4. Claude decides the rest, one call per content type. It may only choose an entry retrieved for that item (an enum in the output schema), and it must quote its evidence.
  5. Code checks every decision. The entry must have been retrieved for this item, the quote must exist in the source or the chosen entry, and tags never create topics. A flagged item blocks approval until a person decides it. A reviewer can pick any entry, which fixes retrieval misses; Claude can't.

Recorded run: 21 items, 3 settled by rules, 18 by Claude in 2 calls, no decision flagged by the checks.

One honest miss: Northbound Staff has no bio, and retrieval never surfaces Editorial Desk, so Claude proposes a new author. That is the reviewer's override in the demo, and the kind of case the evals in stage 05 count.

Without keys, the local hashing embedder stands in. It is fine for spelling variants and blind to meaning; the UI says which embedder built the index, and vectors from two embedders are never compared.

Stage 04: migrate (an agent with tools)

For each post an agent reads the source, fills the draft from the approved mapping and links, writes the fields left to it, checks the draft and submits it to a review queue, or flags it for a person.

Recorded run: all 9 posts submitted in 3–4 turns each, about $0.12 in total, no write rejected. The agent's notes to reviewers are the best part:

The first recording run found three bugs in my code, not in the model. The agent flagged four posts instead of guessing, and each flag pointed at a real defect:

Each one has a regression test.

Stage 05: measure (evals)

Two evals, one per flow, run through the app's real entry points (proposeLinks, runAgent) on cases with hand-written gold answers (samples/evals/). They are never copied from model output, because then the eval would only reward imitation. Ambiguous cases accept several answers.

Results (recorded run):

Eval Result
Linking 98% correct (±4, n=53), retrieval recall 96%. The one miss is Northbound Staff, and the eval attributes it to retrieval.
Agent 19/19 submitted; rules, grounding and region 100%; the judge passes all 14 written fields.

Live cost of a full run: about $0.17 for linking, $0.15 for the agent and under $0.01 for the judge.

Two findings were bugs in the eval itself:

Honest limit. Every metric is at or near its ceiling, with ±4 to ±23 points of noise at these sizes. The evals guard against regressions; showing that a new prompt is better would need harder cases.

Run it

npm install
npm run dev     # http://localhost:3000
npm test
npm run eval -- linking   # replays the recorded eval, no keys needed

No configuration needed: embedded Postgres (PGlite) and recorded model answers. To call Claude and Voyage live, put ANTHROPIC_API_KEY and VOYAGE_API_KEY in .env (see .env.example); add PORTER_RECORD=true to save new answers and vectors for replay.

Stack

Next.js 15 (App Router), TypeScript strict, Zod, Anthropic SDK (structured output), Drizzle on Postgres (Neon / PGlite) with pgvector, Voyage AI embeddings, htmlparser2, @contentful/rich-text-types, Vitest + Testing Library.

Design

A shipping manifest. The fonts are Big Shoulders Stencil (crate stencils), Martian Mono for ids and data, and Instrument Sans for reading. The palette is kraft paper, ultramarine stamp ink and hazard-label yellow. Statuses are rubber stamps. Light and dark themes; respects reduced motion.