dev-booster 1.17.2 → 1.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +62 -0
  3. package/template/.devbooster/MANIFEST.md +34 -1
  4. package/template/.devbooster/boosters/advisor.md +5 -0
  5. package/template/.devbooster/boosters/audit.md +20 -0
  6. package/template/.devbooster/boosters/auto-triage.md +5 -0
  7. package/template/.devbooster/boosters/backend.md +12 -0
  8. package/template/.devbooster/boosters/builder.md +5 -0
  9. package/template/.devbooster/boosters/code-audit.md +19 -0
  10. package/template/.devbooster/boosters/coder.md +5 -0
  11. package/template/.devbooster/boosters/create.md +5 -0
  12. package/template/.devbooster/boosters/debug.md +19 -0
  13. package/template/.devbooster/boosters/deploy.md +12 -0
  14. package/template/.devbooster/boosters/discovery.md +5 -0
  15. package/template/.devbooster/boosters/frontend.md +12 -0
  16. package/template/.devbooster/boosters/implementation.md +5 -0
  17. package/template/.devbooster/boosters/investigation.md +5 -0
  18. package/template/.devbooster/boosters/performance.md +12 -0
  19. package/template/.devbooster/boosters/planning.md +5 -0
  20. package/template/.devbooster/boosters/refactor.md +12 -0
  21. package/template/.devbooster/boosters/review.md +12 -0
  22. package/template/.devbooster/boosters/security.md +14 -0
  23. package/template/.devbooster/boosters/smart-task.md +27 -16
  24. package/template/.devbooster/boosters/stack-refresh.md +20 -0
  25. package/template/.devbooster/boosters/testing.md +12 -0
  26. package/template/.devbooster/hub/knowledge/angular-patterns.md +185 -0
  27. package/template/.devbooster/hub/knowledge/dependency-guide.md +175 -0
  28. package/template/.devbooster/hub/knowledge/eslint-migration.md +206 -0
  29. package/template/.devbooster/hub/knowledge/index.md +91 -0
  30. package/template/.devbooster/hub/knowledge/migration-guides.md +137 -0
  31. package/template/.devbooster/hub/knowledge/monorepo-patterns.md +121 -0
  32. package/template/.devbooster/hub/knowledge/nestjs-patterns.md +185 -0
  33. package/template/.devbooster/hub/knowledge/nextjs-pitfalls.md +226 -0
  34. package/template/.devbooster/hub/knowledge/nodejs-patterns.md +148 -0
  35. package/template/.devbooster/hub/knowledge/package-manager-patterns.md +143 -0
  36. package/template/.devbooster/hub/knowledge/prisma-postgresql-patterns.md +188 -0
  37. package/template/.devbooster/hub/knowledge/react-patterns.md +500 -0
  38. package/template/.devbooster/hub/knowledge/tailwind-shadcn-patterns.md +146 -0
  39. package/template/.devbooster/hub/knowledge/tanstack-patterns.md +278 -0
  40. package/template/.devbooster/hub/knowledge/testing-patterns.md +164 -0
  41. package/template/.devbooster/hub/knowledge/trpc-patterns.md +212 -0
  42. package/template/.devbooster/hub/knowledge/typescript-patterns.md +219 -0
  43. package/template/.devbooster/hub/knowledge/upgrade-fallout.md +154 -0
  44. package/template/.devbooster/hub/knowledge/vite-patterns.md +177 -0
  45. package/template/.devbooster/rules/GUIDE.md +24 -0
  46. package/template/.devbooster/rules/PROTOCOL.md +3 -2
  47. package/template/.devbooster/rules/TRIGGERS.md +14 -0
  48. package/template/DEVBOOSTER_INIT.md +22 -1
@@ -0,0 +1,188 @@
1
+ # Prisma + PostgreSQL Patterns
2
+
3
+ > **Purpose:** Practical guidance for safe Prisma and PostgreSQL changes.
4
+ > **Primary official sources:** [Prisma schema reference](https://www.prisma.io/docs/orm/reference/prisma-schema-reference) · [Prisma Migrate](https://www.prisma.io/docs/orm/prisma-migrate) · [Prisma transactions](https://www.prisma.io/docs/orm/prisma-client/queries/transactions) · [PostgreSQL EXPLAIN](https://www.postgresql.org/docs/current/using-explain.html) · [PostgreSQL indexes](https://www.postgresql.org/docs/current/indexes.html)
5
+
6
+ ## Project Convention Decision Rule
7
+
8
+ Before applying this guidance, verify the installed versions, local rules, existing data-access abstractions, schema, migration history, configuration, and tests. Preserve a valid established project convention; do not replace it only because another documented approach is also valid. Use official sources to verify API behavior, compatibility, constraints, and migrations. Recommend a change only when the developer requests it or evidence shows the current approach is incompatible, unsafe, deprecated, broken, or responsible for a verified issue.
9
+
10
+ ---
11
+
12
+ ## Table of Contents
13
+
14
+ 1. [Schema–Client Generation Drift](#schemaclient-generation-drift)
15
+ 2. [Safe Migration Workflow](#safe-migration-workflow)
16
+ 3. [Expand–Contract Changes](#expandcontract-changes)
17
+ 4. [Relations, Selection, and N+1](#relations-selection-and-n1)
18
+ 5. [Transaction Boundaries](#transaction-boundaries)
19
+ 6. [Indexes and Query Plans](#indexes-and-query-plans)
20
+ 7. [Connection Pooling and Runtime Constraints](#connection-pooling-and-runtime-constraints)
21
+
22
+ ---
23
+
24
+ ## Schema–Client Generation Drift
25
+
26
+ ### Problem
27
+ The Prisma schema, generated client, migration history, and deployed database describe different states. Typical symptoms are missing client properties, runtime errors for a new column, or a client that compiles locally but fails after deployment.
28
+
29
+ ### Verify first
30
+ - Confirm the database URL and schema used by the failing runtime.
31
+ - Compare the checked-in `prisma/schema.prisma`, committed migrations, and generated-client version.
32
+ - Determine whether the change is intentional schema drift, a missed migration, or a stale generated artifact. Do not use `db push` to repair a production migration history without understanding the consequence.
33
+
34
+ ### Fix
35
+ - Treat the Prisma schema and migration files as reviewed source of truth.
36
+ - After changing the schema, create or update the migration in development, then run `prisma generate` where the client is built.
37
+ - Deploy reviewed migrations with `prisma migrate deploy`; keep runtime images/functions responsible for generating or containing the matching client.
38
+ - Use [`prisma migrate diff`](https://www.prisma.io/docs/orm/prisma-migrate/workflows/troubleshooting#using-prisma-migrate-diff) to inspect a suspected difference before resolving drift.
39
+
40
+ ### Verify
41
+ - Run type checking and a narrow query that reads/writes the changed model against a representative database.
42
+ - In the deployment artifact, confirm the generated client version matches the installed `prisma` package and schema.
43
+
44
+ ---
45
+
46
+ ## Safe Migration Workflow
47
+
48
+ ### Problem
49
+ A migration succeeds on an empty development database but risks data loss, locking, or incompatible application behavior on a populated database.
50
+
51
+ ### Verify first
52
+ - Inspect the generated SQL before it reaches a shared environment.
53
+ - Estimate table size, write volume, existing nulls/duplicates, and lock sensitivity.
54
+ - Identify PostgreSQL version and whether the operation can run inside a transaction; some operations, such as `CREATE INDEX CONCURRENTLY`, cannot.
55
+
56
+ ### Fix
57
+ - Create migrations from the schema in development and commit both schema and migration SQL.
58
+ - Make destructive or data-dependent changes explicit. Backfill data deliberately rather than relying on a nullable-to-required change to succeed by chance.
59
+ - Test the actual migration against a production-like copy or representative dataset, including rollback or recovery procedures.
60
+ - Use `migrate deploy` for controlled environments; do not use development reset workflows against data that must be retained.
61
+
62
+ ### Verify
63
+ - Check the migration table and application health after deployment.
64
+ - Confirm expected row counts, constraints, and query behavior rather than treating a zero exit status as sufficient.
65
+
66
+ *Sources: [Prisma production and testing environments](https://www.prisma.io/docs/orm/prisma-migrate/workflows/development-and-production), [PostgreSQL ALTER TABLE](https://www.postgresql.org/docs/current/sql-altertable.html).*
67
+
68
+ ---
69
+
70
+ ## Expand–Contract Changes
71
+
72
+ ### Problem
73
+ A single migration removes or renames a column while older application instances, queued jobs, or rollback images still use it.
74
+
75
+ ### Verify first
76
+ - Identify every deployed version, asynchronous consumer, reporting query, and external integration that reads or writes the affected field.
77
+ - Confirm how long old instances can remain alive and whether a rollback would require the old schema.
78
+
79
+ ### Fix
80
+ 1. **Expand:** Add the new nullable column/table/index without removing the old interface.
81
+ 2. Deploy code that can read the old representation and write the new one (or dual-read/dual-write when necessary).
82
+ 3. Backfill in observable, bounded batches; validate completeness.
83
+ 4. Switch reads to the new representation after all active writers are compatible.
84
+ 5. **Contract:** Remove the old column, constraint, or code only in a later release.
85
+
86
+ Avoid dual writes when a database trigger, one-way compatibility read, or short maintenance window provides a simpler and safer invariant. The correct approach depends on consistency requirements and deployment overlap.
87
+
88
+ ### Verify
89
+ - Measure records remaining to backfill and compare old/new values where both exist.
90
+ - Before contraction, prove that no supported application version issues queries using the old schema.
91
+
92
+ *Source: [Prisma custom migration SQL](https://www.prisma.io/docs/orm/prisma-migrate/workflows/customizing-migrations).*
93
+
94
+ ---
95
+
96
+ ## Relations, Selection, and N+1
97
+
98
+ ### Symptom
99
+ An endpoint becomes slow as result count grows, emits one query per parent row, or transfers much more data than its response needs.
100
+
101
+ ### Verify first
102
+ - Enable query logging or inspect database activity to count queries for one request.
103
+ - Measure the response shape and identify exactly which scalar fields and relations are needed.
104
+ - Check cardinality: a broad `include` across multiple to-many relations can create large result sets even without a classic N+1 loop.
105
+
106
+ ### Fix
107
+ - Use `select` to request only needed scalar fields; use relation `select`/`include` deliberately.
108
+ - Fetch relation data in a bounded query rather than awaiting `findUnique` inside an application loop.
109
+ - Consider Prisma's relation load strategy only after measuring. `join` and `query` have different database and application trade-offs; availability depends on the provider and Prisma version.
110
+ - Paginate parent and child collections with stable ordering. Do not solve unbounded response size solely by adding eager loading.
111
+
112
+ ### Verify
113
+ - Assert query count and payload shape in an integration test or trace.
114
+ - Recheck latency and database load with representative cardinality.
115
+
116
+ *Source: [Prisma relation queries](https://www.prisma.io/docs/orm/prisma-client/queries/relation-queries).*
117
+
118
+ ---
119
+
120
+ ## Transaction Boundaries
121
+
122
+ ### Problem
123
+ A workflow leaves partial state after a failure, or a transaction holds locks/connections while it performs network I/O or slow computation.
124
+
125
+ ### Verify first
126
+ - Define the invariant that must be atomic and the acceptable behavior for retries.
127
+ - Identify external side effects (email, HTTP calls, queues, files): they cannot be atomically committed with a PostgreSQL transaction.
128
+ - Check contention, isolation requirements, and transaction duration under realistic concurrency.
129
+
130
+ ### Fix
131
+ - Use nested writes or `$transaction([])` for independent Prisma operations that must commit together.
132
+ - Use an interactive transaction only when later decisions depend on earlier reads, and keep its callback short.
133
+ - Perform external effects after commit, or record an outbox event transactionally and deliver it separately.
134
+ - Use database constraints and idempotency keys where possible; application-level check-then-insert logic alone races under concurrency.
135
+
136
+ ### Verify
137
+ - Force a failure at each write boundary and confirm the invariant remains true.
138
+ - Load-test conflicting operations and inspect retry/unique-constraint behavior.
139
+
140
+ *Sources: [Prisma transaction guidance](https://www.prisma.io/docs/orm/prisma-client/queries/transactions#transaction-options), [PostgreSQL transaction isolation](https://www.postgresql.org/docs/current/transaction-iso.html).*
141
+
142
+ ---
143
+
144
+ ## Indexes and Query Plans
145
+
146
+ ### Symptom
147
+ A correct query has rising latency, high I/O, sequential scans on a large table, or slow sorts after data growth.
148
+
149
+ ### Verify first
150
+ - Capture the actual SQL and bind values for the slow query.
151
+ - Run `EXPLAIN (ANALYZE, BUFFERS)` in a safe representative environment; it executes the statement, so do not use it casually on writes.
152
+ - Check table statistics, row estimates, predicate selectivity, ordering, joins, and the write cost of a proposed index.
153
+
154
+ ### Fix
155
+ - Add an index that matches the real filter, join, and ordering pattern. Composite index column order matters.
156
+ - Use a partial index only when its predicate consistently matches the query and remains selective.
157
+ - Prefer a separately managed migration for operationally sensitive indexes. PostgreSQL supports `CREATE INDEX CONCURRENTLY`, but it has transaction and failure-handling constraints.
158
+ - Do not add indexes based only on model fields or a plan from a tiny local dataset.
159
+
160
+ ### Verify
161
+ - Compare before/after plans, execution time, buffer reads, and write impact.
162
+ - Confirm the planner uses the index for representative parameters, not just one favorable value.
163
+
164
+ *Sources: [PostgreSQL EXPLAIN](https://www.postgresql.org/docs/current/using-explain.html), [multicolumn indexes](https://www.postgresql.org/docs/current/indexes-multicolumn.html), [CREATE INDEX](https://www.postgresql.org/docs/current/sql-createindex.html).*
165
+
166
+ ---
167
+
168
+ ## Connection Pooling and Runtime Constraints
169
+
170
+ ### Problem
171
+ Deployments intermittently exhaust database connections, work locally but fail under serverless concurrency, or create a Prisma client per request.
172
+
173
+ ### Verify first
174
+ - Determine the runtime model: long-lived process, containers with autoscaling, short-lived functions, edge runtime, or worker fleet.
175
+ - Calculate worst-case connections across all instances and pools against PostgreSQL `max_connections`, reserving capacity for administration and other services.
176
+ - Confirm whether the runtime supports the Prisma engine/client configuration in use; edge and serverless environments have specific constraints.
177
+
178
+ ### Fix
179
+ - Reuse one `PrismaClient` per long-lived process rather than constructing it for every request.
180
+ - Set pool limits based on total deployment concurrency, not a single instance. Use an external pooler where the platform topology requires it, and validate its compatibility with transaction/session behavior.
181
+ - Bound serverless concurrency when needed; connection pooling cannot make unlimited concurrent database work safe.
182
+ - Keep transactions short, because each active transaction consumes a connection.
183
+
184
+ ### Verify
185
+ - Observe active, waiting, and idle connections during a concurrency test.
186
+ - Test cold starts, scale-out, and failure recovery against the intended deployment topology.
187
+
188
+ *Sources: [Prisma connection management](https://www.prisma.io/docs/orm/prisma-client/setup-and-configuration/databases-connections/connection-management), [Prisma serverless guidance](https://www.prisma.io/docs/orm/prisma-client/setup-and-configuration/databases-connections#serverless-environments), [PostgreSQL connection settings](https://www.postgresql.org/docs/current/runtime-config-connection.html).*