Skip to content

Harness engineering for Next.js: the scaffolding that lets AI build your app

Malik Chohra

Malik Chohra

Mobile and web engineer in Berlin, 9 years shipping production apps, writes Code Meet AI.

· 5 min readGuidesProduct
Harness engineering for Next.js: the scaffolding that lets AI build your app

Agents don't fail your Next.js project because the model is weak. They fail because nothing around the model knows your conventions. That scaffolding is the harness, and it's the real work.

You ask the agent for a feature. It builds the route under the wrong convention, invents a data-fetching pattern you abandoned, and wires an env var that does not exist in your setup. The model is not the problem. It opened the session knowing nothing about your app, so it guessed, and its guesses look just plausible enough to merge. The fix is not a better prompt. It is structure around the model that it can build against. That structure is a harness.

Harness engineering is the term forming around this. Here is what it means for a Next.js codebase, and why it decides whether an agent can actually build on your project or just demo on it.

Prompt, then context, then the wall

The first fix everyone tries is the prompt. Better wording, a cleverer system message. It works until you ask about your own app, because a clean prompt answers a generic question well, and your questions are about your routing, your types, your conventions.

So you assemble context by hand: paste the file, paste the rules, paste yesterday's decision. The answers get better, then you hit the wall, and the wall is you, rebuilding the same context every morning while it evaporates at the end of each session.

Prompt to context to harness, each layer wrapping the one before it

A harness is what makes a codebase AI-buildable

A harness is everything around the model that lets it work in your real project: conventions, memory, standards, access. The model is swappable. The harness is the part that makes an agent build *your* Next.js app correctly, and it has roughly five pieces: a standing file about the project, the rules always in context, small memory facts read before acting, real repo and tooling access, and delegation for the heavy grunt work. Skills and scheduled jobs ride on top.

This is most of what "AI-buildable" actually means. A one-shot prompt can produce a demo. A codebase an agent can keep extending without drifting needs the scaffold underneath.

How it looks on a Next.js project

Start with an AGENTS.md at the root that pins the things the agent keeps getting wrong: app-router conventions, where server actions live, the data-fetching pattern, the typed API shape, the protected paths. Add a few memory facts, one per line: "routes return typed responses", "env access goes through lib/env.ts", "tests run with the harness in test/."

Now the agent builds on the route it should, in the pattern you actually use, because the convention is read instead of guessed. That is the difference between an agent that scaffolds your project and one that quietly forks it. I wrote more on this idea in the workflow is the product and building a site with Claude Code.

The harness rots, and maintaining it is the job

The hype skips this part. A harness is not a one-time build. Memory goes stale, conventions change, and a stale fact is worse than none because the agent trusts it and builds on it. Untended scaffolding fills with confident lies about your own app. Prune it on a schedule. Owning a harness does nothing; maintaining it is the whole return. It is also why vibe coding stops scaling past v1: no harness, no structure to hold the next hundred changes.

You don't have to build the scaffold from scratch

The foundation, the conventions, the typed routes, the test setup, the rules an agent reads first, is the same on most Next.js apps. Rebuilding it each time is the slow part.

That is what AI Web Launcher ships: a Next.js 15 boilerplate built so agents can build on it, with the harness already wired, conventions in an AGENTS.md, types and structure the agent reads on the first run. You bring the product. The scaffold is there.

Starting from zero needs no course. One standing file, a few memory facts, and the discipline to add a line every time you explain the same thing twice. That is a harness. Everything past it is refinement.

*First published on Code Meet AI.*