arktype
Expert knowledge for runtime validation in TypeScript using ArkType, a syntax-first validation library with TypeScript-like definitions, JIT compilation for 10x-100x performance over Zod, native recursion support, morphs for data transformation, and Standard Schema compatibility
Best use case
arktype is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Expert knowledge for runtime validation in TypeScript using ArkType, a syntax-first validation library with TypeScript-like definitions, JIT compilation for 10x-100x performance over Zod, native recursion support, morphs for data transformation, and Standard Schema compatibility
Teams using arktype should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/arktype/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How arktype Compares
| Feature / Agent | arktype | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Expert knowledge for runtime validation in TypeScript using ArkType, a syntax-first validation library with TypeScript-like definitions, JIT compilation for 10x-100x performance over Zod, native recursion support, morphs for data transformation, and Standard Schema compatibility
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# ArkType
ArkType is a runtime validation library for TypeScript that uses a **syntax-first approach**—definitions look exactly like TypeScript code. Unlike builder-pattern libraries (Zod, Yup), ArkType JIT-compiles schemas into optimized validators, achieving 10x-100x performance improvements.
## Core Principles
- **Write TypeScript syntax, not builder chains** - `"string >= 8"` instead of `.string().min(8)`
- **Zero drift between static and runtime types** - Automatic type inference from definitions
- **JIT compilation for performance** - Schemas compile to optimized JavaScript functions
- **Native recursion support** - Use Scopes for circular references without `lazy()` wrappers
- **Transform during validation** - Morphs allow data transformation in the validation pipeline
- **Standard Schema compliant** - Works with React Hook Form, TanStack Query, tRPC, and other modern libraries
- **Type-level performance matters** - Track both runtime speed AND TypeScript compiler instantiations
- **String definitions for simple types** - Use `type("string")` for primitives
- **Object definitions for structures** - Use `type({ name: "string" })` for objects
- **Scopes for complex models** - Use `scope({ ... })` for interconnected types
## Quick Reference
### Basic Validation
```typescript
import { type } from "arktype"
// Simple types
const email = type("string.email")
const age = type("number >= 18")
const tags = type("string[]")
// Object schemas
const user = type({
name: "string",
age: "number >= 18",
"email?": "string.email", // Optional field
tags: "string[]"
})
// Validation
const { data, errors } = user({
name: "Alice",
age: 25,
tags: ["typescript"]
})
if (errors) {
console.error(errors.summary)
} else {
console.log(data.name) // Fully typed
}
```
### Type Inference
```typescript
// Infer TypeScript type from ArkType definition
const userSchema = type({ name: "string", age: "number" })
type User = typeof userSchema.infer
// User = { name: string; age: number }
```
## Topics
### Core Concepts
- [Scopes and Recursion](./scopes-recursion.md) - Circular references and interconnected types
- [Generics](./generics.md) - Type functions for reusable schemas (e.g., `Paginated<T>`)
- [Morphs](./morphs.md) - Transform data during validation (string to Date, trimming, etc.)
- [Pattern Matching](./pattern-matching.md) - Type-safe switch statements with `.match()`
### Advanced Features
- [Constraints and Intersections](./constraints.md) - Ranges, regex, divisors, and type combinations
- [Custom Error Messages](./error-messages.md) - Configure errors at global, scope, or type level
- [Framework Integration](./framework-integration.md) - Hono, Fastify, and Standard Schema usage
### Performance and Migration
- [Benchmarking](./benchmarking.md) - Runtime and type-level performance testing with `@ark/attest`
- [Migrating from Zod](./zod-migration.md) - Syntax comparison and migration patterns
## Common Patterns
### Discriminated Unions (Automatic)
```typescript
// ArkType detects discriminants automatically
const response = type([
{ status: "'success'", data: "string" },
"|",
{ status: "'error'", message: "string" }
])
```
### Constraints with Intersection
```typescript
// Email from specific domain
const staffEmail = type("string.email & /.*@company.com/")
// Even numbers under 100
const evenUnder100 = type("number % 2 & < 100")
```
### Data Transformation
```typescript
// Convert string to Date during validation
const dateSchema = type("string").morph((s) => new Date(s))
// Sanitize user input
const username = type("string > 0").morph(s => s.trim().toLowerCase())
```
## ArkType vs Zod
| Feature | ArkType | Zod |
|---------|---------|-----|
| **Syntax** | `"string >= 5"` | `z.string().min(5)` |
| **Performance** | JIT-compiled (10x-100x faster) | Interpreted |
| **Recursion** | Native via Scopes | Requires `z.lazy()` |
| **Inference** | `typeof schema.infer` | `z.infer<typeof schema>` |
| **Bundle Size** | ~40kB (zero deps) | ~13kB (zero deps) |
## When to Use ArkType
- **High-throughput APIs** - Performance critical validation (10k+ items)
- **Complex domain models** - Recursive data structures (folder trees, graphs)
- **TypeScript-first teams** - Prefer type syntax over builder patterns
- **Standard Schema adoption** - Need library compatibility
- **Type-level optimization** - Avoid "excessively deep instantiation" errors
## Resources
- [Official Docs](https://arktype.io)
- [GitHub](https://github.com/arktypeio/arktype)
- [Benchmarks](https://moltar.github.io/typescript-runtime-type-benchmarks)
- [Standard Schema](https://github.com/standard-schema/standard-schema)Related Skills
bgo
Automates the complete Blender build-go workflow, from building and packaging your extension/add-on to removing old versions, installing, enabling, and launching Blender for quick testing and iteration.
database-architect
Expert database architect specializing in data layer design from scratch, technology selection, schema modeling, and scalable database architectures. Masters SQL/NoSQL/TimeSeries database selection, normalization strategies, migration planning, and performance-first design. Handles both greenfield architectures and re-architecture of existing systems. Use PROACTIVELY for database architecture, technology selection, or data modeling decisions.
data-transform-gen
Generate ETL and data transformation scripts. Use when migrating data between systems.
data-sql-optimization
Production-grade SQL optimization for OLTP systems: EXPLAIN/plan analysis, balanced indexing, schema and query design, migrations, backup/recovery, HA, security, and safe performance tuning across PostgreSQL, MySQL, SQL Server, Oracle, SQLite.
data-engineering-backend-architect
Expert backend architect specializing in scalable API design, microservices architecture, and distributed systems. Masters REST/GraphQL/gRPC APIs, event-driven architectures, service mesh patterns, and modern backend frameworks. Handles service boundary definition, inter-service communication, resilience patterns, and observability. Use PROACTIVELY when creating new backend services or APIs. Use when: the task directly matches backend architect responsibilities within plugin data-engineering. Do not use when: a more specific framework or task-focused skill is clearly a better match.
data-client-setup
Install and set up @data-client/react or @data-client/vue in a project. Detects project type (NextJS, Expo, React Native, Vue, plain React) and protocol (REST, GraphQL, custom), then hands off to protocol-specific setup skills.
data-architect
**Master Skill**: Data Architect for PayU. Expert in PostgreSQL design, Performance Tuning (Indexing/Locking), Flyway migrations, CQRS/Event-Sourcing, TimescaleDB, and high-scale JSONB patterns.
darpan-gemini
Use when coding or reviewing the Moqui-based Darpan component to follow local conventions, documentation practices, and verification steps; keep work inside runtime/component/darpan/** and apply both AGENTS files.
dapr-integration
Integrate Dapr building blocks for event-driven microservices - Pub/Sub, State Management, Secrets, Service Invocation, and Jobs API. Use when implementing event-driven architecture for Phase 5. (project)
dapp-sdd:specify
Use when expanding a README-based dApp description into a full specification with user stories and acceptance criteria.
dansk-qa
Use when reviewing Danish copy for anglicisms, technical jargon, defensive tone, vague formulations, English words, and overly formal language. Scans uncommitted files by default or specific files with --file flag.
d3-viz
使用 d3.js 创建交互式数据可视化。此技能应在创建自定义图表、图形、网络图、地理可视化或任何需要对视觉元素、转换或交互进行细粒度控制的复杂基于 SVG 的数据可视化时使用。用于标准图表库之外的定制可视化,无论是 React、Vue、Svelte、原生 JavaScript 还是任何其他环境。