data-access-guidelines

Define Prisma-based data-access guidelines for schemas, DAOs, migrations, and RBAC.

Updated Nov 9, 2025
One-click install
npx skills add https://github.com/ZeroGravitySkin-Ron/Claude --skill data-access-guidelines
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: data-access-guidelines
Source: https://github.com/ZeroGravitySkin-Ron/Claude/tree/main/skills/data-access-guidelines
Command: npx skills add https://github.com/ZeroGravitySkin-Ron/Claude --skill data-access-guidelines

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a quick-reference guide for Quantum Skincare's Prisma-based data-access layer, helping teams design robust schemas, implement DAO patterns, enforce UUID primary keys, apply RBAC with PostgreSQL, manage migrations, and write type-safe queries. It reduces complexity and mental load when building or evolving database access layers.

Core Features & Use Cases

  • Type-safe DB Operations: Enforces UUID primary keys, timestamp fields, and safe query patterns across models.
  • DAO Patterns & Exports: Encourages encapsulated data access with clear public APIs.
  • Migration Workflows: Standardizes how migrations are created, applied, and tested.
  • RBAC & Security: Guides role-based access controls and secure data access practices.
  • Testing Strategies: Provides approaches for unit tests and integration tests for DAOs.

Quick Start

  • Add a new model to prisma/schema.prisma and ensure UUID primary keys with @id @default(uuid()) @db.Uuid.
  • Implement a DAO in src/lib/dao/ and export it via src/index.ts.
  • Run npx prisma migrate dev --name <descriptive_name> and npx prisma generate.
  • Write unit tests for DAO functions and ensure soft-delete handling where applicable.

Frequently Asked Questions about data-access-guidelines

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

FAQPage Schema
How do I design a Prisma schema with type-safe data access patterns?

Type-safe Prisma schemas enforce UUID primary keys with `@id @default(uuid()) @db.Uuid`, standardized timestamp fields, and soft-delete columns. This ensures compile-time type safety and prevents query errors across your data layer.

What's the best way to structure DAOs in a Prisma project?

Implement encapsulated Data Access Objects in `src/lib/dao/` that export a clean public API, handle transactions, apply soft-delete filtering, and map database types to application types. Export DAOs via `src/index.ts` for consistent access patterns.

How do I set up PostgreSQL RBAC with Prisma migrations?

Define role-based access controls in your Prisma schema and migrations, then enforce them through DAO methods that filter queries by user role. Run migrations with `npx prisma migrate dev --name <descriptive_name>` and regenerate types with `npx prisma generate`.

Can I use Prisma for safe, consistent database migrations across models?

Yes. Standardize migrations by creating descriptive named migrations, applying them through the migration workflow, and enforcing schema requirements—UUID keys, timestamps, soft deletes, relations—consistently across all new and existing models.

Why should I add unit tests for Prisma DAO functions?

Unit tests for DAOs validate type-safe queries, soft-delete filtering, transaction handling, and role-based access controls. Testing catches query errors and access violations before production and ensures DAOs remain consistent as models evolve.

What happens if I don't use soft deletes in my Prisma models?

Without soft deletes, you lose audit trails and risk breaking relations when hard-deleting data. This guideline enforces soft-delete columns and DAO filtering to preserve data integrity, maintain referential consistency, and support compliance requirements.