| name | fp-pipeline-refactor |
| description | Refactor imperative TypeScript to Effect-first pipeline composition using curried data-first/data-last APIs, Effect collections, and schema-based IO boundaries. |
FP Pipeline Refactor
Use this skill when code needs to move from imperative style to Effect + kitz functional composition.
Goals
- Prefer pipeline-friendly composition over statement-by-statement mutation.
- Use Effect-native data structures:
HashMap / HashSet
- mutable variants only when profiling proves they are needed.
- Remove untyped boundaries:
- avoid
JSON.parse
- avoid
try/catch
- avoid
Promise orchestration
- avoid
any and type assertions
- Bridge untyped IO with
Schema decode/encode at boundaries.
Repeatable Refactor Flow
- Identify imperative hotspots.
- Normalize data flow into pure transforms and
Effect.gen orchestration.
- Replace native
Map/Set with Effect HashMap/HashSet where the module is already in Effect context.
- Replace
JSON.parse with Schema.decodeUnknown* and explicit schema models.
- Replace
try/catch with Effect.try, Effect.tryPromise, Either, Option, and typed error channels.
- Replace promise chains with
Effect combinators (Effect.all, Effect.forEach, Effect.promise, Effect.async).
- Remove
any and assertions (as, <T>) by introducing schema/constructor functions at boundaries.
- Run lint/tests and keep behavior stable.
Refactor Prompt Template
Refactor this module to Effect-first functional composition.
Constraints:
- Use pipeline-friendly, curried composition patterns.
- Prefer Effect data structures (`HashMap`/`HashSet`; mutable variants only if necessary).
- No `JSON.parse` (use Effect Schema decode/encode codecs).
- No `try/catch` (use `Effect.try`, `Either`, `Option`, typed errors).
- No Promise orchestration (use Effect combinators only).
- No `any`, no assertion casts; rely on inference + schema at IO boundaries.
Deliverables:
1. Updated implementation.
2. Updated tests proving behavior unchanged.
3. Short notes listing removed anti-patterns and replacement patterns.