fp-backend
Functional programming patterns for Node.js/Deno backend development using fp-ts, ReaderTaskEither, and functional dependency injection
npx skills add sickn33/agentic-awesome-skills --skill fp-backend --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
What it does
Describes a set of functional programming patterns for building type-safe, testable backends in Node.js or Deno using fp-ts. It emphasizes using ReaderTaskEither for dependency-aware computations, service composition, and functional dependency injection. It includes examples of defining service modules, composing services, building a dependency container, and running programs with dependencies. It also covers Prisma-based database wrappers, transaction handling, and middleware integration (Express).
How it works
- Core concept is ReaderTaskEither (RTE) to thread dependencies (Reader), asynchronous effects (Task), and potential errors (Either) through service calls.
- Service modules export RTE-returning functions (e.g., create, findById, findMany) that consume a dependencies object via RTE.ask and access db, hasher, mailer, etc.
- Composition patterns show combining multiple services (e.g., UserService, ProductService, PaymentService) using RTE.Do and RTE.bind to build composite results (e.g., createOrder).
- Dependency injection is implemented by building a dependency container in src/deps.ts, layering config, infrastructure (db/redis/logger), and services (hasher, jwt, mailer) to produce AppDeps. A buildDeps function assembles all layers; destroyDeps handles cleanup.
- Running programs uses a program: RTE.ReaderTaskEither<AppDeps, AppError, void> that is invoked with the constructed dependencies. The main flow starts the server, logs startup, and ensures cleanup on exit.
- Prisma wrappers and transaction handling demonstrate error mapping, domain-specific errors, and rolling back on transaction failure via withTransaction, which wraps a program to execute inside a Prisma transaction.
- Express middleware demonstrates converting an RTE handler into an Express RequestHandler and handling errors to HTTP responses.
When to use it
- You are building or refactoring a Node.js or Deno backend with fp-ts.
- The task involves dependency injection, service composition, or typed backend errors with
ReaderTaskEither. - You need functional backend architecture patterns rather than isolated utility snippets.
What it can touch
- Dependencies container and environment: src/deps.ts
- Service modules and domain types: src/services/* (e.g., user.service.ts, order.service.ts)
- Database and Prisma wrappers: src/lib/db.ts, src/lib/transaction.ts
- Middleware integration: src/middleware/fp-express.ts
- Main program entry: src/main.ts
- Prisma models and error handling as defined in the examples
Caveats
- The material defines a risk level of critical.
- The approach relies on TypeScript with fp-ts types (ReaderTaskEither, TaskEither, Either) and Prisma; compatibility depends on project setup.
- It uses explicit domain error tagging and mapping; extend or adjust error types to fit your domain.
- No guarantees of runtime behavior are stated beyond the patterns and examples.
# fp-ts Backend Patterns Functional programming patterns for building type-safe, testable backend services using fp-ts. ## When to Use - You are building or refactoring a Node.js or Deno backend with fp-ts. - The task involves dependency injection, service composition, or typed backend errors with `ReaderTaskEither`. - You need functional backend architecture patterns rather than isolated utility snippets. ## Core Concepts ### ReaderTaskEither (RTE) The `ReaderTaskEither<R, E, A>` type is the backbone of functional backend development: - **R** (Reader): Dependencies/environment (database, config, logger) - **E** (Either left): Error type - **A** (Either right): Success value ```typescript import * as RTE from 'fp-ts/ReaderTaskEither' import * as TE from 'fp-ts/TaskEither' import { pipe } from 'fp-ts/function' // Define your dependencies type Deps = { db: DatabaseClient logger: Logger config: Config } // Define domain errors type AppError = | { _tag: 'NotFound'; resource: string; id: string } | { _tag: 'ValidationError'; message: string } | { _tag: 'DatabaseError'; cause: unknown } | { _tag: 'Unauthorized'; reason: string } // A service function const getUser = (id: string): RTE.Rea
- When to Use
- Core Concepts
- ReaderTaskEither (RTE)
- Service Layer Patterns
- Defining Service Modules
- Composing Services
- Functional Dependency Injection
- Building the Dependency Container
- Running Programs with Dependencies
- Database Operations
- Prisma Wrappers
- Transaction Handling
- Middleware Patterns
- Express Middleware
What does the fp-backend skill do?
Functional programming patterns for Node.js/Deno backend development using fp-ts, ReaderTaskEither, and functional dependency injection
How do I install it?
Run `npx skills add sickn33/agentic-awesome-skills --skill fp-backend --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.