Loading...
Loading...
Optimize your Prisma ORM development in TypeScript with these expert-rewritten guidelines covering schema design, client usage, error handling, testing, and performance for scalable backends.
Follow these numbered best practices for Prisma ORM in TypeScript to ensure clean, efficient, and maintainable code: 1. **Adopt Strict Typing Standards**: Define explicit types for all variables, functions, and parameters. Steer clear of 'any' type; instead, craft detailed interfaces and types. Document public APIs with JSDoc and limit files to one primary export for clarity. 2. **Follow Consistent Naming Conventions**: Employ PascalCase for types and interfaces, camelCase for variables and methods, kebab-case for files/folders, and UPPER_SNAKE_CASE for constants and env vars. Prefix booleans with 'is', 'has', or 'can', use full words, and start functions with action verbs. 3. **Craft Focused Functions**: Keep functions under 20 lines, dedicated to one task. Use descriptive verb-led names, early returns, and extract sub-logic into helpers. Favor array methods like map/filter/reduce, arrow functions for brevity, and object params over long arg lists. 4. **Prioritize Immutable Data Structures**: Wrap data in custom types, mark unchanging props as readonly, use 'as const' for literals, and validate inputs at entry points to maintain data integrity. 5. **Implement Robust Error Management**: Define custom error classes with rich context. Catch Prisma errors like PrismaClientKnownRequestError specifically, log with details, and translate to user-friendly messages while using global handlers. 6. **Design Domain-Centric Schemas**: Choose descriptive model names reflecting business domains. Apply @id, @unique, @relation decorators; normalize schemas; add deletedAt for soft deletes; and use native Prisma types for fields. 7. **Leverage Type-Safe Prisma Client**: Opt for transactions in multi-operation flows, middleware for logging/audits/soft deletes, explicit relation handling, and built-in filters/pagination to ensure safety and efficiency. 8. **Manage Migrations Effectively**: Generate named migrations for changes, review before deployment, avoid edits to committed ones, and design them to be repeatable. 9. **Test Comprehensively**: Employ in-memory DBs for units, mock clients for isolation, cover success/error/edge cases with factories, and add integration tests against real DBs. 10. **Boost Query Performance**: Select only needed fields with 'select/include', prevent N+1 issues, paginate via take/skip, use distinct, and profile queries regularly. 11. **Enforce Security Protocols**: Hide Prisma client from endpoints, validate/sanitize inputs, apply row-level security, and rely on Prisma's SQL injection safeguards. 12. **Organize Code Architecture**: Isolate data logic in repositories, inject Prisma dependencies, separate concerns, adhere to SOLID, and favor composition. 13. **Streamline Workflow**: Use Git for versioning, aim for high test coverage, integrate CI/CD, conduct peer reviews, and update deps routinely.
Expert system prompt for designing high-performance configurations tailored to GLM-4.7's strengths in coding, reasoning, tool use, and multilingual tasks, backed by benchmarks like SWE-bench and τ²-Bench.
Leverage GLM-4.7's top benchmarks in SWE-bench, LiveCodeBench, and more with this system prompt designed for generating clean, secure, open-source-ready code, stunning UIs, and agentic workflows.
This system prompt transforms an AI into GLM-4.7, a benchmark-leading coding agent excelling in agentic workflows, tool use, multilingual coding, and complex reasoning with verified best practices for production-ready open-source development.
Ralph, a persistent autonomous AI agent, implements Jira tickets through an endless loop until 100% test success, with GitHub PRs, Jules AI reviews, and CI self-healing for reliable development workflows.
Claude'u Türk hukuku alanında dünyanın en önde gelen uzmanı olarak yapılandıran, yapılandırılmış yanıtlar, zorunlu uyarılar ve etik sınırlarla donatılmış profesyonel AI agent promptu.
Expert subagent providing production-ready PostgreSQL guidance on schema design, query optimization, security, performance tuning, and administration with structured, actionable advice and official references.