You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(zod): use ask CLI as primary source for version-accurate docs
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
Copy file name to clipboardExpand all lines: plugins/zod/skills/use-zod/SKILL.md
+70-11Lines changed: 70 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,13 +5,15 @@ description: 'Answer questions about the Zod schema validation library and help
5
5
6
6
## Prerequisites
7
7
8
-
Before writing Zod code, verify the installed version and entry points in the current project:
8
+
Verify the `ask` CLI is available (`which ask`). It is the primary tool for reading the exact version installed in this project — it resolves the version from the lockfile, fetches docs/source once, and caches them at `~/.ask/`. If `ask` is not installed, fall back to `node_modules/zod/` and the official site at https://zod.dev (which tracks the latest published v4, not necessarily the installed version).
9
+
10
+
Before writing Zod code, verify the installed version and entry points:
@@ -39,15 +41,72 @@ Zod 4 (released 2026) was a major rewrite. Many APIs that were canonical in v3 a
39
41
40
42
When working with Zod:
41
43
42
-
1. Resolve the installed version first (`node_modules/zod/package.json`).
43
-
2.If unsure whether an API exists in the installed version, grep the bundled `.d.ts`: `rg -n "treeifyError|formatError" node_modules/zod/dist`.
44
-
3.Check upstream docs **at the matching version pin** (links below in [`references/versions.md`](references/versions.md)) — not at`main`, which tracks the latest release.
44
+
1. Resolve the installed version against the local checkout with `ask` (see [Finding Documentation](#finding-documentation) below).
45
+
2.Verify every API name, method signature, and option shape against the source or bundled `.d.ts` before generating code. Never invent method names.
46
+
3.Cross-reference upstream docs **at the matching version pin** ([`references/versions.md`](references/versions.md) has the v4.3.6 / v3.25.76 links) — not `main`, which tracks the latest release.
45
47
4. Run typecheck after every change. Zod schemas are heavily inferred and silent type drift is rare.
46
-
5. Never invent method names. If the user references an API you don't recognise, look it up before answering.
47
-
6. Surface deprecations to the user instead of silently emitting either pattern.
48
+
5. Surface deprecations to the user instead of silently emitting either pattern (e.g. `.superRefine` works but is deprecated in v4 — say so).
48
49
49
50
If documentation cannot be found locally or remotely to back an answer, say so explicitly.
50
51
52
+
## Finding Documentation
53
+
54
+
Resolve the source checkout and docs directory once with `ask`; reuse the paths across reads:
55
+
56
+
```bash
57
+
SRC=$(ask src zod)# checkout root
58
+
DOCS=$(ask docs zod | head -n1)# candidate docs dir
59
+
```
60
+
61
+
Both pin to the version in the project's lockfile. To inspect a specific version regardless of the project, append `@version`:
62
+
63
+
```bash
64
+
SRC_V4=$(ask src zod@4.3.6)
65
+
SRC_V3=$(ask src zod@3.25.76)
66
+
```
67
+
68
+
### Read the README and docs content
69
+
70
+
```bash
71
+
cat "$DOCS/README.md"
72
+
ls "$SRC/packages/docs/content"# v4 docs source (mdx)
73
+
cat "$SRC/packages/docs/content/api.mdx"# full API reference
3.`rg -n "<symbol>" node_modules/zod/dist` — verify the symbol exists in the installed build before suggesting it.
123
+
Prefer `ask` over `node_modules/` — it resolves the project's lockfile-pinned version and gives you full source (with comments and tests), not just the compiled output.
124
+
125
+
```bash
126
+
SRC=$(ask src zod)
127
+
cat "$SRC/packages/zod/package.json"| jq .version # actual installed version
128
+
cat "$SRC/packages/zod/package.json"| jq '.exports | keys'# available subpaths
129
+
rg -n "<symbol>""$SRC/packages/zod/src"# verify symbol exists
130
+
```
131
+
132
+
Pin to a specific version regardless of the project:
0 commit comments