返回 Skill 列表
extension
分类: 开发与工程无需 API Key

backend-standards

在packages/api或packages/db中实现或重构后端逻辑时使用。强制执行路由/服务/数据访问分层、命名约定、TRPC最佳实践和Drizzle模式指南。

person作者: jakexiaohubgithub

Backend Standards (Seagull)

When to use

  • Adding or refactoring tRPC routers/services in packages/api.
  • Changing database schema in packages/db.

Core rules

  • Layering:
    • Router layer in packages/api/src/router (validation, auth, routing only).
    • Service layer in packages/api/src/services for business logic and orchestration.
    • Data access in packages/db (Drizzle).
  • Naming:
    • Files: kebab-case. Variables/functions: camelCase. Types: PascalCase.
    • DB: snake_case tables/columns (Drizzle maps to camelCase).
  • tRPC:
    • Query = read (get, list, search, byId); Mutation = write (create, update, delete, archive).
    • Always define Zod inputs.
    • Throw TRPCError with semantic codes.
  • DB:
    • Schema split by domain under packages/db/src/schema and re-export in index.
    • Use soft delete via deletedAt for core entities.

Workflow reminders

  • Schema change → db migration → router/service updates → frontend usage.
  • Run pnpm lint and pnpm typecheck before commit.

Canonical reference

  • See skills/backend-standards/references/backend-standards.md for the full policy text and examples.