koan-data-modeling

Official

Design robust data models, simply.

Authorsylin-org
Version1.0.0
Installs0

System Documentation

What problem does it solve?

Designing effective data models that encapsulate business logic, manage relationships, and enforce invariants can be complex. This Skill provides a clear, aggregate-first approach to data modeling within Koan Framework, simplifying domain-driven design.

Core Features & Use Cases

  • Aggregate Boundaries: Define entities as aggregates that encapsulate their own business logic and maintain internal consistency.
  • Value Objects: Use immutable value objects (e.g., Money, Address) to represent cohesive data, improving type safety and reducing errors.
  • Lifecycle Hooks: Enforce business rules and invariants by hooking into entity lifecycle events (before save, after load, etc.).
  • Navigation Helpers: Easily define and traverse relationships between entities using simple foreign keys and helper methods, without complex ORM mapping.
  • Use Case: Model an Order entity as an aggregate, ensuring its Total and Status are updated through business methods, not direct property assignments. Use a Money value object for currency, and define a lifecycle hook to prevent negative prices for Product entities.

Quick Start

To define an Order entity with a Money value object and a navigation helper: public record Money(decimal Amount, string Currency); public class Order : Entity<Order> { public string CustomerId { get; set; } = ""; public Money Total { get; private set; } = new(0m, "USD"); public Task<Customer?> GetCustomer() => Customer.Get(CustomerId); }

Dependency Matrix

Required Modules

None required

Components

Standard package

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: koan-data-modeling
Download link: https://github.com/sylin-org/koan-framework/archive/main.zip#koan-data-modeling

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 223,000+ vetted skills library on demand.