@punks/cli 2.1.10 → 2.2.0

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 (453) hide show
  1. package/README.md +3 -1
  2. package/dist/index.js +0 -0
  3. package/package.json +1 -1
  4. package/dist/data/AGENTS.md +0 -119
  5. package/dist/data/catalog/hooks.ts +0 -26
  6. package/dist/data/catalog/lint.ts +0 -266
  7. package/dist/data/catalog/packs.ts +0 -320
  8. package/dist/data/catalog/skills.ts +0 -441
  9. package/dist/data/catalog/tools.ts +0 -48
  10. package/dist/data/control-plane.json +0 -3
  11. package/dist/data/hooks/format-edited-file.mjs +0 -699
  12. package/dist/data/hooks/format-edited-file.sh +0 -37
  13. package/dist/data/hooks/require-tests-for-pr.mjs +0 -206
  14. package/dist/data/hooks/scaffold-update-check.mjs +0 -181
  15. package/dist/data/hooks.test.ts +0 -109
  16. package/dist/data/scripts/sync-subagents.mjs +0 -491
  17. package/dist/data/subagents/manifest.mjs +0 -487
  18. package/dist/data/subagents/manifest.test.ts +0 -40
  19. package/dist/skills/agnostic/backend/backend-domain-structure/SKILL.md +0 -50
  20. package/dist/skills/agnostic/backend/backend-domain-structure/agents/openai.yaml +0 -4
  21. package/dist/skills/agnostic/backend/backend-domain-structure/references/layout.md +0 -167
  22. package/dist/skills/agnostic/backend/backend-recoverable-actions/SKILL.md +0 -49
  23. package/dist/skills/agnostic/backend/backend-recoverable-actions/agents/openai.yaml +0 -4
  24. package/dist/skills/agnostic/backend/backend-recoverable-actions/references/strategy-matrix.md +0 -34
  25. package/dist/skills/agnostic/backend/backend-recoverable-actions/references/test-matrix.md +0 -34
  26. package/dist/skills/agnostic/backend/logging-best-practices/SKILL.md +0 -127
  27. package/dist/skills/agnostic/backend/logging-best-practices/rules/context.md +0 -157
  28. package/dist/skills/agnostic/backend/logging-best-practices/rules/pitfalls.md +0 -118
  29. package/dist/skills/agnostic/backend/logging-best-practices/rules/structure.md +0 -193
  30. package/dist/skills/agnostic/backend/logging-best-practices/rules/wide-events.md +0 -113
  31. package/dist/skills/agnostic/cli/dp-cli/SKILL.md +0 -125
  32. package/dist/skills/agnostic/cli/dp-cli/references/commands.md +0 -70
  33. package/dist/skills/agnostic/cli/dp-cli/references/post-command-flow.md +0 -70
  34. package/dist/skills/agnostic/debug/debug-agent/SKILL.md +0 -184
  35. package/dist/skills/agnostic/docs/docs-onboarding/SKILL.md +0 -46
  36. package/dist/skills/agnostic/docs/docs-onboarding/agents/openai.yaml +0 -4
  37. package/dist/skills/agnostic/docs/docs-onboarding/references/artifact-contract.md +0 -67
  38. package/dist/skills/agnostic/docs/upstream/mattpocock-writing-skills.md +0 -41
  39. package/dist/skills/agnostic/docs/writing-beats/SKILL.md +0 -69
  40. package/dist/skills/agnostic/docs/writing-fragments/SKILL.md +0 -76
  41. package/dist/skills/agnostic/docs/writing-shape/SKILL.md +0 -75
  42. package/dist/skills/agnostic/frontend/agent-browser/.clawdhub/origin.json +0 -7
  43. package/dist/skills/agnostic/frontend/agent-browser/SKILL.md +0 -229
  44. package/dist/skills/agnostic/frontend/agent-browser/references/authentication.md +0 -202
  45. package/dist/skills/agnostic/frontend/agent-browser/references/commands.md +0 -259
  46. package/dist/skills/agnostic/frontend/agent-browser/references/proxy-support.md +0 -188
  47. package/dist/skills/agnostic/frontend/agent-browser/references/session-management.md +0 -193
  48. package/dist/skills/agnostic/frontend/agent-browser/references/snapshot-refs.md +0 -194
  49. package/dist/skills/agnostic/frontend/agent-browser/references/video-recording.md +0 -173
  50. package/dist/skills/agnostic/frontend/agent-browser/templates/authenticated-session.sh +0 -97
  51. package/dist/skills/agnostic/frontend/agent-browser/templates/capture-workflow.sh +0 -69
  52. package/dist/skills/agnostic/frontend/agent-browser/templates/form-automation.sh +0 -62
  53. package/dist/skills/agnostic/frontend/design-taste-frontend/SKILL.md +0 -226
  54. package/dist/skills/agnostic/frontend/frontend-domain-structure/SKILL.md +0 -55
  55. package/dist/skills/agnostic/frontend/frontend-domain-structure/agents/openai.yaml +0 -4
  56. package/dist/skills/agnostic/frontend/frontend-domain-structure/references/react/structure.md +0 -102
  57. package/dist/skills/agnostic/frontend/frontend-domain-structure/references/structure.md +0 -257
  58. package/dist/skills/agnostic/frontend/gpt-taste/SKILL.md +0 -74
  59. package/dist/skills/agnostic/frontend/image-taste-frontend/SKILL.md +0 -1102
  60. package/dist/skills/agnostic/frontend/redesign-existing-projects/SKILL.md +0 -178
  61. package/dist/skills/agnostic/planning/create-plan/REFERENCE.md +0 -37
  62. package/dist/skills/agnostic/planning/create-plan/SKILL.md +0 -87
  63. package/dist/skills/agnostic/planning/create-plan/references/backlog-sync.md +0 -44
  64. package/dist/skills/agnostic/planning/create-plan/references/grill-phase.md +0 -87
  65. package/dist/skills/agnostic/planning/create-plan/references/plan-schema.md +0 -70
  66. package/dist/skills/agnostic/planning/create-plan/references/planner-phase.md +0 -42
  67. package/dist/skills/agnostic/planning/create-plan/references/stop-conditions.md +0 -18
  68. package/dist/skills/agnostic/planning/create-plan/references/tdd-phase.md +0 -26
  69. package/dist/skills/agnostic/planning/create-spec/SKILL.md +0 -110
  70. package/dist/skills/agnostic/planning/create-spec/assets/SPEC-TEMPLATE.md +0 -91
  71. package/dist/skills/agnostic/planning/create-spec/references/backlog-sync.md +0 -49
  72. package/dist/skills/agnostic/planning/create-spec/references/discovery.md +0 -54
  73. package/dist/skills/agnostic/planning/create-spec/references/folder-naming.md +0 -33
  74. package/dist/skills/agnostic/planning/create-spec/references/grill-phase.md +0 -47
  75. package/dist/skills/agnostic/planning/create-spec/references/handoff.md +0 -47
  76. package/dist/skills/agnostic/planning/create-spec/references/questioning.md +0 -51
  77. package/dist/skills/agnostic/planning/create-spec/references/spec-quality-bar.md +0 -58
  78. package/dist/skills/agnostic/planning/create-spec/references/wiki-bookkeeping.md +0 -50
  79. package/dist/skills/agnostic/planning/grill-me/SKILL.md +0 -28
  80. package/dist/skills/agnostic/planning/implement-spec/SKILL.md +0 -99
  81. package/dist/skills/agnostic/planning/implement-spec/assets/IMPLEMENTATION-NOTES-TEMPLATE.md +0 -53
  82. package/dist/skills/agnostic/planning/implement-spec/references/lifecycle.md +0 -193
  83. package/dist/skills/agnostic/planning/implement-spec/references/parallel-orchestration.md +0 -102
  84. package/dist/skills/agnostic/planning/implement-spec/references/parallel-worker-brief.md +0 -67
  85. package/dist/skills/agnostic/planning/implement-spec/references/parallel.md +0 -56
  86. package/dist/skills/agnostic/planning/implement-spec/references/sequential.md +0 -38
  87. package/dist/skills/agnostic/planning/stack/SKILL.md +0 -89
  88. package/dist/skills/agnostic/planning/swarm-planner/SKILL.md +0 -179
  89. package/dist/skills/agnostic/quality/autoreview/SKILL.md +0 -191
  90. package/dist/skills/agnostic/quality/autoreview/scripts/autoreview +0 -1176
  91. package/dist/skills/agnostic/quality/autoreview/scripts/test-review-harness +0 -176
  92. package/dist/skills/agnostic/quality/simplify/SKILL.md +0 -14
  93. package/dist/skills/agnostic/quality/tdd/SKILL.md +0 -107
  94. package/dist/skills/agnostic/quality/tdd/deep-modules.md +0 -33
  95. package/dist/skills/agnostic/quality/tdd/interface-design.md +0 -31
  96. package/dist/skills/agnostic/quality/tdd/mocking.md +0 -59
  97. package/dist/skills/agnostic/quality/tdd/refactoring.md +0 -10
  98. package/dist/skills/agnostic/quality/tdd/tests.md +0 -61
  99. package/dist/skills/agnostic/requirements/requirements-grill/SKILL.md +0 -43
  100. package/dist/skills/agnostic/requirements/requirements-grill/references/artifact-output.md +0 -157
  101. package/dist/skills/agnostic/requirements/requirements-grill/references/grilling-flow.md +0 -69
  102. package/dist/skills/agnostic/requirements/requirements-grill/references/wiki-output.md +0 -101
  103. package/dist/skills/agnostic/requirements/write-backlog/EXAMPLES.md +0 -67
  104. package/dist/skills/agnostic/requirements/write-backlog/REFERENCE.md +0 -262
  105. package/dist/skills/agnostic/requirements/write-backlog/SKILL.md +0 -71
  106. package/dist/skills/agnostic/requirements/write-backlog/assets/concepts/backlog-model.md +0 -69
  107. package/dist/skills/agnostic/requirements/write-backlog/assets/concepts/story-shape.md +0 -66
  108. package/dist/skills/agnostic/requirements/write-backlog/assets/providers/azure-devops-create-payload.md +0 -63
  109. package/dist/skills/agnostic/requirements/write-backlog/assets/providers/github-projects-create-payload.md +0 -224
  110. package/dist/skills/agnostic/requirements/write-backlog/assets/providers/linear-create-payload.md +0 -76
  111. package/dist/skills/agnostic/requirements/write-backlog/assets/providers/monday-create-payload.md +0 -146
  112. package/dist/skills/agnostic/research/improve-codebase-architecture/REFERENCE.md +0 -78
  113. package/dist/skills/agnostic/research/improve-codebase-architecture/SKILL.md +0 -76
  114. package/dist/skills/agnostic/research/parallel-research/SKILL.md +0 -68
  115. package/dist/skills/agnostic/research/parallel-research/agents/openai.yaml +0 -4
  116. package/dist/skills/agnostic/subagents/swarm-planner/SKILL.md +0 -179
  117. package/dist/skills/agnostic/write-a-skill/SKILL.md +0 -117
  118. package/dist/skills/frameworks/better-auth/better-auth-best-practices/SKILL.md +0 -166
  119. package/dist/skills/frameworks/better-auth/better-auth-security-best-practices/SKILL.MD +0 -432
  120. package/dist/skills/frameworks/effect/effect-authoring/SKILL.md +0 -116
  121. package/dist/skills/frameworks/effect/effect-authoring/references/branded-types.md +0 -98
  122. package/dist/skills/frameworks/effect/effect-authoring/references/effect-atom-patterns.md +0 -257
  123. package/dist/skills/frameworks/effect/effect-authoring/references/effect-primitives.md +0 -144
  124. package/dist/skills/frameworks/effect/effect-authoring/references/error-patterns.md +0 -156
  125. package/dist/skills/frameworks/effect/effect-authoring/references/otel-patterns.md +0 -113
  126. package/dist/skills/frameworks/effect/effect-authoring/references/test-patterns.md +0 -146
  127. package/dist/skills/frameworks/effect/effect-backend-structure/SKILL.md +0 -96
  128. package/dist/skills/frameworks/effect/effect-backend-structure/agents/openai.yaml +0 -4
  129. package/dist/skills/frameworks/effect/effect-backend-structure/references/layout.md +0 -68
  130. package/dist/skills/frameworks/effect/effect-best-practices/SKILL.md +0 -517
  131. package/dist/skills/frameworks/effect/effect-best-practices/references/anti-patterns.md +0 -392
  132. package/dist/skills/frameworks/effect/effect-best-practices/references/effect-atom-patterns.md +0 -653
  133. package/dist/skills/frameworks/effect/effect-best-practices/references/error-patterns.md +0 -464
  134. package/dist/skills/frameworks/effect/effect-best-practices/references/language-server.md +0 -287
  135. package/dist/skills/frameworks/effect/effect-best-practices/references/layer-patterns.md +0 -495
  136. package/dist/skills/frameworks/effect/effect-best-practices/references/observability-patterns.md +0 -342
  137. package/dist/skills/frameworks/effect/effect-best-practices/references/rpc-cluster-patterns.md +0 -418
  138. package/dist/skills/frameworks/effect/effect-best-practices/references/schema-patterns.md +0 -353
  139. package/dist/skills/frameworks/effect/effect-best-practices/references/service-patterns.md +0 -299
  140. package/dist/skills/frameworks/effect/effect-recoverable-actions/SKILL.md +0 -65
  141. package/dist/skills/frameworks/effect/effect-recoverable-actions/agents/openai.yaml +0 -4
  142. package/dist/skills/frameworks/effect/effect-recoverable-actions/references/flow-examples.md +0 -154
  143. package/dist/skills/frameworks/effect/effect-recoverable-actions/references/source-backed-primitives.md +0 -104
  144. package/dist/skills/frameworks/effect/effect-recoverable-actions/references/strategy-matrix.md +0 -34
  145. package/dist/skills/frameworks/effect/effect-recoverable-actions/references/test-matrix.md +0 -36
  146. package/dist/skills/frameworks/elysia/elysiajs/SKILL.md +0 -475
  147. package/dist/skills/frameworks/elysia/elysiajs/examples/basic.ts +0 -9
  148. package/dist/skills/frameworks/elysia/elysiajs/examples/body-parser.ts +0 -33
  149. package/dist/skills/frameworks/elysia/elysiajs/examples/complex.ts +0 -112
  150. package/dist/skills/frameworks/elysia/elysiajs/examples/cookie.ts +0 -45
  151. package/dist/skills/frameworks/elysia/elysiajs/examples/error.ts +0 -38
  152. package/dist/skills/frameworks/elysia/elysiajs/examples/file.ts +0 -10
  153. package/dist/skills/frameworks/elysia/elysiajs/examples/guard.ts +0 -34
  154. package/dist/skills/frameworks/elysia/elysiajs/examples/map-response.ts +0 -15
  155. package/dist/skills/frameworks/elysia/elysiajs/examples/redirect.ts +0 -6
  156. package/dist/skills/frameworks/elysia/elysiajs/examples/rename.ts +0 -32
  157. package/dist/skills/frameworks/elysia/elysiajs/examples/schema.ts +0 -61
  158. package/dist/skills/frameworks/elysia/elysiajs/examples/state.ts +0 -6
  159. package/dist/skills/frameworks/elysia/elysiajs/examples/upload-file.ts +0 -20
  160. package/dist/skills/frameworks/elysia/elysiajs/examples/websocket.ts +0 -25
  161. package/dist/skills/frameworks/elysia/elysiajs/integrations/ai-sdk.md +0 -92
  162. package/dist/skills/frameworks/elysia/elysiajs/integrations/astro.md +0 -59
  163. package/dist/skills/frameworks/elysia/elysiajs/integrations/better-auth.md +0 -117
  164. package/dist/skills/frameworks/elysia/elysiajs/integrations/cloudflare-worker.md +0 -95
  165. package/dist/skills/frameworks/elysia/elysiajs/integrations/deno.md +0 -34
  166. package/dist/skills/frameworks/elysia/elysiajs/integrations/drizzle.md +0 -258
  167. package/dist/skills/frameworks/elysia/elysiajs/integrations/expo.md +0 -95
  168. package/dist/skills/frameworks/elysia/elysiajs/integrations/nextjs.md +0 -103
  169. package/dist/skills/frameworks/elysia/elysiajs/integrations/nodejs.md +0 -64
  170. package/dist/skills/frameworks/elysia/elysiajs/integrations/nuxt.md +0 -67
  171. package/dist/skills/frameworks/elysia/elysiajs/integrations/prisma.md +0 -93
  172. package/dist/skills/frameworks/elysia/elysiajs/integrations/react-email.md +0 -134
  173. package/dist/skills/frameworks/elysia/elysiajs/integrations/sveltekit.md +0 -53
  174. package/dist/skills/frameworks/elysia/elysiajs/integrations/tanstack-start.md +0 -87
  175. package/dist/skills/frameworks/elysia/elysiajs/integrations/vercel.md +0 -55
  176. package/dist/skills/frameworks/elysia/elysiajs/patterns/mvc.md +0 -380
  177. package/dist/skills/frameworks/elysia/elysiajs/plugins/bearer.md +0 -30
  178. package/dist/skills/frameworks/elysia/elysiajs/plugins/cors.md +0 -141
  179. package/dist/skills/frameworks/elysia/elysiajs/plugins/cron.md +0 -265
  180. package/dist/skills/frameworks/elysia/elysiajs/plugins/graphql-apollo.md +0 -90
  181. package/dist/skills/frameworks/elysia/elysiajs/plugins/graphql-yoga.md +0 -87
  182. package/dist/skills/frameworks/elysia/elysiajs/plugins/html.md +0 -188
  183. package/dist/skills/frameworks/elysia/elysiajs/plugins/jwt.md +0 -197
  184. package/dist/skills/frameworks/elysia/elysiajs/plugins/openapi.md +0 -246
  185. package/dist/skills/frameworks/elysia/elysiajs/plugins/opentelemetry.md +0 -167
  186. package/dist/skills/frameworks/elysia/elysiajs/plugins/server-timing.md +0 -71
  187. package/dist/skills/frameworks/elysia/elysiajs/plugins/static.md +0 -84
  188. package/dist/skills/frameworks/elysia/elysiajs/references/bun-fullstack-dev-server.md +0 -129
  189. package/dist/skills/frameworks/elysia/elysiajs/references/cookie.md +0 -187
  190. package/dist/skills/frameworks/elysia/elysiajs/references/deployment.md +0 -413
  191. package/dist/skills/frameworks/elysia/elysiajs/references/eden.md +0 -158
  192. package/dist/skills/frameworks/elysia/elysiajs/references/lifecycle.md +0 -198
  193. package/dist/skills/frameworks/elysia/elysiajs/references/macro.md +0 -83
  194. package/dist/skills/frameworks/elysia/elysiajs/references/plugin.md +0 -207
  195. package/dist/skills/frameworks/elysia/elysiajs/references/route.md +0 -331
  196. package/dist/skills/frameworks/elysia/elysiajs/references/testing.md +0 -385
  197. package/dist/skills/frameworks/elysia/elysiajs/references/validation.md +0 -491
  198. package/dist/skills/frameworks/elysia/elysiajs/references/websocket.md +0 -250
  199. package/dist/skills/frameworks/nestjs/nestjs-best-practices/.github/workflows/branch-protection.yml +0 -24
  200. package/dist/skills/frameworks/nestjs/nestjs-best-practices/.github/workflows/deploy.yml +0 -61
  201. package/dist/skills/frameworks/nestjs/nestjs-best-practices/AGENTS.md +0 -5958
  202. package/dist/skills/frameworks/nestjs/nestjs-best-practices/SKILL.md +0 -130
  203. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/api-use-dto-serialization.md +0 -182
  204. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/api-use-interceptors.md +0 -202
  205. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/api-use-pipes.md +0 -205
  206. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/api-versioning.md +0 -191
  207. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/arch-avoid-circular-deps.md +0 -80
  208. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/arch-feature-modules.md +0 -82
  209. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/arch-module-sharing.md +0 -141
  210. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/arch-single-responsibility.md +0 -106
  211. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/arch-use-events.md +0 -108
  212. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/arch-use-repository-pattern.md +0 -97
  213. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/db-avoid-n-plus-one.md +0 -139
  214. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/db-use-migrations.md +0 -129
  215. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/db-use-transactions.md +0 -140
  216. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/devops-graceful-shutdown.md +0 -222
  217. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/devops-use-config-module.md +0 -167
  218. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/devops-use-logging.md +0 -232
  219. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/di-avoid-service-locator.md +0 -104
  220. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/di-interface-segregation.md +0 -165
  221. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/di-liskov-substitution.md +0 -221
  222. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/di-prefer-constructor-injection.md +0 -86
  223. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/di-scope-awareness.md +0 -94
  224. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/di-use-interfaces-tokens.md +0 -101
  225. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/error-handle-async-errors.md +0 -125
  226. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/error-throw-http-exceptions.md +0 -114
  227. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/error-use-exception-filters.md +0 -140
  228. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/micro-use-health-checks.md +0 -226
  229. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/micro-use-patterns.md +0 -167
  230. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/micro-use-queues.md +0 -252
  231. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/perf-async-hooks.md +0 -109
  232. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/perf-lazy-loading.md +0 -121
  233. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/perf-optimize-database.md +0 -131
  234. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/perf-use-caching.md +0 -128
  235. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/security-auth-jwt.md +0 -146
  236. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/security-rate-limiting.md +0 -125
  237. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/security-sanitize-output.md +0 -139
  238. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/security-use-guards.md +0 -135
  239. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/security-validate-all-input.md +0 -150
  240. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/test-e2e-supertest.md +0 -178
  241. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/test-mock-external-services.md +0 -179
  242. package/dist/skills/frameworks/nestjs/nestjs-best-practices/rules/test-use-testing-module.md +0 -153
  243. package/dist/skills/frameworks/nestjs/nestjs-best-practices/scripts/build-agents.ts +0 -299
  244. package/dist/skills/frameworks/nestjs/nestjs-best-practices/scripts/build.sh +0 -16
  245. package/dist/skills/frameworks/nestjs/nestjs-best-practices/scripts/package-lock.json +0 -237
  246. package/dist/skills/frameworks/nestjs/nestjs-best-practices/scripts/package.json +0 -15
  247. package/dist/skills/frameworks/nestjs/nestjs-expert/SKILL.md +0 -208
  248. package/dist/skills/frameworks/nestjs/nestjs-expert/references/authentication.md +0 -166
  249. package/dist/skills/frameworks/nestjs/nestjs-expert/references/controllers-routing.md +0 -111
  250. package/dist/skills/frameworks/nestjs/nestjs-expert/references/dtos-validation.md +0 -153
  251. package/dist/skills/frameworks/nestjs/nestjs-expert/references/migration-from-express.md +0 -1237
  252. package/dist/skills/frameworks/nestjs/nestjs-expert/references/services-di.md +0 -140
  253. package/dist/skills/frameworks/nestjs/nestjs-expert/references/testing-patterns.md +0 -186
  254. package/dist/skills/frameworks/nextjs/next-best-practices/SKILL.md +0 -153
  255. package/dist/skills/frameworks/nextjs/next-best-practices/async-patterns.md +0 -87
  256. package/dist/skills/frameworks/nextjs/next-best-practices/bundling.md +0 -180
  257. package/dist/skills/frameworks/nextjs/next-best-practices/data-patterns.md +0 -297
  258. package/dist/skills/frameworks/nextjs/next-best-practices/debug-tricks.md +0 -105
  259. package/dist/skills/frameworks/nextjs/next-best-practices/directives.md +0 -73
  260. package/dist/skills/frameworks/nextjs/next-best-practices/error-handling.md +0 -227
  261. package/dist/skills/frameworks/nextjs/next-best-practices/file-conventions.md +0 -140
  262. package/dist/skills/frameworks/nextjs/next-best-practices/font.md +0 -245
  263. package/dist/skills/frameworks/nextjs/next-best-practices/functions.md +0 -108
  264. package/dist/skills/frameworks/nextjs/next-best-practices/hydration-error.md +0 -91
  265. package/dist/skills/frameworks/nextjs/next-best-practices/image.md +0 -173
  266. package/dist/skills/frameworks/nextjs/next-best-practices/metadata.md +0 -301
  267. package/dist/skills/frameworks/nextjs/next-best-practices/parallel-routes.md +0 -287
  268. package/dist/skills/frameworks/nextjs/next-best-practices/route-handlers.md +0 -146
  269. package/dist/skills/frameworks/nextjs/next-best-practices/rsc-boundaries.md +0 -159
  270. package/dist/skills/frameworks/nextjs/next-best-practices/runtime-selection.md +0 -39
  271. package/dist/skills/frameworks/nextjs/next-best-practices/scripts.md +0 -141
  272. package/dist/skills/frameworks/nextjs/next-best-practices/self-hosting.md +0 -371
  273. package/dist/skills/frameworks/nextjs/next-best-practices/suspense-boundaries.md +0 -67
  274. package/dist/skills/frameworks/nextjs/next-cache-components/SKILL.md +0 -360
  275. package/dist/skills/frameworks/react/async-react-patterns/SKILL.md +0 -78
  276. package/dist/skills/frameworks/react/vercel-composition-patterns/AGENTS.md +0 -946
  277. package/dist/skills/frameworks/react/vercel-composition-patterns/SKILL.md +0 -89
  278. package/dist/skills/frameworks/react/vercel-composition-patterns/rules/architecture-avoid-boolean-props.md +0 -100
  279. package/dist/skills/frameworks/react/vercel-composition-patterns/rules/architecture-compound-components.md +0 -112
  280. package/dist/skills/frameworks/react/vercel-composition-patterns/rules/patterns-children-over-render-props.md +0 -87
  281. package/dist/skills/frameworks/react/vercel-composition-patterns/rules/patterns-explicit-variants.md +0 -100
  282. package/dist/skills/frameworks/react/vercel-composition-patterns/rules/react19-no-forwardref.md +0 -42
  283. package/dist/skills/frameworks/react/vercel-composition-patterns/rules/state-context-interface.md +0 -191
  284. package/dist/skills/frameworks/react/vercel-composition-patterns/rules/state-decouple-implementation.md +0 -113
  285. package/dist/skills/frameworks/react/vercel-composition-patterns/rules/state-lift-state.md +0 -125
  286. package/dist/skills/frameworks/react/vercel-react-best-practices/AGENTS.md +0 -3750
  287. package/dist/skills/frameworks/react/vercel-react-best-practices/SKILL.md +0 -148
  288. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/advanced-effect-event-deps.md +0 -56
  289. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/advanced-event-handler-refs.md +0 -55
  290. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/advanced-init-once.md +0 -42
  291. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/advanced-use-latest.md +0 -39
  292. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/async-api-routes.md +0 -38
  293. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/async-cheap-condition-before-await.md +0 -37
  294. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/async-defer-await.md +0 -82
  295. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/async-dependencies.md +0 -51
  296. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/async-parallel.md +0 -28
  297. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/async-suspense-boundaries.md +0 -99
  298. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/bundle-barrel-imports.md +0 -60
  299. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/bundle-conditional.md +0 -31
  300. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/bundle-defer-third-party.md +0 -49
  301. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/bundle-dynamic-imports.md +0 -35
  302. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/bundle-preload.md +0 -50
  303. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/client-event-listeners.md +0 -74
  304. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/client-localstorage-schema.md +0 -71
  305. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/client-passive-event-listeners.md +0 -48
  306. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/client-swr-dedup.md +0 -56
  307. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/js-batch-dom-css.md +0 -107
  308. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/js-cache-function-results.md +0 -80
  309. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/js-cache-property-access.md +0 -28
  310. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/js-cache-storage.md +0 -70
  311. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/js-combine-iterations.md +0 -32
  312. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/js-early-exit.md +0 -50
  313. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/js-flatmap-filter.md +0 -60
  314. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/js-hoist-regexp.md +0 -45
  315. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/js-index-maps.md +0 -37
  316. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/js-length-check-first.md +0 -49
  317. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/js-min-max-loop.md +0 -82
  318. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/js-request-idle-callback.md +0 -105
  319. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/js-set-map-lookups.md +0 -24
  320. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/js-tosorted-immutable.md +0 -57
  321. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rendering-activity.md +0 -26
  322. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rendering-animate-svg-wrapper.md +0 -47
  323. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rendering-conditional-render.md +0 -40
  324. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rendering-content-visibility.md +0 -38
  325. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rendering-hoist-jsx.md +0 -46
  326. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rendering-hydration-no-flicker.md +0 -82
  327. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rendering-hydration-suppress-warning.md +0 -30
  328. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rendering-resource-hints.md +0 -85
  329. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rendering-script-defer-async.md +0 -68
  330. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rendering-svg-precision.md +0 -28
  331. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rendering-usetransition-loading.md +0 -75
  332. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rerender-defer-reads.md +0 -39
  333. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rerender-dependencies.md +0 -45
  334. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rerender-derived-state-no-effect.md +0 -40
  335. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rerender-derived-state.md +0 -29
  336. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rerender-functional-setstate.md +0 -74
  337. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rerender-lazy-state-init.md +0 -58
  338. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rerender-memo-with-default-value.md +0 -38
  339. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rerender-memo.md +0 -44
  340. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rerender-move-effect-to-event.md +0 -45
  341. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rerender-no-inline-components.md +0 -82
  342. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rerender-simple-expression-in-memo.md +0 -35
  343. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rerender-split-combined-hooks.md +0 -64
  344. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rerender-transitions.md +0 -40
  345. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rerender-use-deferred-value.md +0 -59
  346. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/rerender-use-ref-transient-values.md +0 -73
  347. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/server-after-nonblocking.md +0 -73
  348. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/server-auth-actions.md +0 -96
  349. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/server-cache-lru.md +0 -41
  350. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/server-cache-react.md +0 -76
  351. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/server-dedup-props.md +0 -65
  352. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/server-hoist-static-io.md +0 -149
  353. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/server-no-shared-module-state.md +0 -50
  354. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/server-parallel-fetching.md +0 -83
  355. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/server-parallel-nested-fetching.md +0 -34
  356. package/dist/skills/frameworks/react/vercel-react-best-practices/rules/server-serialization.md +0 -38
  357. package/dist/skills/frameworks/tanstack-query/tanstack-query/.claude-plugin/plugin.json +0 -12
  358. package/dist/skills/frameworks/tanstack-query/tanstack-query/SKILL.md +0 -849
  359. package/dist/skills/frameworks/tanstack-query/tanstack-query/assets/example-template.txt +0 -14
  360. package/dist/skills/frameworks/tanstack-query/tanstack-query/references/best-practices.md +0 -304
  361. package/dist/skills/frameworks/tanstack-query/tanstack-query/references/common-patterns.md +0 -271
  362. package/dist/skills/frameworks/tanstack-query/tanstack-query/references/example-reference.md +0 -26
  363. package/dist/skills/frameworks/tanstack-query/tanstack-query/references/testing.md +0 -282
  364. package/dist/skills/frameworks/tanstack-query/tanstack-query/references/top-errors.md +0 -332
  365. package/dist/skills/frameworks/tanstack-query/tanstack-query/references/typescript-patterns.md +0 -291
  366. package/dist/skills/frameworks/tanstack-query/tanstack-query/references/v4-to-v5-migration.md +0 -231
  367. package/dist/skills/frameworks/tanstack-query/tanstack-query/rules/tanstack-query.md +0 -126
  368. package/dist/skills/frameworks/tanstack-query/tanstack-query/scripts/example-script.sh +0 -15
  369. package/dist/skills/frameworks/tanstack-query/tanstack-query/templates/custom-hooks-pattern.tsx +0 -281
  370. package/dist/skills/frameworks/tanstack-query/tanstack-query/templates/devtools-setup.tsx +0 -248
  371. package/dist/skills/frameworks/tanstack-query/tanstack-query/templates/error-boundary.tsx +0 -243
  372. package/dist/skills/frameworks/tanstack-query/tanstack-query/templates/package.json +0 -31
  373. package/dist/skills/frameworks/tanstack-query/tanstack-query/templates/provider-setup.tsx +0 -50
  374. package/dist/skills/frameworks/tanstack-query/tanstack-query/templates/query-client-config.ts +0 -72
  375. package/dist/skills/frameworks/tanstack-query/tanstack-query/templates/use-infinite-query.tsx +0 -214
  376. package/dist/skills/frameworks/tanstack-query/tanstack-query/templates/use-mutation-basic.tsx +0 -201
  377. package/dist/skills/frameworks/tanstack-query/tanstack-query/templates/use-mutation-optimistic.tsx +0 -234
  378. package/dist/skills/frameworks/tanstack-query/tanstack-query/templates/use-query-basic.tsx +0 -119
  379. package/dist/skills/frameworks/tanstack-start/tanstack-start/SKILL.md +0 -250
  380. package/dist/skills/frameworks/trpc/tanstack-query/.claude-plugin/plugin.json +0 -12
  381. package/dist/skills/frameworks/trpc/tanstack-query/SKILL.md +0 -1058
  382. package/dist/skills/frameworks/trpc/tanstack-query/assets/example-template.txt +0 -14
  383. package/dist/skills/frameworks/trpc/tanstack-query/references/best-practices.md +0 -304
  384. package/dist/skills/frameworks/trpc/tanstack-query/references/common-patterns.md +0 -271
  385. package/dist/skills/frameworks/trpc/tanstack-query/references/example-reference.md +0 -26
  386. package/dist/skills/frameworks/trpc/tanstack-query/references/testing.md +0 -282
  387. package/dist/skills/frameworks/trpc/tanstack-query/references/top-errors.md +0 -332
  388. package/dist/skills/frameworks/trpc/tanstack-query/references/typescript-patterns.md +0 -291
  389. package/dist/skills/frameworks/trpc/tanstack-query/references/v4-to-v5-migration.md +0 -231
  390. package/dist/skills/frameworks/trpc/tanstack-query/rules/tanstack-query.md +0 -126
  391. package/dist/skills/frameworks/trpc/tanstack-query/scripts/example-script.sh +0 -15
  392. package/dist/skills/frameworks/trpc/tanstack-query/templates/custom-hooks-pattern.tsx +0 -281
  393. package/dist/skills/frameworks/trpc/tanstack-query/templates/devtools-setup.tsx +0 -248
  394. package/dist/skills/frameworks/trpc/tanstack-query/templates/error-boundary.tsx +0 -243
  395. package/dist/skills/frameworks/trpc/tanstack-query/templates/package.json +0 -31
  396. package/dist/skills/frameworks/trpc/tanstack-query/templates/provider-setup.tsx +0 -50
  397. package/dist/skills/frameworks/trpc/tanstack-query/templates/query-client-config.ts +0 -72
  398. package/dist/skills/frameworks/trpc/tanstack-query/templates/use-infinite-query.tsx +0 -214
  399. package/dist/skills/frameworks/trpc/tanstack-query/templates/use-mutation-basic.tsx +0 -201
  400. package/dist/skills/frameworks/trpc/tanstack-query/templates/use-mutation-optimistic.tsx +0 -234
  401. package/dist/skills/frameworks/trpc/tanstack-query/templates/use-query-basic.tsx +0 -119
  402. package/dist/skills/frameworks/turborepo/turborepo/SKILL.md +0 -914
  403. package/dist/skills/frameworks/turborepo/turborepo/command/turborepo.md +0 -70
  404. package/dist/skills/frameworks/turborepo/turborepo/references/best-practices/RULE.md +0 -241
  405. package/dist/skills/frameworks/turborepo/turborepo/references/best-practices/dependencies.md +0 -246
  406. package/dist/skills/frameworks/turborepo/turborepo/references/best-practices/packages.md +0 -335
  407. package/dist/skills/frameworks/turborepo/turborepo/references/best-practices/structure.md +0 -270
  408. package/dist/skills/frameworks/turborepo/turborepo/references/boundaries/RULE.md +0 -126
  409. package/dist/skills/frameworks/turborepo/turborepo/references/caching/RULE.md +0 -107
  410. package/dist/skills/frameworks/turborepo/turborepo/references/caching/gotchas.md +0 -169
  411. package/dist/skills/frameworks/turborepo/turborepo/references/caching/remote-cache.md +0 -127
  412. package/dist/skills/frameworks/turborepo/turborepo/references/ci/RULE.md +0 -79
  413. package/dist/skills/frameworks/turborepo/turborepo/references/ci/github-actions.md +0 -162
  414. package/dist/skills/frameworks/turborepo/turborepo/references/ci/patterns.md +0 -145
  415. package/dist/skills/frameworks/turborepo/turborepo/references/ci/vercel.md +0 -103
  416. package/dist/skills/frameworks/turborepo/turborepo/references/cli/RULE.md +0 -100
  417. package/dist/skills/frameworks/turborepo/turborepo/references/cli/commands.md +0 -297
  418. package/dist/skills/frameworks/turborepo/turborepo/references/configuration/RULE.md +0 -211
  419. package/dist/skills/frameworks/turborepo/turborepo/references/configuration/global-options.md +0 -187
  420. package/dist/skills/frameworks/turborepo/turborepo/references/configuration/gotchas.md +0 -348
  421. package/dist/skills/frameworks/turborepo/turborepo/references/configuration/tasks.md +0 -285
  422. package/dist/skills/frameworks/turborepo/turborepo/references/environment/RULE.md +0 -96
  423. package/dist/skills/frameworks/turborepo/turborepo/references/environment/gotchas.md +0 -141
  424. package/dist/skills/frameworks/turborepo/turborepo/references/environment/modes.md +0 -101
  425. package/dist/skills/frameworks/turborepo/turborepo/references/filtering/RULE.md +0 -148
  426. package/dist/skills/frameworks/turborepo/turborepo/references/filtering/patterns.md +0 -152
  427. package/dist/skills/frameworks/turborepo/turborepo/references/watch/RULE.md +0 -99
  428. package/dist/skills/languages/python/async-python-patterns/SKILL.md +0 -735
  429. package/dist/skills/languages/python/python-code-style/SKILL.md +0 -360
  430. package/dist/skills/languages/python/python-design-patterns/SKILL.md +0 -433
  431. package/dist/skills/languages/python/python-project-structure/SKILL.md +0 -252
  432. package/dist/skills/languages/python/python-testing-patterns/SKILL.md +0 -622
  433. package/dist/skills/languages/python/python-testing-patterns/references/advanced-patterns.md +0 -411
  434. package/dist/skills/languages/typescript/quality-types/SKILL.md +0 -93
  435. package/dist/skills/phases/bug-discovery-phase/REFERENCE.md +0 -140
  436. package/dist/skills/phases/bug-discovery-phase/SKILL.md +0 -78
  437. package/dist/skills/phases/bug-resolution-phase/REFERENCE.md +0 -160
  438. package/dist/skills/phases/bug-resolution-phase/SKILL.md +0 -64
  439. package/dist/skills/phases/debugging-phase/SKILL.md +0 -87
  440. package/dist/skills/phases/delivery-phase/SKILL.md +0 -87
  441. package/dist/skills/phases/docs-ingest-phase/SKILL.md +0 -96
  442. package/dist/skills/phases/docs-ingest-phase/agents/openai.yaml +0 -4
  443. package/dist/skills/phases/docs-ingest-phase/references/concept-pages.md +0 -70
  444. package/dist/skills/phases/docs-ingest-phase/references/flow-pages.md +0 -56
  445. package/dist/skills/phases/docs-ingest-phase/references/fumadocs-routing.md +0 -74
  446. package/dist/skills/phases/docs-ingest-phase/references/public-docs.md +0 -82
  447. package/dist/skills/phases/docs-ingest-phase/references/repo-docs.md +0 -38
  448. package/dist/skills/phases/docs-ingest-phase/references/wiki-ingest.md +0 -133
  449. package/dist/skills/phases/goalify/EXAMPLES.md +0 -78
  450. package/dist/skills/phases/goalify/SKILL.md +0 -129
  451. package/dist/skills/phases/requirements-phase/SKILL.md +0 -69
  452. package/dist/skills/phases/resolve-debt-phase/SKILL.md +0 -87
  453. package/dist/skills/phases/review-phase/SKILL.md +0 -116
@@ -1,135 +0,0 @@
1
- ---
2
- title: Use Guards for Authentication and Authorization
3
- impact: HIGH
4
- impactDescription: Enforces access control before handlers execute
5
- tags: security, guards, authentication, authorization
6
- ---
7
-
8
- ## Use Guards for Authentication and Authorization
9
-
10
- Guards determine whether a request should be handled based on authentication state, roles, permissions, or other conditions. They run after middleware but before pipes and interceptors, making them ideal for access control. Use guards instead of manual checks in controllers.
11
-
12
- **Incorrect (manual auth checks in every handler):**
13
-
14
- ```typescript
15
- // Manual auth checks in every handler
16
- @Controller('admin')
17
- export class AdminController {
18
- @Get('users')
19
- async getUsers(@Request() req) {
20
- if (!req.user) {
21
- throw new UnauthorizedException();
22
- }
23
- if (!req.user.roles.includes('admin')) {
24
- throw new ForbiddenException();
25
- }
26
- return this.adminService.getUsers();
27
- }
28
-
29
- @Delete('users/:id')
30
- async deleteUser(@Request() req, @Param('id') id: string) {
31
- if (!req.user) {
32
- throw new UnauthorizedException();
33
- }
34
- if (!req.user.roles.includes('admin')) {
35
- throw new ForbiddenException();
36
- }
37
- return this.adminService.deleteUser(id);
38
- }
39
- }
40
- ```
41
-
42
- **Correct (guards with declarative decorators):**
43
-
44
- ```typescript
45
- // JWT Auth Guard
46
- @Injectable()
47
- export class JwtAuthGuard implements CanActivate {
48
- constructor(
49
- private jwtService: JwtService,
50
- private reflector: Reflector,
51
- ) {}
52
-
53
- async canActivate(context: ExecutionContext): Promise<boolean> {
54
- // Check for @Public() decorator
55
- const isPublic = this.reflector.getAllAndOverride<boolean>('isPublic', [
56
- context.getHandler(),
57
- context.getClass(),
58
- ]);
59
- if (isPublic) return true;
60
-
61
- const request = context.switchToHttp().getRequest();
62
- const token = this.extractToken(request);
63
-
64
- if (!token) {
65
- throw new UnauthorizedException('No token provided');
66
- }
67
-
68
- try {
69
- request.user = await this.jwtService.verifyAsync(token);
70
- return true;
71
- } catch {
72
- throw new UnauthorizedException('Invalid token');
73
- }
74
- }
75
-
76
- private extractToken(request: Request): string | undefined {
77
- const [type, token] = request.headers.authorization?.split(' ') ?? [];
78
- return type === 'Bearer' ? token : undefined;
79
- }
80
- }
81
-
82
- // Roles Guard
83
- @Injectable()
84
- export class RolesGuard implements CanActivate {
85
- constructor(private reflector: Reflector) {}
86
-
87
- canActivate(context: ExecutionContext): boolean {
88
- const requiredRoles = this.reflector.getAllAndOverride<Role[]>('roles', [
89
- context.getHandler(),
90
- context.getClass(),
91
- ]);
92
-
93
- if (!requiredRoles) return true;
94
-
95
- const { user } = context.switchToHttp().getRequest();
96
- return requiredRoles.some((role) => user.roles?.includes(role));
97
- }
98
- }
99
-
100
- // Decorators
101
- export const Public = () => SetMetadata('isPublic', true);
102
- export const Roles = (...roles: Role[]) => SetMetadata('roles', roles);
103
-
104
- // Register guards globally
105
- @Module({
106
- providers: [
107
- { provide: APP_GUARD, useClass: JwtAuthGuard },
108
- { provide: APP_GUARD, useClass: RolesGuard },
109
- ],
110
- })
111
- export class AppModule {}
112
-
113
- // Clean controller
114
- @Controller('admin')
115
- @Roles(Role.Admin) // Applied to all routes
116
- export class AdminController {
117
- @Get('users')
118
- getUsers(): Promise<User[]> {
119
- return this.adminService.getUsers();
120
- }
121
-
122
- @Delete('users/:id')
123
- deleteUser(@Param('id') id: string): Promise<void> {
124
- return this.adminService.deleteUser(id);
125
- }
126
-
127
- @Public() // Override: no auth required
128
- @Get('health')
129
- health() {
130
- return { status: 'ok' };
131
- }
132
- }
133
- ```
134
-
135
- Reference: [NestJS Guards](https://docs.nestjs.com/guards)
@@ -1,150 +0,0 @@
1
- ---
2
- title: Validate All Input with DTOs and Pipes
3
- impact: HIGH
4
- impactDescription: First line of defense against attacks
5
- tags: security, validation, dto, pipes
6
- ---
7
-
8
- ## Validate All Input with DTOs and Pipes
9
-
10
- Always validate incoming data using class-validator decorators on DTOs and the global ValidationPipe. Never trust user input. Validate all request bodies, query parameters, and route parameters before processing.
11
-
12
- **Incorrect (trust raw input without validation):**
13
-
14
- ```typescript
15
- // Trust raw input without validation
16
- @Controller('users')
17
- export class UsersController {
18
- @Post()
19
- create(@Body() body: any) {
20
- // body could contain anything - SQL injection, XSS, etc.
21
- return this.usersService.create(body);
22
- }
23
-
24
- @Get()
25
- findAll(@Query() query: any) {
26
- // query.limit could be "'; DROP TABLE users; --"
27
- return this.usersService.findAll(query.limit);
28
- }
29
- }
30
-
31
- // DTOs without validation decorators
32
- export class CreateUserDto {
33
- name: string; // No validation
34
- email: string; // Could be "not-an-email"
35
- age: number; // Could be "abc" or -999
36
- }
37
- ```
38
-
39
- **Correct (validated DTOs with global ValidationPipe):**
40
-
41
- ```typescript
42
- // Enable ValidationPipe globally in main.ts
43
- async function bootstrap() {
44
- const app = await NestFactory.create(AppModule);
45
-
46
- app.useGlobalPipes(
47
- new ValidationPipe({
48
- whitelist: true, // Strip unknown properties
49
- forbidNonWhitelisted: true, // Throw on unknown properties
50
- transform: true, // Auto-transform to DTO types
51
- transformOptions: {
52
- enableImplicitConversion: true,
53
- },
54
- }),
55
- );
56
-
57
- await app.listen(3000);
58
- }
59
-
60
- // Create well-validated DTOs
61
- import {
62
- IsString,
63
- IsEmail,
64
- IsInt,
65
- Min,
66
- Max,
67
- IsOptional,
68
- MinLength,
69
- MaxLength,
70
- Matches,
71
- IsNotEmpty,
72
- } from 'class-validator';
73
- import { Transform, Type } from 'class-transformer';
74
-
75
- export class CreateUserDto {
76
- @IsString()
77
- @IsNotEmpty()
78
- @MinLength(2)
79
- @MaxLength(100)
80
- @Transform(({ value }) => value?.trim())
81
- name: string;
82
-
83
- @IsEmail()
84
- @Transform(({ value }) => value?.toLowerCase().trim())
85
- email: string;
86
-
87
- @IsInt()
88
- @Min(0)
89
- @Max(150)
90
- age: number;
91
-
92
- @IsString()
93
- @MinLength(8)
94
- @MaxLength(100)
95
- @Matches(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)/, {
96
- message: 'Password must contain uppercase, lowercase, and number',
97
- })
98
- password: string;
99
- }
100
-
101
- // Query DTO with defaults and transformation
102
- export class FindUsersQueryDto {
103
- @IsOptional()
104
- @IsString()
105
- @MaxLength(100)
106
- search?: string;
107
-
108
- @IsOptional()
109
- @Type(() => Number)
110
- @IsInt()
111
- @Min(1)
112
- @Max(100)
113
- limit: number = 20;
114
-
115
- @IsOptional()
116
- @Type(() => Number)
117
- @IsInt()
118
- @Min(0)
119
- offset: number = 0;
120
- }
121
-
122
- // Param validation
123
- export class UserIdParamDto {
124
- @IsUUID('4')
125
- id: string;
126
- }
127
-
128
- @Controller('users')
129
- export class UsersController {
130
- @Post()
131
- create(@Body() dto: CreateUserDto): Promise<User> {
132
- // dto is guaranteed to be valid
133
- return this.usersService.create(dto);
134
- }
135
-
136
- @Get()
137
- findAll(@Query() query: FindUsersQueryDto): Promise<User[]> {
138
- // query.limit is a number, query.search is sanitized
139
- return this.usersService.findAll(query);
140
- }
141
-
142
- @Get(':id')
143
- findOne(@Param() params: UserIdParamDto): Promise<User> {
144
- // params.id is a valid UUID
145
- return this.usersService.findById(params.id);
146
- }
147
- }
148
- ```
149
-
150
- Reference: [NestJS Validation](https://docs.nestjs.com/techniques/validation)
@@ -1,178 +0,0 @@
1
- ---
2
- title: Use Supertest for E2E Testing
3
- impact: HIGH
4
- impactDescription: Validates the full request/response cycle
5
- tags: testing, e2e, supertest, integration
6
- ---
7
-
8
- ## Use Supertest for E2E Testing
9
-
10
- End-to-end tests use Supertest to make real HTTP requests against your NestJS application. They test the full stack including middleware, guards, pipes, and interceptors. E2E tests catch integration issues that unit tests miss.
11
-
12
- **Incorrect (no proper E2E setup or teardown):**
13
-
14
- ```typescript
15
- // Only unit test controllers
16
- describe('UsersController', () => {
17
- it('should return users', async () => {
18
- const service = { findAll: jest.fn().mockResolvedValue([]) };
19
- const controller = new UsersController(service as any);
20
-
21
- const result = await controller.findAll();
22
-
23
- expect(result).toEqual([]);
24
- // Doesn't test: routes, guards, pipes, serialization
25
- });
26
- });
27
-
28
- // E2E tests without proper setup/teardown
29
- describe('Users API', () => {
30
- it('should create user', async () => {
31
- const app = await NestFactory.create(AppModule);
32
- // No proper initialization
33
- // No cleanup after test
34
- // Hits real database
35
- });
36
- });
37
- ```
38
-
39
- **Correct (proper E2E setup with Supertest):**
40
-
41
- ```typescript
42
- // Proper E2E test setup
43
- import { Test, TestingModule } from '@nestjs/testing';
44
- import { INestApplication, ValidationPipe } from '@nestjs/common';
45
- import * as request from 'supertest';
46
- import { AppModule } from '../src/app.module';
47
-
48
- describe('UsersController (e2e)', () => {
49
- let app: INestApplication;
50
-
51
- beforeAll(async () => {
52
- const moduleFixture: TestingModule = await Test.createTestingModule({
53
- imports: [AppModule],
54
- }).compile();
55
-
56
- app = moduleFixture.createNestApplication();
57
-
58
- // Apply same config as production
59
- app.useGlobalPipes(
60
- new ValidationPipe({
61
- whitelist: true,
62
- transform: true,
63
- forbidNonWhitelisted: true,
64
- }),
65
- );
66
-
67
- await app.init();
68
- });
69
-
70
- afterAll(async () => {
71
- await app.close();
72
- });
73
-
74
- describe('/users (POST)', () => {
75
- it('should create a user', () => {
76
- return request(app.getHttpServer())
77
- .post('/users')
78
- .send({ name: 'John', email: 'john@test.com' })
79
- .expect(201)
80
- .expect((res) => {
81
- expect(res.body).toHaveProperty('id');
82
- expect(res.body.name).toBe('John');
83
- expect(res.body.email).toBe('john@test.com');
84
- });
85
- });
86
-
87
- it('should return 400 for invalid email', () => {
88
- return request(app.getHttpServer())
89
- .post('/users')
90
- .send({ name: 'John', email: 'invalid-email' })
91
- .expect(400)
92
- .expect((res) => {
93
- expect(res.body.message).toContain('email');
94
- });
95
- });
96
- });
97
-
98
- describe('/users/:id (GET)', () => {
99
- it('should return 404 for non-existent user', () => {
100
- return request(app.getHttpServer())
101
- .get('/users/non-existent-id')
102
- .expect(404);
103
- });
104
- });
105
- });
106
-
107
- // Testing with authentication
108
- describe('Protected Routes (e2e)', () => {
109
- let app: INestApplication;
110
- let authToken: string;
111
-
112
- beforeAll(async () => {
113
- const moduleFixture = await Test.createTestingModule({
114
- imports: [AppModule],
115
- }).compile();
116
-
117
- app = moduleFixture.createNestApplication();
118
- app.useGlobalPipes(new ValidationPipe({ whitelist: true }));
119
- await app.init();
120
-
121
- // Get auth token
122
- const loginResponse = await request(app.getHttpServer())
123
- .post('/auth/login')
124
- .send({ email: 'test@test.com', password: 'password' });
125
-
126
- authToken = loginResponse.body.accessToken;
127
- });
128
-
129
- it('should return 401 without token', () => {
130
- return request(app.getHttpServer())
131
- .get('/users/me')
132
- .expect(401);
133
- });
134
-
135
- it('should return user profile with valid token', () => {
136
- return request(app.getHttpServer())
137
- .get('/users/me')
138
- .set('Authorization', `Bearer ${authToken}`)
139
- .expect(200)
140
- .expect((res) => {
141
- expect(res.body.email).toBe('test@test.com');
142
- });
143
- });
144
- });
145
-
146
- // Database isolation for E2E tests
147
- describe('Orders API (e2e)', () => {
148
- let app: INestApplication;
149
- let dataSource: DataSource;
150
-
151
- beforeAll(async () => {
152
- const moduleFixture = await Test.createTestingModule({
153
- imports: [
154
- ConfigModule.forRoot({
155
- envFilePath: '.env.test', // Test database config
156
- }),
157
- AppModule,
158
- ],
159
- }).compile();
160
-
161
- app = moduleFixture.createNestApplication();
162
- dataSource = moduleFixture.get(DataSource);
163
- await app.init();
164
- });
165
-
166
- beforeEach(async () => {
167
- // Clean database between tests
168
- await dataSource.synchronize(true);
169
- });
170
-
171
- afterAll(async () => {
172
- await dataSource.destroy();
173
- await app.close();
174
- });
175
- });
176
- ```
177
-
178
- Reference: [NestJS E2E Testing](https://docs.nestjs.com/fundamentals/testing#end-to-end-testing)
@@ -1,179 +0,0 @@
1
- ---
2
- title: Mock External Services in Tests
3
- impact: HIGH
4
- impactDescription: Ensures fast, reliable, deterministic tests
5
- tags: testing, mocking, external-services, jest
6
- ---
7
-
8
- ## Mock External Services in Tests
9
-
10
- Never call real external services (APIs, databases, message queues) in unit tests. Mock them to ensure tests are fast, deterministic, and don't incur costs. Use realistic mock data and test edge cases like timeouts and errors.
11
-
12
- **Incorrect (calling real APIs and databases):**
13
-
14
- ```typescript
15
- // Call real APIs in tests
16
- describe('PaymentService', () => {
17
- it('should process payment', async () => {
18
- const service = new PaymentService(new StripeClient(realApiKey));
19
- // Hits real Stripe API!
20
- const result = await service.charge('tok_visa', 1000);
21
- // Slow, costs money, flaky
22
- });
23
- });
24
-
25
- // Use real database
26
- describe('UsersService', () => {
27
- beforeEach(async () => {
28
- await connection.query('DELETE FROM users'); // Modifies real DB
29
- });
30
-
31
- it('should create user', async () => {
32
- const user = await service.create({ email: 'test@test.com' });
33
- // Side effects on shared database
34
- });
35
- });
36
-
37
- // Incomplete mocks
38
- const mockHttpService = {
39
- get: jest.fn().mockResolvedValue({ data: {} }),
40
- // Missing error scenarios, missing other methods
41
- };
42
- ```
43
-
44
- **Correct (mock all external dependencies):**
45
-
46
- ```typescript
47
- // Mock HTTP service properly
48
- describe('WeatherService', () => {
49
- let service: WeatherService;
50
- let httpService: jest.Mocked<HttpService>;
51
-
52
- beforeEach(async () => {
53
- const module = await Test.createTestingModule({
54
- providers: [
55
- WeatherService,
56
- {
57
- provide: HttpService,
58
- useValue: {
59
- get: jest.fn(),
60
- post: jest.fn(),
61
- },
62
- },
63
- ],
64
- }).compile();
65
-
66
- service = module.get(WeatherService);
67
- httpService = module.get(HttpService);
68
- });
69
-
70
- it('should return weather data', async () => {
71
- const mockResponse = {
72
- data: { temperature: 72, humidity: 45 },
73
- status: 200,
74
- statusText: 'OK',
75
- headers: {},
76
- config: {},
77
- };
78
-
79
- httpService.get.mockReturnValue(of(mockResponse));
80
-
81
- const result = await service.getWeather('NYC');
82
-
83
- expect(result).toEqual({ temperature: 72, humidity: 45 });
84
- });
85
-
86
- it('should handle API timeout', async () => {
87
- httpService.get.mockReturnValue(
88
- throwError(() => new Error('ETIMEDOUT')),
89
- );
90
-
91
- await expect(service.getWeather('NYC')).rejects.toThrow('Weather service unavailable');
92
- });
93
-
94
- it('should handle rate limiting', async () => {
95
- httpService.get.mockReturnValue(
96
- throwError(() => ({
97
- response: { status: 429, data: { message: 'Rate limited' } },
98
- })),
99
- );
100
-
101
- await expect(service.getWeather('NYC')).rejects.toThrow(TooManyRequestsException);
102
- });
103
- });
104
-
105
- // Mock repository instead of database
106
- describe('UsersService', () => {
107
- let service: UsersService;
108
- let repo: jest.Mocked<Repository<User>>;
109
-
110
- beforeEach(async () => {
111
- const mockRepo = {
112
- find: jest.fn(),
113
- findOne: jest.fn(),
114
- save: jest.fn(),
115
- delete: jest.fn(),
116
- createQueryBuilder: jest.fn(),
117
- };
118
-
119
- const module = await Test.createTestingModule({
120
- providers: [
121
- UsersService,
122
- { provide: getRepositoryToken(User), useValue: mockRepo },
123
- ],
124
- }).compile();
125
-
126
- service = module.get(UsersService);
127
- repo = module.get(getRepositoryToken(User));
128
- });
129
-
130
- it('should find user by id', async () => {
131
- const mockUser = { id: '1', name: 'John', email: 'john@test.com' };
132
- repo.findOne.mockResolvedValue(mockUser);
133
-
134
- const result = await service.findById('1');
135
-
136
- expect(result).toEqual(mockUser);
137
- expect(repo.findOne).toHaveBeenCalledWith({ where: { id: '1' } });
138
- });
139
- });
140
-
141
- // Create mock factory for complex SDKs
142
- function createMockStripe(): jest.Mocked<Stripe> {
143
- return {
144
- paymentIntents: {
145
- create: jest.fn(),
146
- retrieve: jest.fn(),
147
- confirm: jest.fn(),
148
- cancel: jest.fn(),
149
- },
150
- customers: {
151
- create: jest.fn(),
152
- retrieve: jest.fn(),
153
- },
154
- } as any;
155
- }
156
-
157
- // Mock time for time-dependent tests
158
- describe('TokenService', () => {
159
- beforeEach(() => {
160
- jest.useFakeTimers();
161
- jest.setSystemTime(new Date('2024-01-15'));
162
- });
163
-
164
- afterEach(() => {
165
- jest.useRealTimers();
166
- });
167
-
168
- it('should expire token after 1 hour', async () => {
169
- const token = await service.createToken();
170
-
171
- // Fast-forward time
172
- jest.advanceTimersByTime(61 * 60 * 1000);
173
-
174
- expect(await service.isValid(token)).toBe(false);
175
- });
176
- });
177
- ```
178
-
179
- Reference: [Jest Mocking](https://jestjs.io/docs/mock-functions)