entity

Creates DDD domain entities with validation schemas, behavior methods, and language-specific TypeScript or Go playbooks.

4|Updated Jul 30, 2026
One-click install
npx skills add https://github.com/gabriellst/codm --skill entity-gabriellst
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: entity
Source: https://github.com/gabriellst/codm/tree/main/.claude/skills/entity
Command: npx skills add https://github.com/gabriellst/codm --skill entity-gabriellst

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Modeling domain entities consistently across a polyglot DDD codebase is error-prone: validation rules get scattered, version increments land in the wrong layer, and rehydration logic regenerates identities. This Skill encodes the canonical entity patterns for both the TypeScript and Go backends so every aggregate root follows the same rules. ## Core Features & Use Cases - Language dispatch hub: Routes to the TypeScript or Go playbook based on file extension, with per-language registries of mandatory patterns and bad practices. - TypeScript entity playbook: Covers Zod schema declaration, z.instance() value object wiring, interface merging, create() factories, this.validate() behavior methods, and the rule that incrementVersion() lives in repository save(). - Go entity playbook: Covers BaseEntity embedding, New<Name> constructors returning errors, Reconstruct<Name> rehydration, AddDomainEvent/PullDomainEvents, and IncrementVersion inside behavior methods. - Use Case: When adding a new TranscodingJob aggregate to the Go gateway or an Organization aggregate to the TypeScript daemon, invoke this Skill to scaffold the entity with correct validation, events, and versioning on the first pass. ## Quick Start Ask the agent to create a domain entity for your bounded context, for example: create an entity named Product in the catalog context with a name, price, and active status.

Frequently Asked Questions about entity

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

FAQPage Schema
How do I create a DDD domain entity with Zod validation in TypeScript?

Define a module-level Zod schema, extend AggregateRoot<typeof Schema>, set static override schema, and add a static create() factory that calls new Entity(data). Declare fields via interface merging with the inferred Props type rather than class-body assertions.

How do I create a domain entity in Go with domain events?

Embed entities.BaseEntity, write a New<Name> constructor that validates inputs and returns (*T, error), and attach creation events via AddDomainEvent. Behavior methods guard preconditions, mutate state, call IncrementVersion, and return error.

Where should incrementVersion be called in TypeScript vs Go entities?

In TypeScript, incrementVersion() is called in the repository's save() method, never inside entity behavior methods. In Go the convention is reversed: every behavior method that mutates state calls IncrementVersion() itself, and the repository must not call it again.

When should I use a value object instead of an entity?

Use a value object for concepts without identity that are immutable after construction, such as Email, Money, or Address. Use an entity when the object has a stable identity, a lifecycle, and state that changes through behavior methods.

Why does entity rehydration fail or generate a new ID?

Rehydration fails when the create() factory or NewBaseEntity() is used instead of the rehydration path. In TypeScript call the constructor directly with persisted fields; in Go use Reconstruct<Name> with entities.ReconstructBaseEntity to restore the exact persisted ID, timestamps, and version.

Can entity schemas be registered to OpenAPI?

No. Entity schemas are internal write-model objects; registering them exposes refine() source and internal fields in the public openapi.json and client SDK. Only shared value objects and DTOs should be registered.