소스 정보
- 저장소
- carrot-foundation/schemas
- 최근 소스 활동
- 2026년 3월 25일 20:55
- 감지된 SKILL.md 언어
- 영어
- 스타
- 1
- 포크
- 0
설치 방법
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
소스 파일 검토
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
메뉴
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
SOC 직업 분류 기준
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/carrot-foundation/schemas --skill rule-code-style명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
SKILL.md 표시 중
Schema version injection, $id format, and SCHEMA_VERSION environment variable
Generated JSON Schema structure — required fields, validation patterns, and $ref usage
Use when a task is complete and needs the full check, commit, and PR workflow
| name | rule-code-style |
| description | Readable, consistent, and well-structured code across the schemas package |
Apply this rule whenever work touches:
*The schemas package is a published library consumed by many services. Readability and consistency directly affect developer experience across the organization.
Use descriptive, intention-revealing names. Functions should be verbs that describe what they do. Variables should be nouns that describe what they hold.
// BAD: abbreviated, unclear intent
const val = getRes(inp);
const cb = (d: unknown) => proc(d);
// GOOD: descriptive and clear
const parsedSchema = parseSchemaFromInput(rawInput);
const validateDocument = (data: unknown) => DocumentSchema.safeParse(data);
Industry-standard abbreviations are acceptable: id, url, api, uuid, nft, ipfs. Everything else should be spelled out.
Flatten control flow by handling edge cases first. This reduces nesting and makes the "happy path" obvious.
// BAD: deeply nested
function processSchema(input: unknown) {
if (input !== null) {
if (typeof input === 'object') {
if ('type' in input) {
return SchemaMap[input.type];
}
}
}
return undefined;
}
// GOOD: guard clauses
function processSchema(input: unknown) {
if (input === null || typeof input !== 'object') {
return undefined;
}
if (!('type' in input)) {
return undefined;
}
return SchemaMap[input.type];
}
Maximum nesting depth is 2 levels. If you find yourself adding a third level, extract a helper function.
// BAD: 3 levels deep
function validateAll(schemas: SchemaConfig[]) {
for (const config of schemas) {
if (config.enabled) {
for (const field of config.fields) {
// 3 levels — too deep
}
}
}
}
// GOOD: extracted helper
function validateFields(fields: FieldConfig[]): ValidationResult[] {
return fields.map((field) => validateField(field));
}
function validateAll(schemas: SchemaConfig[]) {
const enabledSchemas = schemas.filter((config) => config.enabled);
return enabledSchemas.flatMap((config) => validateFields(config.fields));
}
Prefer functional patterns over classes. This package defines schemas and utilities — pure functions and data transformations are the natural fit.
// BAD: unnecessary class
class SchemaValidator {
private schema: z.ZodType;
constructor(schema: z.ZodType) {
this.schema = schema;
}
validate(data: unknown) {
return this.schema.safeParse(data);
}
}
// GOOD: simple function
function validateWithSchema<T extends z.ZodType>(
schema: T,
data: unknown,
): z.SafeParseReturnType<z.input<T>, z.output<T>> {
return schema.safeParse(data);
}
Use Array.map, Array.filter, Array.reduce, and Array.flatMap instead of imperative loops when transforming data.
Each function should do one thing. If a function name contains "and", it likely needs splitting.
// BAD: does two things
function parseAndValidateSchema(input: string) {
const parsed = JSON.parse(input);
return MassIDDataSchema.parse(parsed);
}
// GOOD: separated concerns
function deserializeInput(input: string): unknown {
return JSON.parse(input);
}
function validateMassIDData(data: unknown): MassIDData {
return MassIDDataSchema.parse(data);
}
Organize files by their role:
*.schema.ts / *.schemas.ts — Zod schema definitions*.types.ts — TypeScript type definitions (when not inferred from Zod)*.constants.ts — constants and enums*.helpers.ts — pure utility functionsindex.ts — barrel exports for public APIKeep files focused. A schema file should contain related schemas and their inferred types, not validation logic or utilities.
Never swallow errors silently. Use .safeParse() and handle both success and failure paths explicitly.
// BAD: silent failure
try {
return schema.parse(data);
} catch {
return undefined;
}
// GOOD: explicit error handling
const result = schema.safeParse(data);
if (!result.success) {
throw new ValidationError('Invalid schema data', result.error.issues);
}
return result.data;