# 010118 Repository Factories

> Domain repository factory — functions accepting Drizzle tables to create reusable CRUD for test (tst_) and production (prd_/sys_) tables.

- Skill: `natuleadan/010118-repository-factories` (Agent Skill, multi-file: 7 files)
- Install (CLI): `npx skillmds@latest add natuleadan/010118-repository-factories`
- Raw SKILL.md: https://api.skillmd.com/api/skills/natuleadan/010118-repository-factories/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- License: MIT
- Author: natuleadan (https://skillmd.com/u/natuleadan)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/natuleadan/010118-repository-factories

---


# Repository Factories

## When to use

When building data access layers that need to work with different table schemas (test vs production) without duplicating code.

## References

| Topic | File |
|---|---|
| Factory pattern overview | `references/factory-pattern.md` |
| Service dual-mode (index + test) | `references/service-dual-mode.md` |
| Generic admin system factory | `references/admin-sys-factory.md` |

## Quick checklist

- [ ] Create one factory per domain, accepting tables as parameters
- [ ] Return an object with CRUD methods
- [ ] Use a type alias for the accepted table shape
- [ ] Cast with `as any` at the call site, not inside the factory
- [ ] Create paired services: `index.ts` (sys_*) and `test.ts` (tst_*)
- [ ] For simple CRUD tables, use the generic `createSysRepo()` factory

