distinct-special-values
Installation
SKILL.md
Use a Distinct Type for Special Values
Overview
Don't use -1, 0, or "" as special values. Use null or a distinct type.
When a function can fail or have a special case, represent it with a type that TypeScript can distinguish, not an in-domain value like -1 that's just a regular number.
When to Use This Skill
- Functions that can fail (not found, error, etc.)
- Values that have a "missing" or "unknown" state
- Wrapping APIs that use sentinel values like -1
- Designing your own return types