repository-rules

Map database rows to domain models with explicit mapToDomain helpers.

Updated Sep 21, 2025
One-click install
npx skills add https://github.com/hmjn023/solid-imager --skill repository-rules
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: repository-rules
Source: https://github.com/hmjn023/solid-imager/tree/main/.opencode/skills/repository-rules
Command: npx skills add https://github.com/hmjn023/solid-imager --skill repository-rules

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Explicit mapping of database rows to domain entities to prevent unsafe casts and subtle type mismatches, ensuring a stable domain layer.

Core Features & Use Cases

  • Explicit mapping with a dedicated mapToDomain helper to keep a clear boundary between DB schemas and domain models.
  • Prevents brittle conversions and typing errors when DB schemas evolve, especially across apps/server/src/infrastructure/repositories.
  • Improves code readability and maintainability by centralizing mapping logic and validation.

Quick Start

Define a mapToDomain function to convert a database row into a domain entity and apply it wherever you map DB results to domain models.

Frequently Asked Questions about repository-rules

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

FAQPage Schema
How do I map database rows to domain models in TypeScript without unsafe casts?

Map database rows to domain models by defining a dedicated mapToDomain helper function that explicitly converts DB schemas into domain entities. This enforces a clear boundary between layers, preventing type mismatches and eliminating unsafe casts in TypeScript.

How do I prevent schema drift when database schemas evolve across migrations?

Prevent schema drift by centralizing mapping logic within explicit mapToDomain functions. This ensures repository implementations align DB schemas with domain entities, maintaining type safety and reducing brittle conversions when database structures change across migrations.

Why do I need explicit DB-to-domain mapping instead of direct database row casting?

Explicit DB-to-domain mapping is needed because direct casting creates subtle type mismatches and brittle conversions. Dedicated mapping functions keep a clear boundary between DB schemas and domain models, ensuring a stable domain layer and improving code readability.

What's the best way to structure repository implementations for type safety?

Structure repository implementations by enforcing clear rules that require dedicated mapToDomain functions. This centralizes validation and mapping logic across infrastructure repositories, maintaining type safety and aligning DB schemas with domain entities throughout the codebase.

Can I use explicit mapping helpers with existing TypeScript domain models?

Yes, explicit mapping helpers integrate with existing TypeScript domain models by defining a mapToDomain function to convert database rows into domain entities. This applies wherever you map DB results, maintaining type safety without altering the domain layer itself.