Free Cursor rule
Immutable state
Return the next value. Do not edit the object you already rendered.
The rule
---
description: Update React state by returning a new value.
globs: "**/*.{ts,tsx}"
alwaysApply: false
---
# Immutable state
- Do not push, splice, or assign into an object that is already in state.
- Build the next array or object, then set state to that value.
- For a click handler that updates a list, copy the list first.
- If two screens show the same fact, they should read one store, not two copies that drift.
How to use it
Copy the rule into .cursor/rules/immutable-state.mdc in your own project. It is free to use. It is a working habit from [Wann Labs](/), the public notes of BrandMatchGrowth, not a promise that your codebase will pass an audit.
If you want the same standard applied to a product people pay for, book a working session. The public product that came out of this shop-and-software work is OpenSign.