Context
promptkit's definePrompt currently accepts a free-form validate function. That's flexible but verbose for the common case where you just want to declare a schema and get types + validation for free.
Proposal
Add an optional schema adapter so users can write:
import { z } from 'zod'
import { definePrompt } from 'promptkit/zod'
const summarize = definePrompt({
name: 'summarize',
schema: z.object({
text: z.string().min(1),
maxLength: z.number().default(100),
}),
template: ({ text, maxLength }) =>
`Summarize in ${maxLength} words: ${text}`,
})
The Zod schema would be used to:
- Validate input (replacing/combining with
validate).
- Provide the TS type for
template via z.infer.
Implementation notes
- Put it in
src/adapters/zod.ts, exported via promptkit/zod (a subpath export — needs a new entry in package.json exports).
- Zod should be a peer dependency, not a runtime dep — keep the core zero-dep.
- Add tests in
tests/adapters/zod.test.ts.
- Mirror the pattern for Valibot and ArkType in follow-up issues.
Acceptance
Good first issue?
Yes — well-scoped, mostly additive. Happy to pair on the design.
/label "good first issue" "help wanted" "adapter" "enhancement"
Context
promptkit's
definePromptcurrently accepts a free-formvalidatefunction. That's flexible but verbose for the common case where you just want to declare a schema and get types + validation for free.Proposal
Add an optional
schemaadapter so users can write:The Zod schema would be used to:
validate).templateviaz.infer.Implementation notes
src/adapters/zod.ts, exported viapromptkit/zod(a subpath export — needs a new entry inpackage.jsonexports).tests/adapters/zod.test.ts.Acceptance
promptkit/zodsubpath export works.schemaoption inferstemplateinput type.ValidationError.Good first issue?
Yes — well-scoped, mostly additive. Happy to pair on the design.
/label "good first issue" "help wanted" "adapter" "enhancement"