rule-code-style

Enforce naming, nesting, and file organization conventions for schema codebases.

1|Updated Apr 17, 2025
One-click install
npx skills add https://github.com/carrot-foundation/schemas --skill rule-code-style
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rule-code-style
Source: https://github.com/carrot-foundation/schemas/tree/main/.agents/skills/rule-code-style
Command: npx skills add https://github.com/carrot-foundation/schemas --skill rule-code-style

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

The schemas package benefits from consistent, readable code; this rule codifies conventions to reduce cognitive load, prevent drift, and streamline maintenance across all schema modules.

Core Features & Use Cases

  • Naming: use descriptive, intention-revealing names; functions should be verbs; variables are nouns.
  • Guard clauses and early returns: flatten control flow by handling edge cases first to keep the happy path clear.
  • Nesting depth: limit nesting to two levels; extract helpers when adding a third level.
  • Functional patterns: prefer pure functions and simple data transformations over unnecessary classes.
  • Single responsibility: ensure functions do one thing and separate concerns when they grow.
  • File organization: organize by role with clear file naming and separation of schemas, types, and utilities.
  • Error handling & formatting: follow safe parsing, consistent error reporting, and automatic formatting per project standards.

Quick Start

Apply these style guidelines to new and existing schema files to ensure consistency.

Frequently Asked Questions about rule-code-style

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enforce consistent naming conventions and code style in schema files?

To enforce consistent code style in schema files, apply rules requiring descriptive, intention-revealing names, verb-based functions, and noun-based variables to reduce cognitive load and prevent drift across modules.

What is the best way to limit nesting depth and flatten control flow in schemas?

The best way to limit nesting depth in schemas is using guard clauses and early returns to handle edge cases first, keeping the happy path clear and restricting nesting to two levels before extracting helpers.

How do I organize schema files by role and separate concerns effectively?

Organize schema files by role with clear file naming and strict separation of schemas, types, and utilities to ensure single responsibility, streamline maintenance, and separate concerns when functions grow.

When should I use guard clauses and functional patterns over classes in schema development?

Use guard clauses and functional patterns in schema development when you need pure functions and simple data transformations, preferring them over unnecessary classes to maintain readability and flatten control flow.

Does this code style rule require automatic formatting and safe parsing for error handling?

Yes, the code style rule requires automatic formatting per project standards, safe parsing, and consistent error reporting to provide robust error handling guidance and ensure clear documentation structure.