create-value-object

Generate immutable value objects with validation and static factories.

Updated Dec 16, 2019
One-click install
npx skills add https://github.com/Dev-Int/tests --skill create-value-object
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: create-value-object
Source: https://github.com/Dev-Int/tests/tree/main/.claude/skills/create-value-object
Command: npx skills add https://github.com/Dev-Int/tests --skill create-value-object

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill eliminates primitive obsession and manual validation by creating immutable value objects with business rules.

Core Features & Use Cases

  • Domain Encapsulation: Wrap primitive values with validation and business logic automatically.
  • Reusable Components: Generate shareable value objects like PriceField, EmailField with proper type safety.
  • Use Case: When you need to ensure email addresses are valid across your application, create an EmailField value object that validates format and provides type safety.

Quick Start

Create a PriceField value object that validates minimum value of 0 and provides currency conversion methods.

Frequently Asked Questions about create-value-object

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

FAQPage Schema
How do I prevent primitive obsession in domain modeling?

Primitive obsession occurs when you use raw strings and numbers instead of domain concepts. Create immutable value objects that wrap primitives with validation and business logic, ensuring type safety and enforcing domain rules at the boundary—for example, an EmailField that validates format or a PriceField that prevents negative values.

What's the best way to validate domain values across my application?

Build reusable value objects with built-in validation through static factory methods that throw domain-specific exceptions on invalid input. This centralizes validation logic, eliminating scattered checks and ensuring consistency wherever those values appear in your codebase.

How do I create immutable, type-safe domain objects?

Define immutable final classes with private constructors and static factory methods (fromString, fromInt, etc.). Include comparison methods, accessors, and optional business logic. This pattern creates type-safe, reusable components that prevent accidental mutation and encode domain constraints.

When should I use value objects in Domain-Driven Design?

Use value objects to encapsulate concepts like prices, emails, quantities, and IDs that carry meaning beyond their primitive type. Value objects are particularly valuable in shared contexts and bounded contexts where multiple aggregates reference the same domain concept.

Can I organize value objects across multiple bounded contexts?

Yes. Place shared, reusable value objects under Shared/Entities/VO for use across bounded contexts. Place bounded-context-specific value objects under their respective BC/Entities/VO folders. This structure supports both reuse and context isolation.

Does this approach support common domain patterns like currency conversion?

Yes. Value objects can include optional business logic beyond validation—for example, a PriceField can implement currency conversion methods. The immutable pattern and static factories keep the implementation clean while encoding domain operations.