本文へ移動
cccskills
無料GitHub で公開

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.

インストール方法を見る

含まれるファイル(2)

  • SKILL.md7.3 KB
  • _scores.json2.7 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

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"). Its own benchmarks put it far ahead of Zod on speed (the project cites an order of magnitude or more; measure your own payloads), and it gives readable error messages and a 1:1 match between your types and validators. Current release at the time of writing: 2.2.x. It implements Standard Schema, so it plugs into libraries that accept that interface.

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("maya.chen@northwind.io");  // "maya.chen@northwind.io"
const error = email("not-an-email");       // ArkErrors: must be an email address (was "not-an-email")

// 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.berg@northwind.io",
  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",      // Only checks the string looks numeric; stays a 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)

string.trim, string.numeric.parse, string.json.parse and string.date.parse are built-in morphs: they validate and convert in one step. Plain string.numeric only validates and leaves a string.

// morphs.ts — Transform data during validation
import { type } from "arktype";

// Parse string to number
const numericString = type("string.numeric.parse");
numericString("42");  // 42 (number)

// Defaults and custom checks
const Settings = type({ retries: "number.integer = 3" });
Settings({});         // { retries: 3 }
const Even = type("number").narrow((n, ctx) => n % 2 === 0 || ctx.mustBe("even"));
Even(3).summary;      // "must be even (was 3)"

// 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.parse"),            // 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",         // Cyclic reference (optional so data can terminate)
    tags: "string[]",
  },
}).export();

const out = types.user({ id: crypto.randomUUID(), name: "Kai" });
if (out instanceof type.errors) console.error(out.summary);

Throwing, JSON Schema and Standard Schema

const Config = type({ port: "number.integer", "host?": "string" });
const config = Config.assert({ port: 8080 });   // returns data or throws TraversalError
const schema = Config.toJsonSchema();            // JSON Schema draft 2020-12 object
Config["~standard"].vendor;                      // "arktype" (Standard Schema interface)

Examples

Example 1: Validate API request bodies

User prompt: "Validate incoming POST requests in my Express API with clear error messages."

The agent installs arktype, defines one type({...}) per endpoint body, and writes a middleware that calls the schema and checks out instanceof type.errors. On failure it responds 400 with out.summary; on success it passes the typed data on. A bad body such as { "age": 3 } returns age must be at least 13 (was 3).

Example 2: Replace Zod with ArkType

User prompt: "My Zod validation is slow on large payloads. Switch to something faster."

The agent translates each Zod schema (z.string().email() becomes "string.email", z.coerce.number() becomes "string.numeric.parse" where the input is a string), swaps safeParse for the instanceof type.errors check, and times both libraries on a real payload before claiming a speedup.

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
  • Faster than Zod in the project's benchmarks — matters for hot paths; measure your own payloads
  • Error messages are human-readable — result.summary for display
  • ? suffix for optional — "bio?": "string" makes bio optional
  • Constraints in the type — "0 <= number < 100" is a range
  • string.numeric does not convert — use string.numeric.parse when you need a number
  • Cyclic types need an escape — make the back-reference optional or an array, or no finite value validates
  • Not as battle-tested as Zod — newer library, smaller ecosystem

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Scripts and configures production rendering in Autodesk 3ds Max with the V-Ray and Corona renderers: output size and files, render elements, denoising, light mix, batch and command-line rendering, and network rendering. Use when a user asks to set up a production render, render several cameras in one batch, render from the command line or on a render farm, add render passes for compositing, or cut render time for archviz and product shots.

日本語の概要は準備中です。原文の説明を表示しています。

TerminalSkills/skills1632026年10月4日 更新

Covers scripting Autodesk 3ds Max, the 3D modeling and rendering application, with MAXScript and Python (pymxs): scene manipulation, object creation, material assignment, camera and light setup, batch operations, and file I/O. Use when tasks involve automating repetitive 3ds Max workflows, batch processing scenes, running scripts headless with 3dsmaxbatch, creating custom tools, or scripting scene setup for archviz, product visualization, or VFX.

日本語の概要は準備中です。原文の説明を表示しています。

TerminalSkills/skills1632026年10月4日 更新

3proxy

無料

3proxy is a small open-source proxy server that runs HTTP/HTTPS, SOCKS4/5, SNI and TCP/UDP port-mapping proxies from one config file. Use when a user asks to set up an HTTP or SOCKS5 proxy, add proxy users and passwords, write 3proxy access rules, chain or rotate upstream (parent) proxies, limit bandwidth, connections or monthly traffic per user, run 3proxy in Docker, or fix a 3proxy.cfg that will not start.

日本語の概要は準備中です。原文の説明を表示しています。

TerminalSkills/skills1632026年10月4日 更新

Builds Agent2Agent (A2A) servers and clients, the open protocol (originally from Google, now under the Linux Foundation) that lets AI agents from different frameworks call each other. Use when the user wants to create an A2A-compliant agent, build an Agent Card, implement task management, connect agents across frameworks, set up agent discovery, handle streaming responses, implement push notifications, or orchestrate multi-agent workflows. Trigger words: a2a, agent to agent, agent2agent, a2a protocol, a2a server, a2a client, agent card, agent interoperability, agent collaboration, multi-agent, agent discovery, a2a sdk, a2a task.

日本語の概要は準備中です。原文の説明を表示しています。

TerminalSkills/skills1632026年10月4日 更新

Plans a controlled experiment (A/B test) so its result can be trusted: writes the hypothesis, picks one primary metric and the guardrails, computes sample size and run time, specifies how visitors are assigned and when exposure is logged, and reads out the result with a confidence interval. Use when someone says "set up an A/B test", "split test this page", "how many visitors do I need", "how long should the experiment run", "is this result significant", "can I stop the test early", or wants to test a headline, price, layout or onboarding change against the current version.

日本語の概要は準備中です。原文の説明を表示しています。

TerminalSkills/skills1632026年10月4日 更新

ably

無料

Ably is a hosted realtime messaging service: clients publish and subscribe to named channels over WebSockets, see who is present, replay message history, and resume after a dropped connection. Use when a user asks to "add realtime updates", "push live notifications to the browser", "show who is online", "add a chat room with typing indicators", "publish from a serverless function", or "authenticate Ably clients without exposing the API key". Covers the ably 2.x JavaScript SDK (Realtime and REST), JWT token authentication, presence, history and rewind, batch publishing, and the @ably/chat 1.x SDK.

日本語の概要は準備中です。原文の説明を表示しています。

TerminalSkills/skills1632026年10月4日 更新

TerminalSkills のスキルをすべて見る

このスキルの問題を報告する