arktype
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "arktype":https://skillpi.com/zh/skills/deepskill-cbb17c42937a5bd38b997285ec2e369d7b208944ca93a92abf8a8142bd2c0056。安装前核对上游来源和版本:https://github.com/TerminalSkills/skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
使用 ArkType 在运行时定义和验证类型——为 TypeScript 提供 1:1 的验证器。适用于需要在 TypeScript 中验证数据、进行运行时类型检查、替代 Zod、追求更快验证或使用 TypeScript 语法编写验证规则的场景。涵盖类型定义、验证、变形(转换)、作用域设置,并包含与 Zod 的对比说明。
介绍来源: third_party · TerminalSkills · 1.0.0 参考来源
SkillPi 解读
- 适合谁
- 翻译待完成,请参阅来源文档。
- 实测状态
- 未测试
文件浏览
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
当前收录版本
1.0.0
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 提供 ArkType 运行时验证库的详细使用指南,适用于 TypeScript 开发者进行高性能数据验证
- 涵盖类型定义、验证、变形、作用域等核心功能,实用性强
亮点
- 触发词精准完整,覆盖多种变体,边界清晰
亮点
- 文档结构清晰,包含多个章节,步骤明确,有端到端示例,frontmatter 完整
亮点
- 提供了 npm 安装命令,代码示例完整,涵盖了主要异常处理,工具来源明确
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
-
安装或获取外部依赖
使用官方来源并锁定版本,在隔离环境检查安装脚本。当前文档检查不覆盖后续下载的代码。
主文档提及 · 第 37 行
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。