基于 SOC 职业分类
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/carrot-foundation/schemas --skill rule-naming-conventions命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 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-naming-conventions |
| description | Naming standards — snake_case properties, kebab-case files, PascalCase types and exports |
Apply this rule whenever work touches:
src/**/*.tsConsistent naming across schemas, files, and exports is non-negotiable for a published package. Every consumer interacts with these names directly.
snake_caseAll properties within Zod schemas use snake_case. This matches the JSON output format and the IPFS data conventions.
// GOOD: snake_case properties
const LocationSchema = z.strictObject({
administrative_division_code: z.string().meta({ ... }),
country_code: CountryCodeSchema.meta({ ... }),
facility_type: FacilityTypeSchema.meta({ ... }),
total_distance_km: z.number().min(0).meta({ ... }),
created_at: IsoDateTimeSchema.meta({ ... }),
});
// BAD: camelCase properties
const LocationSchema = z.strictObject({
administrativeDivisionCode: z.string(), // WRONG
countryCode: z.string(), // WRONG
facilityType: z.string(), // WRONG
});
This is a strict rule — there are no exceptions for "TypeScript convention". The schemas define data contracts, and those contracts use snake_case.
kebab-caseAll files and directories use kebab-case:
GOOD:
src/mass-id/mass-id.data.schema.ts
src/shared/schemas/primitives/ids.schema.ts
src/test-utils/fixtures/mass-id-data.fixture.ts
BAD:
src/massId/MassIdData.schema.ts // PascalCase dir + file
src/shared/schemas/UUID.schema.ts // UPPERCASE
src/mass_id/mass_id_data.schema.ts // snake_case
File naming patterns by type:
{entity}.schema.ts or {entity}.schemas.ts (plural when file contains multiple related schemas){entity}.schema.spec.ts (in __tests__/ directory){entity}.fixture.ts (in src/test-utils/fixtures/){entity}.types.ts{entity}.helpers.ts{entity}.constants.tsindex.ts (barrel exports)PascalCase with Schema suffixAll exported Zod schema constants use PascalCase with a Schema suffix:
// GOOD: PascalCase + Schema suffix
export const MassIDDataSchema = z.strictObject({ ... });
export const LocationSchema = z.strictObject({ ... });
export const ParticipantRoleSchema = z.enum([...]);
export const BlockchainReferenceSchema = z.strictObject({ ... });
export const WastePropertiesSchema = z.strictObject({ ... });
// BAD: missing suffix or wrong casing
export const massIdData = z.strictObject({ ... }); // camelCase, no suffix
export const MASS_ID_DATA_SCHEMA = z.strictObject({ ... }); // UPPER_CASE
export const massIDDataSchema = z.strictObject({ ... }); // camelCase
PascalCase without Schema suffixTypeScript types inferred from schemas drop the Schema suffix:
// GOOD: matches schema name without "Schema"
export type MassIDData = z.infer<typeof MassIDDataSchema>;
export type Location = z.infer<typeof LocationSchema>;
export type Participant = z.infer<typeof ParticipantSchema>;
// BAD: Schema suffix on type
export type MassIDDataSchema = z.infer<typeof MassIDDataSchema>; // Conflicts!
export type LocationSchemaType = z.infer<typeof LocationSchema>; // Redundant suffix
_id suffixFields that hold identifiers always end with _id:
// GOOD: _id suffix for identifiers
participant_id: UuidSchema.meta({ ... }),
location_id: UuidSchema.meta({ ... }),
external_id: ExternalIdSchema.meta({ ... }),
document_id: UuidSchema.meta({ ... }),
// BAD: no _id suffix or inconsistent
participant: UuidSchema.meta({ ... }), // Missing _id
participantId: UuidSchema.meta({ ... }), // camelCase
The only exception is id itself (the primary identifier of an entity), which does not need the prefix.
Use descriptive names that indicate what the timestamp represents:
// GOOD: descriptive timestamp names
created_at: IsoDateTimeSchema.meta({ ... }), // When created
updated_at: IsoDateTimeSchema.meta({ ... }), // When last modified
pickup_date: IsoDateSchema.meta({ ... }), // Date of pickup
recycling_date: IsoDateSchema.meta({ ... }), // Date of recycling
minted_at: IsoDateTimeSchema.meta({ ... }), // When NFT was minted
// BAD: vague timestamp names
date: IsoDateTimeSchema.meta({ ... }), // Date of what?
time: IsoDateTimeSchema.meta({ ... }), // Time of what?
timestamp: IsoDateTimeSchema.meta({ ... }), // Too generic
When a field represents a measurement, include the unit in the name:
// GOOD: unit in name
distance_km: z.number().min(0).meta({ ... }),
weight_kg: z.number().min(0).meta({ ... }),
duration_hours: z.number().min(0).meta({ ... }),
area_hectares: z.number().min(0).meta({ ... }),
total_distance_km: z.number().min(0).meta({ ... }),
// BAD: no unit
distance: z.number().min(0).meta({ ... }), // Kilometers? Miles?
weight: z.number().min(0).meta({ ... }), // Kilograms? Tons?
duration: z.number().min(0).meta({ ... }), // Hours? Seconds?
_code suffixFields holding standardized codes use the _code suffix:
// GOOD: _code suffix for standardized codes
country_code: CountryCodeSchema.meta({ ... }), // ISO 3166-1
administrative_division_code: z.string().meta({ ... }), // ISO 3166-2
currency_code: z.string().meta({ ... }), // ISO 4217
// BAD: missing _code suffix
country: z.string().meta({ ... }), // Ambiguous
admin_division: z.string().meta({ ... }), // Abbreviated + no suffix
camelCaseInternal variables and functions use standard TypeScript camelCase:
// GOOD: camelCase for functions and variables
export function uniqueArrayItems<T>(schema: T, message: string) { ... }
const parsedResult = schema.safeParse(data);
const schemaVersion = getSchemaVersionOrDefault();
This is distinct from schema property names (which are snake_case). The distinction is clear: schema properties define data contracts, while variables and functions are TypeScript implementation details.