Valibot conventions for owned wire contracts and explicit validation outcomes. Use when defining or reviewing Valibot schemas or parsing untrusted data with Valibot.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Valibot Best Practices?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/casper-studios-valibot-best-practices)
---
name: valibot-best-practices
description: Valibot conventions for owned wire contracts and explicit validation outcomes. Use when defining or reviewing Valibot schemas or parsing untrusted data with Valibot.
license: MPL-2.0
metadata:
author: 'Basti Ortiz <ortiz@bastidood.dev>'
source: 'https://github.com/BastiDood/skills'
---
# Valibot Best Practices
> [!IMPORTANT]
> Apply the `codebase-architecture:code-style` principles to Valibot: treat a schema as the owned contract at an untrusted data boundary that defines accepted wire values, produces trusted domain values, and makes invalid input an explicit, intentional outcome.
## Library Sources
- GitHub repository ID: `open-circle/valibot`
- Context7 library ID: `/open-circle/valibot`
- DeepWiki repository ID: `open-circle/valibot`
Use Context7 for current documentation and DeepWiki for implementation details.
## References
Read the references that apply to the current task before defining or reviewing Valibot schemas and parsing code.
1. Make schemas the owned, trusted contract for wire data.
- [Make a schema that proves a domain shape the single source of truth](./references/schema-ownership.md) and infer a type when needed, exposing the schema/type pair only as an intentional public contract.
- [Keep constructors under the `v` namespace](./references/namespace-imports.md) so library ownership stays clear and import forms remain consistent.
2. Encode exact wire semantics inside the schema.
- [Encode missing and `null` wire semantics](./references/wire-nullability.md) with the matching wrapper rather than whichever wrapper compiles.
- [Dispatch literal-tagged alternatives with `v.variant`](./references/discriminated-variants.md) so Valibot selects and reports the failing tagged branch.
- [Define defaults with exact domain meaning in the schema](./references/schema-defaults.md); do not use a default to reinterpret malformed input.
- [Transform normalized wire input inside the schema](./references/schema-transformations.md) with matching built-ins so consumers receive the intended domain values.
3. Make validation failure match the boundary contract.
- [Choose the parse API from the failure contract](./references/parse-failure-contracts.md): abort a violated invariant or return an expected branch, reusing immutable schemas and parser functions.
- [Preserve expected validation issues](./references/validation-failure-preservation.md) instead of substituting an invented `null` or empty value.
Files in this skill
LICENSE.txt16.3 KB
SKILL.md2.5 KB
agents/openai.yaml121 B
references/discriminated-variants.md858 B
references/namespace-imports.md381 B
references/parse-failure-contracts.md697 B
references/schema-defaults.md292 B
references/schema-ownership.md562 B
references/schema-transformations.md212 B
references/serialized-trust-boundaries.md670 B
references/validation-failure-preservation.md565 B