ecs-component-mutators

Encapsulate reusable component update logic in mutator classes for ECS architectures.

Updated Jan 1, 2026
One-click install
npx skills add https://github.com/ViewableGravy/better-ecs --skill ecs-component-mutators
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ecs-component-mutators
Source: https://github.com/ViewableGravy/better-ecs/tree/main/.github/skills/ecs-component-mutators
Command: npx skills add https://github.com/ViewableGravy/better-ecs --skill ecs-component-mutators

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill addresses the challenge of managing repetitive component update logic across multiple systems in an Entity-Component-System (ECS) architecture, preventing code duplication and promoting maintainability.

Core Features & Use Cases

  • Pure State Components: Ensures components remain data-only, separating state from behavior.
  • Reusable Mutator Logic: Encapsulates common update patterns into dedicated mutator classes.
  • Allocation-Light Systems: Reduces object creation within performance-critical game loops.
  • Use Case: In a game, managing cooldown timers for abilities is a common task. Instead of writing the cooldown tick logic in every system that uses a cooldown, a CooldownMutator can be reused, ensuring consistent behavior and cleaner system code.

Quick Start

Run the validation script for the ecs-component-mutators skill.

Frequently Asked Questions about ecs-component-mutators

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

FAQPage Schema
How do I avoid duplicating component update logic across multiple ECS systems?

You can avoid duplicating component update logic by centralizing it in mutator classes. This approach encapsulates common update patterns into dedicated mutator instances, keeping components as pure state containers and improving system clarity.

What is a mutator class in Entity-Component-System architecture?

A mutator class in ECS architecture is a dedicated structure that encapsulates reusable component update behavior. It separates behavior from data by keeping components as pure state containers while managing state updates through bound instances.

How do I keep TypeScript ECS components allocation-light in game loops?

Keep TypeScript ECS components allocation-light by encapsulating behavior in mutator classes rather than components. This reduces object creation within performance-critical game loops by ensuring components remain pure state containers managed by reusable mutators.

Does this mutator pattern work with declarative ECS systems?

Yes, the mutator pattern supports declarative, allocation-light ECS systems. By keeping components as pure state containers and encapsulating behavior in bound mutator instances, it maintains the declarative structure while managing state updates efficiently.

When should I use mutator classes instead of writing system logic directly?

Use mutator classes when you have repetitive component update patterns across multiple systems, such as game ability cooldown timers. Mutators ensure consistent behavior, reduce code duplication, and improve overall system clarity.