Skip to main content
skill CX Codex

arktype-validation — Claude Code skill: what it does, how to install

arktype-validation — a skill for ArkType, where schemas are TypeScript-shaped strings. Covers morphs, scopes and ArkEnv checks for environment variables. Handy for runtime validation that stays close to the type syntax.

MIT 153 installs ★ 29 updated 2026-08-17

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add oakoss/agent-skills --skill arktype-validation -a claude-code
Open on GitHub

What arktype-validation does

ArkType builds runtime validators from strings that read like TypeScript: type({ id: "number", email: "string.email" }). The skill hands the agent a reference for that syntax, so it stops inventing call-style forms such as string.email() and checks failures with instanceof type.errors.

Three reference files sit inside: one on schema types, one on morphs and scopes, one on common patterns. That last file walks through JSON parsing, form and API response validation, plus environment variables via ArkEnv, which also comes with a Vite plugin for build-time checks.

One limit matters up front. This is written for ArkType, not Zod. If your code leans on the Zod ecosystem, or you need JSON Schema output, ArkType is the wrong tool here and the skill says so.

What it helps with

  • define a runtime schema with TypeScript-like string syntax
  • validate an API payload before it reaches the handler
  • coerce environment variables to real types at startup
  • cross-reference types inside a scope()
  • transform input with a morph before validation runs

Example prompts for the agent

  • Write an ArkType schema for the user object, with email optional and format-checked.
  • Validate process.env with arkenv() so PORT comes out as a number.
  • Why does type("string.email()") fail? Show me the version that works.

How to install arktype-validation

1Skills CLI (Vercel)

npx skills add oakoss/agent-skills --skill arktype-validation -a claude-code

2Manually: put the files in place

~/.claude/skills/arktype-validation/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/arktype-validation/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about arktype-validation

How do I install arktype-validation in Claude Code?

Run npx skills add oakoss/agent-skills --skill arktype-validation -a claude-code. The skill file lands at ~/.claude/skills/arktype-validation/SKILL.md.

What does arktype-validation do?

It gives the agent a reference for ArkType: string schemas, morphs and transforms, scope() for cross-references, generics, error handling. ArkEnv covers environment variables, with a Vite plugin alongside.

Does it replace Zod?

No. Zod schemas are handled by a separate skill, and ArkType does not target Zod ecosystem compatibility or JSON Schema output.

Source text

SKILL.md · MIT
---
name: arktype-validation
description: 'ArkType runtime validation with TypeScript-native syntax. Type-safe schemas using string expressions, morphs, scopes, and generics. Includes ArkEnv for typesafe environment variable validation with auto-coercion and Vite plugin. Use when defining schemas, validating data, transforming input, building type-safe APIs with ArkType, or validating environment variables with ArkEnv.'
license: MIT
metadata:
  author: oakoss
  version: '1.2'
user-invocable: false
---

# ArkType Validation

## Overview

ArkType is a TypeScript-native runtime validation library that defines schemas using string expressions mirroring TypeScript syntax, providing editor autocomplete, syntax highlighting, and optimized validators. Use when building type-safe APIs, validating JSON payloads, or replacing Zod with a more TypeScript-idiomatic approach. Not suitable for projects that need Zod ecosystem compatibility or JSON Schema output.

**Package:** `arktype`

## Quick Reference

| Pattern                           | Usage                                           |
| --------------------------------- | ----------------------------------------------- |
| `type({ key: "string" })`         | Define object schema                            |
| `type("string")`                  | Primitive type                                  |
| `"string.email"`, `"string.url"`  | Built-in string validators                      |
| `"string.trim"`, `"string.lower"` | Built-in string morphs (transforms)             |
| `"string.json.parse"`             | Parse JSON string to validated object           |
| `"number > 0"`, `"string >= 1"`   | Inline constraints                              |
| `"string \| number"`              | Union types                                     |
| `"'a' \| 'b' \| 'c'"`             | String literal unions                           |
| `"string[]"`                      | Array types                                     |
| `"key?": "string"`                | Optional properties                             |
| `"key = 'default'"`               | Default values                                  |
| `.pipe()`, `.to()`                | Transform output (morphs)                       |
| `.narrow()`                       | Custom validation (like Zod refine)             |
| `.pick()`, `.omit()`              | Object property selection                       |
| `.merge()`                        | Combine object types                            |
| `scope({...}).export()`           | Named type scopes with cross-references         |
| `type("<t>", { box: "t" })`       | Generic type definitions                        |
| `type.errors`                     | Error handling (check `instanceof type.errors`) |
| `.assert(data)`                   | Throws on invalid input instead of returning    |
| `"(number % 2)#even"`             | Branding — type-only validated marker           |
| `"0 <= number <= 100"`            | Compact range constraints                       |
| `configure()`                     | Global defaults (from `arktype/config`)         |
| `match()`                         | Type-safe pattern matching (2.1)                |
| `"+" : "reject"`                  | Inline undeclared key handling                  |
| `arkenv({ PORT: "number" })`      | Typesafe env var validation (ArkEnv)            |
| `arkenvVitePlugin(Env)`           | Build-time env validation for Vite              |

## Common Mistakes

| Mistake                               | Fix                                             |
| ------------------------------------- | ----------------------------------------------- |
| `type("string.email()")` with parens  | `type("string.email")` (no parens)              |
| Checking errors with `=== null`       | Use `instanceof type.errors`                    |
| `{ key: "string?" }` for optional     | `{ "key?": "string" }` (question mark on key)   |
| Importing from `arktype/types`        | Import `type` and `scope` from `"arktype"`      |
| Nested `type()` in string expressions | Use `scope()` for cross-referencing types       |
| Raw `.pipe()` without error handling  | Use `.pipe.try()` for operations that can throw |
| `"string.lowercase"` for case morph   | `"string.lower"` (also `"string.upper"`)        |
| Configuring after importing `arktype` | Import `arktype/config` before `arktype`        |
| Manual `process.env` parsing          | Use `arkenv()` for auto-coercion and validation |

## Delegation

Use this skill for ArkType schema definitions, runtime validation, morphs/transforms, scopes, and type inference. For Zod-based validation, delegate to the zod-validation skill.

## References

- [Schema Types](references/schema-types.md) — primitives, string keywords, number constraints, objects, arrays, tuples, unions, optional, defaults
- [Morphs and Scopes](references/morphs-and-scopes.md) — pipe, morph transforms, narrow validation, scopes, recursive types, generics, global configuration, pattern matching
- [Common Patterns](references/common-patterns.md) — JSON parsing, form validation, API responses, error handling, ArkEnv environment variables, Vite plugin, comparison with Zod

© oakoss · MIT · oakoss/agent-skills

Similar skills

All skills for Backend and APIs →

From the same set106

The whole set →
pglite Hands your coding agent the PGlite API: a WASM build of PostgreSQL 17.4 with storage backends, transactions, live queries and React hooks. CX Codex +1 156installs tanstack-table Guides React headless table architecture with TanStack Table v8, covering server pagination, filtering, and render bug prevention. CX Codex +1 155installs changesets The changesets skill manages package versions and changelogs in a monorepo. Use it to coordinate releases and publish packages to npm. CX Codex +1 154installs opentofu Get help writing and reviewing OpenTofu configurations and Pulumi programs. Use the skill to manage infrastructure code, state, and environment setups. CX Codex +1 153installs tanstack-router tanstack-router adds guidance for type-safe file-based React routing with @tanstack/react-router. Useful for loaders, search param validation, and code splitting. CX Codex +1 150installs api-testing api-testing is a Claude Code skill for writing REST API integration tests and checking endpoint responses. It activates for HTTP mocking, response validation, and API error tests. CX Codex +1 149installs github-actions Create and configure GitHub Actions workflows, from event triggers and build matrices to caching and authentication. Useful for automating tests, releases, and deployments. CX Codex +1 149installs git-workflow git-workflow guides AI coding agents through trunk-based development, conventional commits, reusable GitHub Actions workflows, and Git history repair. CX Codex +1 149installs

Project sponsors

Companies that keep this analytics open