소스 정보
- 저장소
- carrot-foundation/schemas
- 최근 소스 활동
- 2026년 3월 25일 20:55
- 감지된 SKILL.md 언어
- 영어
- 스타
- 1
- 포크
- 0
설치 방법
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
소스 파일 검토
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
메뉴
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/carrot-foundation/schemas --skill rule-zod명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
SOC 직업 분류 기준
SKILL.md 표시 중
| name | rule-zod |
| description | Zod schema authoring — strictObject, safeExtend, meta(), and composition layers |
Apply this rule whenever work touches:
src/**/*.schema.tssrc/**/*.schemas.tsZod schemas are the single source of truth in this project. They drive TypeScript types, JSON Schema generation, documentation, and runtime validation. Getting them right is critical.
z.strictObject() — alwaysUse z.strictObject() for all object schemas. This rejects unknown properties at parse time, which is essential for IPFS data integrity (extra fields change content hashes).
// BAD: chaining .strict() on z.object()
const LocationSchema = z
.object({
latitude: LatitudeSchema,
longitude: LongitudeSchema,
})
.strict();
// GOOD: strictObject from the start
const LocationSchema = z.strictObject({
latitude: LatitudeSchema,
longitude: LongitudeSchema,
});
.safeExtend()Schemas compose in layers. Use .safeExtend() to build from base to specific:
BaseIpfsSchema (shared $schema, schema, created_at, external_id, external_url, ...)
-> NftIpfsSchema (adds blockchain, name, description, image, attributes, ...)
-> MassIDNftIpfsSchema (adds mass-id-specific data and attributes)
// Base layer — common IPFS record fields
export const BaseIpfsSchema = z.strictObject({
$schema: z.url().meta({ ... }),
schema: SchemaInfoSchema,
created_at: IsoDateTimeSchema.meta({ ... }),
external_id: ExternalIdSchema,
external_url: ExternalUrlSchema,
viewer_reference: ViewerReferenceSchema.optional(),
environment: RecordEnvironmentSchema.optional(),
data: z.record(z.string(), z.unknown()).optional().meta({ ... }),
});
// NFT layer extends base with blockchain and display fields
export const NftIpfsSchema = BaseIpfsSchema.safeExtend({
blockchain: BlockchainReferenceSchema,
name: NonEmptyStringSchema.max(100).meta({ ... }),
short_name: NonEmptyStringSchema.max(50).meta({ ... }),
description: .().({ ... }),
: .({ ... }),
: .({ ... }),
: (, ...).({ ... }),
});
= .({
: .({ ... }),
});
Never use .merge() — it does not preserve strict object behavior. Always use .safeExtend().
.meta() on every fieldEvery field must include .meta() with at minimum title and description. Add examples based on field complexity.
examples (plural array)Use examples by default to show variety — 2 to 4 values is typical:
waste_type: z.string().min(1).max(100).meta({
title: 'Waste Type',
description: 'Category or type of waste material',
examples: ['Organic', 'Plastic', 'Metal', 'Paper'],
}),
example (singular)Use singular example for canonical patterns where one value is sufficient:
$schema: z.url().meta({
title: 'JSON Schema URI',
description: 'URI of the JSON Schema used to validate this record',
example: 'https://raw.githubusercontent.com/carrot-foundation/schemas/...',
}),
Skip examples when a base schema already provides them:
external_id: ExternalIdSchema.meta({
title: 'External ID',
description: 'UUID identifier for external system references',
// No examples needed — ExternalIdSchema (UuidSchema) already has examples
}),
export const MassIDDataSchema = z.strictObject({ ... });
export const LocationSchema = z.strictObject({ ... });
export const ParticipantSchema = z.strictObject({ ... });
export type MassIDData = z.infer<typeof MassIDDataSchema>;
export type Location = z.infer<typeof LocationSchema>;
export type Participant = z.infer<typeof ParticipantSchema>;
.refine()Use .refine() only when built-in validators cannot express the constraint:
// BAD: refine for something built-in
z.string().refine((s) => s.includes('@'), 'Must be email');
// GOOD: built-in validator
z.string().email('Must be valid email');
// BAD: refine for length
z.string().refine((s) => s.length >= 1, 'Required');
// GOOD: built-in constraint
z.string().min(1, 'Required');
// GOOD: refine for cross-field validation (no built-in alternative)
.refine((data) => {
const ids = new Set(data.participants.map((p) => p.id));
return data.events.every((e) => ids.has(e.participant_id));
}, 'All event participant IDs must exist in participants array')
// GOOD: extracted — reused, 3+ fields, domain concept
export const CoordinatesSchema = z.strictObject({
latitude: LatitudeSchema,
longitude: LongitudeSchema,
});
// GOOD: inline — simple, single-use
name: z.string().min(1).max(100).meta({
title: 'Name',
description: 'Name of the entity',
examples: ['Example Name'],
}),
Use consistent casing based on semantic meaning:
['None', 'Low', 'Medium', 'High']['mainnet', 'testnet']['KILOGRAM', 'DATE', 'CURRENCY']Use IsoDateTimeSchema for ISO 8601 strings and unix milliseconds for epoch timestamps. Always include the pattern in the field name:
created_at: IsoDateTimeSchema.meta({ ... }), // ISO 8601 string
pickup_date: IsoDateSchema.meta({ ... }), // ISO 8601 date only
minted_at_ms: z.number().int().meta({ ... }), // Unix milliseconds