repository

Creates repository interfaces and implementations for domain entity persistence in TypeScript and Go backends.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Defining how domain entities are stored, retrieved, and queried from the database requires consistent patterns across languages. This Skill scaffolds the persistence boundary for one entity — the repository interface (domain layer) plus its concrete implementation (infrastructure layer) — so domain logic never depends on the database driver. ## Core Features & Use Cases - Language dispatch hub: Routes to TypeScript (Drizzle ORM) or Go (database/sql) playbooks based on file extension or a --lang flag, with per-language registries of mandatory patterns and bad practices. - TypeScript variant: Generates an abstract class extending Repository<T>, a DrizzleXRepository implementation with toDomain/toPersistence mapping, a mock implementation, and registry-based DI bindings. - Go variant: Generates a folder-per-repo package with interface, Postgres implementation (txOrDB transaction handling, IncrementVersion, domain-event draining), in-memory mock, and fx wiring via fx.As. - Use Case: When adding persistence for a new Customer entity, invoke this Skill to produce the repository contract, the Drizzle or Postgres implementation with upsert semantics, the test mock, and the DI registration in one guided flow. ## Quick Start Ask the agent to create a repository for the Customer entity in the TypeScript backend using the repository skill.

Frequently Asked Questions about repository

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

FAQPage Schema
How do I create a repository for a domain entity with Drizzle ORM?

Create an abstract class extending Repository<T> with finder methods, then a DrizzleXRepository implementation that injects DrizzleDatabaseDriver, maps rows via toDomain with raw primitives, and persists via toPersistence with onConflictDoUpdate. Register both mock and real bindings in the context registry.

How do I implement a repository pattern in Go with Postgres?

Use a folder-per-repo layout with an interface file, a pg_ implementation using database/sql, and a mock. The implementation uses a txOrDB helper to honor UnitOfWork transactions, calls IncrementVersion on save, drains domain events, and returns (nil, nil) instead of sql.ErrNoRows.

Should repository query methods return null or undefined in TypeScript?

Return undefined, never null. Query methods like findById return Promise<Entity | undefined>, and a bare return statement is used when tryCatchAsync yields no row. This is the enforced project convention.

When should I not create a domain repository?

Skip the repository for read-only UI queries, which belong in the ui context via direct Drizzle queries returning DTOs. Also avoid repositories for tables with no entity unless they are infrastructure tables or justified child tables documented on the parent aggregate.

Why does the repository save method call incrementVersion?

incrementVersion advances the entity's optimistic-concurrency version before the upsert writes it. Omitting it breaks optimistic locking, and both the Drizzle and Postgres implementations must call it, with mocks mirroring the same behavior.

How are repositories wired into dependency injection?

TypeScript repositories are declared in the context registry via expandBindings with mock and real tokens, composed into ALL_REGISTRIES. Go repositories are bound in module.go using fx.Provide with fx.Annotate and fx.As so consumers depend on the interface.