create-apppaaaul 2.0.46 → 2.0.48

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 (215) hide show
  1. package/dist/templates/nextjs-ts-clean/project/.agents/skills/api-design-principles/SKILL.md +528 -0
  2. package/dist/templates/nextjs-ts-clean/project/.agents/skills/api-design-principles/assets/api-design-checklist.md +155 -0
  3. package/dist/templates/nextjs-ts-clean/project/.agents/skills/api-design-principles/assets/rest-api-template.py +182 -0
  4. package/dist/templates/nextjs-ts-clean/project/.agents/skills/api-design-principles/references/graphql-schema-design.md +583 -0
  5. package/dist/templates/nextjs-ts-clean/project/.agents/skills/api-design-principles/references/rest-best-practices.md +408 -0
  6. package/dist/templates/nextjs-ts-clean/project/.agents/skills/better-auth-best-practices/SKILL.md +166 -0
  7. package/dist/templates/nextjs-ts-clean/project/.agents/skills/brainstorming/SKILL.md +96 -0
  8. package/dist/templates/nextjs-ts-clean/project/.agents/skills/changelog-generator/SKILL.md +104 -0
  9. package/dist/templates/nextjs-ts-clean/project/.agents/skills/error-handling-patterns/SKILL.md +641 -0
  10. package/dist/templates/nextjs-ts-clean/project/.agents/skills/interface-design/SKILL.md +391 -0
  11. package/dist/templates/nextjs-ts-clean/project/.agents/skills/interface-design/references/critique.md +67 -0
  12. package/dist/templates/nextjs-ts-clean/project/.agents/skills/interface-design/references/example.md +86 -0
  13. package/dist/templates/nextjs-ts-clean/project/.agents/skills/interface-design/references/principles.md +235 -0
  14. package/dist/templates/nextjs-ts-clean/project/.agents/skills/interface-design/references/validation.md +48 -0
  15. package/dist/templates/nextjs-ts-clean/project/.agents/skills/next-best-practices/SKILL.md +153 -0
  16. package/dist/templates/nextjs-ts-clean/project/.agents/skills/next-best-practices/async-patterns.md +87 -0
  17. package/dist/templates/nextjs-ts-clean/project/.agents/skills/next-best-practices/bundling.md +180 -0
  18. package/dist/templates/nextjs-ts-clean/project/.agents/skills/next-best-practices/data-patterns.md +297 -0
  19. package/dist/templates/nextjs-ts-clean/project/.agents/skills/next-best-practices/debug-tricks.md +105 -0
  20. package/dist/templates/nextjs-ts-clean/project/.agents/skills/next-best-practices/directives.md +73 -0
  21. package/dist/templates/nextjs-ts-clean/project/.agents/skills/next-best-practices/error-handling.md +227 -0
  22. package/dist/templates/nextjs-ts-clean/project/.agents/skills/next-best-practices/file-conventions.md +140 -0
  23. package/dist/templates/nextjs-ts-clean/project/.agents/skills/next-best-practices/font.md +245 -0
  24. package/dist/templates/nextjs-ts-clean/project/.agents/skills/next-best-practices/functions.md +108 -0
  25. package/dist/templates/nextjs-ts-clean/project/.agents/skills/next-best-practices/hydration-error.md +91 -0
  26. package/dist/templates/nextjs-ts-clean/project/.agents/skills/next-best-practices/image.md +173 -0
  27. package/dist/templates/nextjs-ts-clean/project/.agents/skills/next-best-practices/metadata.md +301 -0
  28. package/dist/templates/nextjs-ts-clean/project/.agents/skills/next-best-practices/parallel-routes.md +287 -0
  29. package/dist/templates/nextjs-ts-clean/project/.agents/skills/next-best-practices/route-handlers.md +146 -0
  30. package/dist/templates/nextjs-ts-clean/project/.agents/skills/next-best-practices/rsc-boundaries.md +159 -0
  31. package/dist/templates/nextjs-ts-clean/project/.agents/skills/next-best-practices/runtime-selection.md +39 -0
  32. package/dist/templates/nextjs-ts-clean/project/.agents/skills/next-best-practices/scripts.md +141 -0
  33. package/dist/templates/nextjs-ts-clean/project/.agents/skills/next-best-practices/self-hosting.md +371 -0
  34. package/dist/templates/nextjs-ts-clean/project/.agents/skills/next-best-practices/suspense-boundaries.md +67 -0
  35. package/dist/templates/nextjs-ts-clean/project/.agents/skills/postgresql-table-design/SKILL.md +202 -0
  36. package/dist/templates/nextjs-ts-clean/project/.agents/skills/prompt-engineering-patterns/SKILL.md +480 -0
  37. package/dist/templates/nextjs-ts-clean/project/.agents/skills/prompt-engineering-patterns/assets/few-shot-examples.json +106 -0
  38. package/dist/templates/nextjs-ts-clean/project/.agents/skills/prompt-engineering-patterns/assets/prompt-template-library.md +264 -0
  39. package/dist/templates/nextjs-ts-clean/project/.agents/skills/prompt-engineering-patterns/references/chain-of-thought.md +412 -0
  40. package/dist/templates/nextjs-ts-clean/project/.agents/skills/prompt-engineering-patterns/references/few-shot-learning.md +386 -0
  41. package/dist/templates/nextjs-ts-clean/project/.agents/skills/prompt-engineering-patterns/references/prompt-optimization.md +428 -0
  42. package/dist/templates/nextjs-ts-clean/project/.agents/skills/prompt-engineering-patterns/references/prompt-templates.md +484 -0
  43. package/dist/templates/nextjs-ts-clean/project/.agents/skills/prompt-engineering-patterns/references/system-prompts.md +195 -0
  44. package/dist/templates/nextjs-ts-clean/project/.agents/skills/prompt-engineering-patterns/scripts/optimize-prompt.py +279 -0
  45. package/dist/templates/nextjs-ts-clean/project/.agents/skills/seo-audit/SKILL.md +410 -0
  46. package/dist/templates/nextjs-ts-clean/project/.agents/skills/seo-audit/references/aeo-geo-patterns.md +285 -0
  47. package/dist/templates/nextjs-ts-clean/project/.agents/skills/seo-audit/references/ai-writing-detection.md +200 -0
  48. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/AGENTS.md +2934 -0
  49. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/SKILL.md +136 -0
  50. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/advanced-event-handler-refs.md +55 -0
  51. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/advanced-init-once.md +42 -0
  52. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/advanced-use-latest.md +39 -0
  53. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/async-api-routes.md +38 -0
  54. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/async-defer-await.md +80 -0
  55. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/async-dependencies.md +51 -0
  56. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/async-parallel.md +28 -0
  57. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/async-suspense-boundaries.md +99 -0
  58. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/bundle-barrel-imports.md +59 -0
  59. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/bundle-conditional.md +31 -0
  60. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/bundle-defer-third-party.md +49 -0
  61. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/bundle-dynamic-imports.md +35 -0
  62. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/bundle-preload.md +50 -0
  63. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/client-event-listeners.md +74 -0
  64. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/client-localstorage-schema.md +71 -0
  65. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/client-passive-event-listeners.md +48 -0
  66. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/client-swr-dedup.md +56 -0
  67. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/js-batch-dom-css.md +107 -0
  68. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/js-cache-function-results.md +80 -0
  69. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/js-cache-property-access.md +28 -0
  70. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/js-cache-storage.md +70 -0
  71. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/js-combine-iterations.md +32 -0
  72. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/js-early-exit.md +50 -0
  73. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/js-hoist-regexp.md +45 -0
  74. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/js-index-maps.md +37 -0
  75. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/js-length-check-first.md +49 -0
  76. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/js-min-max-loop.md +82 -0
  77. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/js-set-map-lookups.md +24 -0
  78. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/js-tosorted-immutable.md +57 -0
  79. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/rendering-activity.md +26 -0
  80. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/rendering-animate-svg-wrapper.md +47 -0
  81. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/rendering-conditional-render.md +40 -0
  82. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/rendering-content-visibility.md +38 -0
  83. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/rendering-hoist-jsx.md +46 -0
  84. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/rendering-hydration-no-flicker.md +82 -0
  85. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/rendering-hydration-suppress-warning.md +30 -0
  86. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/rendering-svg-precision.md +28 -0
  87. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/rendering-usetransition-loading.md +75 -0
  88. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/rerender-defer-reads.md +39 -0
  89. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/rerender-dependencies.md +45 -0
  90. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/rerender-derived-state-no-effect.md +40 -0
  91. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/rerender-derived-state.md +29 -0
  92. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/rerender-functional-setstate.md +74 -0
  93. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/rerender-lazy-state-init.md +58 -0
  94. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/rerender-memo-with-default-value.md +38 -0
  95. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/rerender-memo.md +44 -0
  96. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/rerender-move-effect-to-event.md +45 -0
  97. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/rerender-simple-expression-in-memo.md +35 -0
  98. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/rerender-transitions.md +40 -0
  99. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/rerender-use-ref-transient-values.md +73 -0
  100. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/server-after-nonblocking.md +73 -0
  101. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/server-auth-actions.md +96 -0
  102. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/server-cache-lru.md +41 -0
  103. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/server-cache-react.md +76 -0
  104. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/server-dedup-props.md +65 -0
  105. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/server-parallel-fetching.md +83 -0
  106. package/dist/templates/nextjs-ts-clean/project/.agents/skills/vercel-react-best-practices/rules/server-serialization.md +38 -0
  107. package/dist/templates/nextjs-ts-clean/project/package.json +1 -1
  108. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/api-design-principles/SKILL.md +528 -0
  109. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/api-design-principles/assets/api-design-checklist.md +155 -0
  110. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/api-design-principles/assets/rest-api-template.py +182 -0
  111. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/api-design-principles/references/graphql-schema-design.md +583 -0
  112. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/api-design-principles/references/rest-best-practices.md +408 -0
  113. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/better-auth-best-practices/SKILL.md +166 -0
  114. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/brainstorming/SKILL.md +96 -0
  115. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/changelog-generator/SKILL.md +104 -0
  116. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/error-handling-patterns/SKILL.md +641 -0
  117. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/interface-design/SKILL.md +391 -0
  118. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/interface-design/references/critique.md +67 -0
  119. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/interface-design/references/example.md +86 -0
  120. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/interface-design/references/principles.md +235 -0
  121. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/interface-design/references/validation.md +48 -0
  122. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/next-best-practices/SKILL.md +153 -0
  123. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/next-best-practices/async-patterns.md +87 -0
  124. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/next-best-practices/bundling.md +180 -0
  125. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/next-best-practices/data-patterns.md +297 -0
  126. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/next-best-practices/debug-tricks.md +105 -0
  127. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/next-best-practices/directives.md +73 -0
  128. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/next-best-practices/error-handling.md +227 -0
  129. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/next-best-practices/file-conventions.md +140 -0
  130. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/next-best-practices/font.md +245 -0
  131. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/next-best-practices/functions.md +108 -0
  132. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/next-best-practices/hydration-error.md +91 -0
  133. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/next-best-practices/image.md +173 -0
  134. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/next-best-practices/metadata.md +301 -0
  135. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/next-best-practices/parallel-routes.md +287 -0
  136. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/next-best-practices/route-handlers.md +146 -0
  137. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/next-best-practices/rsc-boundaries.md +159 -0
  138. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/next-best-practices/runtime-selection.md +39 -0
  139. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/next-best-practices/scripts.md +141 -0
  140. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/next-best-practices/self-hosting.md +371 -0
  141. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/next-best-practices/suspense-boundaries.md +67 -0
  142. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/postgresql-table-design/SKILL.md +202 -0
  143. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/prompt-engineering-patterns/SKILL.md +480 -0
  144. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/prompt-engineering-patterns/assets/few-shot-examples.json +106 -0
  145. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/prompt-engineering-patterns/assets/prompt-template-library.md +264 -0
  146. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/prompt-engineering-patterns/references/chain-of-thought.md +412 -0
  147. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/prompt-engineering-patterns/references/few-shot-learning.md +386 -0
  148. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/prompt-engineering-patterns/references/prompt-optimization.md +428 -0
  149. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/prompt-engineering-patterns/references/prompt-templates.md +484 -0
  150. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/prompt-engineering-patterns/references/system-prompts.md +195 -0
  151. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/prompt-engineering-patterns/scripts/optimize-prompt.py +279 -0
  152. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/seo-audit/SKILL.md +410 -0
  153. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/seo-audit/references/aeo-geo-patterns.md +285 -0
  154. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/seo-audit/references/ai-writing-detection.md +200 -0
  155. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/AGENTS.md +2934 -0
  156. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/SKILL.md +136 -0
  157. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/advanced-event-handler-refs.md +55 -0
  158. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/advanced-init-once.md +42 -0
  159. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/advanced-use-latest.md +39 -0
  160. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/async-api-routes.md +38 -0
  161. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/async-defer-await.md +80 -0
  162. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/async-dependencies.md +51 -0
  163. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/async-parallel.md +28 -0
  164. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/async-suspense-boundaries.md +99 -0
  165. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/bundle-barrel-imports.md +59 -0
  166. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/bundle-conditional.md +31 -0
  167. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/bundle-defer-third-party.md +49 -0
  168. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/bundle-dynamic-imports.md +35 -0
  169. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/bundle-preload.md +50 -0
  170. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/client-event-listeners.md +74 -0
  171. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/client-localstorage-schema.md +71 -0
  172. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/client-passive-event-listeners.md +48 -0
  173. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/client-swr-dedup.md +56 -0
  174. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/js-batch-dom-css.md +107 -0
  175. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/js-cache-function-results.md +80 -0
  176. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/js-cache-property-access.md +28 -0
  177. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/js-cache-storage.md +70 -0
  178. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/js-combine-iterations.md +32 -0
  179. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/js-early-exit.md +50 -0
  180. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/js-hoist-regexp.md +45 -0
  181. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/js-index-maps.md +37 -0
  182. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/js-length-check-first.md +49 -0
  183. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/js-min-max-loop.md +82 -0
  184. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/js-set-map-lookups.md +24 -0
  185. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/js-tosorted-immutable.md +57 -0
  186. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/rendering-activity.md +26 -0
  187. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/rendering-animate-svg-wrapper.md +47 -0
  188. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/rendering-conditional-render.md +40 -0
  189. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/rendering-content-visibility.md +38 -0
  190. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/rendering-hoist-jsx.md +46 -0
  191. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/rendering-hydration-no-flicker.md +82 -0
  192. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/rendering-hydration-suppress-warning.md +30 -0
  193. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/rendering-svg-precision.md +28 -0
  194. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/rendering-usetransition-loading.md +75 -0
  195. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/rerender-defer-reads.md +39 -0
  196. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/rerender-dependencies.md +45 -0
  197. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/rerender-derived-state-no-effect.md +40 -0
  198. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/rerender-derived-state.md +29 -0
  199. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/rerender-functional-setstate.md +74 -0
  200. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/rerender-lazy-state-init.md +58 -0
  201. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/rerender-memo-with-default-value.md +38 -0
  202. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/rerender-memo.md +44 -0
  203. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/rerender-move-effect-to-event.md +45 -0
  204. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/rerender-simple-expression-in-memo.md +35 -0
  205. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/rerender-transitions.md +40 -0
  206. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/rerender-use-ref-transient-values.md +73 -0
  207. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/server-after-nonblocking.md +73 -0
  208. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/server-auth-actions.md +96 -0
  209. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/server-cache-lru.md +41 -0
  210. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/server-cache-react.md +76 -0
  211. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/server-dedup-props.md +65 -0
  212. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/server-parallel-fetching.md +83 -0
  213. package/dist/templates/nextjs-ts-landing-prisma/project/.agents/skills/vercel-react-best-practices/rules/server-serialization.md +38 -0
  214. package/dist/templates/nextjs-ts-landing-prisma/project/package.json +1 -1
  215. package/package.json +1 -1
@@ -0,0 +1,202 @@
1
+ ---
2
+ name: postgresql-table-design
3
+ description: Design a PostgreSQL-specific schema. Covers best-practices, data types, indexing, constraints, performance patterns, and advanced features
4
+ ---
5
+
6
+ # PostgreSQL Table Design
7
+
8
+ ## Core Rules
9
+
10
+ - Define a **PRIMARY KEY** for reference tables (users, orders, etc.). Not always needed for time-series/event/log data. When used, prefer `BIGINT GENERATED ALWAYS AS IDENTITY`; use `UUID` only when global uniqueness/opacity is needed.
11
+ - **Normalize first (to 3NF)** to eliminate data redundancy and update anomalies; denormalize **only** for measured, high-ROI reads where join performance is proven problematic. Premature denormalization creates maintenance burden.
12
+ - Add **NOT NULL** everywhere it’s semantically required; use **DEFAULT**s for common values.
13
+ - Create **indexes for access paths you actually query**: PK/unique (auto), **FK columns (manual!)**, frequent filters/sorts, and join keys.
14
+ - Prefer **TIMESTAMPTZ** for event time; **NUMERIC** for money; **TEXT** for strings; **BIGINT** for integer values, **DOUBLE PRECISION** for floats (or `NUMERIC` for exact decimal arithmetic).
15
+
16
+ ## PostgreSQL “Gotchas”
17
+
18
+ - **Identifiers**: unquoted → lowercased. Avoid quoted/mixed-case names. Convention: use `snake_case` for table/column names.
19
+ - **Unique + NULLs**: UNIQUE allows multiple NULLs. Use `UNIQUE (...) NULLS NOT DISTINCT` (PG15+) to restrict to one NULL.
20
+ - **FK indexes**: PostgreSQL **does not** auto-index FK columns. Add them.
21
+ - **No silent coercions**: length/precision overflows error out (no truncation). Example: inserting 999 into `NUMERIC(2,0)` fails with error, unlike some databases that silently truncate or round.
22
+ - **Sequences/identity have gaps** (normal; don't "fix"). Rollbacks, crashes, and concurrent transactions create gaps in ID sequences (1, 2, 5, 6...). This is expected behavior—don't try to make IDs consecutive.
23
+ - **Heap storage**: no clustered PK by default (unlike SQL Server/MySQL InnoDB); `CLUSTER` is one-off reorganization, not maintained on subsequent inserts. Row order on disk is insertion order unless explicitly clustered.
24
+ - **MVCC**: updates/deletes leave dead tuples; vacuum handles them—design to avoid hot wide-row churn.
25
+
26
+ ## Data Types
27
+
28
+ - **IDs**: `BIGINT GENERATED ALWAYS AS IDENTITY` preferred (`GENERATED BY DEFAULT` also fine); `UUID` when merging/federating/used in a distributed system or for opaque IDs. Generate with `uuidv7()` (preferred if using PG18+) or `gen_random_uuid()` (if using an older PG version).
29
+ - **Integers**: prefer `BIGINT` unless storage space is critical; `INTEGER` for smaller ranges; avoid `SMALLINT` unless constrained.
30
+ - **Floats**: prefer `DOUBLE PRECISION` over `REAL` unless storage space is critical. Use `NUMERIC` for exact decimal arithmetic.
31
+ - **Strings**: prefer `TEXT`; if length limits needed, use `CHECK (LENGTH(col) <= n)` instead of `VARCHAR(n)`; avoid `CHAR(n)`. Use `BYTEA` for binary data. Large strings/binary (>2KB default threshold) automatically stored in TOAST with compression. TOAST storage: `PLAIN` (no TOAST), `EXTENDED` (compress + out-of-line), `EXTERNAL` (out-of-line, no compress), `MAIN` (compress, keep in-line if possible). Default `EXTENDED` usually optimal. Control with `ALTER TABLE tbl ALTER COLUMN col SET STORAGE strategy` and `ALTER TABLE tbl SET (toast_tuple_target = 4096)` for threshold. Case-insensitive: for locale/accent handling use non-deterministic collations; for plain ASCII use expression indexes on `LOWER(col)` (preferred unless column needs case-insensitive PK/FK/UNIQUE) or `CITEXT`.
32
+ - **Money**: `NUMERIC(p,s)` (never float).
33
+ - **Time**: `TIMESTAMPTZ` for timestamps; `DATE` for date-only; `INTERVAL` for durations. Avoid `TIMESTAMP` (without timezone). Use `now()` for transaction start time, `clock_timestamp()` for current wall-clock time.
34
+ - **Booleans**: `BOOLEAN` with `NOT NULL` constraint unless tri-state values are required.
35
+ - **Enums**: `CREATE TYPE ... AS ENUM` for small, stable sets (e.g. US states, days of week). For business-logic-driven and evolving values (e.g. order statuses) → use TEXT (or INT) + CHECK or lookup table.
36
+ - **Arrays**: `TEXT[]`, `INTEGER[]`, etc. Use for ordered lists where you query elements. Index with **GIN** for containment (`@>`, `<@`) and overlap (`&&`) queries. Access: `arr[1]` (1-indexed), `arr[1:3]` (slicing). Good for tags, categories; avoid for relations—use junction tables instead. Literal syntax: `'{val1,val2}'` or `ARRAY[val1,val2]`.
37
+ - **Range types**: `daterange`, `numrange`, `tstzrange` for intervals. Support overlap (`&&`), containment (`@>`), operators. Index with **GiST**. Good for scheduling, versioning, numeric ranges. Pick a bounds scheme and use it consistently; prefer `[)` (inclusive/exclusive) by default.
38
+ - **Network types**: `INET` for IP addresses, `CIDR` for network ranges, `MACADDR` for MAC addresses. Support network operators (`<<`, `>>`, `&&`).
39
+ - **Geometric types**: `POINT`, `LINE`, `POLYGON`, `CIRCLE` for 2D spatial data. Index with **GiST**. Consider **PostGIS** for advanced spatial features.
40
+ - **Text search**: `TSVECTOR` for full-text search documents, `TSQUERY` for search queries. Index `tsvector` with **GIN**. Always specify language: `to_tsvector('english', col)` and `to_tsquery('english', 'query')`. Never use single-argument versions. This applies to both index expressions and queries.
41
+ - **Domain types**: `CREATE DOMAIN email AS TEXT CHECK (VALUE ~ '^[^@]+@[^@]+$')` for reusable custom types with validation. Enforces constraints across tables.
42
+ - **Composite types**: `CREATE TYPE address AS (street TEXT, city TEXT, zip TEXT)` for structured data within columns. Access with `(col).field` syntax.
43
+ - **JSONB**: preferred over JSON; index with **GIN**. Use only for optional/semi-structured attrs. ONLY use JSON if the original ordering of the contents MUST be preserved.
44
+ - **Vector types**: `vector` type by `pgvector` for vector similarity search for embeddings.
45
+
46
+ ### Do not use the following data types
47
+
48
+ - DO NOT use `timestamp` (without time zone); DO use `timestamptz` instead.
49
+ - DO NOT use `char(n)` or `varchar(n)`; DO use `text` instead.
50
+ - DO NOT use `money` type; DO use `numeric` instead.
51
+ - DO NOT use `timetz` type; DO use `timestamptz` instead.
52
+ - DO NOT use `timestamptz(0)` or any other precision specification; DO use `timestamptz` instead
53
+ - DO NOT use `serial` type; DO use `generated always as identity` instead.
54
+
55
+ ## Table Types
56
+
57
+ - **Regular**: default; fully durable, logged.
58
+ - **TEMPORARY**: session-scoped, auto-dropped, not logged. Faster for scratch work.
59
+ - **UNLOGGED**: persistent but not crash-safe. Faster writes; good for caches/staging.
60
+
61
+ ## Row-Level Security
62
+
63
+ Enable with `ALTER TABLE tbl ENABLE ROW LEVEL SECURITY`. Create policies: `CREATE POLICY user_access ON orders FOR SELECT TO app_users USING (user_id = current_user_id())`. Built-in user-based access control at the row level.
64
+
65
+ ## Constraints
66
+
67
+ - **PK**: implicit UNIQUE + NOT NULL; creates a B-tree index.
68
+ - **FK**: specify `ON DELETE/UPDATE` action (`CASCADE`, `RESTRICT`, `SET NULL`, `SET DEFAULT`). Add explicit index on referencing column—speeds up joins and prevents locking issues on parent deletes/updates. Use `DEFERRABLE INITIALLY DEFERRED` for circular FK dependencies checked at transaction end.
69
+ - **UNIQUE**: creates a B-tree index; allows multiple NULLs unless `NULLS NOT DISTINCT` (PG15+). Standard behavior: `(1, NULL)` and `(1, NULL)` are allowed. With `NULLS NOT DISTINCT`: only one `(1, NULL)` allowed. Prefer `NULLS NOT DISTINCT` unless you specifically need duplicate NULLs.
70
+ - **CHECK**: row-local constraints; NULL values pass the check (three-valued logic). Example: `CHECK (price > 0)` allows NULL prices. Combine with `NOT NULL` to enforce: `price NUMERIC NOT NULL CHECK (price > 0)`.
71
+ - **EXCLUDE**: prevents overlapping values using operators. `EXCLUDE USING gist (room_id WITH =, booking_period WITH &&)` prevents double-booking rooms. Requires appropriate index type (often GiST).
72
+
73
+ ## Indexing
74
+
75
+ - **B-tree**: default for equality/range queries (`=`, `<`, `>`, `BETWEEN`, `ORDER BY`)
76
+ - **Composite**: order matters—index used if equality on leftmost prefix (`WHERE a = ? AND b > ?` uses index on `(a,b)`, but `WHERE b = ?` does not). Put most selective/frequently filtered columns first.
77
+ - **Covering**: `CREATE INDEX ON tbl (id) INCLUDE (name, email)` - includes non-key columns for index-only scans without visiting table.
78
+ - **Partial**: for hot subsets (`WHERE status = 'active'` → `CREATE INDEX ON tbl (user_id) WHERE status = 'active'`). Any query with `status = 'active'` can use this index.
79
+ - **Expression**: for computed search keys (`CREATE INDEX ON tbl (LOWER(email))`). Expression must match exactly in WHERE clause: `WHERE LOWER(email) = 'user@example.com'`.
80
+ - **GIN**: JSONB containment/existence, arrays (`@>`, `?`), full-text search (`@@`)
81
+ - **GiST**: ranges, geometry, exclusion constraints
82
+ - **BRIN**: very large, naturally ordered data (time-series)—minimal storage overhead. Effective when row order on disk correlates with indexed column (insertion order or after `CLUSTER`).
83
+
84
+ ## Partitioning
85
+
86
+ - Use for very large tables (>100M rows) where queries consistently filter on partition key (often time/date).
87
+ - Alternate use: use for tables where data maintenance tasks dictates e.g. data pruned or bulk replaced periodically
88
+ - **RANGE**: common for time-series (`PARTITION BY RANGE (created_at)`). Create partitions: `CREATE TABLE logs_2024_01 PARTITION OF logs FOR VALUES FROM ('2024-01-01') TO ('2024-02-01')`. **TimescaleDB** automates time-based or ID-based partitioning with retention policies and compression.
89
+ - **LIST**: for discrete values (`PARTITION BY LIST (region)`). Example: `FOR VALUES IN ('us-east', 'us-west')`.
90
+ - **HASH**: for even distribution when no natural key (`PARTITION BY HASH (user_id)`). Creates N partitions with modulus.
91
+ - **Constraint exclusion**: requires `CHECK` constraints on partitions for query planner to prune. Auto-created for declarative partitioning (PG10+).
92
+ - Prefer declarative partitioning or hypertables. Do NOT use table inheritance.
93
+ - **Limitations**: no global UNIQUE constraints—include partition key in PK/UNIQUE. FKs from partitioned tables not supported; use triggers.
94
+
95
+ ## Special Considerations
96
+
97
+ ### Update-Heavy Tables
98
+
99
+ - **Separate hot/cold columns**—put frequently updated columns in separate table to minimize bloat.
100
+ - **Use `fillfactor=90`** to leave space for HOT updates that avoid index maintenance.
101
+ - **Avoid updating indexed columns**—prevents beneficial HOT updates.
102
+ - **Partition by update patterns**—separate frequently updated rows in a different partition from stable data.
103
+
104
+ ### Insert-Heavy Workloads
105
+
106
+ - **Minimize indexes**—only create what you query; every index slows inserts.
107
+ - **Use `COPY` or multi-row `INSERT`** instead of single-row inserts.
108
+ - **UNLOGGED tables** for rebuildable staging data—much faster writes.
109
+ - **Defer index creation** for bulk loads—>drop index, load data, recreate indexes.
110
+ - **Partition by time/hash** to distribute load. **TimescaleDB** automates partitioning and compression of insert-heavy data.
111
+ - **Use a natural key for primary key** such as a (timestamp, device_id) if enforcing global uniqueness is important many insert-heavy tables don't need a primary key at all.
112
+ - If you do need a surrogate key, **Prefer `BIGINT GENERATED ALWAYS AS IDENTITY` over `UUID`**.
113
+
114
+ ### Upsert-Friendly Design
115
+
116
+ - **Requires UNIQUE index** on conflict target columns—`ON CONFLICT (col1, col2)` needs exact matching unique index (partial indexes don't work).
117
+ - **Use `EXCLUDED.column`** to reference would-be-inserted values; only update columns that actually changed to reduce write overhead.
118
+ - **`DO NOTHING` faster** than `DO UPDATE` when no actual update needed.
119
+
120
+ ### Safe Schema Evolution
121
+
122
+ - **Transactional DDL**: most DDL operations can run in transactions and be rolled back—`BEGIN; ALTER TABLE...; ROLLBACK;` for safe testing.
123
+ - **Concurrent index creation**: `CREATE INDEX CONCURRENTLY` avoids blocking writes but can't run in transactions.
124
+ - **Volatile defaults cause rewrites**: adding `NOT NULL` columns with volatile defaults (e.g., `now()`, `gen_random_uuid()`) rewrites entire table. Non-volatile defaults are fast.
125
+ - **Drop constraints before columns**: `ALTER TABLE DROP CONSTRAINT` then `DROP COLUMN` to avoid dependency issues.
126
+ - **Function signature changes**: `CREATE OR REPLACE` with different arguments creates overloads, not replacements. DROP old version if no overload desired.
127
+
128
+ ## Generated Columns
129
+
130
+ - `... GENERATED ALWAYS AS (<expr>) STORED` for computed, indexable fields. PG18+ adds `VIRTUAL` columns (computed on read, not stored).
131
+
132
+ ## Extensions
133
+
134
+ - **`pgcrypto`**: `crypt()` for password hashing.
135
+ - **`uuid-ossp`**: alternative UUID functions; prefer `pgcrypto` for new projects.
136
+ - **`pg_trgm`**: fuzzy text search with `%` operator, `similarity()` function. Index with GIN for `LIKE '%pattern%'` acceleration.
137
+ - **`citext`**: case-insensitive text type. Prefer expression indexes on `LOWER(col)` unless you need case-insensitive constraints.
138
+ - **`btree_gin`/`btree_gist`**: enable mixed-type indexes (e.g., GIN index on both JSONB and text columns).
139
+ - **`hstore`**: key-value pairs; mostly superseded by JSONB but useful for simple string mappings.
140
+ - **`timescaledb`**: essential for time-series—automated partitioning, retention, compression, continuous aggregates.
141
+ - **`postgis`**: comprehensive geospatial support beyond basic geometric types—essential for location-based applications.
142
+ - **`pgvector`**: vector similarity search for embeddings.
143
+ - **`pgaudit`**: audit logging for all database activity.
144
+
145
+ ## JSONB Guidance
146
+
147
+ - Prefer `JSONB` with **GIN** index.
148
+ - Default: `CREATE INDEX ON tbl USING GIN (jsonb_col);` → accelerates:
149
+ - **Containment** `jsonb_col @> '{"k":"v"}'`
150
+ - **Key existence** `jsonb_col ? 'k'`, **any/all keys** `?\|`, `?&`
151
+ - **Path containment** on nested docs
152
+ - **Disjunction** `jsonb_col @> ANY(ARRAY['{"status":"active"}', '{"status":"pending"}'])`
153
+ - Heavy `@>` workloads: consider opclass `jsonb_path_ops` for smaller/faster containment-only indexes:
154
+ - `CREATE INDEX ON tbl USING GIN (jsonb_col jsonb_path_ops);`
155
+ - **Trade-off**: loses support for key existence (`?`, `?|`, `?&`) queries—only supports containment (`@>`)
156
+ - Equality/range on a specific scalar field: extract and index with B-tree (generated column or expression):
157
+ - `ALTER TABLE tbl ADD COLUMN price INT GENERATED ALWAYS AS ((jsonb_col->>'price')::INT) STORED;`
158
+ - `CREATE INDEX ON tbl (price);`
159
+ - Prefer queries like `WHERE price BETWEEN 100 AND 500` (uses B-tree) over `WHERE (jsonb_col->>'price')::INT BETWEEN 100 AND 500` without index.
160
+ - Arrays inside JSONB: use GIN + `@>` for containment (e.g., tags). Consider `jsonb_path_ops` if only doing containment.
161
+ - Keep core relations in tables; use JSONB for optional/variable attributes.
162
+ - Use constraints to limit allowed JSONB values in a column e.g. `config JSONB NOT NULL CHECK(jsonb_typeof(config) = 'object')`
163
+
164
+ ## Examples
165
+
166
+ ### Users
167
+
168
+ ```sql
169
+ CREATE TABLE users (
170
+ user_id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
171
+ email TEXT NOT NULL UNIQUE,
172
+ name TEXT NOT NULL,
173
+ created_at TIMESTAMPTZ NOT NULL DEFAULT now()
174
+ );
175
+ CREATE UNIQUE INDEX ON users (LOWER(email));
176
+ CREATE INDEX ON users (created_at);
177
+ ```
178
+
179
+ ### Orders
180
+
181
+ ```sql
182
+ CREATE TABLE orders (
183
+ order_id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
184
+ user_id BIGINT NOT NULL REFERENCES users(user_id),
185
+ status TEXT NOT NULL DEFAULT 'PENDING' CHECK (status IN ('PENDING','PAID','CANCELED')),
186
+ total NUMERIC(10,2) NOT NULL CHECK (total > 0),
187
+ created_at TIMESTAMPTZ NOT NULL DEFAULT now()
188
+ );
189
+ CREATE INDEX ON orders (user_id);
190
+ CREATE INDEX ON orders (created_at);
191
+ ```
192
+
193
+ ### JSONB
194
+
195
+ ```sql
196
+ CREATE TABLE profiles (
197
+ user_id BIGINT PRIMARY KEY REFERENCES users(user_id),
198
+ attrs JSONB NOT NULL DEFAULT '{}',
199
+ theme TEXT GENERATED ALWAYS AS (attrs->>'theme') STORED
200
+ );
201
+ CREATE INDEX profiles_attrs_gin ON profiles USING GIN (attrs);
202
+ ```
@@ -0,0 +1,480 @@
1
+ ---
2
+ name: prompt-engineering-patterns
3
+ description: Master advanced prompt engineering techniques to maximize LLM performance, reliability, and controllability in production. Use when optimizing prompts, improving LLM outputs, or designing production prompt templates.
4
+ ---
5
+
6
+ # Prompt Engineering Patterns
7
+
8
+ Master advanced prompt engineering techniques to maximize LLM performance, reliability, and controllability.
9
+
10
+ ## When to Use This Skill
11
+
12
+ - Designing complex prompts for production LLM applications
13
+ - Optimizing prompt performance and consistency
14
+ - Implementing structured reasoning patterns (chain-of-thought, tree-of-thought)
15
+ - Building few-shot learning systems with dynamic example selection
16
+ - Creating reusable prompt templates with variable interpolation
17
+ - Debugging and refining prompts that produce inconsistent outputs
18
+ - Implementing system prompts for specialized AI assistants
19
+ - Using structured outputs (JSON mode) for reliable parsing
20
+
21
+ ## Core Capabilities
22
+
23
+ ### 1. Few-Shot Learning
24
+
25
+ - Example selection strategies (semantic similarity, diversity sampling)
26
+ - Balancing example count with context window constraints
27
+ - Constructing effective demonstrations with input-output pairs
28
+ - Dynamic example retrieval from knowledge bases
29
+ - Handling edge cases through strategic example selection
30
+
31
+ ### 2. Chain-of-Thought Prompting
32
+
33
+ - Step-by-step reasoning elicitation
34
+ - Zero-shot CoT with "Let's think step by step"
35
+ - Few-shot CoT with reasoning traces
36
+ - Self-consistency techniques (sampling multiple reasoning paths)
37
+ - Verification and validation steps
38
+
39
+ ### 3. Structured Outputs
40
+
41
+ - JSON mode for reliable parsing
42
+ - Pydantic schema enforcement
43
+ - Type-safe response handling
44
+ - Error handling for malformed outputs
45
+
46
+ ### 4. Prompt Optimization
47
+
48
+ - Iterative refinement workflows
49
+ - A/B testing prompt variations
50
+ - Measuring prompt performance metrics (accuracy, consistency, latency)
51
+ - Reducing token usage while maintaining quality
52
+ - Handling edge cases and failure modes
53
+
54
+ ### 5. Template Systems
55
+
56
+ - Variable interpolation and formatting
57
+ - Conditional prompt sections
58
+ - Multi-turn conversation templates
59
+ - Role-based prompt composition
60
+ - Modular prompt components
61
+
62
+ ### 6. System Prompt Design
63
+
64
+ - Setting model behavior and constraints
65
+ - Defining output formats and structure
66
+ - Establishing role and expertise
67
+ - Safety guidelines and content policies
68
+ - Context setting and background information
69
+
70
+ ## Quick Start
71
+
72
+ ```python
73
+ from langchain_anthropic import ChatAnthropic
74
+ from langchain_core.prompts import ChatPromptTemplate
75
+ from pydantic import BaseModel, Field
76
+
77
+ # Define structured output schema
78
+ class SQLQuery(BaseModel):
79
+ query: str = Field(description="The SQL query")
80
+ explanation: str = Field(description="Brief explanation of what the query does")
81
+ tables_used: list[str] = Field(description="List of tables referenced")
82
+
83
+ # Initialize model with structured output
84
+ llm = ChatAnthropic(model="claude-sonnet-4-5")
85
+ structured_llm = llm.with_structured_output(SQLQuery)
86
+
87
+ # Create prompt template
88
+ prompt = ChatPromptTemplate.from_messages([
89
+ ("system", """You are an expert SQL developer. Generate efficient, secure SQL queries.
90
+ Always use parameterized queries to prevent SQL injection.
91
+ Explain your reasoning briefly."""),
92
+ ("user", "Convert this to SQL: {query}")
93
+ ])
94
+
95
+ # Create chain
96
+ chain = prompt | structured_llm
97
+
98
+ # Use
99
+ result = await chain.ainvoke({
100
+ "query": "Find all users who registered in the last 30 days"
101
+ })
102
+ print(result.query)
103
+ print(result.explanation)
104
+ ```
105
+
106
+ ## Key Patterns
107
+
108
+ ### Pattern 1: Structured Output with Pydantic
109
+
110
+ ```python
111
+ from anthropic import Anthropic
112
+ from pydantic import BaseModel, Field
113
+ from typing import Literal
114
+ import json
115
+
116
+ class SentimentAnalysis(BaseModel):
117
+ sentiment: Literal["positive", "negative", "neutral"]
118
+ confidence: float = Field(ge=0, le=1)
119
+ key_phrases: list[str]
120
+ reasoning: str
121
+
122
+ async def analyze_sentiment(text: str) -> SentimentAnalysis:
123
+ """Analyze sentiment with structured output."""
124
+ client = Anthropic()
125
+
126
+ message = client.messages.create(
127
+ model="claude-sonnet-4-5",
128
+ max_tokens=500,
129
+ messages=[{
130
+ "role": "user",
131
+ "content": f"""Analyze the sentiment of this text.
132
+
133
+ Text: {text}
134
+
135
+ Respond with JSON matching this schema:
136
+ {{
137
+ "sentiment": "positive" | "negative" | "neutral",
138
+ "confidence": 0.0-1.0,
139
+ "key_phrases": ["phrase1", "phrase2"],
140
+ "reasoning": "brief explanation"
141
+ }}"""
142
+ }]
143
+ )
144
+
145
+ return SentimentAnalysis(**json.loads(message.content[0].text))
146
+ ```
147
+
148
+ ### Pattern 2: Chain-of-Thought with Self-Verification
149
+
150
+ ```python
151
+ from langchain_core.prompts import ChatPromptTemplate
152
+
153
+ cot_prompt = ChatPromptTemplate.from_template("""
154
+ Solve this problem step by step.
155
+
156
+ Problem: {problem}
157
+
158
+ Instructions:
159
+ 1. Break down the problem into clear steps
160
+ 2. Work through each step showing your reasoning
161
+ 3. State your final answer
162
+ 4. Verify your answer by checking it against the original problem
163
+
164
+ Format your response as:
165
+ ## Steps
166
+ [Your step-by-step reasoning]
167
+
168
+ ## Answer
169
+ [Your final answer]
170
+
171
+ ## Verification
172
+ [Check that your answer is correct]
173
+ """)
174
+ ```
175
+
176
+ ### Pattern 3: Few-Shot with Dynamic Example Selection
177
+
178
+ ```python
179
+ from langchain_voyageai import VoyageAIEmbeddings
180
+ from langchain_core.example_selectors import SemanticSimilarityExampleSelector
181
+ from langchain_chroma import Chroma
182
+
183
+ # Create example selector with semantic similarity
184
+ example_selector = SemanticSimilarityExampleSelector.from_examples(
185
+ examples=[
186
+ {"input": "How do I reset my password?", "output": "Go to Settings > Security > Reset Password"},
187
+ {"input": "Where can I see my order history?", "output": "Navigate to Account > Orders"},
188
+ {"input": "How do I contact support?", "output": "Click Help > Contact Us or email support@example.com"},
189
+ ],
190
+ embeddings=VoyageAIEmbeddings(model="voyage-3-large"),
191
+ vectorstore_cls=Chroma,
192
+ k=2 # Select 2 most similar examples
193
+ )
194
+
195
+ async def get_few_shot_prompt(query: str) -> str:
196
+ """Build prompt with dynamically selected examples."""
197
+ examples = await example_selector.aselect_examples({"input": query})
198
+
199
+ examples_text = "\n".join(
200
+ f"User: {ex['input']}\nAssistant: {ex['output']}"
201
+ for ex in examples
202
+ )
203
+
204
+ return f"""You are a helpful customer support assistant.
205
+
206
+ Here are some example interactions:
207
+ {examples_text}
208
+
209
+ Now respond to this query:
210
+ User: {query}
211
+ Assistant:"""
212
+ ```
213
+
214
+ ### Pattern 4: Progressive Disclosure
215
+
216
+ Start with simple prompts, add complexity only when needed:
217
+
218
+ ```python
219
+ PROMPT_LEVELS = {
220
+ # Level 1: Direct instruction
221
+ "simple": "Summarize this article: {text}",
222
+
223
+ # Level 2: Add constraints
224
+ "constrained": """Summarize this article in 3 bullet points, focusing on:
225
+ - Key findings
226
+ - Main conclusions
227
+ - Practical implications
228
+
229
+ Article: {text}""",
230
+
231
+ # Level 3: Add reasoning
232
+ "reasoning": """Read this article carefully.
233
+ 1. First, identify the main topic and thesis
234
+ 2. Then, extract the key supporting points
235
+ 3. Finally, summarize in 3 bullet points
236
+
237
+ Article: {text}
238
+
239
+ Summary:""",
240
+
241
+ # Level 4: Add examples
242
+ "few_shot": """Read articles and provide concise summaries.
243
+
244
+ Example:
245
+ Article: "New research shows that regular exercise can reduce anxiety by up to 40%..."
246
+ Summary:
247
+ • Regular exercise reduces anxiety by up to 40%
248
+ • 30 minutes of moderate activity 3x/week is sufficient
249
+ • Benefits appear within 2 weeks of starting
250
+
251
+ Now summarize this article:
252
+ Article: {text}
253
+
254
+ Summary:"""
255
+ }
256
+ ```
257
+
258
+ ### Pattern 5: Error Recovery and Fallback
259
+
260
+ ```python
261
+ from pydantic import BaseModel, ValidationError
262
+ import json
263
+
264
+ class ResponseWithConfidence(BaseModel):
265
+ answer: str
266
+ confidence: float
267
+ sources: list[str]
268
+ alternative_interpretations: list[str] = []
269
+
270
+ ERROR_RECOVERY_PROMPT = """
271
+ Answer the question based on the context provided.
272
+
273
+ Context: {context}
274
+ Question: {question}
275
+
276
+ Instructions:
277
+ 1. If you can answer confidently (>0.8), provide a direct answer
278
+ 2. If you're somewhat confident (0.5-0.8), provide your best answer with caveats
279
+ 3. If you're uncertain (<0.5), explain what information is missing
280
+ 4. Always provide alternative interpretations if the question is ambiguous
281
+
282
+ Respond in JSON:
283
+ {{
284
+ "answer": "your answer or 'I cannot determine this from the context'",
285
+ "confidence": 0.0-1.0,
286
+ "sources": ["relevant context excerpts"],
287
+ "alternative_interpretations": ["if question is ambiguous"]
288
+ }}
289
+ """
290
+
291
+ async def answer_with_fallback(
292
+ context: str,
293
+ question: str,
294
+ llm
295
+ ) -> ResponseWithConfidence:
296
+ """Answer with error recovery and fallback."""
297
+ prompt = ERROR_RECOVERY_PROMPT.format(context=context, question=question)
298
+
299
+ try:
300
+ response = await llm.ainvoke(prompt)
301
+ return ResponseWithConfidence(**json.loads(response.content))
302
+ except (json.JSONDecodeError, ValidationError) as e:
303
+ # Fallback: try to extract answer without structure
304
+ simple_prompt = f"Based on: {context}\n\nAnswer: {question}"
305
+ simple_response = await llm.ainvoke(simple_prompt)
306
+ return ResponseWithConfidence(
307
+ answer=simple_response.content,
308
+ confidence=0.5,
309
+ sources=["fallback extraction"],
310
+ alternative_interpretations=[]
311
+ )
312
+ ```
313
+
314
+ ### Pattern 6: Role-Based System Prompts
315
+
316
+ ```python
317
+ SYSTEM_PROMPTS = {
318
+ "analyst": """You are a senior data analyst with expertise in SQL, Python, and business intelligence.
319
+
320
+ Your responsibilities:
321
+ - Write efficient, well-documented queries
322
+ - Explain your analysis methodology
323
+ - Highlight key insights and recommendations
324
+ - Flag any data quality concerns
325
+
326
+ Communication style:
327
+ - Be precise and technical when discussing methodology
328
+ - Translate technical findings into business impact
329
+ - Use clear visualizations when helpful""",
330
+
331
+ "assistant": """You are a helpful AI assistant focused on accuracy and clarity.
332
+
333
+ Core principles:
334
+ - Always cite sources when making factual claims
335
+ - Acknowledge uncertainty rather than guessing
336
+ - Ask clarifying questions when the request is ambiguous
337
+ - Provide step-by-step explanations for complex topics
338
+
339
+ Constraints:
340
+ - Do not provide medical, legal, or financial advice
341
+ - Redirect harmful requests appropriately
342
+ - Protect user privacy""",
343
+
344
+ "code_reviewer": """You are a senior software engineer conducting code reviews.
345
+
346
+ Review criteria:
347
+ - Correctness: Does the code work as intended?
348
+ - Security: Are there any vulnerabilities?
349
+ - Performance: Are there efficiency concerns?
350
+ - Maintainability: Is the code readable and well-structured?
351
+ - Best practices: Does it follow language idioms?
352
+
353
+ Output format:
354
+ 1. Summary assessment (approve/request changes)
355
+ 2. Critical issues (must fix)
356
+ 3. Suggestions (nice to have)
357
+ 4. Positive feedback (what's done well)"""
358
+ }
359
+ ```
360
+
361
+ ## Integration Patterns
362
+
363
+ ### With RAG Systems
364
+
365
+ ```python
366
+ RAG_PROMPT = """You are a knowledgeable assistant that answers questions based on provided context.
367
+
368
+ Context (retrieved from knowledge base):
369
+ {context}
370
+
371
+ Instructions:
372
+ 1. Answer ONLY based on the provided context
373
+ 2. If the context doesn't contain the answer, say "I don't have information about that in my knowledge base"
374
+ 3. Cite specific passages using [1], [2] notation
375
+ 4. If the question is ambiguous, ask for clarification
376
+
377
+ Question: {question}
378
+
379
+ Answer:"""
380
+ ```
381
+
382
+ ### With Validation and Verification
383
+
384
+ ```python
385
+ VALIDATED_PROMPT = """Complete the following task:
386
+
387
+ Task: {task}
388
+
389
+ After generating your response, verify it meets ALL these criteria:
390
+ ✓ Directly addresses the original request
391
+ ✓ Contains no factual errors
392
+ ✓ Is appropriately detailed (not too brief, not too verbose)
393
+ ✓ Uses proper formatting
394
+ ✓ Is safe and appropriate
395
+
396
+ If verification fails on any criterion, revise before responding.
397
+
398
+ Response:"""
399
+ ```
400
+
401
+ ## Performance Optimization
402
+
403
+ ### Token Efficiency
404
+
405
+ ```python
406
+ # Before: Verbose prompt (150+ tokens)
407
+ verbose_prompt = """
408
+ I would like you to please take the following text and provide me with a comprehensive
409
+ summary of the main points. The summary should capture the key ideas and important details
410
+ while being concise and easy to understand.
411
+ """
412
+
413
+ # After: Concise prompt (30 tokens)
414
+ concise_prompt = """Summarize the key points concisely:
415
+
416
+ {text}
417
+
418
+ Summary:"""
419
+ ```
420
+
421
+ ### Caching Common Prefixes
422
+
423
+ ```python
424
+ from anthropic import Anthropic
425
+
426
+ client = Anthropic()
427
+
428
+ # Use prompt caching for repeated system prompts
429
+ response = client.messages.create(
430
+ model="claude-sonnet-4-5",
431
+ max_tokens=1000,
432
+ system=[
433
+ {
434
+ "type": "text",
435
+ "text": LONG_SYSTEM_PROMPT,
436
+ "cache_control": {"type": "ephemeral"}
437
+ }
438
+ ],
439
+ messages=[{"role": "user", "content": user_query}]
440
+ )
441
+ ```
442
+
443
+ ## Best Practices
444
+
445
+ 1. **Be Specific**: Vague prompts produce inconsistent results
446
+ 2. **Show, Don't Tell**: Examples are more effective than descriptions
447
+ 3. **Use Structured Outputs**: Enforce schemas with Pydantic for reliability
448
+ 4. **Test Extensively**: Evaluate on diverse, representative inputs
449
+ 5. **Iterate Rapidly**: Small changes can have large impacts
450
+ 6. **Monitor Performance**: Track metrics in production
451
+ 7. **Version Control**: Treat prompts as code with proper versioning
452
+ 8. **Document Intent**: Explain why prompts are structured as they are
453
+
454
+ ## Common Pitfalls
455
+
456
+ - **Over-engineering**: Starting with complex prompts before trying simple ones
457
+ - **Example pollution**: Using examples that don't match the target task
458
+ - **Context overflow**: Exceeding token limits with excessive examples
459
+ - **Ambiguous instructions**: Leaving room for multiple interpretations
460
+ - **Ignoring edge cases**: Not testing on unusual or boundary inputs
461
+ - **No error handling**: Assuming outputs will always be well-formed
462
+ - **Hardcoded values**: Not parameterizing prompts for reuse
463
+
464
+ ## Success Metrics
465
+
466
+ Track these KPIs for your prompts:
467
+
468
+ - **Accuracy**: Correctness of outputs
469
+ - **Consistency**: Reproducibility across similar inputs
470
+ - **Latency**: Response time (P50, P95, P99)
471
+ - **Token Usage**: Average tokens per request
472
+ - **Success Rate**: Percentage of valid, parseable outputs
473
+ - **User Satisfaction**: Ratings and feedback
474
+
475
+ ## Resources
476
+
477
+ - [Anthropic Prompt Engineering Guide](https://docs.anthropic.com/en/docs/build-with-claude/prompt-engineering)
478
+ - [Claude Prompt Caching](https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching)
479
+ - [OpenAI Prompt Engineering](https://platform.openai.com/docs/guides/prompt-engineering)
480
+ - [LangChain Prompts](https://python.langchain.com/docs/concepts/prompts/)