ddd-repository-design

Reviews DDD repository interfaces for naming, CQS compliance, and aggregate I/O type violations.

Updated Jun 23, 2026
One-click install
npx skills add https://github.com/j5ik2o/marp-ai-base --skill ddd-repository-design-j5ik2o
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ddd-repository-design
Source: https://github.com/j5ik2o/marp-ai-base/tree/main/.agents/skills/ddd-repository-design
Command: npx skills add https://github.com/j5ik2o/marp-ai-base --skill ddd-repository-design-j5ik2o

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Repository interfaces often drift into anti-patterns: names derived from tables or DTOs, methods leaking domain logic or SQL terminology, and return types exposing infrastructure records instead of aggregates. This Skill detects those violations during code review, new implementation, or refactoring and proposes concrete fixes. ## Core Features & Use Cases - Naming Rule Enforcement: Verifies repository names follow the AggregateName + Repository convention and flags infrastructure terms like Table, Dto, Entity, Record, or Row. - CQS Method Validation: Checks that each method is either a query returning aggregates with no side effects or a command accepting aggregates and returning void, covering single-item, multi-item, synchronous, and asynchronous (Future, async/await, Result/Either) patterns. - Anti-Pattern Detection: Identifies DTO/record return types, domain-logic method names (leave, activate, cancel), SQL-style names (insert, update, select, upsert), and repositories calling other repositories instead of coordinating in the use-case layer. - Use Case: During a pull request review, ask the AI to check a new OrderRepository interface; it flags that findById returns OrderDto and that store returns an OrderId, then suggests corrected signatures. ## Quick Start Ask the AI to review the design of your repository interface, for example by saying "Review this OrderRepository interface for DDD design violations."

Frequently Asked Questions about ddd-repository-design

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

FAQPage Schema
How do I name a repository in DDD?

Name repositories after the aggregate they persist, using the pattern AggregateName plus Repository, such as OrderRepository or UserRepository. Avoid names derived from tables, DTOs, or infrastructure terms like Table, Entity, Record, or Row.

What is CQS in repository design?

CQS (Command Query Separation) requires each repository method to be either a query that returns aggregates without side effects or a command that accepts an aggregate and returns void. A method like store must not return the saved record or an ID.

Should a repository return DTOs or domain aggregates?

A repository should return domain aggregates, not DTOs, table records, or partial summaries. Returning infrastructure types leaks persistence details into the domain layer and breaks the aggregate boundary.

Can a repository call another repository?

No, a repository implementation must not depend on another repository. Coordinating multiple aggregates is the responsibility of the use-case layer (application service), which fetches from each repository and combines the results.

Which method names are allowed on a DDD repository?

Allowed names express collection-style I/O: store, findById, delete, put, remove, add, and plural forms like storeMulti or findByIds. Domain terms (leave, activate, cancel) and SQL terms (insert, update, select, upsert) are prohibited.

Does this repository design guidance work for languages other than Kotlin?

Yes, the rules are language-independent and cover Java, Kotlin, Scala, TypeScript, Go, Rust, and Python. It includes synchronous, Future-based, and async/await patterns with either exception or Result/Either error handling.