Skip to main content

Contracts are JS — Day 1 with sidecar *.nudo.js

· 2 min read
Nudo Contributors
Nudo maintainers

Launch series (2/5) — published together on 2026-09-21. Read in order: Day 0 — observe JavaScript without rewriting it · *Contracts are JS — Day 1 with sidecar .nudo.js · Nudo vs TypeScript — when a JS-first gate is the right tool · Nudo for coding agents — agents.md, agent integration, stable diagnostics · The 22-file smear: how call-site attribution almost shipped fake precision

Nudo’s contract product is not a second type language. Contracts are ordinary JavaScript modules: sidecar *.nudo.js files that auto-bind to same-name exports, or in-source @nudo:contract.

// pricing.nudo.js
import { number, fn } from "@nudojs/core";

export const lineTotal = fn(
{ price: number().gt(0), qty: number().ge(1) },
number().gt(0)
);
npx nudojs check pricing.js
issues
[error] lineTotal: actual ⊭ expected (nudo:constraint-violated)
actual: 0 #exact
expected: price > 0

Product rules​

RuleMeaning
Contract surface*.nudo.js / @nudo:contract (@nudo:contract is an alias)
@nudo:caseDebug witnesses only — never the contract product
Draftsnudo contract --draft is reviewable; never auto-bound
check vs exportcheck validates Abs; export projects lossy dts/zod/guards
any vs unknownEntry any = unconstrained; unknown = inference failed

Logic-first teams draft from call sites; contracts-first teams write the sidecar up front. Both meet on the same Abs face.

Next: contract guide · diagnostics · recipes.