Apply functional programming composition techniques in JavaScript and TypeScript. Use this skill whenever the user asks about function composition, pipe, compose, currying, partial application, point-free style, pure functions, immutability, functors, monads, lenses, functional mixins, factory functions, or object composition. Also trigger when the user asks how to avoid class inheritance, how to build reusable abstractions in JavaScript or TypeScript, how to compose async operations, how to reduce coupling through FP patterns, TypeScript composition, or functional TypeScript. Even if they just say "compose these functions", "pipe this data", or "make this more functional", use this skill. DO NOT USE when: the user is designing class-based OOP architecture or asking about SOLID principles — use `oop-principles` instead.
التثبيت
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
Apply functional programming composition techniques in JavaScript and TypeScript. Use this skill whenever the user asks about function composition, pipe, compose, currying, partial application, point-free style, pure functions, immutability, functors, monads, lenses, functional mixins, factory functions, or object composition. Also trigger when the user asks how to avoid class inheritance, how to build reusable abstractions in JavaScript or TypeScript, how to compose async operations, how to reduce coupling through FP patterns, TypeScript composition, or functional TypeScript. Even if they just say "compose these functions", "pipe this data", or "make this more functional", use this skill. DO NOT USE when: the user is designing class-based OOP architecture or asking about SOLID principles — use `oop-principles` instead.
Identify the coupling — is the problem inheritance, shared mutable state, or entangled side effects? See Composition Hierarchy below.
Choose the composition tool — pure function → factory → functional mixin → class (last resort). Use the Checklist below.
Apply the pattern — read the matching reference file for the concrete technique.
Verify — can the new unit be tested without mocks? Can it be reused without importing its collaborators?
Central thesis: all software design is composition — breaking problems down into small pieces and composing solutions back up. The choice of how to compose shapes everything about maintainability, testability, and flexibility.
Core Vocabulary
Term
Definition
Pure function
Same input → same output, no side effects
Composition
Combining small functions into a larger one by feeding each output as the next input
Currying
Transform (a, b) => c into a => b => c
Partial application
Fix some arguments, return a function for the rest
Point-free
Define functions without mentioning their arguments
Functor
A container with a .map() method that obeys functor laws
Monad
A functor that also flattens nested contexts via .chain()
Lens
A composable getter/setter pair for immutable nested state
Read On Demand
Read When
File
Writing pure functions, composing with pipe/compose, debugging pipelines
PASS (run 2026-06-25, strongest signal). Decisive — haiku 0→83, opus 17→100. Baselines reach for extends; the skill enforces composition (factory/mixin) and correctly DEFERS the SRP follow-up to oop-principles (anti-trigger holds). Gate per skill-optimizer/release-gates.md.