Reduce branching and nested control flow in TypeScript while preserving behavior; use when asked to simplify, flatten, or refactor conditional logic for testability/readability.
설치
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
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.