cc-codeconductor 1.4.2 → 1.5.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 (305) hide show
  1. package/README.md +52 -14
  2. package/dist/domain/product/entities.d.ts +1 -1
  3. package/dist/index.js +811 -354
  4. package/dist/library.js +47 -3
  5. package/dist/validation/schemas.d.ts +183 -21
  6. package/docs/generated/cli.md +16 -0
  7. package/package.json +1 -1
  8. package/presets/agy/README.md +1 -1
  9. package/presets/agy/hooks.json +1 -1
  10. package/presets/agy/scripts/invoke-hook.cjs +20 -5
  11. package/presets/agy/settings.json +1 -1
  12. package/presets/agy/skills/api-versioning/SKILL.md +394 -0
  13. package/presets/agy/skills/astro/SKILL.md +318 -0
  14. package/presets/agy/skills/auth-token-inspector/SKILL.md +30 -0
  15. package/presets/agy/skills/cc-pagespeed/SKILL.md +2 -3
  16. package/presets/agy/skills/code-review/SKILL.md +207 -0
  17. package/presets/agy/skills/django-orm/SKILL.md +460 -0
  18. package/presets/agy/skills/django-uv/SKILL.md +405 -0
  19. package/presets/agy/skills/drizzle-schema-architect/SKILL.md +50 -0
  20. package/presets/agy/skills/fastapi-pydantic-strict/SKILL.md +43 -0
  21. package/presets/agy/skills/jpa-nplusone-detector/SKILL.md +45 -0
  22. package/presets/agy/skills/jpa-postgres/SKILL.md +623 -0
  23. package/presets/agy/skills/livewire-alpine-bridge/SKILL.md +35 -0
  24. package/presets/agy/skills/nextjs-typescript/SKILL.md +390 -0
  25. package/presets/agy/skills/python/SKILL.md +611 -0
  26. package/presets/agy/skills/seo-analytics-injector/SKILL.md +43 -0
  27. package/presets/agy/skills/spring-auth-auditor/SKILL.md +29 -0
  28. package/presets/agy/skills/spring-boot-feature/SKILL.md +563 -0
  29. package/presets/agy/skills/spring-boot-testing-strategy/SKILL.md +475 -0
  30. package/presets/agy/skills/tailwind-responsive-auditor/SKILL.md +29 -0
  31. package/presets/agy/skills/tdd-mutation-tester/SKILL.md +27 -0
  32. package/presets/agy/workflows/cc-api-contract.md +4 -5
  33. package/presets/agy/workflows/cc-backlog.md +4 -5
  34. package/presets/agy/workflows/cc-clarify.md +4 -5
  35. package/presets/agy/workflows/cc-council.md +4 -5
  36. package/presets/agy/workflows/cc-db-migration.md +4 -5
  37. package/presets/agy/workflows/cc-explore.md +4 -5
  38. package/presets/agy/workflows/cc-feature.md +4 -5
  39. package/presets/agy/workflows/cc-fix.md +4 -5
  40. package/presets/agy/workflows/cc-handoff.md +8 -5
  41. package/presets/agy/workflows/cc-iterative.md +4 -5
  42. package/presets/agy/workflows/cc-odd.md +4 -3
  43. package/presets/agy/workflows/cc-openspec.md +5 -6
  44. package/presets/agy/workflows/cc-pagespeed.md +6 -8
  45. package/presets/agy/workflows/cc-prototype.md +4 -5
  46. package/presets/agy/workflows/cc-refactor.md +4 -5
  47. package/presets/agy/workflows/cc-review.md +35 -5
  48. package/presets/agy/workflows/cc-scorecard.md +4 -5
  49. package/presets/agy/workflows/cc-security.md +5 -6
  50. package/presets/agy/workflows/cc-spec-mutation.md +4 -5
  51. package/presets/agy/workflows/cc-tdd-cycle.md +4 -5
  52. package/presets/agy/workflows/cc-test-plan.md +4 -5
  53. package/presets/agy/workflows/cc-triage.md +4 -5
  54. package/presets/claude/CLAUDE.md +6 -5
  55. package/presets/claude/commands/cc/api-contract.md +4 -5
  56. package/presets/claude/commands/cc/backlog.md +4 -5
  57. package/presets/claude/commands/cc/clarify.md +4 -5
  58. package/presets/claude/commands/cc/council.md +4 -5
  59. package/presets/claude/commands/cc/db-migration.md +4 -5
  60. package/presets/claude/commands/cc/explore.md +4 -5
  61. package/presets/claude/commands/cc/feature.md +4 -5
  62. package/presets/claude/commands/cc/fix.md +4 -5
  63. package/presets/claude/commands/cc/handoff.md +8 -5
  64. package/presets/claude/commands/cc/iterative.md +4 -5
  65. package/presets/claude/commands/cc/odd.md +4 -3
  66. package/presets/claude/commands/cc/openspec.md +23 -7
  67. package/presets/claude/commands/cc/pagespeed.md +4 -5
  68. package/presets/claude/commands/cc/prototype.md +4 -5
  69. package/presets/claude/commands/cc/refactor.md +4 -5
  70. package/presets/claude/commands/cc/review.md +37 -5
  71. package/presets/claude/commands/cc/scorecard.md +4 -5
  72. package/presets/claude/commands/cc/security.md +4 -5
  73. package/presets/claude/commands/cc/spec-mutation.md +4 -5
  74. package/presets/claude/commands/cc/tdd-cycle.md +4 -5
  75. package/presets/claude/commands/cc/test-plan.md +4 -5
  76. package/presets/claude/commands/cc/triage.md +4 -5
  77. package/presets/claude/settings.json +33 -79
  78. package/presets/claude/skills/android/SKILL.md +1 -1
  79. package/presets/claude/skills/api-versioning/SKILL.md +1 -1
  80. package/presets/claude/skills/astro/SKILL.md +318 -0
  81. package/presets/claude/skills/auth-token-inspector/SKILL.md +30 -0
  82. package/presets/claude/skills/code-review/SKILL.md +207 -0
  83. package/presets/claude/skills/django-orm/SKILL.md +1 -1
  84. package/presets/claude/skills/django-testing/SKILL.md +1 -1
  85. package/presets/claude/skills/django-uv/SKILL.md +405 -0
  86. package/presets/claude/skills/drizzle-schema-architect/SKILL.md +50 -0
  87. package/presets/claude/skills/fastapi-pydantic-strict/SKILL.md +43 -0
  88. package/presets/claude/skills/jpa-nplusone-detector/SKILL.md +45 -0
  89. package/presets/claude/skills/jpa-postgres/SKILL.md +1 -1
  90. package/presets/claude/skills/livewire-alpine-bridge/SKILL.md +35 -0
  91. package/presets/claude/skills/nextjs-typescript/SKILL.md +390 -0
  92. package/presets/claude/skills/pagespeed-perf/SKILL.md +1 -1
  93. package/presets/claude/skills/python/SKILL.md +1 -1
  94. package/presets/claude/skills/python-django-stack/SKILL.md +1 -1
  95. package/presets/claude/skills/python-fastapi-stack/SKILL.md +1 -1
  96. package/presets/claude/skills/security/SKILL.md +1 -1
  97. package/presets/claude/skills/seo-analytics-injector/SKILL.md +43 -0
  98. package/presets/claude/skills/spring-auth-auditor/SKILL.md +29 -0
  99. package/presets/claude/skills/spring-boot-feature/SKILL.md +1 -1
  100. package/presets/claude/skills/spring-boot-kotlin/SKILL.md +1 -1
  101. package/presets/claude/skills/spring-boot-testing-strategy/SKILL.md +475 -0
  102. package/presets/claude/skills/sqlalchemy/SKILL.md +1 -1
  103. package/presets/claude/skills/tailwind-responsive-auditor/SKILL.md +29 -0
  104. package/presets/claude/skills/tdd-mutation-tester/SKILL.md +27 -0
  105. package/presets/claude/skills/testing-strategy/SKILL.md +1 -1
  106. package/presets/codex/config.toml +2 -0
  107. package/presets/codex/skills/android/SKILL.md +1 -1
  108. package/presets/codex/skills/api-versioning/SKILL.md +1 -1
  109. package/presets/codex/skills/astro/SKILL.md +318 -0
  110. package/presets/codex/skills/auth-token-inspector/SKILL.md +30 -0
  111. package/presets/codex/skills/cc-api-contract/SKILL.md +4 -5
  112. package/presets/codex/skills/cc-backlog/SKILL.md +4 -5
  113. package/presets/codex/skills/cc-clarify/SKILL.md +4 -5
  114. package/presets/codex/skills/cc-council/SKILL.md +10 -5
  115. package/presets/codex/skills/cc-db-migration/SKILL.md +4 -5
  116. package/presets/codex/skills/cc-explore/SKILL.md +4 -5
  117. package/presets/codex/skills/cc-feature/SKILL.md +4 -5
  118. package/presets/codex/skills/cc-fix/SKILL.md +4 -5
  119. package/presets/codex/skills/cc-handoff/SKILL.md +8 -5
  120. package/presets/codex/skills/cc-iterative/SKILL.md +4 -5
  121. package/presets/codex/skills/cc-odd/SKILL.md +4 -3
  122. package/presets/codex/skills/cc-openspec/SKILL.md +12 -7
  123. package/presets/codex/skills/cc-pagespeed/SKILL.md +6 -8
  124. package/presets/codex/skills/cc-prototype/SKILL.md +4 -5
  125. package/presets/codex/skills/cc-refactor/SKILL.md +4 -5
  126. package/presets/codex/skills/cc-review/SKILL.md +35 -5
  127. package/presets/codex/skills/cc-scorecard/SKILL.md +4 -5
  128. package/presets/codex/skills/cc-security/SKILL.md +5 -6
  129. package/presets/codex/skills/cc-spec-mutation/SKILL.md +4 -5
  130. package/presets/codex/skills/cc-tdd-cycle/SKILL.md +4 -5
  131. package/presets/codex/skills/cc-test-plan/SKILL.md +4 -5
  132. package/presets/codex/skills/cc-triage/SKILL.md +4 -5
  133. package/presets/codex/skills/code-review/SKILL.md +207 -0
  134. package/presets/codex/skills/django-orm/SKILL.md +1 -1
  135. package/presets/codex/skills/django-testing/SKILL.md +1 -1
  136. package/presets/codex/skills/django-uv/SKILL.md +405 -0
  137. package/presets/codex/skills/drizzle-schema-architect/SKILL.md +50 -0
  138. package/presets/codex/skills/fastapi-pydantic-strict/SKILL.md +43 -0
  139. package/presets/codex/skills/jpa-nplusone-detector/SKILL.md +45 -0
  140. package/presets/codex/skills/jpa-postgres/SKILL.md +1 -1
  141. package/presets/codex/skills/livewire-alpine-bridge/SKILL.md +35 -0
  142. package/presets/codex/skills/nextjs-typescript/SKILL.md +390 -0
  143. package/presets/codex/skills/pagespeed-perf/SKILL.md +1 -1
  144. package/presets/codex/skills/python/SKILL.md +1 -1
  145. package/presets/codex/skills/python-django-stack/SKILL.md +1 -1
  146. package/presets/codex/skills/python-fastapi-stack/SKILL.md +1 -1
  147. package/presets/codex/skills/security-ai-llm/SKILL.md +43 -0
  148. package/presets/codex/skills/security-blue-team/SKILL.md +43 -0
  149. package/presets/codex/skills/security-cloud/SKILL.md +43 -0
  150. package/presets/codex/skills/security-crypto/SKILL.md +43 -0
  151. package/presets/codex/skills/security-exploit-dev/SKILL.md +45 -0
  152. package/presets/codex/skills/security-grc/SKILL.md +43 -0
  153. package/presets/codex/skills/security-incident-response/SKILL.md +45 -0
  154. package/presets/codex/skills/security-log-analysis/SKILL.md +43 -0
  155. package/presets/codex/skills/security-malware-analysis/SKILL.md +44 -0
  156. package/presets/codex/skills/security-mobile/SKILL.md +43 -0
  157. package/presets/codex/skills/security-network/SKILL.md +43 -0
  158. package/presets/codex/skills/security-ot-ics/SKILL.md +43 -0
  159. package/presets/codex/skills/security-recon/SKILL.md +45 -0
  160. package/presets/codex/skills/security-red-team/SKILL.md +44 -0
  161. package/presets/codex/skills/security-reverse-engineering/SKILL.md +44 -0
  162. package/presets/codex/skills/security-soc-automation/SKILL.md +43 -0
  163. package/presets/codex/skills/security-threat-hunting/SKILL.md +43 -0
  164. package/presets/codex/skills/security-vuln-assessment/SKILL.md +45 -0
  165. package/presets/codex/skills/security-web/SKILL.md +44 -0
  166. package/presets/codex/skills/seo-analytics-injector/SKILL.md +43 -0
  167. package/presets/codex/skills/spring-auth-auditor/SKILL.md +29 -0
  168. package/presets/codex/skills/spring-boot-feature/SKILL.md +2 -2
  169. package/presets/codex/skills/spring-boot-kotlin/SKILL.md +1 -1
  170. package/presets/codex/skills/spring-boot-testing-strategy/SKILL.md +475 -0
  171. package/presets/codex/skills/sqlalchemy/SKILL.md +1 -1
  172. package/presets/codex/skills/tailwind-responsive-auditor/SKILL.md +29 -0
  173. package/presets/codex/skills/tdd-mutation-tester/SKILL.md +27 -0
  174. package/presets/codex/skills/testing-strategy/SKILL.md +1 -1
  175. package/presets/cursor/commands/cc/api-contract.md +4 -5
  176. package/presets/cursor/commands/cc/backlog.md +4 -5
  177. package/presets/cursor/commands/cc/clarify.md +4 -5
  178. package/presets/cursor/commands/cc/council.md +4 -5
  179. package/presets/cursor/commands/cc/db-migration.md +4 -5
  180. package/presets/cursor/commands/cc/explore.md +4 -5
  181. package/presets/cursor/commands/cc/feature.md +4 -5
  182. package/presets/cursor/commands/cc/fix.md +4 -5
  183. package/presets/cursor/commands/cc/handoff.md +8 -5
  184. package/presets/cursor/commands/cc/iterative.md +4 -5
  185. package/presets/cursor/commands/cc/odd.md +4 -3
  186. package/presets/cursor/commands/cc/openspec.md +6 -7
  187. package/presets/cursor/commands/cc/pagespeed.md +6 -8
  188. package/presets/cursor/commands/cc/prototype.md +4 -5
  189. package/presets/cursor/commands/cc/refactor.md +4 -5
  190. package/presets/cursor/commands/cc/review.md +35 -5
  191. package/presets/cursor/commands/cc/scorecard.md +4 -5
  192. package/presets/cursor/commands/cc/security.md +5 -6
  193. package/presets/cursor/commands/cc/spec-mutation.md +4 -5
  194. package/presets/cursor/commands/cc/tdd-cycle.md +4 -5
  195. package/presets/cursor/commands/cc/test-plan.md +4 -5
  196. package/presets/cursor/commands/cc/triage.md +4 -5
  197. package/presets/cursor/skills/android/SKILL.md +1 -1
  198. package/presets/cursor/skills/api-versioning/SKILL.md +2 -1
  199. package/presets/cursor/skills/astro/SKILL.md +1 -1
  200. package/presets/cursor/skills/auth-token-inspector/SKILL.md +1 -1
  201. package/presets/cursor/skills/code-review/SKILL.md +1 -1
  202. package/presets/cursor/skills/django-orm/SKILL.md +3 -5
  203. package/presets/cursor/skills/django-testing/SKILL.md +1 -1
  204. package/presets/cursor/skills/django-uv/SKILL.md +1 -1
  205. package/presets/cursor/skills/drizzle-schema-architect/SKILL.md +1 -1
  206. package/presets/cursor/skills/fastapi-pydantic-strict/SKILL.md +1 -1
  207. package/presets/cursor/skills/jpa-nplusone-detector/SKILL.md +1 -1
  208. package/presets/cursor/skills/jpa-postgres/SKILL.md +2 -4
  209. package/presets/cursor/skills/livewire-alpine-bridge/SKILL.md +1 -1
  210. package/presets/cursor/skills/nextjs-typescript/SKILL.md +1 -1
  211. package/presets/cursor/skills/pagespeed-perf/SKILL.md +1 -1
  212. package/presets/cursor/skills/python/SKILL.md +6 -7
  213. package/presets/cursor/skills/python-django-stack/SKILL.md +1 -1
  214. package/presets/cursor/skills/python-fastapi-stack/SKILL.md +1 -1
  215. package/presets/cursor/skills/security/SKILL.md +1 -1
  216. package/presets/cursor/skills/seo-analytics-injector/SKILL.md +1 -1
  217. package/presets/cursor/skills/spring-auth-auditor/SKILL.md +1 -1
  218. package/presets/cursor/skills/spring-boot-feature/SKILL.md +2 -4
  219. package/presets/cursor/skills/spring-boot-kotlin/SKILL.md +1 -1
  220. package/presets/cursor/skills/spring-boot-testing-strategy/SKILL.md +1 -1
  221. package/presets/cursor/skills/sqlalchemy/SKILL.md +1 -1
  222. package/presets/cursor/skills/tailwind-responsive-auditor/SKILL.md +1 -1
  223. package/presets/cursor/skills/tdd-mutation-tester/SKILL.md +1 -1
  224. package/presets/gemini/commands/cc/api-contract.toml +4 -5
  225. package/presets/gemini/commands/cc/backlog.toml +4 -5
  226. package/presets/gemini/commands/cc/clarify.toml +4 -5
  227. package/presets/gemini/commands/cc/council.toml +4 -5
  228. package/presets/gemini/commands/cc/db-migration.toml +4 -5
  229. package/presets/gemini/commands/cc/explore.toml +4 -5
  230. package/presets/gemini/commands/cc/feature.toml +4 -5
  231. package/presets/gemini/commands/cc/fix.toml +4 -5
  232. package/presets/gemini/commands/cc/handoff.toml +8 -5
  233. package/presets/gemini/commands/cc/iterative.toml +4 -5
  234. package/presets/gemini/commands/cc/odd.toml +4 -3
  235. package/presets/gemini/commands/cc/openspec.toml +6 -7
  236. package/presets/gemini/commands/cc/pagespeed.toml +6 -8
  237. package/presets/gemini/commands/cc/prototype.toml +4 -5
  238. package/presets/gemini/commands/cc/refactor.toml +4 -5
  239. package/presets/gemini/commands/cc/review.toml +35 -5
  240. package/presets/gemini/commands/cc/scorecard.toml +4 -5
  241. package/presets/gemini/commands/cc/security.toml +5 -6
  242. package/presets/gemini/commands/cc/spec-mutation.toml +4 -5
  243. package/presets/gemini/commands/cc/tdd-cycle.toml +4 -5
  244. package/presets/gemini/commands/cc/test-plan.toml +4 -5
  245. package/presets/gemini/commands/cc/triage.toml +4 -5
  246. package/presets/opencode/README.md +45 -52
  247. package/presets/opencode/commands/cc-api-contract.md +4 -5
  248. package/presets/opencode/commands/cc-backlog.md +4 -5
  249. package/presets/opencode/commands/cc-clarify.md +4 -5
  250. package/presets/opencode/commands/cc-council.md +4 -5
  251. package/presets/opencode/commands/cc-db-migration.md +4 -5
  252. package/presets/opencode/commands/cc-explore.md +4 -5
  253. package/presets/opencode/commands/cc-feature.md +4 -5
  254. package/presets/opencode/commands/cc-fix.md +4 -5
  255. package/presets/opencode/commands/cc-handoff.md +8 -5
  256. package/presets/opencode/commands/cc-iterative.md +4 -5
  257. package/presets/opencode/commands/cc-odd.md +4 -3
  258. package/presets/opencode/commands/cc-openspec.md +6 -7
  259. package/presets/opencode/commands/cc-pagespeed.md +6 -8
  260. package/presets/opencode/commands/cc-prototype.md +4 -5
  261. package/presets/opencode/commands/cc-refactor.md +4 -5
  262. package/presets/opencode/commands/cc-review.md +35 -5
  263. package/presets/opencode/commands/cc-scorecard.md +4 -5
  264. package/presets/opencode/commands/cc-security.md +5 -6
  265. package/presets/opencode/commands/cc-spec-mutation.md +4 -5
  266. package/presets/opencode/commands/cc-tdd-cycle.md +4 -5
  267. package/presets/opencode/commands/cc-test-plan.md +4 -5
  268. package/presets/opencode/commands/cc-triage.md +4 -5
  269. package/presets/opencode/opencode.jsonc +1 -1
  270. package/presets/opencode/skills/android/SKILL.md +1 -1
  271. package/presets/opencode/skills/api-versioning/SKILL.md +2 -1
  272. package/presets/opencode/skills/astro/SKILL.md +1 -1
  273. package/presets/opencode/skills/auth-token-inspector/SKILL.md +1 -1
  274. package/presets/opencode/skills/code-review/SKILL.md +1 -1
  275. package/presets/opencode/skills/django-orm/SKILL.md +3 -3
  276. package/presets/opencode/skills/django-testing/SKILL.md +1 -1
  277. package/presets/opencode/skills/django-uv/SKILL.md +1 -1
  278. package/presets/opencode/skills/drizzle-schema-architect/SKILL.md +1 -1
  279. package/presets/opencode/skills/fastapi-pydantic-strict/SKILL.md +1 -1
  280. package/presets/opencode/skills/jpa-nplusone-detector/SKILL.md +1 -1
  281. package/presets/opencode/skills/jpa-postgres/SKILL.md +2 -1
  282. package/presets/opencode/skills/livewire-alpine-bridge/SKILL.md +1 -1
  283. package/presets/opencode/skills/nextjs-typescript/SKILL.md +1 -1
  284. package/presets/opencode/skills/pagespeed-perf/SKILL.md +1 -1
  285. package/presets/opencode/skills/python/SKILL.md +6 -5
  286. package/presets/opencode/skills/python-django-stack/SKILL.md +1 -1
  287. package/presets/opencode/skills/python-fastapi-stack/SKILL.md +1 -1
  288. package/presets/opencode/skills/security/SKILL.md +1 -1
  289. package/presets/opencode/skills/seo-analytics-injector/SKILL.md +1 -1
  290. package/presets/opencode/skills/spring-auth-auditor/SKILL.md +1 -1
  291. package/presets/opencode/skills/spring-boot-feature/SKILL.md +2 -1
  292. package/presets/opencode/skills/spring-boot-kotlin/SKILL.md +1 -1
  293. package/presets/opencode/skills/spring-boot-testing-strategy/SKILL.md +1 -1
  294. package/presets/opencode/skills/sqlalchemy/SKILL.md +1 -1
  295. package/presets/opencode/skills/tailwind-responsive-auditor/SKILL.md +1 -1
  296. package/presets/opencode/skills/tdd-mutation-tester/SKILL.md +1 -1
  297. package/presets/seo-hotel/skills/astro-seo/SKILL.md +1 -1
  298. package/presets/seo-hotel/skills/geo-readiness/SKILL.md +1 -1
  299. package/presets/seo-hotel/skills/off-page/SKILL.md +1 -1
  300. package/presets/seo-hotel/skills/schema-validator/SKILL.md +1 -1
  301. package/presets/seo-hotel/skills/seo-audit/SKILL.md +1 -1
  302. package/presets/shared/invoke-hook.cjs +20 -5
  303. package/src/presets/manifests/codex.yml +3 -0
  304. package/src/presets/models/roles.yml +54 -56
  305. package/src/presets/shared-skills.yml +58 -22
@@ -0,0 +1,390 @@
1
+ ---
2
+ id: nextjs-typescript
3
+ name: nextjs-typescript
4
+ description: >
5
+ Provides expert knowledge for building Next.js 15+ applications with the App Router, TypeScript, Server Components, Server Actions, and TanStack Query.
6
+
7
+ user-invokable: true
8
+ license: MIT
9
+ metadata:
10
+ author: lgzarturo
11
+ category: frontend
12
+
13
+ compatibility:
14
+ tools: [claude, codex, gemini, agy, opencode]
15
+ stacks:
16
+ languages: []
17
+ frameworks: []
18
+
19
+ risk:
20
+ level: medium
21
+ can_execute_shell: false
22
+ can_modify_files: true
23
+ requires_network: false
24
+
25
+ inputs: []
26
+
27
+ outputs: []
28
+
29
+ quality:
30
+ reviewed_by: codeconductor-core
31
+ version: 0.1.0
32
+ ---
33
+
34
+
35
+
36
+ # Next.js + TypeScript
37
+
38
+ ## Server vs Client Components
39
+
40
+ The App Router defaults to Server Components. Every component is a Server
41
+ Component unless it explicitly opts in to the client.
42
+
43
+ ### Decision Rule
44
+
45
+ ```text
46
+ Does the component need any of the following?
47
+ - useState / useReducer
48
+ - useEffect / lifecycle methods
49
+ - Browser APIs (window, document, localStorage)
50
+ - Event listeners (onClick, onChange, onSubmit)
51
+ - Third-party libraries that require the DOM
52
+
53
+ YES → Client Component (`"use client"` directive)
54
+ NO → Server Component (default, no directive needed)
55
+ ```
56
+
57
+ Keep the `"use client"` boundary as far down the component tree as possible.
58
+ Wrap only the interactive leaf node, not the entire page.
59
+
60
+ ### Server Component (default)
61
+
62
+ ```tsx
63
+ // app/users/page.tsx — no directive needed
64
+ import { db } from '@/lib/db';
65
+
66
+ export default async function UsersPage() {
67
+ // Direct database access — no API round-trip needed
68
+ const users = await db.user.findMany({ orderBy: { createdAt: 'desc' } });
69
+
70
+ return (
71
+ <ul>
72
+ {users.map(user => (
73
+ <li key={user.id}>{user.email}</li>
74
+ ))}
75
+ </ul>
76
+ );
77
+ }
78
+ ```
79
+
80
+ ### Client Component
81
+
82
+ ```tsx
83
+ // components/ui/counter.tsx
84
+ 'use client';
85
+
86
+ import { useState } from 'react';
87
+
88
+ interface Props {
89
+ initialCount?: number;
90
+ }
91
+
92
+ export function Counter({ initialCount = 0 }: Props) {
93
+ const [count, setCount] = useState(initialCount);
94
+ return <button onClick={() => setCount(c => c + 1)}>Count: {count}</button>;
95
+ }
96
+ ```
97
+
98
+ ### Composing Server and Client
99
+
100
+ ```tsx
101
+ // app/dashboard/page.tsx — Server Component
102
+ import { Counter } from '@/components/ui/counter'; // Client
103
+ import { getUser } from '@/lib/queries'; // Server-only function
104
+
105
+ export default async function DashboardPage() {
106
+ const user = await getUser(); // runs on the server
107
+
108
+ return (
109
+ <div>
110
+ <h1>Welcome, {user.name}</h1>
111
+ <Counter initialCount={user.loginCount} /> {/* client island */}
112
+ </div>
113
+ );
114
+ }
115
+ ```
116
+
117
+ Passing server data to client components as props is correct. The server
118
+ renders the Server Component tree first, serializes the props, and sends them
119
+ to the client.
120
+
121
+ ## Data Fetching
122
+
123
+ ### Server Component Fetching (recommended for initial data)
124
+
125
+ ```tsx
126
+ // app/posts/[id]/page.tsx
127
+ interface Props {
128
+ params: Promise<{ id: string }>;
129
+ }
130
+
131
+ export default async function PostPage({ params }: Props) {
132
+ const { id } = await params;
133
+ const post = await fetch(`https://api.example.com/posts/${id}`, {
134
+ next: { revalidate: 3600 }, // ISR: revalidate every hour
135
+ }).then(r => r.json());
136
+
137
+ if (!post) notFound();
138
+
139
+ return <article>{post.title}</article>;
140
+ }
141
+ ```
142
+
143
+ Cache strategies:
144
+
145
+ | `cache` option | Behavior |
146
+ |----------------|----------|
147
+ | `force-cache` | Cache indefinitely (default for fetch in RSC) |
148
+ | `no-store` | Never cache — fresh on every request |
149
+ | `next: { revalidate: N }` | ISR — revalidate after N seconds |
150
+ | `next: { tags: ['posts'] }` | On-demand revalidation via tag |
151
+
152
+ ### Server Actions (mutations)
153
+
154
+ Server Actions run on the server. Use them for form submissions and mutations.
155
+ Never use them for reads.
156
+
157
+ ```tsx
158
+ // app/posts/create/actions.ts
159
+ 'use server';
160
+
161
+ import { revalidatePath } from 'next/cache';
162
+ import { redirect } from 'next/navigation';
163
+ import { z } from 'zod';
164
+ import { db } from '@/lib/db';
165
+
166
+ const CreatePostSchema = z.object({
167
+ title: z.string().min(1).max(200),
168
+ content: z.string().min(1),
169
+ });
170
+
171
+ export async function createPost(formData: FormData) {
172
+ const parsed = CreatePostSchema.safeParse({
173
+ title: formData.get('title'),
174
+ content: formData.get('content'),
175
+ });
176
+
177
+ if (!parsed.success) {
178
+ return { error: parsed.error.flatten().fieldErrors };
179
+ }
180
+
181
+ await db.post.create({ data: parsed.data });
182
+
183
+ revalidatePath('/posts');
184
+ redirect('/posts');
185
+ }
186
+ ```
187
+
188
+ ```tsx
189
+ // app/posts/create/page.tsx
190
+ import { createPost } from './actions';
191
+
192
+ export default function CreatePostPage() {
193
+ return (
194
+ <form action={createPost}>
195
+ <input name="title" type="text" required />
196
+ <textarea name="content" required />
197
+ <button type="submit">Create</button>
198
+ </form>
199
+ );
200
+ }
201
+ ```
202
+
203
+ Rules for Server Actions:
204
+
205
+ - Always validate input with Zod — do not trust `FormData` values
206
+ - Return error objects for validation failures; use `redirect()` for success
207
+ - Call `revalidatePath()` or `revalidateTag()` after mutations that affect
208
+ cached data
209
+ - Never put secrets or auth logic in Client Components — keep it in actions
210
+
211
+ ### TanStack Query (client-side data)
212
+
213
+ Use TanStack Query for data that must stay fresh on the client: real-time
214
+ feeds, user-specific data after mutations, optimistic updates.
215
+
216
+ ```tsx
217
+ // components/posts/post-list.tsx
218
+ 'use client';
219
+
220
+ import { useQuery } from '@tanstack/react-query';
221
+
222
+ interface Post {
223
+ id: string;
224
+ title: string;
225
+ }
226
+
227
+ export function PostList() {
228
+ const { data, isLoading, error } = useQuery<Post[]>({
229
+ queryKey: ['posts'],
230
+ queryFn: () => fetch('/api/posts').then(r => r.json()),
231
+ staleTime: 60_000, // treat data as fresh for 60 seconds
232
+ });
233
+
234
+ if (isLoading) return <p>Loading...</p>;
235
+ if (error) return <p>Failed to load posts.</p>;
236
+
237
+ return (
238
+ <ul>
239
+ {data?.map(post => <li key={post.id}>{post.title}</li>)}
240
+ </ul>
241
+ );
242
+ }
243
+ ```
244
+
245
+ Do not use TanStack Query for data that a Server Component can fetch directly.
246
+ The extra client-side fetch is unnecessary when the data can be fetched at
247
+ render time on the server.
248
+
249
+ ## Route Handlers
250
+
251
+ Use route handlers for: webhooks, third-party OAuth callbacks, or endpoints
252
+ consumed by non-Next.js clients.
253
+
254
+ ```typescript
255
+ // app/api/posts/route.ts
256
+ import { NextRequest, NextResponse } from 'next/server';
257
+ import { z } from 'zod';
258
+ import { db } from '@/lib/db';
259
+
260
+ const CreatePostBody = z.object({
261
+ title: z.string().min(1),
262
+ content: z.string().min(1),
263
+ });
264
+
265
+ export async function GET() {
266
+ const posts = await db.post.findMany({ orderBy: { createdAt: 'desc' } });
267
+ return NextResponse.json(posts);
268
+ }
269
+
270
+ export async function POST(request: NextRequest) {
271
+ const body = await request.json();
272
+ const parsed = CreatePostBody.safeParse(body);
273
+
274
+ if (!parsed.success) {
275
+ return NextResponse.json(
276
+ { error: parsed.error.flatten() },
277
+ { status: 400 }
278
+ );
279
+ }
280
+
281
+ const post = await db.post.create({ data: parsed.data });
282
+ return NextResponse.json(post, { status: 201 });
283
+ }
284
+ ```
285
+
286
+ ## Metadata API
287
+
288
+ ```tsx
289
+ // app/posts/[id]/page.tsx
290
+ import type { Metadata } from 'next';
291
+
292
+ interface Props {
293
+ params: Promise<{ id: string }>;
294
+ }
295
+
296
+ export async function generateMetadata({ params }: Props): Promise<Metadata> {
297
+ const { id } = await params;
298
+ const post = await fetch(`/api/posts/${id}`).then(r => r.json());
299
+
300
+ return {
301
+ title: post.title,
302
+ description: post.excerpt,
303
+ openGraph: {
304
+ title: post.title,
305
+ images: [{ url: post.coverImage }],
306
+ },
307
+ };
308
+ }
309
+ ```
310
+
311
+ Never hardcode metadata in `<head>` tags — use the Metadata API. It handles
312
+ deduplication, inheritance, and streaming correctly.
313
+
314
+ ## Streaming with Suspense
315
+
316
+ ```tsx
317
+ // app/dashboard/page.tsx
318
+ import { Suspense } from 'react';
319
+ import { UserStats } from './user-stats'; // slow data fetch
320
+ import { RecentActivity } from './recent'; // fast data fetch
321
+
322
+ export default function DashboardPage() {
323
+ return (
324
+ <div>
325
+ <RecentActivity /> {/* renders immediately */}
326
+ <Suspense fallback={<p>Loading stats...</p>}>
327
+ <UserStats /> {/* streams in when ready */}
328
+ </Suspense>
329
+ </div>
330
+ );
331
+ }
332
+ ```
333
+
334
+ Wrap independently slow data sources in their own `<Suspense>` boundaries.
335
+ Do not wrap the entire page — that defeats streaming.
336
+
337
+ ## TypeScript Conventions
338
+
339
+ ```typescript
340
+ // Use type imports for type-only imports
341
+ import type { User } from '@prisma/client';
342
+
343
+ // Prefer interfaces for object shapes that may be extended
344
+ interface UserCardProps {
345
+ user: Pick<User, 'id' | 'name' | 'email'>;
346
+ onSelect?: (id: string) => void;
347
+ }
348
+
349
+ // Use type aliases for unions and computed types
350
+ type Status = 'active' | 'inactive' | 'pending';
351
+ type UserWithPosts = User & { posts: Post[] };
352
+ ```
353
+
354
+ Rules:
355
+
356
+ - Never use `any` — use `unknown` and narrow with type guards
357
+ - Use `satisfies` to validate objects against a type without widening
358
+ - Co-locate type definitions with the component or function that uses them;
359
+ export only what other modules need
360
+ - Use `next/navigation` hooks (`useRouter`, `usePathname`) not `next/router` —
361
+ the latter is Pages Router only
362
+
363
+ ## Project Structure
364
+
365
+ ```text
366
+ app/
367
+ (auth)/ — route group, no URL segment
368
+ login/page.tsx
369
+ register/page.tsx
370
+ (dashboard)/
371
+ dashboard/page.tsx
372
+ posts/
373
+ [id]/page.tsx
374
+ create/
375
+ page.tsx
376
+ actions.ts
377
+ api/
378
+ posts/route.ts
379
+ layout.tsx — root layout
380
+ not-found.tsx
381
+
382
+ components/
383
+ ui/ — generic, reusable components
384
+ posts/ — domain-specific components
385
+
386
+ lib/
387
+ db.ts — database client
388
+ auth.ts — auth configuration
389
+ queries.ts — reusable server-side query functions
390
+ ```