Skip to content
Back to skills

Zod

ASecurity

Load this skill first when writing, reviewing or testing Zod schemas or their JSON Schema output in this repo: it maps each Zod source to its generated files and lists the Zod 4 behaviors that break schemas and tests.

  • 971 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added December 1, 2026
ai-agentsgonodetestinggitapi

Works with

  • cli
  • api
  • mcp

Security analysis

A100/100

Pro scans all 3 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add bgauryy/octocode --skill zod --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Zod?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Zod
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/bgauryy-zod/badge)](https://www.skillsdirectory.com/skills/bgauryy-zod)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: zod
description: "Load this skill first when writing, reviewing or testing Zod schemas or their JSON Schema output in this repo: it maps each Zod source to its generated files and lists the Zod 4 behaviors that break schemas and tests."
license: MIT
metadata:
  author: Anivar Aravind
  author_url: https://anivar.net
  source: https://github.com/anivar/zod-skill/tree/bb0620d
---

# Zod in Octocode

Every workspace resolves one Zod 4 (`rg -n '^"zod@' -A1 yarn.lock`; 4.6.7 when written). Settle an API question in `node_modules/zod/v4/classic/schemas.d.ts` (it marks deprecations) or a short `node` probe, not from memory.

## Sources and outputs

Edit the Zod source and run its generator (`$DEV` as [AGENTS.md](../../AGENTS.md#work-locally) defines it); never edit the output.

| Zod source | Output | Regenerate |
|---|---|---|
| Tool schemas in core (`../octocode-mcp-host/packages/octocode-core`) | `packages/octocode-config/contract/` | `$DEV contracts:regen` ([pipeline](../octocode-dev/docs/DEVELOPMENT.md#contract-pipeline)) |
| `packages/octocode-config/scripts/config-contract/` (`schema.ts` validates `declaration/`) | `config-contract.json` and `.schema.json`, `src/config/contract.generated.ts` (package root), `<repo>/docs/CONFIGURATION.md` | `yarn workspace @octocodeai/config generate:config-contract` ([adding config](../octocode-dev/docs/ADDING_CONFIG.md)) |
| `packages/octocode-agents-communication/src/catalog/` | `<pkg>/assets/catalog.json`, `src/runtime/catalog-types.generated.ts` | `yarn workspace @octocodeai/octocode-agents-communication types` |
| `packages/octocode-browser-tools/src/contract/` | `<pkg>/dist/contract.js`, `<pkg>/dist/engine/chrome-contract.mjs`, `<pkg>/dist/runtime.js` | `yarn workspace @octocodeai/octocode-browser-tools build` |
| `packages/mcp-to-cli`: `defineCommand({ schema })` | CLI flags and help, MCP `inputSchema` | none: built at run time |

- agents-communication: Zod is a devDependency; nothing in `src/runtime`, `src/entries` or `src/hosts` may import it (`tests/catalog-source.test.ts`). A shared shape goes through `define()` in `catalog/registry.ts` (one `$defs` entry, `$ref` at each use); keywords Zod cannot state ride in `.meta()`; `catalog/json-schema.ts` maps Zod's output to the dialect `src/runtime/validation.ts` enforces.
- mcp-to-cli: flags come from `z.toJSONSchema(schema, { io: 'input', unrepresentable: 'any' })`. MCP SDK v2 takes the Zod schema itself as a Standard Schema; a JSON Schema tool is wrapped by `jsonSchemaStandard`.

## Zod 4 behaviors

Before writing a schema, reading its JSON Schema output or asserting on its errors, check [Zod 4 behaviors](references/zod4-behaviors.md): `toJSONSchema` modes, `.default` versus `.prefault`, object modes, records, errors, coercion and the preferred APIs.

## Tests

- Generated files are tested against their sources (`config-contract-generation.test.ts`, `tool-contract-current.test.ts`, `catalog-source.test.ts`): regenerate, never edit the expected file.
- Assert `success === false` before reading issues: an `if (!result.success)` block alone passes once the schema accepts the input. Match issue `code` and `path`, not message text.
- Vary one field per rejection case from a valid base; cover missing versus `undefined` versus `null`, both sides of each bound, and the transformed output.
- A JSON Schema snapshot misses refinements and transforms, and fixtures generated from the schema share its mistakes: keep hand-written cases.
- After a JSON Schema change, run its consumer too: CLI help and flags (`commandHelp`), MCP `tools/list`, or the catalog validator.

## Done

Stop when the source is edited, its generator has run, the generated-file test passes and the consumer shows the change. Return the result first, then the source and generated files changed, the generator and tests run with results, and any consumer left unchecked.

Files in this skill

  • LICENSE1 KB
  • SKILL.md3.8 KB
  • references/zod4-behaviors.md2.2 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.