arktype
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "arktype" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-cbb17c42937a5bd38b997285ec2e369d7b208944ca93a92abf8a8142bd2c0056. Verify the upstream source and version against https://github.com/TerminalSkills/skills before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
github.com
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Define and validate runtime types with ArkType — a 1:1 validator for TypeScript. Suitable for scenarios that require validating data in TypeScript, runtime type checks, an alternative to Zod, faster validation, or writing validators using TypeScript syntax. Covers type definition, validation, transformations, scoping, and comparisons with Zod.
Introduction source: third_party · TerminalSkills · 1.0.0 Reference
SkillPi interpretation
- Audience
- 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)
- Testing
- Not tested
Browse files
Frontmatter
name: arktype
description: >-
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.
license: Apache-2.0
compatibility: "TypeScript 5.1+. Node.js/Bun/Deno/browser."
metadata:
author: terminal-skills
version: "1.0.0"
category: development
tags: ["validation", "typescript", "arktype", "runtime-types", "schema"]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
npm install arktype
Basic Types
// types.ts — Define types using TypeScript syntax
import { type } from "arktype";
// String with constraints
const email = type("string.email");
const result = email("user@example.com"); // "user@example.com"
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: "kai@example.com",
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
// 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)
// 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)
// 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"notz.string().email() type.errorsfor error checking —result instanceof type.errors.inferfor 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.summaryfor 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
Current listing version
1.0.0
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供 ArkType 运行时验证库的详细使用指南,适用于 TypeScript 开发者进行高性能数据验证
- 涵盖类型定义、验证、变形、作用域等核心功能,实用性强
Highlights
- 触发词精准完整,覆盖多种变体,边界清晰
Highlights
- 文档结构清晰,包含多个章节,步骤明确,有端到端示例,frontmatter 完整
Highlights
- 提供了 npm 安装命令,代码示例完整,涵盖了主要异常处理,工具来源明确
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
-
Install or fetch external dependencies
Use official sources and pin versions. Check install scripts in an isolated environment. This document check does not cover code downloaded later.
Mentioned in main document · lines 37
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.