create-entity

Create NestJS domain entities with DDD patterns and static create().

13|1|Updated Jun 28, 2023
One-click install
npx skills add https://github.com/jovicon/nestjs-clean-architecture-event-driven-template --skill create-entity-jovicon
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: create-entity
Source: https://github.com/jovicon/nestjs-clean-architecture-event-driven-template/tree/main/.claude/skills/create-entity
Command: npx skills add https://github.com/jovicon/nestjs-clean-architecture-event-driven-template --skill create-entity-jovicon

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill helps developers scaffold a domain entity or aggregate root in a NestJS project, enforcing DDD principles and consistent lifecycle management.

Core Features & Use Cases

  • Scaffold domain entities or aggregates with a private constructor and a static create() factory method.
  • Choose between aggregate root or regular entity by defaulting to aggregate-root behavior and extending AggregateRoot<Props> or Entity<Props> accordingly.
  • Identity and lifecycle management using UniqueEntityID and proper invariants to control state changes.
  • Business logic and validation via domain methods and a Guard pattern, returning a Result<EntityName> from create().
  • Framework-free domain layer ensures clean architecture independence and testability.

Quick Start

Provide the module-name and entity-name to generate src/modules/<module-name>/domain/<Entity-name>.ts using this skill.

Frequently Asked Questions about create-entity

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

FAQPage Schema
How do I create a domain entity in NestJS following DDD patterns?

Scaffold a domain entity in NestJS following DDD patterns by using a private constructor, a static create() factory method, and UniqueEntityID-based identity to enforce invariants and maintain a framework-free domain layer.

What is the difference between an aggregate root and a regular entity in domain-driven design?

In domain-driven design, an aggregate root extends AggregateRoot<Props> to manage invariants across multiple objects, while a regular entity extends Entity<Props> to manage its own independent lifecycle within a module.

How do I validate invariants when modeling a domain entity with domain-driven design?

Validate invariants when modeling a domain entity by applying a Guard pattern inside the static create() method, returning a Result<EntityName> object that encapsulates the success or failure of business rule validation.

Can I keep my domain layer framework-free when using NestJS for domain modeling?

Yes, you can keep your domain layer framework-free when using NestJS for domain modeling by encapsulating business logic in pure TypeScript entities with private constructors, ensuring clean architecture independence and testability.

What is the best way to manage identity and lifecycle in a DDD aggregate root?

Manage identity and lifecycle in a DDD aggregate root by assigning a UniqueEntityID upon creation and controlling state changes exclusively through domain logic methods, ensuring all invariants are maintained across transitions.

When should I use a static create() method instead of a constructor for a domain entity?

Use a static create() method instead of a constructor for a domain entity when you need to run Guard-based validation and return a Result object, preventing the instantiation of an entity in an invalid state.