ts-npm-zod-starter
$
npx mdskill add kongyo2/agent-primary-ts-starters/ts-npm-zod-starterInstall zod for runtime validation in TypeScript npm projects.
- Enforces boundary-only parsing to prevent double validation.
- Uses npm add zod to manage dependencies correctly.
- Generates schema files with inferred types and parse wrappers.
- Applies the Boundary Parsing Policy automatically.
SKILL.md
.github/skills/ts-npm-zod-starterView on GitHub ↗
--- name: ts-npm-zod-starter description: Add zod to a TypeScript npm project and install the boundary-only parsing convention. Use when starting a new TS project that needs runtime schema validation, or when layering zod onto an existing TS npm project — even if the user doesn't explicitly say "zod" or "validation". --- # TS + npm Zod Starter Use this when adding zod to a TypeScript npm project. In a monorepo, edit the workspace the user names — ask if it isn't named. ## Expected Outcome - `zod` is in `dependencies` of the target `package.json`. - The Boundary Parsing Policy below is the documented convention for the project's zod usage. ## Installation ```bash npm add zod ``` zod ships runtime code, so it belongs in `dependencies` (not `devDependencies`). When zod is already declared, keep its current version unless the user asks for a change. ## Boundary Parsing Policy - Parse untrusted input at the boundary with `z.parse` / `z.safeParse`. Downstream code takes the parsed value as trusted and does not re-parse. - `z.infer<typeof Schema>` is the single source of truth for the static type — let it stand alone instead of declaring a parallel `interface` or `type` alias. Why: parsing at every layer doubles the work and obscures where the trust boundary actually is. ## Schemas Directory When the project has a concrete shape worth validating, add its schema under `src/schemas/<name>.ts`, exporting the schema, its `z.infer` type, and a `parse(raw: unknown)` wrapper used at the boundary. When `src/schemas/` already exists, defer to the project's existing convention. ## Verification - `npx tsc --noEmit` passes. - `zod` appears under `dependencies` in `package.json`. ## References - zod docs: <https://zod.dev/>
More from kongyo2/agent-primary-ts-starters
- ts-npm-oxlint-starterAdd Oxlint to a TypeScript npm project with agent-friendly defaults that focus error-level diagnostics on real bugs, silence stylistic noise, and emit output in oxlint's `agent` format for downstream LLM consumption. Use when bootstrapping a new TS project that needs linting, or when adding Oxlint to an existing TS npm project — even if the user doesn't explicitly say "oxlint" or "linter".
- ts-npm-prettier-starterAdd Prettier to a TypeScript npm project with agent-friendly defaults that minimize diff size and keep line numbers stable across LLM-driven edits. Use when bootstrapping a new TS project that needs auto-formatting, or when adding Prettier to an existing TS npm project — even if the user doesn't explicitly say "prettier" or "formatter".
- ts-tsconfig-modern-strict-starterSet up a TypeScript tsconfig.json with modern (ESNext + bundler/nodenext) and maximally strict settings, tuned so that `tsc --noEmit` becomes a fast, reliable inner feedback loop for the LLM agent doing the editing. Use whenever a tsconfig.json is being created, edited, reviewed, troubleshot, or even just discussed — apply the standing policy even when the user only asks about a single option. Default to this skill instead of free-recall whenever the answer involves a tsconfig field.