Skip to content

feat(zod): add use-zod skill plugin#168

Merged
amondnet merged 5 commits intomainfrom
amondnet/zod-plugin
Apr 29, 2026
Merged

feat(zod): add use-zod skill plugin#168
amondnet merged 5 commits intomainfrom
amondnet/zod-plugin

Conversation

@amondnet
Copy link
Copy Markdown
Contributor

@amondnet amondnet commented Apr 29, 2026

Summary

Adds a new built-in zod plugin at plugins/zod/, following the same pattern established in PR #161 (mastra) and PR #159 (better-auth). No MCP server — the plugin is a pure skills-only plugin, identical in structure to both precedents.

What's New

Plugin layout

plugins/zod/ mirrors plugins/mastra/ and plugins/better-auth/:

  • .claude-plugin/plugin.json — plugin manifest (name, version, description, author, homepage, repository, license, keywords)
  • skills/use-zod/SKILL.md — main skill definition; activates when Zod schemas, validation, or parsing are mentioned

Skill files (4 total)

File Purpose
skills/use-zod/SKILL.md Skill definition — trigger patterns, usage guide, when to prefer Zod, version detection
skills/use-zod/versions.md Side-by-side Zod v3 vs v4 API reference; acts as a quick cheatsheet
skills/use-zod/schemas.md Schema construction patterns for primitives, objects, arrays, unions, transforms, refinements
skills/use-zod/parsing-and-errors.md Parsing methods (.parse, .safeParse, .parseAsync) and error handling

No MCP server

Zod is a pure schema-validation library with stable, well-documented APIs. A skill providing inline reference is sufficient; no runtime server is needed.

v3 ↔ v4 migration callouts surfaced in the skill

  • format / flattentreeifyError / flattenError / prettifyError
  • Separate message / errorMap issue params → unified error param
  • z.lazy + TypeScript annotation → property getter pattern for recursive schemas
  • .superRefine deprecated → .check
  • New in v4: z.codec, .overwrite, zod/mini lightweight build

ask CLI integration (mirrors better-auth from PR #159)

The skill instructs Claude to resolve version-accurate docs and source via the ask CLI tool first (ask_public_library zod), falling back to node_modules/zod/. This ensures advice reflects the installed version rather than training-data snapshot.

Registry changes

File Change
.claude-plugin/marketplace.json New entry for zod plugin
release-please-config.json New component plugins/zod
README.md Added zod to the built-in plugins table

New files

plugins/zod/.claude-plugin/plugin.json
plugins/zod/skills/use-zod/SKILL.md
plugins/zod/skills/use-zod/versions.md
plugins/zod/skills/use-zod/schemas.md
plugins/zod/skills/use-zod/parsing-and-errors.md

Modified registry files

.claude-plugin/marketplace.json
release-please-config.json
README.md

Verification

claude plugin validate plugins/zod passes. The homepage/repository warning visible in CI output is a pre-existing issue on main (affects other plugins as well) and is unrelated to this PR.


Summary by cubic

Adds a built-in zod skills-only plugin with version-aware help for Zod v3 and v4 (schemas, parsing, errors, and migrations). Mirrors the mastra/better-auth pattern, uses ask for version detection, and requires no MCP server.

  • New Features

    • New plugins/zod/ with skills/use-zod/ and references/ (schemas, parsing-and-errors, versions) covering common APIs, error handling, and v3↔v4 differences.
    • Version detection via ask (ask src zod, ask docs zod) with node_modules/zod/ fallback.
    • Migration notes: err.format/err.flattenz.treeifyError/z.flattenError; { message, errorMap }{ error }; recursion via getters; new z.codec (v4.1+), .overwrite, and zod/mini.
    • Registered in .claude-plugin/marketplace.json, added release config in release-please-config.json, and updated README.
  • Bug Fixes

    • Corrected guidance: .superRefine remains the recommended multi-issue API in v4; .check is a lower-level, performance-focused alternative.
    • Docs/metadata fixes: corrected Zod v4 release year (2025), fixed a recursive example to use a self-referencing variable, and updated plugin author to upstream Zod.

Written for commit 0af26ed. Summary will update on new commits.

Hand-written workflow skill for Zod schema validation, mirroring the
mastra plugin pattern from #161. Single trigger-heavy SKILL.md plus
three references (versions, schemas, parsing-and-errors) covering
both Zod v3 and v4 with inline migration callouts.

Key v3 → v4 differences surfaced:
- err.format() / err.flatten() → z.treeifyError() / z.flattenError()
- separate { message, errorMap } → unified { error } param
- z.lazy + ZodType<T> annotation → property getters for recursion
- .superRefine() (deprecated) → .check()
- new in v4: z.codec, z.prettifyError, .overwrite, zod/mini

No MCP server (zod has no official docs MCP server). Skills-only
plugin with skills: ['./skills/'].
- .claude-plugin/marketplace.json: add zod entry pointing to ./plugins/zod
- release-please-config.json: add plugins/zod with simple release-type and
  extra-files jsonpath $.version for plugin.json bumps
- README.md: append Zod section after Portless mirroring existing entries
Mirrors the use-better-auth pattern: lead with `ask src zod` /
`ask docs zod` to read the lockfile-pinned source (with comments and
tests), demoting node_modules/zod/dist to a fallback for environments
where ask isn't installed.

- New 'Finding Documentation' section in SKILL.md showing the
  SRC=$(ask src zod) idiom for reading docs, verifying symbols, and
  finding canonical examples in tests
- versions.md 'When in doubt' switched to ask-first verification with
  explicit @Version pinning examples for v4.3.6 and v3.25.76
- 'When typecheck or runtime fails' debug snippet now greps
  $(ask src zod)/packages/zod/src instead of node_modules/zod/dist
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
claude-code-plugins Ready Ready Preview, Comment Apr 29, 2026 7:35pm

Request Review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new plugin for Zod, including a comprehensive skill set and reference documentation for both v3 and v4. The changes include updates to the marketplace configuration, README, and release-please settings. Several critical issues were identified in the documentation regarding incorrect versioning claims (hallucinating a 2026 release date for v4 and non-existent version numbers) and the misidentification of the current stable version. Additionally, the plugin metadata needs to be updated to credit the upstream organization rather than an individual contributor.

Comment thread plugins/zod/skills/use-zod/SKILL.md
Comment thread plugins/zod/skills/use-zod/SKILL.md Outdated
Comment thread plugins/zod/skills/use-zod/references/versions.md
Comment thread plugins/zod/.claude-plugin/plugin.json
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 issues found across 8 files

Confidence score: 4/5

  • This PR is safe to merge; all noted issues are documentation inaccuracies with low to moderate user impact.
  • Most significant: plugins/zod/skills/use-zod/references/versions.md has an invalid recursive schema example (Self is undefined), which could mislead readers copying the v4 snippet.
  • Also in plugins/zod/skills/use-zod/references/parsing-and-errors.md, the .loose() API call is incorrect for v4 and should be z.looseObject(...) or legacy .passthrough().
  • Pay close attention to plugins/zod/skills/use-zod/references/versions.md, plugins/zod/skills/use-zod/references/parsing-and-errors.md, plugins/zod/skills/use-zod/SKILL.md - fix v4 example/API usage and release-year accuracy.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="plugins/zod/skills/use-zod/references/versions.md">

<violation number="1" location="plugins/zod/skills/use-zod/references/versions.md:84">
P2: The recursive schema example uses `Self`, which is undefined. This makes the v4 example invalid when copied; the getter should reference the schema variable itself.</violation>
</file>

<file name="plugins/zod/skills/use-zod/SKILL.md">

<violation number="1" location="plugins/zod/skills/use-zod/SKILL.md:34">
P3: Correct the Zod v4 release year; the current text says 2026, but official docs place the v4 root/npm transition in 2025.</violation>
</file>

<file name="plugins/zod/skills/use-zod/references/parsing-and-errors.md">

<violation number="1" location="plugins/zod/skills/use-zod/references/parsing-and-errors.md:225">
P2: The v4 migration guidance references `.loose()`, which is not a Zod v4 object API; use `z.looseObject(...)` (or legacy `.passthrough()`) instead.</violation>
</file>
Architecture diagram
sequenceDiagram
    participant User as "User / Claude"
    participant Skill as "NEW: Zod Skill Plugin"
    participant Ask as "ask CLI Tool"
    participant FS as "Local Filesystem (node_modules)"
    participant Cache as "ask Cache (~/.ask/)*"

    Note over User,Cache: Runtime Skill Activation (Trigger: "zod", "z.object", etc.)

    User->>Skill: "How do I format errors in this project?"
    
    Skill->>FS: "NEW: Check installed version (package.json)"
    FS-->>Skill: "Return version (e.g., v4.3.6)"

    alt "NEW: ask CLI available"
        Skill->>Ask: "ask src zod / ask docs zod"
        Ask->>FS: "Resolve version from lockfile"
        alt "Data not in cache"
            Ask->>Ask: "Fetch version-accurate source/docs"
            Ask->>Cache: "Store source/docs"
        end
        Ask-->>Skill: "Return paths ($SRC, $DOCS)"
        
        Skill->>Cache: "NEW: Search symbols/tests (rg/fd)"
        Cache-->>Skill: "API signatures & usage examples"
    else "fallback: ask CLI missing"
        Skill->>FS: "Inspect node_modules/zod/dist"
        FS-->>Skill: "Return compiled output/types"
    end

    Note over Skill: "NEW: Branch logic based on version (v3 vs v4)"

    alt "Version is v4"
        Skill->>Skill: "CHANGED: Select v4 APIs (treeifyError, .check())"
    else "Version is v3"
        Skill->>Skill: "Select v3 APIs (err.format(), .superRefine())"
    end

    Skill-->>User: "Return version-accurate advice & migration callouts"
Loading

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread plugins/zod/skills/use-zod/references/versions.md Outdated
Comment thread plugins/zod/skills/use-zod/references/parsing-and-errors.md
Comment thread plugins/zod/skills/use-zod/SKILL.md Outdated
@amondnet amondnet self-assigned this Apr 29, 2026
The v4 docs (api.mdx@v4.3.6) present .superRefine() as the standard
recommended API for multi-issue refinements, with .check() as a
lower-level, more verbose alternative for performance-sensitive
paths. The skill had this inverted in 6 places, claiming .superRefine
was deprecated.

- SKILL.md: rewrite the 'training-data miswritten' bullet to describe
  .superRefine as recommended, .check as lower-level
- SKILL.md: drop the bogus 'flagged as deprecated' debug bullet
- SKILL.md: include both .superRefine and .check (low-level) in the
  v4 row of the version-detection table
- versions.md: rewrite the multi-issue refinement cheatsheet row
- versions.md: rewrite the 'New in v4' bullet for .check
- schemas.md: invert the multi-issue refinement example so
  .superRefine leads as canonical, .check follows as lower-level
- schemas.md: drop the 'avoid .superRefine in v4' bullet entirely

Caught by review-documentation-analyzer in /review:code-review-loop
iteration 1.
Apply 3 of 4 review thread suggestions on PR #168:

- plugin.json: author restructured to upstream-org form
  ('Zod' / https://github.com/colinhacks/zod) per the mastra and
  better-auth precedent (@gemini-code-assist)
- SKILL.md: Zod 4 release year corrected from 2026 to 2025
  (v4.0.1 published 2025-07-10) (@cubic-dev-ai)
- versions.md: recursive-schema example fixed — replaced
  undefined 'Self' placeholder with a self-referencing 'Tree'
  variable so the snippet works as written (@cubic-dev-ai)

Skipped: @cubic-dev-ai's claim that '.loose()' is not a v4 object
API. Verified false against zod@v4.3.6 classic/schemas.ts:1269
('inst.loose = () => inst.clone(...)'). The .loose() instance
method exists alongside z.looseObject({...}) — both are valid.
@amondnet amondnet merged commit 95319ce into main Apr 29, 2026
7 checks passed
@amondnet amondnet deleted the amondnet/zod-plugin branch April 29, 2026 19:59
@pleaeai-bot pleaeai-bot Bot mentioned this pull request Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant