option-patterns

Convert nullable TypeScript inputs to Option types and enforce exhaustive handling.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/aitchwhy/dotfiles --skill option-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: option-patterns
Source: https://github.com/aitchwhy/dotfiles/tree/main/config/agents/skills/option-patterns
Command: npx skills add https://github.com/aitchwhy/dotfiles --skill option-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Shows how to use Option to avoid nullability, ensure exhaustive handling.

Core Features & Use Cases

  • Convert nullable data to Option at boundaries
  • Pattern-match on Some/None
  • Map to JSON-friendly nulls when needed

Quick Start

Convert user.phone to Option at input and render a null-safe output when needed.

Frequently Asked Questions about option-patterns

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

FAQPage Schema
How do I eliminate null values from TypeScript code?

Option patterns eliminate nulls by converting nullable data to Option types at input boundaries using Option.fromNullable, then pattern-matching on Some/None cases. This enforces exhaustive handling so null checks become compile-time safe, preventing silent null propagation through your codebase.

How do I handle nullable fields in API responses safely?

Map API nullable fields to Option types at the boundary layer, converting JSON nulls with Option.fromNullable. Use Option.match to handle Some and None cases explicitly, and Option.getOrNull or Option.getOrElse to produce null-safe outputs when returning to callers or serializing back to JSON.

What's the difference between nullable types and Option?

Nullable types allow null silently; Option makes null handling explicit and mandatory. Option requires exhaustive pattern-matching on Some and None, catching null-related bugs at compile time rather than runtime, and works with Schema integration to validate domain types at API boundaries.

Can I use Option patterns with JSON schemas?

Yes. Option patterns integrate with Schema to map API nullable fields to domain Option types, enforcing type-safe conversion at boundaries. This allows you to validate and transform JSON payloads with nullable properties into Option-backed domain models automatically.

Do I need prior functional programming experience to use Option?

No. Option is a straightforward nullable container. Start by converting nullable inputs with Option.fromNullable, then use Option.match to handle Some and None cases. The pattern works in TypeScript without advanced functional programming knowledge.

When should I not use Option patterns?

Option works best for nullable domain data and API contracts. Avoid it for performance-critical paths where the overhead of wrapping matters, or when your codebase already has a established null-coalescing pattern. For simple leaf values without branching logic, plain nulls may suffice.