domain-model

Create immutable React domain models with createModelFactory and Valibot validation.

Updated Dec 18, 2021
One-click install
npx skills add https://github.com/isihigameKoudai/utils --skill domain-model-isihigamekoudai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: domain-model
Source: https://github.com/isihigameKoudai/utils/tree/main/.opencode/skills/domain-model
Command: npx skills add https://github.com/isihigameKoudai/utils --skill domain-model-isihigamekoudai

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill automates the creation of immutable Domain Models in React applications, reducing development time and improving code quality by enforcing DDD principles with Valibot validation and computed properties.

Core Features & Use Cases

  • Immutable Domain Models: Utilizes createModelFactory to generate immutable models with Object.freeze and readonly properties.
  • Valibot Validation: Integrates Valibot for robust runtime validation and error handling.
  • Computed Properties: Adds computed properties like formatted labels and derived values using extensions.
  • Use Case: Simplify the process of designing and implementing complex models like entities, repositories, and services, reducing manual error prone work and ensuring data consistency.

Quick Start

Use the domain-model skill to create a new model for your React application with the following command: create-model MyModel

Frequently Asked Questions about domain-model

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

FAQPage Schema
How do I create immutable domain models in a React application?

To create immutable domain models in React, use the `createModelFactory` method. This function generates models with `Object.freeze` and readonly properties, ensuring data consistency by preventing accidental modifications to your entities.

What is the best way to validate TypeScript domain models with Valibot?

The best way to validate TypeScript domain models with Valibot is integrating it directly into your model factory. This Skill combines Valibot runtime validation with DDD principles to provide robust type-safe error handling for your React application data.

Can I add computed properties to immutable React domain models?

Yes, you can add computed properties to immutable React domain models using extensions. These extensions allow you to append derived values and formatted labels to your models without violating immutability or altering the original data structure.

Does this domain-model approach work for DDD-compliant React applications?

Yes, this approach works specifically for DDD-compliant React applications. It streamlines the design and implementation of complex DDD structures like entities, repositories, and services while maintaining type-safe and immutable data handling.

How do I start building a new domain model using TypeScript and Valibot?

To start building a new domain model, execute the `create-model` command followed by your model name. This initializes the model structure using Valibot validation and `createModelFactory` for immediate immutability in your React project.