fp-immutable

Implement immutable TypeScript state updates using spread patterns and readonly types.

11|3|Updated Jan 30, 2026
One-click install
npx skills add https://github.com/whatiskadudoing/fp-ts-skills --skill fp-immutable
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: fp-immutable
Source: https://github.com/whatiskadudoing/fp-ts-skills/tree/main/skills/fp-immutable
Command: npx skills add https://github.com/whatiskadudoing/fp-ts-skills --skill fp-immutable

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Immutable state updates in TypeScript can be error-prone and hard to reason about, leading to bugs when mutating shared state or nested structures. This Skill provides practical patterns to perform safe immutable updates using spread operators, readonly types, and optional tooling like Immer, enabling predictable state management and easier debugging.

Core Features & Use Cases

  • Spread-based updates for arrays and objects, including nested structures.
  • Readonly typing and deep immutability concepts to prevent accidental mutations.
  • Common tasks and patterns for UI state management, data transformation, and safe object composition.
  • Optional Immer-based workflow for complex updates while preserving immutability.

Quick Start

  • Create a TypeScript project and implement a few immutable updates using the patterns shown in the Skill.
  • Try updating a nested state object and verify old versions remain unchanged.

Frequently Asked Questions about fp-immutable

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

FAQPage Schema
How do I update nested state immutably in TypeScript?

To update nested state immutably in TypeScript, apply spread-based patterns at each nesting level to create new object references while preserving the original state structure. This ensures predictable state management without accidental mutations.

How does readonly typing prevent accidental state mutations in TypeScript?

Readonly typing prevents accidental state mutations in TypeScript by enforcing immutability at compile-time, restricting property assignments on objects and arrays to ensure safe, branchless updates in UI state workflows.

What's the best way to manage immutable state in React or Redux-like workflows?

The best way to manage immutable state in React or Redux-like workflows is using spread operators for shallow updates and optional tooling like Immer for complex nested structures to guarantee reliable state transformations.

Do I need Immer to handle complex immutability patterns in TypeScript?

You do not need Immer to handle immutability patterns in TypeScript, as spread operators and readonly types cover basic nested updates. Immer is an optional tooling choice for managing complex updates while preserving immutability.

Why does updating shared TypeScript state cause bugs and how can I fix it?

Updating shared TypeScript state causes bugs because direct mutations make state changes hard to track. Fix this by applying immutable update patterns, using spread operators and readonly types to avoid mutating shared structures.