ESLint for TypeScript and Zod drift. Catch contract drift before it reaches runtime.
Built for teams that already have TS types and Zod schemas and want CI to fail when they drift.
import { z } from "zod";
export interface User {
name: string;
email?: string;
age: number;
}
export const UserSchema = z.object({
name: z.string(),
email: z.string(),
age: z.string(),
role: z.string(),
});npx zodrift checkFails CI on drift (exit 1), passes when synced (exit 0).
Example output:
✗ User ↔ UserSchema
- optional mismatch for email: type=optional, schema=required
- type mismatch for age: type=number, schema=string
- extra in schema: role
What it catches:
- missing fields
- extra fields
- required vs optional mismatch
- basic type mismatch
- semantic mismatch when your TS type is not assignable to
z.input<typeof Schema>/z.output<typeof Schema>(optional mode)
Already supported:
- nested object checks
- arrays and tuples
- union checks
- JSON output and SARIF output
CI quick start:
- run: npx zodrift check --pattern "src/**/*.{ts,tsx}" --semantics bothExit codes:
0: no drift1: drift found2: parser/runtime error
Useful commands:
# Check current project
npx zodrift check --pattern "src/**/*.{ts,tsx}"
# Add semantic compatibility checks for z.input/z.output
npx zodrift check --pattern "src/**/*.{ts,tsx}" --semantics both
# Machine-readable report for CI artifacts
npx zodrift check --format json --out reports/zodrift.json
# SARIF for GitHub code scanning
npx zodrift check --format sarif --out reports/zodrift.sarif
# Safe autofix pass (dry-run first)
npx zodrift fix --pattern "src/**/*.ts" --dry-runRoadmap:
- deeper semantic coverage for Zod effects/refine/transform chains
- strict bidirectional semantic mode
- official GitHub Action wrapper with SARIF upload
- config file support (
.zodrift.json) - JUnit/Checkstyle reporters for enterprise CI
