Zod

TypeScript-first schema validation.

Goals

Validate the raw JSON output from axe agents (specifically inertia-decomposer) at the boundary between the LLM and the domain logic — catching malformed or non-compliant responses before they can corrupt task data.

Effectiveness

Excellent. Zod is exactly the right tool for this boundary. The schema is expressive enough to describe what the LLM should produce, coercive enough to handle what it actually produces, and integrates cleanly with TypeScript's type system so validated data flows through the rest of the code as typed values.

What made it effective

Bonus utility

The ZodError thrown on schema violations is structured enough to log the specific field that failed — useful for diagnosing which LLM output pattern is non-compliant.

Friction / pain points / surprises

None significant. Zod does exactly what it claims.