@wazir-dev/cli 1.0.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 (629) hide show
  1. package/AGENTS.md +111 -0
  2. package/CHANGELOG.md +14 -0
  3. package/CONTRIBUTING.md +101 -0
  4. package/LICENSE +21 -0
  5. package/README.md +314 -0
  6. package/assets/composition-engine.mmd +34 -0
  7. package/assets/demo-script.sh +17 -0
  8. package/assets/logo-dark.svg +14 -0
  9. package/assets/logo.svg +14 -0
  10. package/assets/pipeline.mmd +39 -0
  11. package/assets/record-demo.sh +51 -0
  12. package/docs/README.md +51 -0
  13. package/docs/adapters/context-mode.md +60 -0
  14. package/docs/concepts/architecture.md +87 -0
  15. package/docs/concepts/artifact-model.md +60 -0
  16. package/docs/concepts/composition-engine.md +36 -0
  17. package/docs/concepts/indexing-and-recall.md +160 -0
  18. package/docs/concepts/observability.md +41 -0
  19. package/docs/concepts/roles-and-workflows.md +59 -0
  20. package/docs/concepts/terminology-policy.md +27 -0
  21. package/docs/getting-started/01-installation.md +78 -0
  22. package/docs/getting-started/02-first-run.md +102 -0
  23. package/docs/getting-started/03-adding-to-project.md +15 -0
  24. package/docs/getting-started/04-host-setup.md +15 -0
  25. package/docs/guides/ci-integration.md +15 -0
  26. package/docs/guides/creating-skills.md +15 -0
  27. package/docs/guides/expertise-module-authoring.md +15 -0
  28. package/docs/guides/hook-development.md +15 -0
  29. package/docs/guides/memory-and-learnings.md +34 -0
  30. package/docs/guides/multi-host-export.md +15 -0
  31. package/docs/guides/troubleshooting.md +101 -0
  32. package/docs/guides/writing-custom-roles.md +15 -0
  33. package/docs/plans/2026-03-15-cli-pipeline-integration-design.md +592 -0
  34. package/docs/plans/2026-03-15-cli-pipeline-integration-plan.md +598 -0
  35. package/docs/plans/2026-03-15-docs-enforcement-plan.md +238 -0
  36. package/docs/readmes/INDEX.md +99 -0
  37. package/docs/readmes/features/expertise/README.md +171 -0
  38. package/docs/readmes/features/exports/README.md +222 -0
  39. package/docs/readmes/features/hooks/README.md +103 -0
  40. package/docs/readmes/features/hooks/loop-cap-guard.md +133 -0
  41. package/docs/readmes/features/hooks/post-tool-capture.md +121 -0
  42. package/docs/readmes/features/hooks/post-tool-lint.md +130 -0
  43. package/docs/readmes/features/hooks/pre-compact-summary.md +122 -0
  44. package/docs/readmes/features/hooks/pre-tool-capture-route.md +100 -0
  45. package/docs/readmes/features/hooks/protected-path-write-guard.md +128 -0
  46. package/docs/readmes/features/hooks/session-start.md +119 -0
  47. package/docs/readmes/features/hooks/stop-handoff-harvest.md +125 -0
  48. package/docs/readmes/features/roles/README.md +157 -0
  49. package/docs/readmes/features/roles/clarifier.md +152 -0
  50. package/docs/readmes/features/roles/content-author.md +190 -0
  51. package/docs/readmes/features/roles/designer.md +193 -0
  52. package/docs/readmes/features/roles/executor.md +184 -0
  53. package/docs/readmes/features/roles/learner.md +210 -0
  54. package/docs/readmes/features/roles/planner.md +182 -0
  55. package/docs/readmes/features/roles/researcher.md +164 -0
  56. package/docs/readmes/features/roles/reviewer.md +184 -0
  57. package/docs/readmes/features/roles/specifier.md +162 -0
  58. package/docs/readmes/features/roles/verifier.md +215 -0
  59. package/docs/readmes/features/schemas/README.md +178 -0
  60. package/docs/readmes/features/skills/README.md +63 -0
  61. package/docs/readmes/features/skills/brainstorming.md +96 -0
  62. package/docs/readmes/features/skills/debugging.md +148 -0
  63. package/docs/readmes/features/skills/design.md +120 -0
  64. package/docs/readmes/features/skills/prepare-next.md +109 -0
  65. package/docs/readmes/features/skills/run-audit.md +159 -0
  66. package/docs/readmes/features/skills/scan-project.md +109 -0
  67. package/docs/readmes/features/skills/self-audit.md +176 -0
  68. package/docs/readmes/features/skills/tdd.md +137 -0
  69. package/docs/readmes/features/skills/using-skills.md +92 -0
  70. package/docs/readmes/features/skills/verification.md +120 -0
  71. package/docs/readmes/features/skills/writing-plans.md +104 -0
  72. package/docs/readmes/features/tooling/README.md +320 -0
  73. package/docs/readmes/features/workflows/README.md +186 -0
  74. package/docs/readmes/features/workflows/author.md +181 -0
  75. package/docs/readmes/features/workflows/clarify.md +154 -0
  76. package/docs/readmes/features/workflows/design-review.md +171 -0
  77. package/docs/readmes/features/workflows/design.md +169 -0
  78. package/docs/readmes/features/workflows/discover.md +162 -0
  79. package/docs/readmes/features/workflows/execute.md +173 -0
  80. package/docs/readmes/features/workflows/learn.md +167 -0
  81. package/docs/readmes/features/workflows/plan-review.md +165 -0
  82. package/docs/readmes/features/workflows/plan.md +170 -0
  83. package/docs/readmes/features/workflows/prepare-next.md +167 -0
  84. package/docs/readmes/features/workflows/review.md +169 -0
  85. package/docs/readmes/features/workflows/run-audit.md +191 -0
  86. package/docs/readmes/features/workflows/spec-challenge.md +159 -0
  87. package/docs/readmes/features/workflows/specify.md +160 -0
  88. package/docs/readmes/features/workflows/verify.md +177 -0
  89. package/docs/readmes/packages/README.md +50 -0
  90. package/docs/readmes/packages/ajv.md +117 -0
  91. package/docs/readmes/packages/context-mode.md +118 -0
  92. package/docs/readmes/packages/gray-matter.md +116 -0
  93. package/docs/readmes/packages/node-test.md +137 -0
  94. package/docs/readmes/packages/yaml.md +112 -0
  95. package/docs/reference/configuration-reference.md +159 -0
  96. package/docs/reference/expertise-index.md +52 -0
  97. package/docs/reference/git-flow.md +43 -0
  98. package/docs/reference/hooks.md +87 -0
  99. package/docs/reference/host-exports.md +50 -0
  100. package/docs/reference/launch-checklist.md +172 -0
  101. package/docs/reference/marketplace-listings.md +76 -0
  102. package/docs/reference/release-process.md +34 -0
  103. package/docs/reference/roles-reference.md +77 -0
  104. package/docs/reference/skills.md +33 -0
  105. package/docs/reference/templates.md +29 -0
  106. package/docs/reference/tooling-cli.md +94 -0
  107. package/docs/truth-claims.yaml +222 -0
  108. package/expertise/PROGRESS.md +63 -0
  109. package/expertise/README.md +18 -0
  110. package/expertise/antipatterns/PROGRESS.md +56 -0
  111. package/expertise/antipatterns/backend/api-design-antipatterns.md +1271 -0
  112. package/expertise/antipatterns/backend/auth-antipatterns.md +1195 -0
  113. package/expertise/antipatterns/backend/caching-antipatterns.md +622 -0
  114. package/expertise/antipatterns/backend/database-antipatterns.md +1038 -0
  115. package/expertise/antipatterns/backend/index.md +24 -0
  116. package/expertise/antipatterns/backend/microservices-antipatterns.md +850 -0
  117. package/expertise/antipatterns/code/architecture-antipatterns.md +919 -0
  118. package/expertise/antipatterns/code/async-antipatterns.md +622 -0
  119. package/expertise/antipatterns/code/code-smells.md +1186 -0
  120. package/expertise/antipatterns/code/dependency-antipatterns.md +1209 -0
  121. package/expertise/antipatterns/code/error-handling-antipatterns.md +1360 -0
  122. package/expertise/antipatterns/code/index.md +27 -0
  123. package/expertise/antipatterns/code/naming-and-abstraction.md +1118 -0
  124. package/expertise/antipatterns/code/state-management-antipatterns.md +1076 -0
  125. package/expertise/antipatterns/code/testing-antipatterns.md +1053 -0
  126. package/expertise/antipatterns/design/accessibility-antipatterns.md +1136 -0
  127. package/expertise/antipatterns/design/dark-patterns.md +1121 -0
  128. package/expertise/antipatterns/design/index.md +22 -0
  129. package/expertise/antipatterns/design/ui-antipatterns.md +1202 -0
  130. package/expertise/antipatterns/design/ux-antipatterns.md +680 -0
  131. package/expertise/antipatterns/frontend/css-layout-antipatterns.md +691 -0
  132. package/expertise/antipatterns/frontend/flutter-antipatterns.md +1827 -0
  133. package/expertise/antipatterns/frontend/index.md +23 -0
  134. package/expertise/antipatterns/frontend/mobile-antipatterns.md +573 -0
  135. package/expertise/antipatterns/frontend/react-antipatterns.md +1128 -0
  136. package/expertise/antipatterns/frontend/spa-antipatterns.md +1235 -0
  137. package/expertise/antipatterns/index.md +31 -0
  138. package/expertise/antipatterns/performance/index.md +20 -0
  139. package/expertise/antipatterns/performance/performance-antipatterns.md +1013 -0
  140. package/expertise/antipatterns/performance/premature-optimization.md +623 -0
  141. package/expertise/antipatterns/performance/scaling-antipatterns.md +785 -0
  142. package/expertise/antipatterns/process/ai-coding-antipatterns.md +853 -0
  143. package/expertise/antipatterns/process/code-review-antipatterns.md +656 -0
  144. package/expertise/antipatterns/process/deployment-antipatterns.md +920 -0
  145. package/expertise/antipatterns/process/index.md +23 -0
  146. package/expertise/antipatterns/process/technical-debt-antipatterns.md +647 -0
  147. package/expertise/antipatterns/security/index.md +20 -0
  148. package/expertise/antipatterns/security/secrets-antipatterns.md +849 -0
  149. package/expertise/antipatterns/security/security-theater.md +843 -0
  150. package/expertise/antipatterns/security/vulnerability-patterns.md +801 -0
  151. package/expertise/architecture/PROGRESS.md +70 -0
  152. package/expertise/architecture/data/caching-architecture.md +671 -0
  153. package/expertise/architecture/data/data-consistency.md +574 -0
  154. package/expertise/architecture/data/data-modeling.md +536 -0
  155. package/expertise/architecture/data/event-streams-and-queues.md +634 -0
  156. package/expertise/architecture/data/index.md +25 -0
  157. package/expertise/architecture/data/search-architecture.md +663 -0
  158. package/expertise/architecture/data/sql-vs-nosql.md +708 -0
  159. package/expertise/architecture/decisions/architecture-decision-records.md +640 -0
  160. package/expertise/architecture/decisions/build-vs-buy.md +616 -0
  161. package/expertise/architecture/decisions/index.md +23 -0
  162. package/expertise/architecture/decisions/monolith-to-microservices.md +790 -0
  163. package/expertise/architecture/decisions/technology-selection.md +616 -0
  164. package/expertise/architecture/distributed/cap-theorem-and-tradeoffs.md +800 -0
  165. package/expertise/architecture/distributed/circuit-breaker-bulkhead.md +741 -0
  166. package/expertise/architecture/distributed/consensus-and-coordination.md +796 -0
  167. package/expertise/architecture/distributed/distributed-systems-fundamentals.md +564 -0
  168. package/expertise/architecture/distributed/idempotency-and-retry.md +796 -0
  169. package/expertise/architecture/distributed/index.md +25 -0
  170. package/expertise/architecture/distributed/saga-pattern.md +797 -0
  171. package/expertise/architecture/foundations/architectural-thinking.md +460 -0
  172. package/expertise/architecture/foundations/coupling-and-cohesion.md +770 -0
  173. package/expertise/architecture/foundations/design-principles-solid.md +649 -0
  174. package/expertise/architecture/foundations/domain-driven-design.md +719 -0
  175. package/expertise/architecture/foundations/index.md +25 -0
  176. package/expertise/architecture/foundations/separation-of-concerns.md +472 -0
  177. package/expertise/architecture/foundations/twelve-factor-app.md +797 -0
  178. package/expertise/architecture/index.md +34 -0
  179. package/expertise/architecture/integration/api-design-graphql.md +638 -0
  180. package/expertise/architecture/integration/api-design-grpc.md +804 -0
  181. package/expertise/architecture/integration/api-design-rest.md +892 -0
  182. package/expertise/architecture/integration/index.md +25 -0
  183. package/expertise/architecture/integration/third-party-integration.md +795 -0
  184. package/expertise/architecture/integration/webhooks-and-callbacks.md +1152 -0
  185. package/expertise/architecture/integration/websockets-realtime.md +791 -0
  186. package/expertise/architecture/mobile-architecture/index.md +22 -0
  187. package/expertise/architecture/mobile-architecture/mobile-app-architecture.md +780 -0
  188. package/expertise/architecture/mobile-architecture/mobile-backend-for-frontend.md +670 -0
  189. package/expertise/architecture/mobile-architecture/offline-first.md +719 -0
  190. package/expertise/architecture/mobile-architecture/push-and-sync.md +782 -0
  191. package/expertise/architecture/patterns/cqrs-event-sourcing.md +717 -0
  192. package/expertise/architecture/patterns/event-driven.md +797 -0
  193. package/expertise/architecture/patterns/hexagonal-clean-architecture.md +870 -0
  194. package/expertise/architecture/patterns/index.md +27 -0
  195. package/expertise/architecture/patterns/layered-architecture.md +736 -0
  196. package/expertise/architecture/patterns/microservices.md +753 -0
  197. package/expertise/architecture/patterns/modular-monolith.md +692 -0
  198. package/expertise/architecture/patterns/monolith.md +626 -0
  199. package/expertise/architecture/patterns/plugin-architecture.md +735 -0
  200. package/expertise/architecture/patterns/serverless.md +780 -0
  201. package/expertise/architecture/scaling/database-scaling.md +615 -0
  202. package/expertise/architecture/scaling/feature-flags-and-rollouts.md +757 -0
  203. package/expertise/architecture/scaling/horizontal-vs-vertical.md +606 -0
  204. package/expertise/architecture/scaling/index.md +24 -0
  205. package/expertise/architecture/scaling/multi-tenancy.md +800 -0
  206. package/expertise/architecture/scaling/stateless-design.md +787 -0
  207. package/expertise/backend/embedded-firmware.md +625 -0
  208. package/expertise/backend/go.md +853 -0
  209. package/expertise/backend/index.md +24 -0
  210. package/expertise/backend/java-spring.md +448 -0
  211. package/expertise/backend/node-typescript.md +625 -0
  212. package/expertise/backend/python-fastapi.md +724 -0
  213. package/expertise/backend/rust.md +458 -0
  214. package/expertise/backend/solidity.md +711 -0
  215. package/expertise/composition-map.yaml +443 -0
  216. package/expertise/content/foundations/content-modeling.md +395 -0
  217. package/expertise/content/foundations/editorial-standards.md +449 -0
  218. package/expertise/content/foundations/index.md +24 -0
  219. package/expertise/content/foundations/microcopy.md +455 -0
  220. package/expertise/content/foundations/terminology-governance.md +509 -0
  221. package/expertise/content/index.md +34 -0
  222. package/expertise/content/patterns/accessibility-copy.md +518 -0
  223. package/expertise/content/patterns/index.md +24 -0
  224. package/expertise/content/patterns/notification-content.md +433 -0
  225. package/expertise/content/patterns/sample-content.md +486 -0
  226. package/expertise/content/patterns/state-copy.md +439 -0
  227. package/expertise/design/PROGRESS.md +58 -0
  228. package/expertise/design/disciplines/dark-mode-theming.md +577 -0
  229. package/expertise/design/disciplines/design-systems.md +595 -0
  230. package/expertise/design/disciplines/index.md +25 -0
  231. package/expertise/design/disciplines/information-architecture.md +800 -0
  232. package/expertise/design/disciplines/interaction-design.md +788 -0
  233. package/expertise/design/disciplines/responsive-design.md +552 -0
  234. package/expertise/design/disciplines/usability-testing.md +516 -0
  235. package/expertise/design/disciplines/user-research.md +792 -0
  236. package/expertise/design/foundations/accessibility-design.md +796 -0
  237. package/expertise/design/foundations/color-theory.md +797 -0
  238. package/expertise/design/foundations/iconography.md +795 -0
  239. package/expertise/design/foundations/index.md +26 -0
  240. package/expertise/design/foundations/motion-and-animation.md +653 -0
  241. package/expertise/design/foundations/rtl-design.md +585 -0
  242. package/expertise/design/foundations/spacing-and-layout.md +607 -0
  243. package/expertise/design/foundations/typography.md +800 -0
  244. package/expertise/design/foundations/visual-hierarchy.md +761 -0
  245. package/expertise/design/index.md +32 -0
  246. package/expertise/design/patterns/authentication-flows.md +474 -0
  247. package/expertise/design/patterns/content-consumption.md +789 -0
  248. package/expertise/design/patterns/data-display.md +618 -0
  249. package/expertise/design/patterns/e-commerce.md +1494 -0
  250. package/expertise/design/patterns/feedback-and-states.md +642 -0
  251. package/expertise/design/patterns/forms-and-input.md +819 -0
  252. package/expertise/design/patterns/gamification.md +801 -0
  253. package/expertise/design/patterns/index.md +31 -0
  254. package/expertise/design/patterns/microinteractions.md +449 -0
  255. package/expertise/design/patterns/navigation.md +800 -0
  256. package/expertise/design/patterns/notifications.md +705 -0
  257. package/expertise/design/patterns/onboarding.md +700 -0
  258. package/expertise/design/patterns/search-and-filter.md +601 -0
  259. package/expertise/design/patterns/settings-and-preferences.md +768 -0
  260. package/expertise/design/patterns/social-and-community.md +748 -0
  261. package/expertise/design/platforms/desktop-native.md +612 -0
  262. package/expertise/design/platforms/index.md +25 -0
  263. package/expertise/design/platforms/mobile-android.md +825 -0
  264. package/expertise/design/platforms/mobile-cross-platform.md +983 -0
  265. package/expertise/design/platforms/mobile-ios.md +699 -0
  266. package/expertise/design/platforms/tablet.md +794 -0
  267. package/expertise/design/platforms/web-dashboard.md +790 -0
  268. package/expertise/design/platforms/web-responsive.md +550 -0
  269. package/expertise/design/psychology/behavioral-nudges.md +449 -0
  270. package/expertise/design/psychology/cognitive-load.md +1191 -0
  271. package/expertise/design/psychology/error-psychology.md +778 -0
  272. package/expertise/design/psychology/index.md +22 -0
  273. package/expertise/design/psychology/persuasive-design.md +736 -0
  274. package/expertise/design/psychology/user-mental-models.md +623 -0
  275. package/expertise/design/tooling/open-pencil.md +266 -0
  276. package/expertise/frontend/angular.md +1073 -0
  277. package/expertise/frontend/desktop-electron.md +546 -0
  278. package/expertise/frontend/flutter.md +782 -0
  279. package/expertise/frontend/index.md +27 -0
  280. package/expertise/frontend/native-android.md +409 -0
  281. package/expertise/frontend/native-ios.md +490 -0
  282. package/expertise/frontend/react-native.md +1160 -0
  283. package/expertise/frontend/react.md +808 -0
  284. package/expertise/frontend/vue.md +1089 -0
  285. package/expertise/humanize/domain-rules-code.md +79 -0
  286. package/expertise/humanize/domain-rules-content.md +67 -0
  287. package/expertise/humanize/domain-rules-technical-docs.md +56 -0
  288. package/expertise/humanize/index.md +35 -0
  289. package/expertise/humanize/self-audit-checklist.md +87 -0
  290. package/expertise/humanize/sentence-patterns.md +218 -0
  291. package/expertise/humanize/vocabulary-blacklist.md +105 -0
  292. package/expertise/i18n/PROGRESS.md +65 -0
  293. package/expertise/i18n/advanced/accessibility-and-i18n.md +28 -0
  294. package/expertise/i18n/advanced/bidirectional-text-algorithm.md +38 -0
  295. package/expertise/i18n/advanced/complex-scripts.md +30 -0
  296. package/expertise/i18n/advanced/performance-and-i18n.md +27 -0
  297. package/expertise/i18n/advanced/testing-i18n.md +28 -0
  298. package/expertise/i18n/content/content-adaptation.md +23 -0
  299. package/expertise/i18n/content/locale-specific-formatting.md +23 -0
  300. package/expertise/i18n/content/machine-translation-integration.md +28 -0
  301. package/expertise/i18n/content/translation-management.md +29 -0
  302. package/expertise/i18n/foundations/date-time-calendars.md +67 -0
  303. package/expertise/i18n/foundations/i18n-architecture.md +272 -0
  304. package/expertise/i18n/foundations/locale-and-language-tags.md +79 -0
  305. package/expertise/i18n/foundations/numbers-currency-units.md +61 -0
  306. package/expertise/i18n/foundations/pluralization-and-gender.md +109 -0
  307. package/expertise/i18n/foundations/string-externalization.md +236 -0
  308. package/expertise/i18n/foundations/text-direction-bidi.md +241 -0
  309. package/expertise/i18n/foundations/unicode-and-encoding.md +86 -0
  310. package/expertise/i18n/index.md +38 -0
  311. package/expertise/i18n/platform/backend-i18n.md +31 -0
  312. package/expertise/i18n/platform/flutter-i18n.md +148 -0
  313. package/expertise/i18n/platform/native-android-i18n.md +36 -0
  314. package/expertise/i18n/platform/native-ios-i18n.md +36 -0
  315. package/expertise/i18n/platform/react-i18n.md +103 -0
  316. package/expertise/i18n/platform/web-css-i18n.md +81 -0
  317. package/expertise/i18n/rtl/arabic-specific.md +175 -0
  318. package/expertise/i18n/rtl/hebrew-specific.md +149 -0
  319. package/expertise/i18n/rtl/rtl-animations-and-transitions.md +111 -0
  320. package/expertise/i18n/rtl/rtl-forms-and-input.md +161 -0
  321. package/expertise/i18n/rtl/rtl-fundamentals.md +211 -0
  322. package/expertise/i18n/rtl/rtl-icons-and-images.md +181 -0
  323. package/expertise/i18n/rtl/rtl-layout-mirroring.md +252 -0
  324. package/expertise/i18n/rtl/rtl-navigation-and-gestures.md +107 -0
  325. package/expertise/i18n/rtl/rtl-testing-and-qa.md +147 -0
  326. package/expertise/i18n/rtl/rtl-typography.md +160 -0
  327. package/expertise/index.md +113 -0
  328. package/expertise/index.yaml +216 -0
  329. package/expertise/infrastructure/cloud-aws.md +597 -0
  330. package/expertise/infrastructure/cloud-gcp.md +599 -0
  331. package/expertise/infrastructure/cybersecurity.md +816 -0
  332. package/expertise/infrastructure/database-mongodb.md +447 -0
  333. package/expertise/infrastructure/database-postgres.md +400 -0
  334. package/expertise/infrastructure/devops-cicd.md +787 -0
  335. package/expertise/infrastructure/index.md +27 -0
  336. package/expertise/performance/PROGRESS.md +50 -0
  337. package/expertise/performance/backend/api-latency.md +1204 -0
  338. package/expertise/performance/backend/background-jobs.md +506 -0
  339. package/expertise/performance/backend/connection-pooling.md +1209 -0
  340. package/expertise/performance/backend/database-query-optimization.md +515 -0
  341. package/expertise/performance/backend/index.md +23 -0
  342. package/expertise/performance/backend/rate-limiting-and-throttling.md +971 -0
  343. package/expertise/performance/foundations/algorithmic-complexity.md +954 -0
  344. package/expertise/performance/foundations/caching-strategies.md +489 -0
  345. package/expertise/performance/foundations/concurrency-and-parallelism.md +847 -0
  346. package/expertise/performance/foundations/index.md +24 -0
  347. package/expertise/performance/foundations/measuring-and-profiling.md +440 -0
  348. package/expertise/performance/foundations/memory-management.md +964 -0
  349. package/expertise/performance/foundations/performance-budgets.md +1314 -0
  350. package/expertise/performance/index.md +31 -0
  351. package/expertise/performance/infrastructure/auto-scaling.md +1059 -0
  352. package/expertise/performance/infrastructure/cdn-and-edge.md +1081 -0
  353. package/expertise/performance/infrastructure/index.md +22 -0
  354. package/expertise/performance/infrastructure/load-balancing.md +1081 -0
  355. package/expertise/performance/infrastructure/observability.md +1079 -0
  356. package/expertise/performance/mobile/index.md +23 -0
  357. package/expertise/performance/mobile/mobile-animations.md +544 -0
  358. package/expertise/performance/mobile/mobile-memory-battery.md +416 -0
  359. package/expertise/performance/mobile/mobile-network.md +452 -0
  360. package/expertise/performance/mobile/mobile-rendering.md +599 -0
  361. package/expertise/performance/mobile/mobile-startup-time.md +505 -0
  362. package/expertise/performance/platform-specific/flutter-performance.md +647 -0
  363. package/expertise/performance/platform-specific/index.md +22 -0
  364. package/expertise/performance/platform-specific/node-performance.md +1307 -0
  365. package/expertise/performance/platform-specific/postgres-performance.md +1366 -0
  366. package/expertise/performance/platform-specific/react-performance.md +1403 -0
  367. package/expertise/performance/web/bundle-optimization.md +1239 -0
  368. package/expertise/performance/web/image-and-media.md +636 -0
  369. package/expertise/performance/web/index.md +24 -0
  370. package/expertise/performance/web/network-optimization.md +1133 -0
  371. package/expertise/performance/web/rendering-performance.md +1098 -0
  372. package/expertise/performance/web/ssr-and-hydration.md +918 -0
  373. package/expertise/performance/web/web-vitals.md +1374 -0
  374. package/expertise/quality/accessibility.md +985 -0
  375. package/expertise/quality/evidence-based-verification.md +499 -0
  376. package/expertise/quality/index.md +24 -0
  377. package/expertise/quality/ml-model-audit.md +614 -0
  378. package/expertise/quality/performance.md +600 -0
  379. package/expertise/quality/testing-api.md +891 -0
  380. package/expertise/quality/testing-mobile.md +496 -0
  381. package/expertise/quality/testing-web.md +849 -0
  382. package/expertise/security/PROGRESS.md +54 -0
  383. package/expertise/security/agentic-identity.md +540 -0
  384. package/expertise/security/compliance-frameworks.md +601 -0
  385. package/expertise/security/data/data-encryption.md +364 -0
  386. package/expertise/security/data/data-privacy-gdpr.md +692 -0
  387. package/expertise/security/data/database-security.md +1171 -0
  388. package/expertise/security/data/index.md +22 -0
  389. package/expertise/security/data/pii-handling.md +531 -0
  390. package/expertise/security/foundations/authentication.md +1041 -0
  391. package/expertise/security/foundations/authorization.md +603 -0
  392. package/expertise/security/foundations/cryptography.md +1001 -0
  393. package/expertise/security/foundations/index.md +25 -0
  394. package/expertise/security/foundations/owasp-top-10.md +1354 -0
  395. package/expertise/security/foundations/secrets-management.md +1217 -0
  396. package/expertise/security/foundations/secure-sdlc.md +700 -0
  397. package/expertise/security/foundations/supply-chain-security.md +698 -0
  398. package/expertise/security/index.md +31 -0
  399. package/expertise/security/infrastructure/cloud-security-aws.md +1296 -0
  400. package/expertise/security/infrastructure/cloud-security-gcp.md +1376 -0
  401. package/expertise/security/infrastructure/container-security.md +721 -0
  402. package/expertise/security/infrastructure/incident-response.md +1295 -0
  403. package/expertise/security/infrastructure/index.md +24 -0
  404. package/expertise/security/infrastructure/logging-and-monitoring.md +1618 -0
  405. package/expertise/security/infrastructure/network-security.md +1337 -0
  406. package/expertise/security/mobile/index.md +23 -0
  407. package/expertise/security/mobile/mobile-android-security.md +1218 -0
  408. package/expertise/security/mobile/mobile-binary-protection.md +1229 -0
  409. package/expertise/security/mobile/mobile-data-storage.md +1265 -0
  410. package/expertise/security/mobile/mobile-ios-security.md +1401 -0
  411. package/expertise/security/mobile/mobile-network-security.md +1520 -0
  412. package/expertise/security/smart-contract-security.md +594 -0
  413. package/expertise/security/testing/index.md +22 -0
  414. package/expertise/security/testing/penetration-testing.md +1258 -0
  415. package/expertise/security/testing/security-code-review.md +1765 -0
  416. package/expertise/security/testing/threat-modeling.md +1074 -0
  417. package/expertise/security/testing/vulnerability-scanning.md +1062 -0
  418. package/expertise/security/web/api-security.md +586 -0
  419. package/expertise/security/web/cors-and-headers.md +433 -0
  420. package/expertise/security/web/csrf.md +562 -0
  421. package/expertise/security/web/file-upload.md +1477 -0
  422. package/expertise/security/web/index.md +25 -0
  423. package/expertise/security/web/injection.md +1375 -0
  424. package/expertise/security/web/session-management.md +1101 -0
  425. package/expertise/security/web/xss.md +1158 -0
  426. package/exports/README.md +17 -0
  427. package/exports/hosts/claude/.claude/agents/clarifier.md +42 -0
  428. package/exports/hosts/claude/.claude/agents/content-author.md +63 -0
  429. package/exports/hosts/claude/.claude/agents/designer.md +55 -0
  430. package/exports/hosts/claude/.claude/agents/executor.md +55 -0
  431. package/exports/hosts/claude/.claude/agents/learner.md +51 -0
  432. package/exports/hosts/claude/.claude/agents/planner.md +53 -0
  433. package/exports/hosts/claude/.claude/agents/researcher.md +43 -0
  434. package/exports/hosts/claude/.claude/agents/reviewer.md +54 -0
  435. package/exports/hosts/claude/.claude/agents/specifier.md +47 -0
  436. package/exports/hosts/claude/.claude/agents/verifier.md +71 -0
  437. package/exports/hosts/claude/.claude/commands/author.md +42 -0
  438. package/exports/hosts/claude/.claude/commands/clarify.md +38 -0
  439. package/exports/hosts/claude/.claude/commands/design-review.md +46 -0
  440. package/exports/hosts/claude/.claude/commands/design.md +44 -0
  441. package/exports/hosts/claude/.claude/commands/discover.md +37 -0
  442. package/exports/hosts/claude/.claude/commands/execute.md +48 -0
  443. package/exports/hosts/claude/.claude/commands/learn.md +38 -0
  444. package/exports/hosts/claude/.claude/commands/plan-review.md +42 -0
  445. package/exports/hosts/claude/.claude/commands/plan.md +39 -0
  446. package/exports/hosts/claude/.claude/commands/prepare-next.md +37 -0
  447. package/exports/hosts/claude/.claude/commands/review.md +40 -0
  448. package/exports/hosts/claude/.claude/commands/run-audit.md +41 -0
  449. package/exports/hosts/claude/.claude/commands/spec-challenge.md +41 -0
  450. package/exports/hosts/claude/.claude/commands/specify.md +38 -0
  451. package/exports/hosts/claude/.claude/commands/verify.md +37 -0
  452. package/exports/hosts/claude/.claude/settings.json +34 -0
  453. package/exports/hosts/claude/CLAUDE.md +19 -0
  454. package/exports/hosts/claude/export.manifest.json +38 -0
  455. package/exports/hosts/claude/host-package.json +67 -0
  456. package/exports/hosts/codex/AGENTS.md +19 -0
  457. package/exports/hosts/codex/export.manifest.json +38 -0
  458. package/exports/hosts/codex/host-package.json +41 -0
  459. package/exports/hosts/cursor/.cursor/hooks.json +16 -0
  460. package/exports/hosts/cursor/.cursor/rules/wazir-core.mdc +19 -0
  461. package/exports/hosts/cursor/export.manifest.json +38 -0
  462. package/exports/hosts/cursor/host-package.json +42 -0
  463. package/exports/hosts/gemini/GEMINI.md +19 -0
  464. package/exports/hosts/gemini/export.manifest.json +38 -0
  465. package/exports/hosts/gemini/host-package.json +41 -0
  466. package/hooks/README.md +18 -0
  467. package/hooks/definitions/loop_cap_guard.yaml +21 -0
  468. package/hooks/definitions/post_tool_capture.yaml +24 -0
  469. package/hooks/definitions/pre_compact_summary.yaml +19 -0
  470. package/hooks/definitions/pre_tool_capture_route.yaml +19 -0
  471. package/hooks/definitions/protected_path_write_guard.yaml +19 -0
  472. package/hooks/definitions/session_start.yaml +19 -0
  473. package/hooks/definitions/stop_handoff_harvest.yaml +20 -0
  474. package/hooks/loop-cap-guard +17 -0
  475. package/hooks/post-tool-lint +36 -0
  476. package/hooks/protected-path-write-guard +17 -0
  477. package/hooks/session-start +41 -0
  478. package/llms-full.txt +2355 -0
  479. package/llms.txt +43 -0
  480. package/package.json +79 -0
  481. package/roles/README.md +20 -0
  482. package/roles/clarifier.md +42 -0
  483. package/roles/content-author.md +63 -0
  484. package/roles/designer.md +55 -0
  485. package/roles/executor.md +55 -0
  486. package/roles/learner.md +51 -0
  487. package/roles/planner.md +53 -0
  488. package/roles/researcher.md +43 -0
  489. package/roles/reviewer.md +54 -0
  490. package/roles/specifier.md +47 -0
  491. package/roles/verifier.md +71 -0
  492. package/schemas/README.md +24 -0
  493. package/schemas/accepted-learning.schema.json +20 -0
  494. package/schemas/author-artifact.schema.json +156 -0
  495. package/schemas/clarification.schema.json +19 -0
  496. package/schemas/design-artifact.schema.json +80 -0
  497. package/schemas/docs-claim.schema.json +18 -0
  498. package/schemas/export-manifest.schema.json +20 -0
  499. package/schemas/hook.schema.json +67 -0
  500. package/schemas/host-export-package.schema.json +18 -0
  501. package/schemas/implementation-plan.schema.json +19 -0
  502. package/schemas/proposed-learning.schema.json +19 -0
  503. package/schemas/research.schema.json +18 -0
  504. package/schemas/review.schema.json +29 -0
  505. package/schemas/run-manifest.schema.json +18 -0
  506. package/schemas/spec-challenge.schema.json +18 -0
  507. package/schemas/spec.schema.json +20 -0
  508. package/schemas/usage.schema.json +102 -0
  509. package/schemas/verification-proof.schema.json +29 -0
  510. package/schemas/wazir-manifest.schema.json +173 -0
  511. package/skills/README.md +40 -0
  512. package/skills/brainstorming/SKILL.md +77 -0
  513. package/skills/debugging/SKILL.md +50 -0
  514. package/skills/design/SKILL.md +61 -0
  515. package/skills/dispatching-parallel-agents/SKILL.md +128 -0
  516. package/skills/executing-plans/SKILL.md +70 -0
  517. package/skills/finishing-a-development-branch/SKILL.md +169 -0
  518. package/skills/humanize/SKILL.md +123 -0
  519. package/skills/init-pipeline/SKILL.md +124 -0
  520. package/skills/prepare-next/SKILL.md +20 -0
  521. package/skills/receiving-code-review/SKILL.md +123 -0
  522. package/skills/requesting-code-review/SKILL.md +105 -0
  523. package/skills/requesting-code-review/code-reviewer.md +108 -0
  524. package/skills/run-audit/SKILL.md +197 -0
  525. package/skills/scan-project/SKILL.md +41 -0
  526. package/skills/self-audit/SKILL.md +153 -0
  527. package/skills/subagent-driven-development/SKILL.md +154 -0
  528. package/skills/subagent-driven-development/code-quality-reviewer-prompt.md +26 -0
  529. package/skills/subagent-driven-development/implementer-prompt.md +102 -0
  530. package/skills/subagent-driven-development/spec-reviewer-prompt.md +61 -0
  531. package/skills/tdd/SKILL.md +23 -0
  532. package/skills/using-git-worktrees/SKILL.md +163 -0
  533. package/skills/using-skills/SKILL.md +95 -0
  534. package/skills/verification/SKILL.md +22 -0
  535. package/skills/wazir/SKILL.md +463 -0
  536. package/skills/writing-plans/SKILL.md +30 -0
  537. package/skills/writing-skills/SKILL.md +157 -0
  538. package/skills/writing-skills/anthropic-best-practices.md +122 -0
  539. package/skills/writing-skills/persuasion-principles.md +50 -0
  540. package/templates/README.md +20 -0
  541. package/templates/artifacts/README.md +10 -0
  542. package/templates/artifacts/accepted-learning.md +19 -0
  543. package/templates/artifacts/accepted-learning.template.json +12 -0
  544. package/templates/artifacts/author.md +74 -0
  545. package/templates/artifacts/author.template.json +19 -0
  546. package/templates/artifacts/clarification.md +21 -0
  547. package/templates/artifacts/clarification.template.json +12 -0
  548. package/templates/artifacts/execute-notes.md +19 -0
  549. package/templates/artifacts/implementation-plan.md +21 -0
  550. package/templates/artifacts/implementation-plan.template.json +11 -0
  551. package/templates/artifacts/learning-proposal.md +19 -0
  552. package/templates/artifacts/next-run-handoff.md +21 -0
  553. package/templates/artifacts/plan-review.md +19 -0
  554. package/templates/artifacts/proposed-learning.template.json +12 -0
  555. package/templates/artifacts/research.md +21 -0
  556. package/templates/artifacts/research.template.json +12 -0
  557. package/templates/artifacts/review-findings.md +19 -0
  558. package/templates/artifacts/review.template.json +11 -0
  559. package/templates/artifacts/run-manifest.template.json +8 -0
  560. package/templates/artifacts/spec-challenge.md +19 -0
  561. package/templates/artifacts/spec-challenge.template.json +11 -0
  562. package/templates/artifacts/spec.md +21 -0
  563. package/templates/artifacts/spec.template.json +12 -0
  564. package/templates/artifacts/verification-proof.md +19 -0
  565. package/templates/artifacts/verification-proof.template.json +11 -0
  566. package/templates/examples/accepted-learning.example.json +14 -0
  567. package/templates/examples/author.example.json +152 -0
  568. package/templates/examples/clarification.example.json +15 -0
  569. package/templates/examples/docs-claim.example.json +8 -0
  570. package/templates/examples/export-manifest.example.json +7 -0
  571. package/templates/examples/host-export-package.example.json +11 -0
  572. package/templates/examples/implementation-plan.example.json +17 -0
  573. package/templates/examples/proposed-learning.example.json +13 -0
  574. package/templates/examples/research.example.json +15 -0
  575. package/templates/examples/research.example.md +6 -0
  576. package/templates/examples/review.example.json +17 -0
  577. package/templates/examples/run-manifest.example.json +9 -0
  578. package/templates/examples/spec-challenge.example.json +14 -0
  579. package/templates/examples/spec.example.json +21 -0
  580. package/templates/examples/verification-proof.example.json +21 -0
  581. package/templates/examples/wazir-manifest.example.yaml +65 -0
  582. package/templates/task-definition-schema.md +99 -0
  583. package/tooling/README.md +20 -0
  584. package/tooling/src/adapters/context-mode.js +50 -0
  585. package/tooling/src/capture/command.js +376 -0
  586. package/tooling/src/capture/store.js +99 -0
  587. package/tooling/src/capture/usage.js +270 -0
  588. package/tooling/src/checks/branches.js +50 -0
  589. package/tooling/src/checks/brand-truth.js +110 -0
  590. package/tooling/src/checks/changelog.js +231 -0
  591. package/tooling/src/checks/command-registry.js +36 -0
  592. package/tooling/src/checks/commits.js +102 -0
  593. package/tooling/src/checks/docs-drift.js +103 -0
  594. package/tooling/src/checks/docs-truth.js +201 -0
  595. package/tooling/src/checks/runtime-surface.js +156 -0
  596. package/tooling/src/cli.js +116 -0
  597. package/tooling/src/command-options.js +56 -0
  598. package/tooling/src/commands/validate.js +320 -0
  599. package/tooling/src/doctor/command.js +91 -0
  600. package/tooling/src/export/command.js +77 -0
  601. package/tooling/src/export/compiler.js +498 -0
  602. package/tooling/src/guards/loop-cap-guard.js +52 -0
  603. package/tooling/src/guards/protected-path-write-guard.js +67 -0
  604. package/tooling/src/index/command.js +152 -0
  605. package/tooling/src/index/storage.js +1061 -0
  606. package/tooling/src/index/summarizers.js +261 -0
  607. package/tooling/src/loaders.js +18 -0
  608. package/tooling/src/project-root.js +22 -0
  609. package/tooling/src/recall/command.js +225 -0
  610. package/tooling/src/schema-validator.js +30 -0
  611. package/tooling/src/state-root.js +40 -0
  612. package/tooling/src/status/command.js +71 -0
  613. package/wazir.manifest.yaml +135 -0
  614. package/workflows/README.md +19 -0
  615. package/workflows/author.md +42 -0
  616. package/workflows/clarify.md +38 -0
  617. package/workflows/design-review.md +46 -0
  618. package/workflows/design.md +44 -0
  619. package/workflows/discover.md +37 -0
  620. package/workflows/execute.md +48 -0
  621. package/workflows/learn.md +38 -0
  622. package/workflows/plan-review.md +42 -0
  623. package/workflows/plan.md +39 -0
  624. package/workflows/prepare-next.md +37 -0
  625. package/workflows/review.md +40 -0
  626. package/workflows/run-audit.md +41 -0
  627. package/workflows/spec-challenge.md +41 -0
  628. package/workflows/specify.md +38 -0
  629. package/workflows/verify.md +37 -0
@@ -0,0 +1,616 @@
1
+ # Build vs Buy — Architecture Expertise Module
2
+
3
+ > The build vs buy decision determines whether to develop a capability in-house or adopt an existing solution (SaaS, open-source, or commercial off-the-shelf). The default should be "buy" for commodity capabilities and "build" for competitive differentiators. Most teams over-build — custom auth systems, custom CMS, custom email infrastructure — wasting months on solved problems. According to Forrester's 2024 Software Development Trends Report, 67% of failed software implementations stem from incorrect build vs buy decisions, and more than 35% of large enterprise custom software initiatives are abandoned entirely.
4
+
5
+ > **Category:** Decision
6
+ > **Complexity:** Moderate
7
+ > **Applies when:** Adding any new capability to a system — authentication, payments, search, email, analytics, CMS, scheduling, monitoring, or any infrastructure component
8
+
9
+ ---
10
+
11
+ ## What This Is
12
+
13
+ ### The Build vs Buy Spectrum
14
+
15
+ Build vs buy is not a binary choice. It is a spectrum with at least four distinct positions, each with different cost profiles, control levels, and maintenance burdens.
16
+
17
+ **Fully Custom (Build from Scratch)** — Your team writes every line of code. You own the full stack, from data model to UI. You bear 100% of the maintenance burden, security patching, scaling, and on-call rotation. This is appropriate only when the capability is your core product or when no existing solution can meet genuinely unique requirements. Examples: a fintech company building its own ledger system, a search company building its own ranking algorithm.
18
+
19
+ **Open-Source with Customization** — You adopt an open-source project as a foundation and extend it to fit your needs. You get a head start (often years of community-hardened code) but still own deployment, configuration, upgrades, and any custom patches. You avoid vendor lock-in but accept operational burden. The fork-and-modify path is particularly dangerous — your customizations can diverge from upstream, making future upgrades painful or impossible. Examples: deploying Keycloak for auth, running self-hosted PostgreSQL, using Apache Airflow for workflow orchestration.
20
+
21
+ **SaaS with Integration (Buy and Integrate)** — You subscribe to a managed service and integrate it via APIs, SDKs, or webhooks. The vendor handles infrastructure, scaling, security patching, and compliance certifications. You trade control for velocity. Your integration code becomes the boundary — well-designed integrations use adapter patterns that allow future vendor swaps. Examples: Auth0/Clerk for authentication, Stripe for payments, SendGrid for email, Datadog for monitoring.
22
+
23
+ **Fully Managed / Embedded (Buy and Delegate)** — You use a turnkey solution that requires minimal integration. Often this means embedding a vendor's complete workflow — their UI, their data model, their opinionated flow. Maximum speed, minimum control. Appropriate for capabilities that are entirely commodity and where your users do not need a custom experience. Examples: Shopify for e-commerce, WordPress for content management, Zendesk for support ticketing.
24
+
25
+ ### The Core vs Context Framework
26
+
27
+ The most useful mental model for build vs buy decisions comes from Geoffrey Moore's concept of **core vs context**:
28
+
29
+ - **Core** — Activities that create competitive differentiation. These are what your customers pay you for. They are unique to your business, hard to replicate, and directly drive revenue or retention. You should build these, because control over them is a strategic asset.
30
+
31
+ - **Context** — Everything else. Activities that are necessary but do not differentiate you. Authentication, email delivery, payment processing, logging, monitoring, CI/CD — these are table stakes. Every company needs them, none of your customers chose you because of your login page. You should buy these, because building them diverts engineering time from core work.
32
+
33
+ The mistake most engineering teams make is misclassifying context as core. "We need customization" is the most common justification, and it is almost always wrong. Most SaaS solutions cover 90% of requirements out of the box, and the remaining 10% is rarely worth months of custom development.
34
+
35
+ ### What This Decision Is Not
36
+
37
+ **Not a one-time choice.** Build vs buy decisions should be revisited as the market evolves. What required custom development five years ago may now be a commodity SaaS offering. Conversely, a capability you bought may have become so central to your product that bringing it in-house is warranted.
38
+
39
+ **Not purely a cost calculation.** TCO analysis is necessary but not sufficient. Strategic alignment, team capability, time-to-market pressure, and competitive dynamics all factor in. A spreadsheet alone will not give you the right answer.
40
+
41
+ **Not a reflection of engineering competence.** Choosing to buy is not an admission that your team "can't build it." It is a recognition that their time is better spent on problems that only they can solve. The best engineering teams are aggressive about buying commodity capabilities precisely because they understand their own value.
42
+
43
+ ---
44
+
45
+ ## When to Build
46
+
47
+ ### The Qualifying Conditions for Custom Development
48
+
49
+ Build when **two or more** of these conditions are true. If only one is true, the case for building is weak and should be scrutinized.
50
+
51
+ **The capability is your core competitive advantage.** If this is what customers pay you for — if removing it would make your product indistinguishable from competitors — then you need full control over its evolution. Google built its own search ranking algorithm. Stripe built its own payment infrastructure. Netflix built its own recommendation engine. These companies did not adopt off-the-shelf solutions for their core differentiators because doing so would have ceded their competitive moat.
52
+
53
+ **Existing solutions genuinely cannot meet your requirements.** Not "we want a slightly different button color" — genuinely cannot. This means you have evaluated at least three commercial solutions and two open-source options, spoken with their sales engineers, done proof-of-concept integrations, and confirmed that the gaps are fundamental, not configuration oversights. The bar here should be high: can you articulate exactly which requirements are unmet and why they are non-negotiable?
54
+
55
+ **Regulatory or compliance constraints mandate full control.** Some industries (healthcare, defense, financial services) have compliance requirements that prohibit third-party data processing for certain data types. HIPAA, SOC 2, FedRAMP, PCI-DSS — these can constrain vendor choices or eliminate them entirely. But verify this carefully: most major SaaS vendors now hold these certifications. "We're in healthcare so we need to build everything" has not been true for years.
56
+
57
+ **Volume economics make SaaS pricing prohibitive.** SaaS pricing is designed for the median customer. If you are at extreme scale — sending billions of emails, processing millions of transactions, storing petabytes of data — the per-unit economics of SaaS can become untenable. At this point, custom infrastructure amortizes its development cost over enough volume to justify the investment. But be honest about whether you are actually at this scale or merely aspire to be. Building for hypothetical future scale is one of the most expensive mistakes in software engineering.
58
+
59
+ **The integration surface is the product itself.** If the capability you are evaluating is deeply intertwined with your user experience — if it is not a background service but a visible, interactive part of your product — then the limitations of vendor-provided UIs and workflows may be genuinely constraining. A generic embedded checkout flow may be acceptable; a generic core workflow editor probably is not.
60
+
61
+ ### Real-World "Build" Decisions That Were Right
62
+
63
+ **Stripe building payment infrastructure** — When Stripe launched in 2010, existing payment processing required months of integration, byzantine APIs, and per-merchant bank relationships. Stripe's entire competitive advantage was making this easy. Building it was not optional — it was the product.
64
+
65
+ **Netflix building its recommendation engine** — Recommendations drive 80% of content watched on Netflix. This is not a feature — it is the core product experience. Netflix invested heavily in custom ML infrastructure because the quality of recommendations directly determines subscriber retention.
66
+
67
+ **Shopify building its own checkout** — Shopify's checkout conversion rate is a key competitive metric against competitors. Owning this flow end-to-end lets them optimize every pixel for conversion, run continuous A/B tests, and provide merchants with unique capabilities that generic checkout widgets cannot match.
68
+
69
+ ---
70
+
71
+ ## When to Buy
72
+
73
+ ### The Case for Buying Is Usually Stronger Than You Think
74
+
75
+ The default should be "buy" unless you have a compelling, specific reason to build. Here is why.
76
+
77
+ **Commodity capabilities are solved problems.** Authentication, email delivery, payment processing, search, logging, monitoring, error tracking, feature flagging, A/B testing — these have been built, hardened, scaled, and battle-tested by dedicated companies whose entire business depends on them being excellent. Your custom implementation will not be better. It will be worse — less secure, less tested, less maintained, with fewer edge cases handled.
78
+
79
+ **The real cost of building is 5-10x the initial estimate.** Forrester Research found that 60% of companies underestimate the long-term cost of maintaining custom-built software. Forrester's Total Economic Impact model estimates that 78% of lifetime software TCO accrues after launch, not during initial development. That custom auth system you estimated at 3 weeks of work? Add ongoing security patching, session management edge cases, password reset flows, MFA support, SSO integration, compliance audits, and on-call rotation. You are now looking at a permanent maintenance burden that grows every year.
80
+
81
+ **Opportunity cost is the largest hidden cost.** Every month your team spends building a custom email system is a month they are not building features that differentiate your product. For a startup, this can be existential — competitors who bought commodity capabilities and spent their engineering time on core product are shipping faster, learning faster, and capturing market share.
82
+
83
+ **SaaS vendors have dedicated security teams.** When you build custom authentication, you are now responsible for credential storage, brute-force protection, session management, token rotation, CSRF protection, XSS mitigation, and every OWASP Top 10 vulnerability. Auth0 has an entire security team doing this full-time. Your team has one developer who "knows security pretty well." The risk asymmetry is enormous.
84
+
85
+ ### The "We Need Customization" Fallacy
86
+
87
+ This is the most common justification for building, and it is almost always wrong. The pattern:
88
+
89
+ 1. Team evaluates SaaS solution.
90
+ 2. Team finds it covers 90% of requirements.
91
+ 3. Team identifies a 10% gap in customization.
92
+ 4. Team decides to build from scratch to get 100% coverage.
93
+ 5. Team spends 6 months building a solution that covers 70% of what the SaaS offered, plus the 10% custom requirement.
94
+ 6. Team now maintains a worse solution indefinitely.
95
+
96
+ The correct response to a 10% gap is usually: adapt your requirements, use the vendor's extension points, or build a thin integration layer on top of the vendor solution. Building from scratch to avoid a 10% compromise is almost never economically rational.
97
+
98
+ ### Real-World "Buy" Decisions — Lessons from the Field
99
+
100
+ **Every startup that built custom auth** — Building custom authentication is the canonical example of wasted engineering effort. Auth0 integration takes hours. Clerk integration takes minutes (approximately 20 lines of code for production-ready auth). Building custom auth with email/password, social login, MFA, session management, and password reset takes 2-4 months minimum — and then requires ongoing security maintenance forever. The custom solution will be less secure than Auth0 or Clerk on day one and the gap will widen over time. Building SAML support alone is estimated at $250,000-500,000 in engineering time.
101
+
102
+ **Payment processing** — Stripe provides access to 125+ payment methods through a single integration. Building custom payment processing infrastructure requires 6-18 months of dedicated engineering time for initial integration alone, plus ongoing compliance with PCI-DSS, fraud detection, dispute management, and regulatory requirements across jurisdictions. Becoming a full payment facilitator requires handling customer onboarding, underwriting, dispute management, compliance, support, dashboards, and reporting — a multi-year, multi-team endeavor.
103
+
104
+ **Email infrastructure** — SendGrid, Postmark, and Amazon SES handle deliverability, bounce management, spam compliance (CAN-SPAM, GDPR), IP reputation management, and scaling to millions of messages. Building custom email sending infrastructure means managing SMTP servers, SPF/DKIM/DMARC configuration, deliverability optimization, bounce handling, feedback loops with ISPs, and blocklist monitoring. Teams that build this spend months getting out of spam folders.
105
+
106
+ **Monitoring and observability** — Datadog, New Relic, and Grafana Cloud provide unified logging, metrics, tracing, and alerting with pre-built integrations for hundreds of technologies. Custom monitoring stacks require deploying and maintaining Prometheus, Grafana, Loki, Tempo, AlertManager, and their associated storage backends — a full-time job for at least one infrastructure engineer.
107
+
108
+ **Search** — Algolia and Elasticsearch-as-a-Service (Elastic Cloud) provide sub-50ms search with typo tolerance, faceting, relevance tuning, and analytics. Custom search implementation requires building and maintaining inverted indices, relevance scoring, query parsing, and scaling infrastructure. Teams that build custom search spend months achieving what Algolia provides on day one.
109
+
110
+ ---
111
+
112
+ ## How It Works — The Evaluation Framework
113
+
114
+ ### Step 1: Classify Core vs Context
115
+
116
+ Before evaluating any specific solution, answer this question honestly: **Is this capability a competitive differentiator?**
117
+
118
+ Apply the "press release test": if you removed this capability from your product, would your customers notice? Would they switch to a competitor? If the answer is no, it is context, and you should default to buying.
119
+
120
+ Apply the "10x test": if you made this capability 10x better, would it meaningfully improve your competitive position? If a 10x improvement in your auth system would not matter to customers but a 10x improvement in your recommendation engine would, then auth is context and recommendations are core.
121
+
122
+ ### Step 2: Total Cost of Ownership Analysis
123
+
124
+ TCO must be calculated over a 3-5 year window to capture the full picture. Short-term cost comparisons are misleading because they hide the maintenance iceberg.
125
+
126
+ **Build TCO Components:**
127
+
128
+ | Cost Category | Year 1 | Year 2-5 (Annual) |
129
+ |---|---|---|
130
+ | Development (salaries, benefits) | High | Moderate |
131
+ | Infrastructure (servers, databases) | Moderate | Moderate-High |
132
+ | Security (audits, patching, incidents) | Low | Moderate-High |
133
+ | Maintenance (bug fixes, upgrades) | Low | High |
134
+ | Opportunity cost (features not built) | Very High | High |
135
+ | On-call and operational support | Moderate | Moderate |
136
+ | Documentation and knowledge transfer | Moderate | Moderate |
137
+ | **Cumulative trajectory** | **High** | **Accelerating** |
138
+
139
+ **Buy TCO Components:**
140
+
141
+ | Cost Category | Year 1 | Year 2-5 (Annual) |
142
+ |---|---|---|
143
+ | Subscription / licensing fees | Moderate | Moderate (may increase) |
144
+ | Integration development | Moderate | Low |
145
+ | Training and onboarding | Low | Low |
146
+ | Migration / data portability prep | Low | Low |
147
+ | Vendor management overhead | Low | Low |
148
+ | Risk of vendor price increases | None | Low-Moderate |
149
+ | Risk of vendor discontinuation | None | Low |
150
+ | **Cumulative trajectory** | **Moderate** | **Predictable** |
151
+
152
+ **The critical insight:** Build costs accelerate over time (technical debt, security patches, framework upgrades, team turnover requiring knowledge transfer). Buy costs are predictable and often decrease as a percentage of revenue as the company grows.
153
+
154
+ **TCO Formula:**
155
+
156
+ ```
157
+ Build TCO = Development Cost + (Annual Maintenance x Years) + Opportunity Cost
158
+ Buy TCO = (Annual Subscription x Years) + Integration Cost + Migration Risk Premium
159
+ ```
160
+
161
+ The opportunity cost term is what most analyses omit — and it is usually the largest number. If your 4-person team spends 3 months building custom search instead of core product features, and your burn rate is $80K/month fully loaded per engineer, the opportunity cost is $960K — not in cash, but in deferred product development that could have driven revenue.
162
+
163
+ ### Step 3: Vendor Evaluation Criteria
164
+
165
+ When evaluating buy options, assess these dimensions:
166
+
167
+ **Functional fit** — Does it cover at least 80% of your requirements without customization? What are its extension points (APIs, webhooks, plugins)? Can you work around gaps with integration code rather than forking or replacing?
168
+
169
+ **Integration architecture** — Does it offer well-documented REST/GraphQL APIs? Does it support webhooks for event-driven integration? Are there SDKs for your language/framework? Can you integrate at the API level (loose coupling) rather than the UI level (tight coupling)?
170
+
171
+ **Pricing model and trajectory** — What is the pricing model (per-seat, per-usage, flat-rate)? How does pricing scale with your projected growth? Are there tier cliffs where costs jump dramatically? What is the pricing history — does this vendor raise prices aggressively?
172
+
173
+ **Vendor viability** — Is the company profitable or well-funded? How large is the customer base? Is it a single-product company (higher risk) or a diversified platform (lower risk)? What is the bus factor — is the product tied to a single founder or small team?
174
+
175
+ **Data portability** — Can you export all your data in standard formats? Are there contractual guarantees for data portability? How long would a migration take? What is the documented exit process?
176
+
177
+ **Compliance and security** — Does the vendor hold relevant certifications (SOC 2, HIPAA, ISO 27001, PCI-DSS)? Where is data stored geographically? What is their incident response track record? Do they support your data residency requirements?
178
+
179
+ ### Step 4: Integration Architecture
180
+
181
+ Regardless of what you buy, the integration design determines whether you can switch later. Follow these principles:
182
+
183
+ **Use the Adapter Pattern (Ports and Adapters).** Never let vendor-specific types leak into your domain layer. Define your own interface (port) for the capability and implement it using the vendor's SDK (adapter). If you later switch vendors, you replace the adapter, not the domain code.
184
+
185
+ ```
186
+ // Port (your interface)
187
+ interface PaymentGateway {
188
+ charge(amount: Money, method: PaymentMethod): Promise<PaymentResult>
189
+ refund(paymentId: string, amount: Money): Promise<RefundResult>
190
+ }
191
+
192
+ // Adapter (vendor implementation)
193
+ class StripePaymentGateway implements PaymentGateway {
194
+ charge(amount: Money, method: PaymentMethod): Promise<PaymentResult> {
195
+ // Stripe-specific implementation
196
+ }
197
+ }
198
+
199
+ // Your domain code depends only on PaymentGateway, never on Stripe directly
200
+ ```
201
+
202
+ **Store canonical data in your own database.** Even when using a SaaS for a capability, maintain a local copy of critical data in your own schema. If you use Auth0 for authentication, still store user profiles in your database. If you use Stripe for payments, still record transactions in your ledger. This makes vendor migration tractable and gives you query flexibility the vendor may not offer.
203
+
204
+ **Use webhooks over polling.** Webhook-based integration creates clear event boundaries between your system and the vendor. These events become your integration contract — if you switch vendors, you just need the new vendor to emit equivalent events.
205
+
206
+ **Wrap vendor UIs in your own components.** If you embed vendor-provided UI elements (Stripe Elements, Auth0 Lock), wrap them in your own components. This localizes the blast radius of a vendor swap to the wrapper, not every page that uses the component.
207
+
208
+ ### Step 5: Vendor Risk Assessment and Lock-In Mitigation
209
+
210
+ **Architectural mitigation:**
211
+ - Modular architecture with clear boundaries between vendor-dependent and vendor-independent code.
212
+ - Use open standards (OAuth 2.0, OpenID Connect, SMTP, S3-compatible APIs) wherever possible, so you can swap implementations without changing contracts.
213
+ - Avoid proprietary query languages, data formats, or protocols when open alternatives exist.
214
+ - Design for data portability from day one — never store critical data exclusively in a vendor's system without a synchronization or export mechanism.
215
+
216
+ **Contractual mitigation:**
217
+ - Negotiate annual renewal options over multi-year commitments to maintain flexibility.
218
+ - Include explicit data portability and exit clauses in contracts.
219
+ - Define SLAs with financial penalties for downtime or data availability failures.
220
+ - Require advance notice of pricing changes (12+ months) and cap annual price increases contractually.
221
+
222
+ **Operational mitigation:**
223
+ - Maintain a documented exit plan for every critical vendor dependency, including estimated migration timeline and resource requirements.
224
+ - Run periodic "fire drills" — can you actually export your data and import it into an alternative? Theory is not enough; test it.
225
+ - Monitor vendor health signals: employee reviews on Glassdoor, funding news, customer sentiment, product roadmap activity.
226
+ - Avoid concentrating too many capabilities with a single vendor (the "all-in-on-AWS" trap).
227
+
228
+ ---
229
+
230
+ ## Trade-Offs Matrix
231
+
232
+ ### Build vs Buy — Detailed Comparison
233
+
234
+ | Dimension | Build | Buy |
235
+ |---|---|---|
236
+ | **Time to market** | Months to years. Even a v1.0 of a well-functioning platform takes 6-12 months. | Days to weeks. SaaS setup is typically hours; integration takes days to weeks. |
237
+ | **Upfront cost** | High. Developer salaries, infrastructure setup, design, testing. | Low to moderate. Subscription fees, integration development. |
238
+ | **Long-term cost** | Accelerating. Maintenance, security, upgrades, on-call, knowledge transfer. 78% of TCO accrues post-launch. | Predictable. Subscription fees with potential price increases. |
239
+ | **Customization** | Unlimited. You control every aspect of the implementation. | Limited to vendor extension points. APIs, webhooks, plugins, configuration. |
240
+ | **Control** | Full. You own the code, the data, the roadmap. | Partial. You are dependent on vendor roadmap, pricing decisions, and API stability. |
241
+ | **Security responsibility** | Yours entirely. You handle patching, auditing, penetration testing, incident response. | Shared. Vendor handles infrastructure security; you handle integration security. |
242
+ | **Scalability** | Your problem. You architect, provision, and operate the scaling infrastructure. | Vendor's problem (mostly). Enterprise SaaS is designed to scale; you handle integration scaling. |
243
+ | **Vendor lock-in risk** | None. | Moderate to high, depending on integration architecture and data portability. |
244
+ | **Maintenance burden** | Permanent and growing. Bug fixes, dependency updates, framework migrations, OS patches. | Minimal. Vendor handles maintenance; you maintain integration code only. |
245
+ | **Opportunity cost** | Very high. Every engineer building commodity capabilities is not building core product. | Low. Engineers focus on differentiating features. |
246
+ | **Team expertise required** | Deep domain expertise needed. Auth requires security expertise; payments require fintech expertise. | Integration expertise only. API consumption, webhook handling, error mapping. |
247
+ | **Reliability track record** | Unproven. Your custom solution has zero production hours on day one. | Proven. Major SaaS products serve thousands of customers and have battle-tested reliability. |
248
+
249
+ ### The Hybrid Row — Often the Right Answer
250
+
251
+ | Dimension | Hybrid (Buy + Extend) |
252
+ |---|---|
253
+ | **Time to market** | Weeks to low months. Buy the foundation, build the differentiation layer. |
254
+ | **Cost profile** | Moderate and predictable. Subscription + targeted custom development. |
255
+ | **Customization** | Targeted. Customize the 10-20% that matters; accept defaults for the rest. |
256
+ | **Lock-in risk** | Manageable. Adapter pattern isolates vendor dependency; data stays in your systems. |
257
+ | **Maintenance burden** | Low. Vendor maintains the platform; you maintain integration and extension code. |
258
+
259
+ ---
260
+
261
+ ## Evolution Path
262
+
263
+ ### Stage 1: Default to Buy (Seed to Series A)
264
+
265
+ At this stage, every engineering hour is precious. Buy everything that is not your core product. Auth? Clerk or Auth0. Payments? Stripe. Email? SendGrid. Search? Algolia. Monitoring? Datadog or a simple logging stack. CMS? Contentful or Sanity. The goal is to ship your core product as fast as possible and validate product-market fit. Building commodity infrastructure at this stage is one of the most common startup killers.
266
+
267
+ **Anti-pattern to avoid:** "We'll build our own because SaaS costs will be too high at scale." You do not have scale. You may never have scale. Optimize for survival and learning speed, not hypothetical future costs.
268
+
269
+ ### Stage 2: Selective In-Housing (Series B to Series C)
270
+
271
+ Once you have product-market fit and meaningful scale, some bought capabilities may warrant bringing in-house. Criteria for in-housing:
272
+
273
+ - The vendor's pricing has become a material percentage of COGS (>5% of revenue).
274
+ - The capability has become a competitive differentiator that the vendor's product constrains.
275
+ - Your team has grown enough to absorb the maintenance burden without impacting core product velocity.
276
+ - You have identified specific limitations in the vendor solution that are demonstrably costing you revenue or growth.
277
+
278
+ Even at this stage, most capabilities should remain bought. Typically only 1-2 capabilities merit in-housing, not a wholesale "bring everything in-house" initiative.
279
+
280
+ ### Stage 3: Strategic Platform Ownership (Growth / Enterprise)
281
+
282
+ At significant scale, some companies build internal platforms for capabilities that are strategically important. Amazon built its own deployment infrastructure (which became AWS). Netflix built its own CDN (Open Connect). These decisions were justified by extreme scale (hundreds of millions of users) and strategic importance (infrastructure became a competitive moat or revenue stream).
283
+
284
+ Most companies never reach this stage, and those that do still buy extensively for non-core capabilities. Amazon uses third-party vendors for plenty of internal tooling. Netflix uses third-party solutions for many back-office functions.
285
+
286
+ ### The Re-evaluation Cadence
287
+
288
+ Every 18-24 months, review your build vs buy decisions:
289
+
290
+ - Has the vendor landscape changed? New entrants may solve problems your custom code addresses.
291
+ - Has your custom solution accumulated technical debt that a vendor migration would eliminate?
292
+ - Has a previously commodity capability become a competitive differentiator (or vice versa)?
293
+ - Has your scale changed enough to shift the cost calculus?
294
+
295
+ ---
296
+
297
+ ## Failure Modes
298
+
299
+ ### NIH Syndrome (Not Invented Here)
300
+
301
+ **What it is:** A cultural bias toward building everything in-house, rejecting external solutions regardless of their merit. Engineers want to build because building is more interesting than integrating. Managers want to build because it feels like "owning" the solution. Neither is a valid business justification.
302
+
303
+ **How it manifests:**
304
+ - "We can build a better version." (You almost certainly cannot, for commodity capabilities.)
305
+ - "We don't want to depend on a third party." (You already depend on your cloud provider, your programming language, your operating system, and dozens of open-source libraries.)
306
+ - "It'll be a good learning experience for the team." (Learning experiences should not be funded by the business as production infrastructure.)
307
+ - "We tried [vendor] and it didn't work." (Did you try configuring it correctly? Did you contact support? Did you try the three other vendors?)
308
+
309
+ **Real-world consequences:** MIT Sloan Management Review research documents how NIH syndrome kills innovation across industries. In software, it manifests as startups spending their first 6 months building custom auth, custom email, custom admin panels, and custom deployment pipelines — and shipping zero product features. A logistics startup built its own web framework instead of adopting Django or Rails, burning months on a solved problem while competitors shipped.
310
+
311
+ **How to counter it:**
312
+ - Require a formal "buy analysis" before any build decision. The team must evaluate at least 3 external options and document why each was rejected.
313
+ - Track the ratio of time spent on core vs context development. If more than 30% of engineering time goes to context work, something is wrong.
314
+ - Celebrate smart buying decisions as loudly as building achievements.
315
+
316
+ ### Vendor Over-Reliance (The Other Extreme)
317
+
318
+ **What it is:** Outsourcing so aggressively that you lose the ability to operate independently. Your entire stack is SaaS — your auth, your database, your search, your analytics, your email, your payments — all from different vendors, with no local data copies and no exit plans.
319
+
320
+ **How it manifests:**
321
+ - A single vendor outage takes down your entire product.
322
+ - A vendor price increase of 3x forces an emergency migration with no prepared alternative.
323
+ - A vendor sunset announcement leaves you scrambling with 12 months to replace a deeply integrated dependency.
324
+ - You cannot answer basic questions about your own users, transactions, or content without querying vendor APIs.
325
+
326
+ **How to counter it:**
327
+ - Maintain canonical data in your own database for every critical entity.
328
+ - Document exit plans for every Tier 1 vendor dependency.
329
+ - Never let a single vendor control more than 2 critical capabilities.
330
+ - Test data export and migration procedures annually.
331
+
332
+ ### Underestimating Maintenance Cost
333
+
334
+ **What it is:** Approving a build decision based on initial development estimates without accounting for the years of maintenance that follow. The build is funded, the feature ships, the team celebrates — and then the slow drain begins.
335
+
336
+ **How it manifests:**
337
+ - "We built it in 3 months" becomes "we've had 2 engineers maintaining it for 3 years."
338
+ - Security vulnerabilities in the custom solution are discovered months after they would have been patched by a vendor.
339
+ - The original developers leave the company. Knowledge transfer is incomplete. The remaining team is afraid to modify the code.
340
+ - Dependency upgrades (Node.js major versions, framework migrations, OS updates) require dedicated sprints that compete with product development.
341
+
342
+ **The numbers:** Forrester found that 78% of lifetime software TCO accrues after initial development. A $200K build project with a 5-year lifespan has a true cost closer to $900K when maintenance, security, and opportunity cost are included.
343
+
344
+ ### The "We'll Open-Source It" Trap
345
+
346
+ **What it is:** Justifying a build decision by claiming the result will be open-sourced, attracting community contributions that reduce maintenance burden. In reality, successful open-source projects require dedicated investment in documentation, community management, contributor onboarding, and governance — often as much effort as the software itself.
347
+
348
+ **Reality check:** The vast majority of corporate open-source projects receive zero external contributions. Open-sourcing code does not create a community. It creates a GitHub repository that the original team still maintains entirely.
349
+
350
+ ### Sunk Cost Continuation
351
+
352
+ **What it is:** Continuing to invest in a custom solution because of the resources already spent, even when a vendor solution would be cheaper going forward. "We've already spent 18 months building this — we can't throw it away."
353
+
354
+ **The correction:** The 18 months are gone regardless. The only question is: what is the cheapest path forward from today? If migrating to a vendor costs 2 months but saves 1 engineer-year annually in maintenance, the migration pays for itself in 2 months. The sunk cost is irrelevant.
355
+
356
+ ---
357
+
358
+ ## Technology Landscape — Common Build vs Buy Decisions
359
+
360
+ ### Authentication and Identity
361
+
362
+ | Option | Type | Integration Time | Annual Cost (10K users) | Key Strength |
363
+ |---|---|---|---|---|
364
+ | Auth0 | SaaS | Hours-Days | ~$1,000-3,000 | Enterprise features, extensive identity provider support |
365
+ | Clerk | SaaS | Minutes-Hours | ~$200-500 | Developer experience, pre-built UI components, fastest integration |
366
+ | Firebase Auth | SaaS | Hours | Free-$300 | Google ecosystem integration, generous free tier |
367
+ | Keycloak | Open-source | Days-Weeks | $0 + ops cost | Full control, self-hosted, enterprise SSO |
368
+ | SuperTokens | Open-source | Hours-Days | Free-$500 | Self-hosted option with managed offering |
369
+ | Custom build | Build | 2-4 months | $250K+ (engineering) | Full control (rarely justified) |
370
+
371
+ **Recommendation:** Buy. Authentication is the most commonly over-built capability. Unless you are building an identity product (like Auth0 itself), there is no competitive advantage in custom auth. The security risk of custom auth alone should disqualify it for most teams.
372
+
373
+ ### Payments
374
+
375
+ | Option | Type | Integration Time | Pricing Model | Key Strength |
376
+ |---|---|---|---|---|
377
+ | Stripe | SaaS | Days | 2.9% + $0.30/txn | Developer experience, 125+ payment methods, global |
378
+ | Braintree | SaaS | Days-Weeks | 2.59% + $0.49/txn | PayPal integration, established enterprise presence |
379
+ | Adyen | SaaS | Weeks | Interchange++ | Enterprise-grade, unified commerce |
380
+ | Square | SaaS | Days | 2.6% + $0.10/txn | In-person + online unified |
381
+ | Custom PSP integration | Build | 6-18 months | Interchange + custom | Full control (justified only at extreme scale) |
382
+
383
+ **Recommendation:** Buy. Payment processing involves PCI-DSS compliance, fraud detection, dispute management, and regulatory compliance across jurisdictions. The engineering effort to build this is 6-18 months minimum and requires specialized fintech expertise. Only companies processing billions in annual volume should consider custom infrastructure.
384
+
385
+ ### Email Delivery
386
+
387
+ | Option | Type | Volume (monthly) | Pricing | Key Strength |
388
+ |---|---|---|---|---|
389
+ | SendGrid | SaaS | Up to 100B+ | Free-$90/month (low vol) | Deliverability, analytics, templates |
390
+ | Postmark | SaaS | Up to millions | $15/month (10K emails) | Transactional email specialist, best deliverability |
391
+ | Amazon SES | SaaS/IaaS | Unlimited | $0.10/1K emails | Lowest cost at scale, AWS integration |
392
+ | Mailgun | SaaS | Up to millions | $35/month (50K emails) | Developer-focused, good API |
393
+ | Custom SMTP | Build | Unlimited | Infra + engineering | Full control (rarely justified) |
394
+
395
+ **Recommendation:** Buy. Email deliverability is a specialized discipline involving IP reputation management, ISP relationship management, bounce handling, and spam compliance. Building custom email infrastructure means months of work getting out of spam folders.
396
+
397
+ ### Search
398
+
399
+ | Option | Type | Integration Time | Pricing | Key Strength |
400
+ |---|---|---|---|---|
401
+ | Algolia | SaaS | Hours-Days | Free-$1/1K requests | Speed (<50ms), typo tolerance, relevance tuning |
402
+ | Elasticsearch (Elastic Cloud) | Managed | Days-Weeks | $95+/month | Full-text search, aggregations, analytics |
403
+ | Typesense | Open-source | Hours-Days | Free + hosting | Simple, fast, open-source alternative to Algolia |
404
+ | Meilisearch | Open-source | Hours-Days | Free + hosting | Developer-friendly, easy setup |
405
+ | Custom search | Build | Months | Engineering cost | Full control (justified only for core search products) |
406
+
407
+ **Recommendation:** Buy unless search is your core product. Algolia provides sub-50ms search with typo tolerance, faceting, and analytics out of the box. Custom search requires building and maintaining inverted indices, relevance scoring, query parsing, and scaling infrastructure.
408
+
409
+ ### Monitoring and Observability
410
+
411
+ | Option | Type | Integration Time | Pricing | Key Strength |
412
+ |---|---|---|---|---|
413
+ | Datadog | SaaS | Hours | $15-35/host/month | Unified platform, 700+ integrations |
414
+ | New Relic | SaaS | Hours | Free-$0.30/GB | Generous free tier, full-stack observability |
415
+ | Grafana Cloud | SaaS | Hours-Days | Free-usage based | Open-source foundation, flexible |
416
+ | Self-hosted (Prometheus + Grafana + Loki) | Open-source | Days-Weeks | $0 + ops cost | Full control, no data egress costs |
417
+ | Custom monitoring | Build | Months | Engineering cost | Full control (never justified) |
418
+
419
+ **Recommendation:** Buy or use managed open-source. Custom monitoring stacks require dedicated infrastructure engineering. Self-hosted Prometheus/Grafana is viable for cost-sensitive teams with infrastructure expertise, but Datadog or Grafana Cloud is almost always the better choice for teams without dedicated platform engineers.
420
+
421
+ ---
422
+
423
+ ## Decision Tree
424
+
425
+ Use this flowchart for any new capability:
426
+
427
+ ```
428
+ START: You need a new capability
429
+
430
+ Q1: Is this your core competitive differentiator?
431
+ ├─ YES → Q2: Can you hire/retain the expertise to build and maintain it?
432
+ │ ├─ YES → Q3: Is your timeline > 6 months?
433
+ │ │ ├─ YES → BUILD (with milestones and kill criteria)
434
+ │ │ └─ NO → BUY now, plan to BUILD later if validated
435
+ │ └─ NO → BUY and invest in hiring (do not build with insufficient expertise)
436
+
437
+ └─ NO (this is context) → Q4: Does a commercial/open-source solution exist?
438
+ ├─ YES → Q5: Does it cover ≥80% of requirements?
439
+ │ ├─ YES → BUY (adapt the 20% or accept the gap)
440
+ │ └─ NO → Q6: Can you combine solutions to reach 80%?
441
+ │ ├─ YES → BUY (hybrid integration)
442
+ │ └─ NO → BUILD (but reassess — is the
443
+ │ requirement genuinely unique or
444
+ │ over-specified?)
445
+
446
+ └─ NO → Q7: Is this a common capability that should exist?
447
+ ├─ YES → BUILD minimally, consider open-sourcing
448
+ └─ NO → BUILD (you may have found a genuine gap)
449
+ ```
450
+
451
+ **Kill criteria for build decisions:** Before starting any build, define conditions under which you will abandon the custom implementation and switch to buying. Examples: "If we exceed 4 months of development," "If we cannot achieve 99.9% uptime in the first 3 months," "If maintenance consumes more than 20% of one engineer's time." Without kill criteria, build projects become zombie projects that consume resources indefinitely.
452
+
453
+ ---
454
+
455
+ ## Implementation Sketch — Structuring a Buy Decision
456
+
457
+ ### Phase 1: Requirements and Market Scan (1-2 weeks)
458
+
459
+ ```markdown
460
+ ## Capability Assessment Template
461
+
462
+ ### 1. Capability Definition
463
+ - What capability do we need?
464
+ - Is this core (competitive differentiator) or context (necessary but not differentiating)?
465
+ - What is the business impact of not having this capability?
466
+
467
+ ### 2. Requirements (MoSCoW)
468
+ - Must Have: [list non-negotiable requirements]
469
+ - Should Have: [list important but flexible requirements]
470
+ - Could Have: [list nice-to-have requirements]
471
+ - Won't Have: [list explicitly excluded requirements]
472
+
473
+ ### 3. Market Scan
474
+ - Commercial SaaS options evaluated: [minimum 3]
475
+ - Open-source options evaluated: [minimum 2]
476
+ - For each option:
477
+ - Functional fit (% of Must Have covered)
478
+ - Integration complexity (API quality, SDK availability)
479
+ - Pricing at current and projected scale
480
+ - Vendor viability assessment
481
+ - Data portability and exit cost
482
+
483
+ ### 4. TCO Comparison (3-year window)
484
+ - Build: [development + maintenance + opportunity cost]
485
+ - Buy (option A): [subscription + integration + migration risk]
486
+ - Buy (option B): [subscription + integration + migration risk]
487
+ - Hybrid: [subscription + custom extension development]
488
+
489
+ ### 5. Recommendation
490
+ - Recommended approach: [Build / Buy / Hybrid]
491
+ - Primary justification: [1-2 sentences]
492
+ - Risk mitigation plan: [vendor exit plan or build kill criteria]
493
+ - Timeline and resource requirements: [estimate]
494
+ ```
495
+
496
+ ### Phase 2: Proof of Concept (1-2 weeks)
497
+
498
+ For buy decisions, run a PoC with the top 1-2 vendors:
499
+
500
+ ```typescript
501
+ // Example: Evaluating a payment provider
502
+ // Goal: Validate integration complexity, API ergonomics, and feature coverage
503
+
504
+ // 1. Set up sandbox/test environment
505
+ // 2. Implement core flows: charge, refund, webhook handling
506
+ // 3. Measure: integration time, documentation quality, error handling
507
+ // 4. Test edge cases: failed payments, partial refunds, currency conversion
508
+ // 5. Evaluate: dashboard quality, reporting capabilities, support responsiveness
509
+
510
+ // Integration architecture using adapter pattern:
511
+ interface PaymentPort {
512
+ createCharge(request: ChargeRequest): Promise<ChargeResult>;
513
+ processRefund(chargeId: string, amount: Money): Promise<RefundResult>;
514
+ handleWebhook(payload: unknown, signature: string): Promise<WebhookEvent>;
515
+ }
516
+
517
+ // Vendor-specific adapter (replaceable without touching domain code)
518
+ class StripeAdapter implements PaymentPort {
519
+ constructor(private stripe: Stripe) {}
520
+
521
+ async createCharge(request: ChargeRequest): Promise<ChargeResult> {
522
+ const intent = await this.stripe.paymentIntents.create({
523
+ amount: request.amount.cents,
524
+ currency: request.amount.currency,
525
+ payment_method: request.methodId,
526
+ confirm: true,
527
+ });
528
+ return this.mapToChargeResult(intent);
529
+ }
530
+
531
+ async processRefund(chargeId: string, amount: Money): Promise<RefundResult> {
532
+ const refund = await this.stripe.refunds.create({
533
+ payment_intent: chargeId,
534
+ amount: amount.cents,
535
+ });
536
+ return this.mapToRefundResult(refund);
537
+ }
538
+
539
+ async handleWebhook(payload: unknown, signature: string): Promise<WebhookEvent> {
540
+ const event = this.stripe.webhooks.constructEvent(
541
+ payload as string, signature, this.webhookSecret
542
+ );
543
+ return this.mapToWebhookEvent(event);
544
+ }
545
+ }
546
+
547
+ // Domain code uses only PaymentPort — never Stripe types directly
548
+ class OrderService {
549
+ constructor(private payments: PaymentPort) {}
550
+
551
+ async checkout(order: Order): Promise<CheckoutResult> {
552
+ const charge = await this.payments.createCharge({
553
+ amount: order.total,
554
+ methodId: order.paymentMethodId,
555
+ });
556
+ // Domain logic here — completely vendor-agnostic
557
+ }
558
+ }
559
+ ```
560
+
561
+ ### Phase 3: Integration and Rollout (2-4 weeks)
562
+
563
+ For the selected vendor:
564
+
565
+ 1. **Implement the adapter pattern** — Vendor-specific code lives exclusively in adapter classes. Domain code depends on your interfaces, never on vendor types.
566
+ 2. **Set up data synchronization** — Critical entities (users, transactions, subscriptions) are mirrored to your own database via webhooks.
567
+ 3. **Configure monitoring** — Track vendor API latency, error rates, and availability as first-class metrics in your observability stack.
568
+ 4. **Document the exit plan** — Before going to production, write the migration runbook for switching to an alternative vendor.
569
+ 5. **Gradual rollout** — Use feature flags to roll out the vendor integration to a subset of users first. Monitor for integration issues before full rollout.
570
+
571
+ ---
572
+
573
+ ## Anti-Patterns Checklist
574
+
575
+ Use this checklist in architecture reviews to catch common build vs buy mistakes:
576
+
577
+ - [ ] **Resume-driven development** — Is the team building this because it is technically interesting rather than business-justified?
578
+ - [ ] **NIH syndrome** — Has the team evaluated at least 3 external solutions before proposing to build?
579
+ - [ ] **Premature optimization** — Is the team building for hypothetical future scale rather than current reality?
580
+ - [ ] **Missing TCO analysis** — Does the build proposal include maintenance cost estimates for years 2-5?
581
+ - [ ] **Missing opportunity cost** — Does the analysis account for what the team will not build while building this?
582
+ - [ ] **Single-vendor evaluation** — Did the team try one vendor, find it lacking, and conclude "we need to build"?
583
+ - [ ] **Over-specified requirements** — Are requirements genuinely non-negotiable, or could they be relaxed to enable a buy solution?
584
+ - [ ] **No kill criteria** — If building, are there defined conditions under which the team will stop and switch to buying?
585
+ - [ ] **No exit plan** — If buying, is there a documented plan for migrating away from the vendor?
586
+ - [ ] **Sunk cost fallacy** — Is the team continuing a build because of past investment rather than future value?
587
+
588
+ ---
589
+
590
+ ## Key Takeaways
591
+
592
+ 1. **Default to buy for context, build for core.** If a capability is not your competitive differentiator, you should almost certainly buy it.
593
+
594
+ 2. **The real cost of building is 5-10x the initial estimate.** 78% of TCO accrues post-launch. Factor in maintenance, security, on-call, and opportunity cost.
595
+
596
+ 3. **"We need customization" is usually wrong.** Most SaaS covers 90% of requirements. Building from scratch for the remaining 10% is rarely rational.
597
+
598
+ 4. **Use the adapter pattern for all vendor integrations.** Vendor-specific code in adapter classes, domain code depends on your interfaces. This makes vendor swaps tractable.
599
+
600
+ 5. **Store canonical data in your own database.** Never let a vendor be the sole owner of your critical data. Mirror it locally via webhooks.
601
+
602
+ 6. **Define kill criteria before building and exit plans before buying.** Without these, build projects become zombies and vendor dependencies become traps.
603
+
604
+ 7. **Revisit decisions every 18-24 months.** The vendor landscape evolves. Yesterday's build-only capability may be today's commodity SaaS.
605
+
606
+ 8. **Opportunity cost is the largest hidden cost.** Every month spent building commodity infrastructure is a month not spent on your core product.
607
+
608
+ ---
609
+
610
+ ## Cross-References
611
+
612
+ - **[Technology Selection](../foundations/architectural-thinking.md)** — Broader framework for evaluating technology choices beyond build vs buy.
613
+ - **[Architecture Decision Records](../foundations/architectural-thinking.md)** — Document build vs buy decisions as ADRs for future reference and institutional learning.
614
+ - **[Third-Party Integration](../integration/api-design-rest.md)** — API design patterns for integrating with vendor services.
615
+ - **[Hexagonal / Clean Architecture](../patterns/hexagonal-clean-architecture.md)** — The adapter pattern that enables vendor-agnostic integration architecture.
616
+ - **[Domain-Driven Design](../foundations/domain-driven-design.md)** — Core vs context aligns with DDD's bounded context concept; vendor integrations belong in anti-corruption layers.
@@ -0,0 +1,23 @@
1
+ # Directory Purpose
2
+
3
+ The `decisions` directory provides frameworks and methodologies for making, documenting, and evaluating strategic architectural choices.
4
+
5
+ # Key Concepts
6
+
7
+ - Documenting system changes
8
+ - Evaluating third-party solutions
9
+ - Migrating legacy architectures
10
+ - Standardizing technology stacks
11
+
12
+ # File Map
13
+
14
+ - `architecture-decision-records.md` — how to write and maintain ADRs
15
+ - `build-vs-buy.md` — frameworks for deciding whether to build or integrate
16
+ - `monolith-to-microservices.md` — strategies for breaking down monoliths
17
+ - `technology-selection.md` — choosing frameworks, languages, and tools
18
+
19
+ # Reading Guide
20
+
21
+ If introducing a new tool → read `technology-selection.md`
22
+ If recording a system change → read `architecture-decision-records.md`
23
+ If splitting a monolithic app → read `monolith-to-microservices.md`