Skip to content
Back to skills

Entity Source Of Truth Update

ASecurity

Change an entity end-to-end across Prisma, OpenAPI, generated models, NestJS services/controllers, and tests in this repository. Use when adding/removing entity fields, changing entity types, or updating entity behavior and you must keep DB schema, API contract, generated types, and runtime mappings aligned.

  • 4 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 26, 2026
developmentsqlapidatabase

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 3 files and shows the line behind each finding

Scanned November 26, 2026

npx -y skills add zsutton00/hey-hey --skill entity-source-of-truth-update --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Entity Source Of Truth Update?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Entity Source Of Truth Update
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/zsutton00-entity-source-of-truth-update/badge)](https://www.skillsdirectory.com/skills/zsutton00-entity-source-of-truth-update)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: entity-source-of-truth-update
description: Change an entity end-to-end across Prisma, OpenAPI, generated models, NestJS services/controllers, and tests in this repository. Use when adding/removing entity fields, changing entity types, or updating entity behavior and you must keep DB schema, API contract, generated types, and runtime mappings aligned.
---

# Entity Source Of Truth Update

## Invariant

Keep one entity contract flow: Prisma schema and DB shape -> OpenAPI schema -> generated models -> service/controller mappings -> tests and fixtures. Fail fast on missing required fields and fix upstream callers instead of adding fallback defaults.

## Workflow

1. State root cause before edits:
   Name the invariant that must hold, what breaks it, and which caller owns each required field.
2. Audit call sites before code changes:
   Find service mappers, controller responses, request builders, fixtures, and tests that touch the changed entity fields.
3. Update DB and Prisma first when persistence shape changes:
   Edit `prisma/schema.prisma`, keep DB naming in lower snake_case, and map Prisma names with `@map`/`@@map` (including enums when DB enum type names are snake_case). Run `pnpm db:generate`. When a migration is required, add a new Flyway SQL migration in `db/flyway/`.
4. Update OpenAPI contract:
   Edit `../openapi/specs/schemas/<entity>.yaml` and related references in `../openapi/specs/api/openapi.yaml`.
5. Regenerate API models:
   Run `pnpm run generate:api`.
6. Verify generated output:
   Confirm `src/generated/model/*.ts` and `src/generated/model/models.ts` reflect the contract change and do not hand-edit generated files.
7. Update implementation:
   Adjust service logic and controller request/response usage so payloads match generated types exactly.
8. Update tests and fixtures:
   Update mocks/fixtures and add regression coverage for changed behavior.
9. Verify end-to-end:
   Run targeted Jest suites for touched modules and always run `pnpm tsc --noEmit`.

## Hard Rules

- Keep generated/OpenAPI/Prisma shapes aligned; treat drift as an integration failure.
- Database identifiers are lower snake_case. Prisma camel/Pascal names must map explicitly via `@map`/`@@map`.
- Do not widen generated DTOs or add stricter local constraints unless OpenAPI changes first.
- Do not invent placeholder defaults for required fields.
- Do not hand-edit `src/generated`.

## Quick Commands

- Find impacted files:
  `rg -n "<EntityName>|<fieldName>|Controller|Service" src prisma ../openapi/specs`
- Prisma client generation:
  `pnpm db:generate`
- Migration authoring (when needed):
  `db/flyway/V<timestamp>__<description>.sql`
- Migration validation:
  `pnpm db:flyway:validate`
- API model generation:
  `pnpm run generate:api`
- Targeted tests:
  `pnpm jest src/services/<entity> src/controllers/<entity>`
- Final typecheck:
  `pnpm tsc --noEmit`

## Reference

Use `references/checklist.md` for the compact repeatable checklist.

Files in this skill

  • SKILL.md2.9 KB
  • agents/openai.yaml301 B
  • references/checklist.md1.2 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.