From dm-arch
Apply when encountering switch/if-else dispatch on entity type, designing entity systems, or refactoring toward extensibility. Provides registry-based dispatch, capability composition, and infrastructure-first patterns. Complements solid-architecture.
How this skill is triggered — by the user, by Claude, or both
Slash command
/dm-arch:data-oriented-architectureThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Activate this skill when:
Activate this skill when:
Separate data from behavior, dispatch via registry.
Entity = Pure Data (what it IS) + type discriminator
Definition = Bundled Behavior (what it DOES)
Registry = Type → Definition mapping (HOW to dispatch)
Switch statements scattered throughout codebase:
// Scattered in rendering.ts
switch (entity.type) {
case 'typeA': renderA(entity); break;
case 'typeB': renderB(entity); break;
}
// Scattered in update.ts
switch (entity.type) {
case 'typeA': updateA(entity); break;
case 'typeB': updateB(entity); break;
}
// Adding new type = edit N files
Single registry bundling all type-specific behavior:
// definitions.ts - ONE location for all type-specific code
const DEFS: Record<EntityType, Definition> = {
typeA: { render: renderA, update: updateA, ... },
typeB: { render: renderB, update: updateB, ... },
};
// Consumers dispatch generically
DEFS[entity.type].render(entity, ctx);
DEFS[entity.type].update(entity, dt);
// Adding new type = ONE registry entry, ZERO consumer changes
Definition interface with all operationsDEFS: Record<Type, Definition> registrygetDef(type): Definition helpergetDef(entity.type).operation()Record, Rust match)Not all entities need all behaviors. Deep inheritance or marker interfaces create coupling.
Optional capability configs with type guards:
interface Definition<T> {
// Required for all
create(): T;
render(): void;
// Optional capabilities - entities opt-in
collision?: CollisionConfig;
physics?: PhysicsConfig;
persistence?: PersistenceConfig;
}
// Type guard for safe access
function hasCollision(def): def is Definition & { collision: CollisionConfig } {
return def.collision !== undefined;
}
// Consumer checks capability
if (hasCollision(def)) {
collisionSystem.register(entity, def.collision);
}
BaseDefinition (create, render, layer)
↓ extends
DomainDefinition (domain-specific: AI, weapons)
↓ implemented by
ConcreteDefinitions (typeA, typeB, typeC)
// Base - works for any domain
interface EntityDefinition<TState, TType> {
type: TType;
create(pos): TState;
update?(entity, ctx): void;
render(entity, ctx): void;
collision?: CollisionConfig;
physics?: PhysicsConfig;
}
// Domain-specific extension
interface EnemyDefinition extends EntityDefinition<EnemyState, EnemyType> {
aiStrategy: AIStrategy;
weapons: WeaponConfig[];
}
// Another domain
interface PickupDefinition extends EntityDefinition<PickupState, PickupType> {
onCollect(collector): void;
floatAnimation: AnimationConfig;
}
Functions with many parameters, hard to extend.
Bundle related parameters into context objects:
// Bad - hard to extend
function update(entity, dt, playerPos, playerVel, gravity, time) { ... }
// Good - extensible
interface UpdateContext {
dt: number;
playerPos: Vec2;
playerVel: Vec2;
// Easy to add fields without breaking signatures
}
function update(entity, ctx: UpdateContext) { ... }
interface BaseContext { dt: number; }
interface AIContext extends BaseContext { playerPos: Vec2; threats: Entity[]; }
interface RenderContext { graphics: Graphics; screenPos: Vec2; scale: number; }
If writing a switch statement on entity type, infrastructure is missing.
Adding new type requires editing N files. Fix: Consolidate into registry.
SpecialEnemy extends FlyingEnemy extends Enemy extends Entity
Fix: Capability composition.
interface Entity {
weapon?: Weapon; // null checks everywhere
}
Fix: Separate capability with type guard.
Creating registry for 1 type. Fix: Wait for second type to validate pattern.
Definition with 50 fields for every possible behavior. Fix: Required base + optional capabilities.
Use language features to ensure all types are handled:
// TypeScript - Record requires all keys
const DEFS: Record<EntityType, Definition> = {
// Compiler error if type missing
};
// Helper for switch exhaustiveness
function assertNever(x: never): never {
throw new Error(`Unexpected: ${x}`);
}
When designing entity systems:
npx claudepluginhub rbergman/dark-matter-marketplace --plugin dm-archGuides module and component design using paradigm-agnostic principles: Composition Over Inheritance, Law of Demeter, Tell Don't Ask, Encapsulation. Examples in Elixir and TypeScript/React.
Provides Unity ECS patterns with DOTS, Jobs, and Burst for high-performance games, managing thousands of entities, data-oriented systems, and CPU optimization.
Provides Domain-Driven Design tactical patterns for modeling entities, value objects, domain services, repositories, aggregates, and bounded contexts in complex business domains.