# Data

> Data — Index

- Skill: `persimmon-automation-labs/data` (Agent Skill)
- Install (CLI): `npx skillmds@latest add persimmon-automation-labs/data`
- Raw SKILL.md: https://api.skillmd.com/api/skills/persimmon-automation-labs/data/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: Persimmon-Automation-Labs (https://skillmd.com/u/persimmon-automation-labs)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/persimmon-automation-labs/data

---


# Data — Index

Persimmon data = PostgreSQL with `pgvector`, accessed through Prisma with one shared client. This mother is a map; follow the child for the actual work.

## Trigger

- "Design the schema for…" / "Add a Prisma model / migration"
- "Store embeddings" / "vector column" / "pgvector"
- "Search by similarity" / "HNSW index"

## The child skills

| Skill | When to use | Owns |
|---|---|---|
| `data-prisma-pgvector` | Any schema design, migration, vector column, or similarity query | Prisma schema patterns, pgvector extension setup, HNSW indexing (`vector_cosine_ops`), cosine-similarity queries, the one-shared-client rule |
| `data-schema-design` | Modeling rigor before a schema is final | Snapshot-mutable-values, lifecycle enums, join models, FK/cardinality, the validation lenses |
| `data-booking-availability` | Reservations / slots / availability | Slot schema, availability queries, blackout/lead-time, waitlist, deposits |
| `data-db-cli` | Inspect or query the live DB without writing a script | The read-only-by-default `db` CLI (`npm run db`) + Postgres MCP setup, the `--write`/`--prod` safety gates |

## Persimmon data defaults — one-screen summary

- **One Prisma client** in `src/lib/db.ts`. Never instantiate `PrismaClient` elsewhere.
- **Migrations**: `prisma migrate dev` locally. On Railway, apply via `prisma db push` in the build step OR a migrate-deploy job — pick one per project and stick with it.
- **After `db push` with enum/model changes**: restart the dev server (the running Prisma client is stale).
- **pgvector index**: HNSW beats IVFFlat for recall + latency under ~10M rows. Build with `CREATE INDEX ... USING hnsw (embedding vector_cosine_ops)`.
- **Never query a filtered-subset HNSW index without the filter.**
- **Naming**: models `PascalCase` singular; fields `camelCase`; `createdAt`/`updatedAt` on every model; Postgres enums, not string constants.

## Anti-patterns banned

- Instantiating `PrismaClient` outside `src/lib/db.ts`
- Mixing `migrate` and `db push` strategies in one project
- Unfiltered queries against a filtered-subset vector index
- String constants where a Postgres enum belongs

## Relationship to other mothers

| Mother | Connection |
|---|---|
| `ai` | `ai-rag-retrieval` stores/searches embeddings here |
| `stack` | Server Actions read/write through the shared Prisma client |
| `quality` | N+1, unbounded lists, missing indexes flagged by `quality-review-data-layer` |

