Reduce branching and nested control flow in TypeScript while preserving behavior; use when asked to simplify, flatten, or refactor conditional logic for testability/readability.
Instalación
Instalar con Codex o Claude Copia este prompt, pégalo en Codex, Claude u otro asistente, y deja que revise la página de la skill y la instale por ti.
Reduce branching and nested control flow in TypeScript while preserving behavior; use when asked to simplify, flatten, or refactor conditional logic for testability/readability.
Flatten Branching in TypeScript
Workflow
Identify nested conditionals, repeated guards, and duplicated mapping/serialization logic.
Use early return/continue to flatten nested blocks.
Extract small helpers for repeated conversions (timestamps, DTO mapping, error handling).
Replace repeated boolean gates with named flags (e.g., shouldRedact, isUnauthorized).
Use switch for event-type fanout and delegate to small helpers where possible.
Build arrays with optional entries plus filter(Boolean) to avoid conditional pushes.
Keep behavior identical: compare inputs/outputs and error messages before and after.
Run relevant tests; add or update tests only if behavior would otherwise be ambiguous.
Prefer small loader helpers that return { table, state } | null to collapse repeated null checks.
Use a shared unary wrapper for gRPC handlers to eliminate per-handler try/catch blocks.