fp-refactor

Migrates imperative TypeScript code to functional patterns using fp-ts Either, Option, and TaskEither.

3|2|Updated Feb 13, 2026
One-click install
npx skills add https://github.com/Yoodaddy0311/artibot --skill fp-refactor-yoodaddy0311
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: fp-refactor
Source: https://github.com/Yoodaddy0311/artibot/tree/main/plugins/artibot/skills/fp-refactor
Command: npx skills add https://github.com/Yoodaddy0311/artibot --skill fp-refactor-yoodaddy0311

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires fp-ts.

What problem does it solve? Converting imperative TypeScript code (try-catch blocks, null checks, callbacks, class-based DI) into composable functional patterns is error-prone without a clear migration strategy, and teams often struggle to adopt fp-ts incrementally without breaking existing code. ## Core Features & Use Cases - Pattern Mapping: Converts try-catch to Either/TaskEither, null checks to Option, callbacks to Task, class DI to Reader, and loops to map/filter/reduce. - Gradual Migration Strategy: Provides a three-phase approach using boundary adapters (toEither, fromNullable) so FP and imperative code coexist safely. - Composition Guidance: Teaches pipe()-based composition to replace nested calls and eliminate intermediate variables. - Use Case: A developer wants to eliminate try-catch error handling in a service layer; the skill shows how to wrap existing code with tryCatch, chain validations with E.chain, and propagate typed domain errors through the Either left channel. ## Quick Start Ask the AI to refactor a TypeScript function that uses try-catch and null checks into fp-ts Either and Option patterns with pipe composition.

Frequently Asked Questions about fp-refactor

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

FAQPage Schema
How do I convert try-catch to Either in TypeScript with fp-ts?▼

Use tryCatch from fp-ts/Either to wrap the throwing function and map the caught value to a typed error. For async code, use tryCatch from fp-ts/TaskEither so failures propagate through the type system instead of runtime exceptions.

How to replace null checks with Option in fp-ts?▼

Wrap the nullable value with fromNullable, then use chain and map inside a pipe to transform it. This forces callers to explicitly handle the None case instead of silently receiving undefined from optional chaining.

fp-ts Either vs async/await with try-catch, which is better?▼

TaskEither composes error handling in the type system and propagates failures automatically across chains of three or more async operations. For a single fetch call, plain async/await with try-catch is acceptable and simpler.

Can I adopt fp-ts gradually without rewriting my whole codebase?▼

Yes, gradual migration is the documented strategy. Start with boundary adapters like toEither and fromNullable so FP and imperative code coexist, then convert utilities, service layers, and domain models in phases.

When should I not refactor code to functional patterns with fp-ts?▼

Avoid FP refactoring for simple CRUD handlers, scripts without error branching, performance-critical paths, or teams with no FP experience and no learning budget. Also avoid modules with less than 60% test coverage since there is no safety net.