Agent skill · Databases

fp-refactor

Comprehensive guide for refactoring imperative TypeScript code to fp-ts functional patterns

Nick44,086★ · +407/wk · 1 repos on radarProfile →
claude-codecodexcursorMIT
Install
npx skills add sickn33/agentic-awesome-skills --skill fp-refactor --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 1
SKILL.md size: 45 KB
Bundled scripts: none
Version: 1.0.0
Declared author: fp-ts-skills
Path: skills/fp-refactor/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 44,414 · +328 this week
Language: Python
Read our review of the source →

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

Review
written from the skill's own SKILL.md · Aug 5, 2026

What it does

This skill provides comprehensive patterns and strategies for migrating existing imperative TypeScript code to fp-ts functional programming patterns.

How it works

  • When refactoring, it suggests converting try/catch blocks to Either or TaskEither, including synchronous and asynchronous examples, and provides a step-by-step refactoring guide:
    1. Identify the error type
    2. Change return type to Either<E, T>
    3. Replace throw statements with E.left(...)
    4. Replace returns with E.right(...)
    5. Remove try-catch blocks
    6. Update callers using pipe with E.flatMap
  • It shows converting null/undefined checks to Option, including wrapping nullable values with fromNullable, changing return types to Option, and using O.map/O.flatMap, with explicit boundary handling via getOrElse or match.
  • It covers converting callbacks to Task, including Node-style callbacks to Task, and wrapping fs/promises in TaskEither with examples for reading and writing files, and composing multiple files.
  • It includes patterns for converting class-based DI to Reader, and converting imperative loops to functional operations, though the provided excerpt focuses on the above three areas.
  • It provides concrete code patterns: functions like parseJSON to Either, fetchUser to TaskEither, getDatabaseUrl to Option, findUserById to Option, readFile/writeFile to TaskEither, and multi-file processing via traverse.

When to use it

  • You are refactoring an existing imperative TypeScript codebase toward fp-ts patterns.
  • The task involves converting try/catch, null checks, callbacks, DI, or loops into functional equivalents.
  • You need migration guidance and tradeoffs, not just isolated fp-ts examples.

What it can touch

  • The skill references and demonstrates touchpoints with:
    • fp-ts/Either, fp-ts/TaskEither, fp-ts/Option
    • pipe from fp-ts/function
    • Specific utilities: TE.tryCatch, TE.flatMap, TE.map, E.left, E.right, O.fromNullable, O.map, O.flatMap, O.match, A.findFirst, A.traverse
    • File system APIs: fs.readFile, fs.writeFile (demonstrated via fs/promises in examples)

Caveats

  • Declared risk: critical
  • The skill provides patterns and examples; outcomes depend on correct application to actual codebases
  • It emphasizes not to speculate beyond the coded patterns and to follow the step-by-step guides shown for refactoring
From the SKILL.md

# Refactoring Imperative Code to fp-ts This skill provides comprehensive patterns and strategies for migrating existing imperative TypeScript code to fp-ts functional programming patterns. ## When to Use - You are refactoring an existing imperative TypeScript codebase toward fp-ts patterns. - The task involves converting `try/catch`, null checks, callbacks, DI, or loops into functional equivalents. - You need migration guidance and tradeoffs, not just isolated fp-ts examples. ## Table of Contents 1. [Converting try-catch to Either/TaskEither](#1-converting-try-catch-to-eithertaskeither) 2. [Converting null checks to Option](#2-converting-null-checks-to-option) 3. [Converting callbacks to Task](#3-converting-callbacks-to-task) 4. [Converting class-based DI to Reader](#4-converting-class-based-di-to-reader) 5. [Converting imperative loops to functional operations](#5-converting-imperative-loops-to-functional-operations) 6. [Migrating Promise chains to TaskEither](#6-migrating-promise-chains-to-taskeither) 7. [Common Pitfalls](#7-common-pitfalls) 8. [Gradual Adoption Strategies](#8-gradual-adoption-strategies) 9. [When NOT to Refactor](#9-when-not-to-refactor) --- ## 1. Converting try

What's inside
Steps it walks through
  1. When to Use
  2. Table of Contents
  3. 1. Converting try-catch to Either/TaskEither
  4. The Problem with try-catch
  5. Pattern: Synchronous try-catch to Either
  6. Step-by-Step Refactoring Guide
  7. Pattern: Async try-catch to TaskEither
  8. Helper: tryCatch Utility
  9. 2. Converting null checks to Option
  10. The Problem with null/undefined
  11. Pattern: Simple null checks to Option
  12. Pattern: Array find operations
  13. Converting Between Option and Either
  14. 3. Converting callbacks to Task
More from agentic-awesome-skills
All skills →
About this skill
What does the fp-refactor skill do?

Comprehensive guide for refactoring imperative TypeScript code to fp-ts functional patterns

How do I install it?

Run `npx skills add sickn33/agentic-awesome-skills --skill fp-refactor --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From sickn33/agentic-awesome-skills, a repository with 44,414 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going