원클릭으로
stack-l3-zod
Zod v4 TypeScript-first schema validation — complete API, patterns, and v3→v4 migration
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Zod v4 TypeScript-first schema validation — complete API, patterns, and v3→v4 migration
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Use when detecting and guardrailing against premature completion claims — verifying that subagent "done" assertions are backed by fresh runtime evidence, enforcing dual-signal completion protocol (doer + verifier must agree), and catching hollow "it works" claims that skip verification. Triggers on: "verify completion", "completion detection", "dual-signal", "premature completion", "evidence before claims", "hollow done", "fake done", "completion guardrail", "verify before complete", "block completion until verified", "done but not verified", "did it actually work", "completion verification", "dual-signal completion", "two-agent completion", "fresh evidence requirement". NOT for loop mechanics (iterative-loop), delegation patterns (subagent-delegation-patterns), or quality gate triad orchestration (quality-gate-orchestration).
Use when making cross-cutting changes, cross-pane modifications, framework migrations, or breaking changes that span multiple layers or frameworks (GSD, BMAD, Hivemind, or other). Triggers on: "cross-cutting change", "cross-pane change", "multi-layer change", "framework migration", "breaking change across frameworks", "change impact analysis", "cross-framework change", "multi-pane impact", "test-first change ordering", "dependency ordering across layers", "consumer impact tracing", "interface-first change", "ordered change management". NOT for single-layer changes, single-framework refactors, or cosmetic edits. Framework-agnostic — works across GSD, BMAD, Hivemind, or any project governance framework.
Evaluates whether implementation evidence is sufficient to pass quality gates. Enforces an evidence hierarchy from live runtime proof (L1) down to documentation summaries (L5), and refuses gate passage when evidence is missing, mocked where integration is claimed, or insufficient for the gate type. Use during code review gates, phase audits, milestone verification, integration checks, and deployment readiness. Activates after gate-spec-compliance clears spec alignment — this is the terminal gate in the triad (lifecycle → spec → evidence). Triggers: "evidence check", "gate evidence", "verify runtime proof", "evidence truth", "is there proof this works", "evidence hierarchy", "gate truth", "runtime evidence", "integration evidence", "mock-only detection", "completion honesty", "gate passed", "gate failed". Terminal skill in the quality gate triad — if evidence PASSES, all 3 gates clear.
Internal quality gate that evaluates whether Hivemind harness implementations correctly participate in the runtime lifecycle — covering 9-surface mutation authority, CQRS boundaries, actor hierarchy, event-driven wiring, classification fit (src/ vs .opencode/ vs .hivemind/), and OpenCode SDK surface compliance. Synthesized from .planning/codebase/ARCHITECTURE.md (9-surface authority table) and ingested @opencode-ai/plugin SDK v1.14.44 from anomalyco/opencode (tool(), hook() signatures). Use when performing a lifecycle gate check, auditing harness module integration, verifying CQRS boundary compliance, checking delegation hierarchy constraints, evaluating tool/hook registration correctness, running a harness quality gate, validating plugin composition integrity, or running phase audit on src/ modules. Activates during code review of src/ files, phase audit, milestone verification, integration check, and deployment readiness workflows.
Spec compliance gate performing bidirectional traceability, gap detection (4 types), EARS acceptance criteria validation, and anti-pattern scanning. Use during code review gates, phase audits, milestone verification, and deployment readiness. Middle gate in the quality triad (lifecycle → spec → evidence). Routes to gate-evidence-truth on PASS; STOPS with gap report on FAIL. Includes remediation routing to hm-spec-driven-authoring, hm-test-driven-execution, and hm-debug for fix workflows. Triggers on: "spec compliance", "verify against spec", "gap analysis", "compliance gate", "phase audit gate", "acceptance criteria check", "spec-to-code", "deployment readiness", "triad gate", "spec gate middle", "quality triad".
Detects and fixes drift between AGENTS.md documentation and actual codebase state. Scans source files and .opencode/ directories, compares claims against reality, produces a structured drift report, then applies targeted edits. Triggers on: 'sync agents md', 'update AGENTS.md', 'fix agents md drift', 'AGENTS.md out of date', 'check agent instruction drift'. NOT for generic documentation writing or README refreshes.
| name | stack-l3-zod |
| version | 4.x |
| description | Zod v4 TypeScript-first schema validation — complete API, patterns, and v3→v4 migration |
| triggers | ["zod","schema validation","z.object","z.string","safeParse","ZodError","type inference","schema definition","validation","z.infer","zod v4","zod migration","z.number","z.array","z.enum","z.union",".refine",".transform",".pipe"] |
| metadata | {"layer":"3","role":"reference","lineage":"stack"} |
Progressive disclosure reference — start here, dive into
references/as needed.
import { z } from "zod";
// Define schema
const UserSchema = z.object({
id: z.uuid(),
name: z.string().min(1),
email: z.email(),
age: z.number().int().positive().optional(),
role: z.enum(["admin", "user", "moderator"]),
});
// Type inference
type User = z.infer<typeof UserSchema>;
// Parse (throws on failure)
const user = UserSchema.parse(rawData);
// Safe parse (no throw)
const result = UserSchema.safeParse(rawData);
if (result.success) {
console.log(result.data); // typed as User
} else {
console.log(z.prettifyError(result.error));
}
| Import | Purpose |
|---|---|
import { z } from "zod" | Classic API (method chaining) — recommended |
import { z } from "zod/mini" | Mini API (functional, tree-shakable) |
import * as core from "zod/v4/core" | Core primitives (library authors) |
import { z } from "zod/v3" | Legacy v3 compat |
| Topic | File |
|---|---|
| Architecture & package structure | references/architecture.md |
| All schema types (primitives to complex) | references/api/types.md |
| All methods (optional, transform, refine…) | references/api/methods.md |
| Error handling (safeParse, ZodError) | references/api/error-handling.md |
| Type inference (z.infer, z.input, z.output) | references/api/inference.md |
| Development patterns (tools, config) | references/patterns/dev.md |
| Testing patterns with Zod | references/patterns/testing.md |
| Expert guide (beyond docs) | references/expert-guide.md |
| Anti-patterns (8 common mistakes) | references/anti-patterns.md |
| Migration from v3 to v4 | references/migration/v3-to-v4.md |
error parameter replaces required_error, invalid_type_error, errorMapz.string().email() → z.email() (method form deprecated)z.record() requires two args: z.record(z.string(), z.number()).superRefine() → .check() with cleaner APIZodError.flatten() / .format() deprecated → use z.treeifyError(), z.prettifyError()z.coerce input type is unknown (was specific type).merge() deprecated → use .extend() with destructuringz.toJSONSchema(schema)z.uuid() stricter (RFC 9562) — use z.guid() for permissive matchingz.nativeEnum() deprecated → z.enum() now handles itABSOLUTE RULE: No bundled reference, cached asset, or stale pattern from this skill shall be consumed for tech-stack API interface decisions without MCP-verified validation against the project's ACTUAL versions (package.json + lockfile), canonical source mappings (
.hivemind/STACKS-REFERENCES.md), AND a raw codebase context scan of the current implementation state.
Skills bundle references and assets as ORIENTATION tools — they help you understand WHAT exists and WHERE to look. But every bundled reference is a SNAPSHOT, frozen at the moment of ingestion. Stacks evolve: packages release breaking changes, APIs shift, SDKs deprecate surfaces. Using stale bundled signatures as implementation authority produces silent runtime errors.
Before ANY tech-stack API interface from this skill's references/assets is used for implementation, code generation, or quality gate decisions:
STEP 1 — CONSUME .hivemind/STACKS-REFERENCES.md
├─ Read the canonical stack→repo→version mapping table
├─ Identify the correct GitHub repo for each dependency
└─ Confirm the repo is active (not archived), version is current
STEP 2 — READ package.json + lockfile
├─ Extract the ACTUAL installed version (npm ls / grep lockfile)
├─ Cross-reference repo URL from STACKS-REFERENCES.md against npm registry
└─ Flag any discrepancy between bundled version and installed version
STEP 3 — RAW CODEBASE CONTEXT SCAN
├─ grep/glob the actual src/ directory structure for current implementation
├─ Read current implementation files — not stale docs or bundled references
├─ Verify the claimed API signatures match current codebase reality
└─ Check import paths, type definitions, and function signatures exist in actual code
STEP 4 — MCP LIVE VALIDATION (minimum 2 tools)
├─ Context7: resolve-library-id → query-docs (API signatures at installed version)
├─ DeepWiki: ask-question (architecture patterns, behavioral semantics)
├─ Repomix: pack-remote-repository (full repo analysis at correct version tag)
├─ Exa: web-search (latest docs, tutorials, migration guides)
├─ Tavily: search + extract (version-specific migration info)
├─ GitHub: get-file-contents (exact source verification at correct version)
└─ GitMCP: search-code (source-level pattern matching)
STEP 5 — VERIFICATION RECORD
├─ Source URL + version confirmed to match package.json
├─ MCP tool(s) used + fetch timestamp
├─ Codebase scan paths + findings
├─ Version match status (MATCHED / MISMATCHED / UNVERIFIED)
└─ Flag as BLOCKING if version mismatch or critical staleness detected
| Action | Rule |
|---|---|
| Orientation (understanding WHAT exists, WHERE to look) | ✅ Reference-tier allowed from bundled assets without live validation |
| API signature lookup for implementation | 🚫 BLOCKED without live MCP validation (Step 4) + codebase scan (Step 3) |
| Interface verification for quality gates | 🚫 BLOCKED without live MCP validation (Step 4) + version match (Step 2) |
| Version-sensitive behavioral claims | 🚫 BLOCKED without live MCP validation (Step 4) |
| Architecture pattern understanding | ✅ Reference-tier allowed, but recommend live verification for production decisions |
| Generating code from bundled patterns | 🚫 BLOCKED — route to live MCP tools for current API surface |
| Workflow Phase | IRON CLAW Trigger | Required Validation |
|---|---|---|
| Implementation | Before using any API from bundled refs | Steps 2-4 minimum |
| Code review | When verifying API usage against docs | Steps 2-4 minimum |
| Quality gate | Before PASS verdict on interface claims | Steps 1-5 full |
| Research | When synthesizing findings from cached assets | Steps 4-5 minimum |
| Audit | When reporting version-based findings | Steps 1-5 full |
zod/mini| When working on... | Also load... | Because... |
|---|---|---|
| Tool schema definitions | stack-opencode | Zod→JSON Schema conversion has silent failures (see tool-internals.md) |
| Testing schema validation | stack-vitest | Schema test patterns, edge case coverage |
| TDD with schema validation | hm-test-driven-execution | RED/GREEN/REFACTOR for schema development |
| API boundary validation | stack-nextjs | Route handler validation with Zod |
Source: colinhacks/zod v4.0.1 · Repomix download 2026-04-28
Reference documents provide facts, not workflows. When facts conflict with reality, this section guides resolution.
npx --yes ctx7 library zod "v4 migration guide".npm list zod or node -e "console.log(require('zod/package.json').version)".references/migration/v3-to-v4.md for the migration meta-pattern.node_modules/zod/lib/index.d.ts or node_modules/zod/v4/core/index.d.ts for type signatures.references/api/types.md, references/api/methods.md) — extracted from v4.0.1.node -e "require.resolve('zod')".zod/package.json version."z.object({}).safeParse({}) — if it works but the API shape differs, the reference is out of date..extend() instead of .merge()") should be verified against their runtime.zod/mini tree-shaking strategies, discriminated union auto-complete behavior, z.preprocess vs z.pipe performance, recursive schema patterns, and integration with non-TypeScript environments.references/expert-guide.md and references/anti-patterns.md cover deeper patterns.colinhacks/zod for known edge cases and RFCs.