arktype
Define runtime-validated types with ArkType — TypeScript's 1:1 validator. Use when someone asks to "validate data in TypeScript", "runtime type checking", "ArkType", "type-safe validation", "alternative to Zod", "faster validation library", or "validate with TypeScript syntax". Covers type definitions, validation, morphs (transforms), scopes, and comparison with Zod.
What this skill does
# ArkType
## Overview
ArkType is a runtime validation library that uses TypeScript's own syntax for type definitions. Instead of learning a new API (`z.string().email()`), you write types the way you already know (`"string.email"`). It's the fastest TypeScript validator — 100x faster than Zod for complex schemas — with better error messages and 1:1 correspondence between your types and validators.
## When to Use
- Runtime validation where performance matters (hot paths, large payloads)
- Want to write validators using TypeScript syntax (not a builder API)
- Need detailed, human-readable error messages
- Replacing Zod in performance-critical applications
- Type-safe data transformations (morphs)
## Instructions
### Setup
```bash
npm install arktype
```
### Basic Types
```typescript
// types.ts — Define types using TypeScript syntax
import { type } from "arktype";
// String with constraints
const email = type("string.email");
const result = email("[email protected]"); // "[email protected]"
const error = email("not-an-email"); // ArkErrors: must be an email address
// Object types — looks like TypeScript
const User = type({
name: "string >= 2", // String with min length 2
email: "string.email",
age: "number.integer >= 13", // Integer, min 13
role: "'admin' | 'user'", // Literal union
"bio?": "string <= 500", // Optional, max 500 chars
});
// Infer the TypeScript type — no separate interface needed
type User = typeof User.infer;
// { name: string; email: string; age: number; role: "admin" | "user"; bio?: string }
// Validate
const valid = User({
name: "Kai",
email: "[email protected]",
age: 25,
role: "user",
});
if (valid instanceof type.errors) {
console.log(valid.summary); // Human-readable error message
} else {
console.log(valid.name); // Typed as User
}
```
### Arrays and Nested Types
```typescript
// complex.ts — Complex nested types
import { type } from "arktype";
const Address = type({
street: "string",
city: "string",
zip: "string.numeric", // Numeric string
country: "string == 2", // Exactly 2 characters (ISO code)
});
const Order = type({
id: "string.uuid",
items: type({
productId: "string",
quantity: "number.integer > 0",
price: "number > 0",
}).array(), // Array of items
shippingAddress: Address,
total: "number > 0",
status: "'pending' | 'shipped' | 'delivered'",
createdAt: "Date",
});
type Order = typeof Order.infer;
```
### Morphs (Transforms)
```typescript
// morphs.ts — Transform data during validation
import { type } from "arktype";
// Parse string to number
const numericString = type("string.numeric").pipe((s) => Number(s));
numericString("42"); // 42 (number)
// Parse and transform API input
const CreateUserInput = type({
name: "string.trim", // Auto-trim
email: type("string.email").pipe((e) => e.toLowerCase()), // Lowercase
age: type("string.numeric").pipe(Number), // String → number
tags: type("string").pipe((s) => s.split(",")), // "a,b,c" → ["a","b","c"]
});
```
### Scopes (Reusable Type Systems)
```typescript
// scope.ts — Define interconnected types
import { scope } from "arktype";
const types = scope({
user: {
id: "string.uuid",
name: "string >= 2",
email: "string.email",
posts: "post[]",
},
post: {
id: "string.uuid",
title: "string >= 1",
content: "string",
author: "user", // Recursive reference
tags: "string[]",
},
}).export();
const user = types.user(data);
```
## Examples
### Example 1: Validate API request bodies
**User prompt:** "Validate incoming POST requests in my Express API with clear error messages."
The agent will define ArkType schemas for each endpoint's body, create validation middleware, and return structured error responses.
### Example 2: Replace Zod with ArkType
**User prompt:** "My Zod validation is slow on large payloads. Switch to something faster."
The agent will translate Zod schemas to ArkType syntax, update validation middleware, and benchmark the improvement.
## Guidelines
- **TypeScript syntax** — `"string.email"` not `z.string().email()`
- **`type.errors` for error checking** — `result instanceof type.errors`
- **`.infer` for TypeScript type** — no duplicate interface definitions
- **Morphs for transforms** — `.pipe()` to transform during validation
- **Scopes for complex schemas** — define interconnected types with forward references
- **100x faster than Zod** — matters for hot paths and large payloads
- **Error messages are human-readable** — `result.summary` for display
- **`?` suffix for optional** — `"bio?": "string"` makes bio optional
- **Constraints in the type** — `"number >= 0 < 100"` is a range
- **Not as battle-tested as Zod** — newer library, smaller ecosystem
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.