Communitygithub.com

Prisma 技能

Prisma 模式设计、迁移和查询优化。

Prisma 技能 是什么?

该技能为使用 Prisma 的开发人员提供了一系列最佳实践和规则,专注于数据库模式设计、迁移管理和查询优化。它强调将 `prisma/schema.prisma` 作为单一事实来源,并推荐使用 `select` 而非 `include` 以仅获取所需字段,从而提升性能。技能涵盖了事务处理(使用 `prisma.$transaction`)、软删除(通过 `deletedAt` 字段和中间件过滤器)、频繁查询字段的索引创建以及关系定义(需要显式使用 `@relation`)。此外,还提供了迁移命令(`npx prisma migrate dev`)、无服务器环境的连接池(Prisma Accelerate 或 PgBouncer)以及类型生成(`npx prisma generate`)的指导。该技能适用于所有支持 Prisma 的平台(如 Claude Code、Cursor、Codex),帮助开发者避免常见陷阱(如 N+1 查询、未分页的全表扫描、不必要的原始 SQL),确保高效、可维护的数据库操作。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/YepAPI/skills/tree/HEAD/skills/prisma

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

Prisma

规则

  • 模式文件在 prisma/schema.prisma 中——单一事实来源
  • 使用 select 而非 include——只获取需要的字段
  • 多步骤修改使用事务:prisma.$transaction([...])
  • 通过 deletedAt DateTime? 字段和中间件过滤器实现软删除
  • 对频繁查询的字段建立索引:@@index([fieldName])
  • 关系定义:始终显式定义两个方向(@relation)
  • 迁移:npx prisma migrate dev --name descriptive-name
  • 无服务器环境连接池:使用 Prisma Accelerate 或 PgBouncer
  • 类型生成:模式变更后执行 npx prisma generate

避免

  • include: { relation: true } 当只需要一个字段时——改用 select
  • N+1 查询——改用 include 或带嵌套关系的 select
  • 当 Prisma API 可以处理时使用原始 SQL——仅在复杂聚合时使用 $queryRaw
  • prisma.table.findMany() 不加 take 限制——始终进行分页

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

YepAPI/skills

WCAG 2.1 AA — semantic HTML, keyboard navigation, screen readers.

YepAPI/skills

Experiment setup, variant splitting, statistical significance, and feature flag integration.

YepAPI/skills

CRUD generators, data tables, user management, role-based access, and bulk operations.

YepAPI/skills

Monitor what ChatGPT and Gemini say about your brand using YepAPI.

YepAPI/skills

Queue workers with BullMQ/Inngest/Trigger.dev, job retries, dead letter queues, concurrency.

YepAPI/skills

Commander.js, interactive prompts with Clack, spinners, colors, config files, exit codes, and npm publishing.

YepAPI/skills

cmdk integration, Cmd+K trigger, fuzzy search, grouped actions, keyboard navigation, and dynamic action registration.

YepAPI/skills

Content planning with trend and sentiment data from YepAPI.

YepAPI/skills

Content calendar, keyword-driven planning, and content briefs.

YepAPI/skills

Theme switching with CSS variables, system preference detection, next-themes, and persistence.

YepAPI/skills

Threaded comments, @mentions, reactions, moderation queue, optimistic UI, and cursor pagination.

YepAPI/skills

Competitive analysis between domains using YepAPI.

YepAPI/skills

Layout grids, KPI cards, data tables with sorting/filtering, sidebar navigation, and responsive breakpoints.

YepAPI/skills

Data encryption — TLS everywhere, AES-256-GCM for PII, bcrypt passwords, encrypted backups.

YepAPI/skills

Chart patterns with Recharts/Nivo/D3, responsive containers, color scales, and accessibility.

YepAPI/skills

Drizzle schema definition, push vs migrate, type-safe queries, relations, transactions, and prepared statements.

YepAPI/skills

Upload handling, resize/compress, CDN delivery, blur placeholders, and next/image patterns.

YepAPI/skills

Local business and Google Maps research using YepAPI.

YepAPI/skills

Cursor-based pagination, IntersectionObserver, virtualized lists with @tanstack/react-virtual, and scroll position restoration.

YepAPI/skills

Chat UI components, streaming responses with AI SDK, context window management, and RAG patterns.

相关技能