effect-schema
БесплатноБез исполняемых скриптовНе проверенUse when @effect/schema patterns including schema definition, validation, parsing, encoding, and transformations. Use for type-safe data validation in Effect…
от TheBushidoCollective★ 202 звезды на GitHubОб этом скилле
Effect Schema
Master type-safe data validation and transformation with @effect/schema. This skill covers schema definition, parsing, encoding, and advanced schema patterns for building robust data pipelines.
Basic Schema Types
Primitive Schemas
import { Schema } from "@effect/schema"
// Primitive types
const StringSchema = Schema.String
const NumberSchema = Schema.Number
const BooleanSchema = Schema.Boolean
const BigIntSchema = Schema.BigInt
const SymbolSchema = Schema.Symbol
// Special types
const UndefinedSchema = Schema.Undefined
const VoidSchema = Schema.Void
const NullSchema = Schema.Null
const UnknownSchema = Schema.Unknown
const AnySchema = Schema.Any
Literal Values
import { Schema } from "@effect/schema"
// String literal
const HelloSchema = Schema.Literal("hello")
// Number literal
const FortyTwoSchema = Schema.Literal(42)
// Boolean literal
const TrueSchema = Schema.Literal(true)
// Multiple literals (union)
const StatusSchema = Schema.Literal("pending", "approved", "rejected")
Struct Schemas
Basic Struct
import { Schema } from "@effect/schema"
// Define user schema
const UserSchema = Schema.Struct({
id: Schema.String,
name: Schema.String,
age: Schema.Number,
email: Schema.String
})
// Infer TypeScript type
type User = Schema.Schema.Type<typeof UserSchema>
// { id: string; name: string; age: number; email: string }
Optional Fields
import { Schema } from "@effect/schema"
const PersonSchema = Schema.Struct({
name: Schema.String,
age: Schema.Number,
email: Schema.optional(Schema.String),
phone: Schema.optional(Schema.String)
})
type Person = Schema.Schema.Type<typeof PersonSchema>
// { name: string; age: number; email?: string; phone?: string }
Nested Schemas
import { Schema } from "@effect/schema"
const AddressSchema = Schema.Struct({
street: Schema.String,
city: Schema.String,
zipCode: Schema.String
})
const UserWithAddressSchema = Schema.Struct({
id: Schema.String,
name: Schema.String,
address: AddressSchema
})
Arrays and Collections
Array Schemas
import { Schema } from "@effect/schema"
// Array of strings
const StringArraySchema = Schema.Array(Schema.String)
// Array of numbers
const NumberArraySchema = Schema.Array(Schema.Number)
// Array of complex objects
const UsersSchema = Schema.Array(UserSchema)
// Non-empty array
const NonEmptyStringArray = Schema.NonEmptyArray(Schema.String)
Tuple Schemas
import { Schema } from "@effect/schema"
// Fixed tuple
const CoordinatesSchema = Schema.Tuple(
Schema.Number, // latitude
Schema.Number // longitude
)
// Tuple with optional elements
const ResponseSchema = Schema.Tuple(
Schema.Number, // status code
Schema.String, // message
Schema.optional(Schema.Unknown) // optional data
)
Record Schemas
import { Schema } from "@effect/schema"
// String keys, number values
const ScoresSchema = Schema.Record({
key: Schema.String,
value: Schema.Number
})
// Using template literals for keys
const ConfigSchema = Schema.Record({
key: Schema.TemplateLiteral("config.", Schema.String),
value: Schema.String
})
Union and Intersection
Union Types
import { Schema } from "@effect/schema"
// Simple union
const StringOrNumberSchema = Schema.Union(
Schema.String,
Schema.Number
)
// Tagged union (discriminated)
const ShapeSchema = Schema.Union(
Schema.Struct({
kind: Schema.Literal("circle"),
radius: Schema.Number
}),
Schema.Struct({
kind: Schema.Literal("rectangle"),
width: Schema.Number,
height: Schema.Number
})
)
type Shape = Schema.Schema.Type<typeof ShapeSchema>
// { kind: "circle"; radius: number } | { kind: "rectangle"; width: number; height: number }
Intersection Types
import { Schema } from "@effect/schema"
const TimestampsSchema = Schema.Struct({
createdAt: Schema.Date,
updatedAt: Schema.Date
})
const UserWithTimestampsSchema = Schema.extend(
UserSchema,
TimestampsSchema
)
// Equivalent to intersection
const ManualIntersection = Schema.Struct({
...UserSchema.fields,
...TimestampsSchema.fields
})
Parsing and Validation
Synchronous Parsing
import { Schema } from "@effect/schema"
const UserSchema = Schema.Struct({
name: Schema.String,
age: Schema.Number
})
// Parse unknown data
const parseUser = Schema.decodeUnknownSync(UserSchema)
try {
const user = parseUser({ name: "Alice", age: 30 })
console.log(user) // { name: "Alice", age: 30 }
} catch (error) {
console.error("Validation failed:", error)
}
// Invalid data throws
parseUser({ name: "Bob" }) // Throws: missing 'age' field
Effect-Based Parsing
import { Schema } from "@effect/schema"
import { Effect } from "effect"
const parseUserEffect = Schema.decodeUnkno
Установить effect-schema в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
BashReadWriteEditFAQ
Что делает скилл effect-schema?
Use when @effect/schema patterns including schema definition, validation, parsing, encoding, and transformations. Use for type-safe data validation in Effect applications.
Как установить скилл effect-schema?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл effect-schema запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic