value-object

Creates immutable value objects in TypeScript and Go following DDD domain modeling patterns.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Domain concepts like Email, CPF, Money, and Address are defined by their attributes rather than identity, and modeling them as plain primitives leads to invalid states, duplicated validation, and broken immutability. This Skill provides language-specific playbooks for creating self-validating, immutable value objects in both TypeScript and Go backends. ## 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 playbook: Covers schema-driven base classes (BasePrimitiveValueObject, BaseValueObject), Zod schema validation, declaration merging, .input() schema reuse, and z.instance() composition in entities. - Go playbook: Covers private-field structs, New<Name> constructors returning (T, error), the Value/String/Equals/IsZero accessor quartet, and composite VOs using go-playground/validator struct tags. - Use Case: When adding a CRM value object to a doctor bounded context, the Skill provides the exact schema, class shape, error-code casting, and checklist so the VO validates itself at construction and integrates with entities and repositories. ## Quick Start Ask the agent to create a value object for a domain concept such as Email or Money in the target backend, and it will load the matching TypeScript or Go playbook and apply its patterns.

Frequently Asked Questions about value-object

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

FAQPage Schema
How do I create an immutable value object in TypeScript with Zod?

Define a Zod schema with transforms and refinements, then extend BasePrimitiveValueObject for single values or BaseValueObject for composites with a static override schema. The base class runs safeParse, throws BaseError on failure, and assigns properties, so no manual constructor logic is needed.

How do I create a value object in Go with validation?

Declare a struct with private fields and a New<Name> constructor returning (T, error) that validates input and returns errors.NewBaseError on failure. Expose Value, String, Equals, and IsZero accessors, and use validate struct tags with validation.ValidateWithCode for composite VOs.

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

Use a value object when the concept is defined entirely by its attributes and has no identity, such as Email, Money, or Address. Use an entity when the object needs an ID, mutable state, and equality by identity rather than by value.

What is the difference between BasePrimitiveValueObject and BaseValueObject?

BasePrimitiveValueObject wraps a single primitive like a string, number, or Date in a value property, as with Email or CPF. BaseValueObject handles multi-field composites like Address or CRM and requires interface declaration merging with Z.infer for typed properties.

Why should Go value object constructors never panic?

A panicking constructor crashes the entire request instead of letting the caller handle invalid input. Constructors must return (T, error) with a typed errors.NewBaseError code so the HTTP mapper can translate failures into correct status codes.

When should I not use a value object?

Avoid value objects for plain strings with no validation or domain behavior, for values needing identity across time, and for large data bags without invariants. In those cases use plain fields, entities, or simple structs instead.