소스 정보
- 저장소
- 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-code-comments명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
SOC 직업 분류 기준
SKILL.md 표시 중
| name | rule-code-comments |
| description | When and how to write effective comments — favor self-documenting code |
Apply this rule whenever work touches:
src/**/*.tsWell-named schemas and types are the primary documentation. Comments supplement when the code alone cannot convey intent, constraints, or domain knowledge.
The best comment is no comment. If you feel the need to add a comment, first ask: can I rename this variable, function, or type to make the comment unnecessary?
// BAD: comment restates what the code does
// Parse the input data
const parsedData = parseInput(data);
// BAD: comment explains a cryptic name
// Maximum number of retries
const mr = 3;
// GOOD: name is self-documenting
const maxRetries = 3;
const parsedInput = parseInput(data);
When a comment is necessary, it should explain the reason behind a decision — not narrate the code.
// BAD: restates the code
// Check if weight is greater than zero
if (weight_kg > 0) { ... }
// GOOD: explains domain constraint
// Negative weights indicate measurement errors and must be rejected
// per methodology rule MR-2024-003
if (weight_kg > 0) { ... }
// BAD: obvious comment
// Create a strict object schema
const LocationSchema = z.strictObject({ ... });
// GOOD: explains non-obvious design decision
// strictObject prevents extra properties from silently passing validation,
// which is critical for IPFS data integrity — any extra field would
// change the content hash
const LocationSchema = z.strictObject({ ... });
Schema libraries encode business rules. Document the domain knowledge that future developers will not find in the code.
// GOOD: domain context that cannot be inferred from code
// ISO 3166-2 subdivision codes (e.g., "BR-SP" for Sao Paulo, Brazil).
// Required by the MassID methodology for geographic attribution of
// waste collection impact.
const AdministrativeDivisionCodeSchema = z
.string()
.regex(/^[A-Z]{2}-[A-Z0-9]+$/);
// GOOD: explains constraint origin
// Maximum 17 attributes enforced by the smart contract's mint function.
// Adding more requires a contract upgrade.
const MassIDAttributesSchema = z.array(AttributeSchema).max(17);
Use TSDoc (/** ... */) sparingly — only for exported symbols where the name and type signature are insufficient.
// GOOD: TSDoc adds value for a utility with non-obvious behavior
/**
* Creates a Zod schema that validates array items are unique by a selector.
* Uses Set-based comparison for uniqueness checking.
*
* @param schema - The Zod schema for individual array items
* @param selector - Function to extract the uniqueness key from each item
* @param errorMessage - Custom error message for duplicate violations
*/
export function uniqueBy<T extends z.ZodTypeAny, K>(
schema: T,
selector: (item: z.infer<T>) => K,
errorMessage?: string,
) { ... }
// BAD: TSDoc adds no value — name and types are clear
/**
* The MassID data schema.
* Validates MassID data objects.
* @type {z.ZodObject}
*/
export const MassIDDataSchema = z.strictObject({ ... });
Skip TSDoc entirely when the export name, type signature, and .meta() already communicate everything. Schema exports with good .meta() titles and descriptions rarely need additional TSDoc.
Never commit commented-out code. Use version control to retrieve old code. If code is temporarily disabled, use a clear mechanism:
// BAD: dead code polluting the file
// const OldSchema = z.object({
// legacy_field: z.string(),
// });
// ACCEPTABLE: feature flag with tracking
// TODO(SCHEMAS-456): re-enable after v2 migration
const ENABLE_EXTENDED_VALIDATION = false;
TODOs must include context and a tracking reference. Bare TODOs are not acceptable.
// BAD: no context, no tracking
// TODO: fix this
// BAD: context but no tracking
// TODO: handle edge case for empty arrays
// GOOD: context + tracking reference
// TODO(SCHEMAS-789): add validation for negative coordinates
// after methodology team confirms the constraint rules
// GOOD: context + owner for short-term items
// TODO(@username): extract to shared utility before merging
.meta() as documentationIn this project, .meta() is a form of documentation. Use it to document fields instead of inline comments:
// BAD: comment next to field
// The UUID identifier for external system references
external_id: ExternalIdSchema,
// GOOD: meta serves as structured documentation
external_id: ExternalIdSchema.meta({
title: 'External ID',
description: 'UUID identifier for external system references',
}),
This approach generates documentation automatically via JSON Schema output, making it more useful than static comments.