Reduce branching and nested control flow in TypeScript while preserving behavior; use when asked to simplify, flatten, or refactor conditional logic for testability/readability.
Installation
Installer avec Codex ou Claude Copiez ce prompt, collez-le dans Codex, Claude ou un autre assistant, puis laissez-le vérifier la page du skill et l'installer pour vous.
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.