avoid-arbitrary-stateful-objects

Installation
SKILL.md

Summary

Minimize the use of long-lived, mutable objects (state containers). Prefer passing immutable data through stateless functions. When state is required, use explicit creation patterns like Factory or Builder rather than ad-hoc stateful classes.

Rationale

  • Predictability: Stateless functions are easier to test and reason about because their output depends only on their input.
  • Debugging: Tracking state mutation across an application is a common source of bugs. Hidden state makes reproduction difficult.
  • Concurrency: Immutable data is inherently safe to share across async contexts or threads (in environments that support it).

Guidance

  1. Immutability: Prefer readonly properties and const variables.
  2. Pure Functions: Write logic as functions that take data and return new data, without mutating this.
  3. Controlled State: If you need state (e.g., a connection pool, a cache), use a Factory function to create it explicitly, rather than hiding it inside a class constructor's side effects.

Examples

Installs
1
First Seen
Apr 5, 2026
avoid-arbitrary-stateful-objects — mew-ton/coding-guidelines