distinct-special-values

Community

Give special states a distinct type, not -1.

Authorluyi985
Version1.0.0
Installs0

System Documentation

What problem does it solve?

Don't use -1, 0, or "" as special values. Use null or a distinct type to represent missing or exceptional states, enabling TypeScript to distinguish them and prevent logic errors.

Core Features & Use Cases

  • Use null, undefined, or tagged unions to model "missing" or "unknown" states.
  • Wrap APIs that rely on sentinel values like -1 to expose safe types.
  • Prefer explicit error states and well-defined return types to reduce bugs in large codebases.

Quick Start

Refactor functions that use sentinel values like -1 or "" to return a distinct type (e.g., number | null or a tagged union) and update call sites to handle the new type.

Dependency Matrix

Required Modules

None required

Components

Standard package

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: distinct-special-values
Download link: https://github.com/luyi985/lyi-bash/archive/main.zip#distinct-special-values

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.