value-object-patterns

Model domain concepts as immutable Value Objects with validation and equality semantics.

6|Updated Nov 20, 2025
One-click install
npx skills add https://github.com/daishiman/AIWorkflowOrchestrator --skill value-object-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: value-object-patterns
Source: https://github.com/daishiman/AIWorkflowOrchestrator/tree/main/.claude/skills/value-object-patterns
Command: npx skills add https://github.com/daishiman/AIWorkflowOrchestrator --skill value-object-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill provides expert guidance on designing and implementing Value Objects in Domain-Driven Design (DDD), solving common issues like primitive obsession, inconsistent validation, and unclear domain logic. It helps you build more type-safe, immutable, and expressive domain models.

Core Features & Use Cases

  • Core Concepts: Explains the fundamentals of Value Objects, their immutability, equality, and self-validation, distinguishing them from Entities.
  • Design & Implementation Patterns: Offers common patterns for various Value Objects (e.g., Money, EmailAddress, DateRange) and strategies for validation.
  • Primitive Obsession Detection: Includes a script to identify areas in your codebase where primitive types could be replaced by Value Objects.
  • Use Case: When refactoring a legacy codebase, use this skill to identify string or number parameters that represent domain concepts (like email, amount, userId). Then, apply the provided templates and patterns to create dedicated Value Objects, improving type safety and encapsulating domain logic.

Quick Start

Use the value-object-patterns skill to detect primitive obsession in the 'src/domain/' directory. Suggest suitable Value Object patterns for the identified issues. Provide a template for a simple Value Object for an 'EmailAddress'.

Frequently Asked Questions about value-object-patterns

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

FAQPage Schema
What is primitive obsession and how do Value Objects solve it?

Primitive obsession occurs when domain concepts like email addresses or monetary amounts are represented as raw strings or numbers instead of dedicated types. Value Objects solve this by encapsulating primitives in immutable, self-validating types that enforce domain rules and improve type safety.

How do I design an immutable Value Object with validation?

Create a Value Object with a private constructor, factory method for validated construction, and immutable fields. The factory method validates input before instantiation, ensuring only valid instances exist. Implement equality based on value semantics, not identity.

Can I use Value Objects for composite domain concepts like addresses?

Yes. Composite Value Objects combine multiple related fields—street, city, postal code—into a single immutable type. Each field is validated individually and as a cohesive unit, encapsulating address domain logic and ensuring consistency across your model.

How do I identify where primitive obsession exists in my codebase?

Use the included primitive obsession detection script on your domain code. It scans for string and number parameters representing domain concepts—email, amount, userId—highlighting candidates for Value Object refactoring.

What's the difference between Value Objects and Entities in Domain-Driven Design?

Value Objects are immutable types defined by their values and lack identity; Entities have persistent identity and can change state. Use Value Objects for domain concepts like Money or DateRange; use Entities for domain objects requiring lifecycle tracking.

How do I handle serialization of Value Objects?

Implement serialization through factory methods or custom serializers that reconstruct Value Objects via validated construction. This preserves immutability and validation invariants during storage or API transmission.