@ruaruababa/vibe-kit 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 (462) hide show
  1. package/CATALOG.md +317 -0
  2. package/README.md +121 -0
  3. package/aliases.json +65 -0
  4. package/bin/vibe.js +2 -0
  5. package/bundles.json +265 -0
  6. package/catalog.json +1560 -0
  7. package/dist/antigravity-skills/bin/cli.js +438 -0
  8. package/dist/antigravity-skills/lib/skill-utils.js +158 -0
  9. package/dist/antigravity-skills/scripts/build-catalog.js +305 -0
  10. package/dist/antigravity-skills/scripts/normalize-frontmatter.js +144 -0
  11. package/dist/antigravity-skills/scripts/validate-skills.js +230 -0
  12. package/dist/bin/vibe.js +2 -0
  13. package/dist/dist/src/cli/index.js +26 -0
  14. package/dist/lib/skill-utils.js +158 -0
  15. package/dist/scripts/build-catalog.js +50 -0
  16. package/dist/scripts/normalize-frontmatter.js +144 -0
  17. package/dist/scripts/validate-skills.js +56 -0
  18. package/dist/src/cli/index.js +146 -0
  19. package/dist/src/types/index.js +13 -0
  20. package/dist/src/utils/fs.js +1 -0
  21. package/package.json +43 -0
  22. package/skills/accessibility-compliance-accessibility-audit/SKILL.md +42 -0
  23. package/skills/accessibility-compliance-accessibility-audit/resources/implementation-playbook.md +502 -0
  24. package/skills/agent-orchestration-improve-agent/SKILL.md +349 -0
  25. package/skills/agent-orchestration-multi-agent-optimize/SKILL.md +239 -0
  26. package/skills/agent-orchestrator/SKILL.md +24 -0
  27. package/skills/ai-engineer/SKILL.md +171 -0
  28. package/skills/airflow-dag-patterns/SKILL.md +41 -0
  29. package/skills/airflow-dag-patterns/resources/implementation-playbook.md +509 -0
  30. package/skills/angular-migration/SKILL.md +428 -0
  31. package/skills/anti-reversing-techniques/SKILL.md +42 -0
  32. package/skills/anti-reversing-techniques/resources/implementation-playbook.md +539 -0
  33. package/skills/api-design-principles/SKILL.md +37 -0
  34. package/skills/api-design-principles/assets/api-design-checklist.md +155 -0
  35. package/skills/api-design-principles/assets/rest-api-template.py +182 -0
  36. package/skills/api-design-principles/references/graphql-schema-design.md +583 -0
  37. package/skills/api-design-principles/references/rest-best-practices.md +408 -0
  38. package/skills/api-design-principles/resources/implementation-playbook.md +513 -0
  39. package/skills/api-documenter/SKILL.md +184 -0
  40. package/skills/api-testing-observability-api-mock/SKILL.md +46 -0
  41. package/skills/api-testing-observability-api-mock/resources/implementation-playbook.md +1327 -0
  42. package/skills/application-performance-performance-optimization/SKILL.md +154 -0
  43. package/skills/architect-review/SKILL.md +174 -0
  44. package/skills/architecture-decision-records/SKILL.md +441 -0
  45. package/skills/architecture-patterns/SKILL.md +37 -0
  46. package/skills/architecture-patterns/resources/implementation-playbook.md +479 -0
  47. package/skills/arm-cortex-expert/SKILL.md +306 -0
  48. package/skills/async-python-patterns/SKILL.md +39 -0
  49. package/skills/async-python-patterns/resources/implementation-playbook.md +678 -0
  50. package/skills/attack-tree-construction/SKILL.md +38 -0
  51. package/skills/attack-tree-construction/resources/implementation-playbook.md +671 -0
  52. package/skills/auth-implementation-patterns/SKILL.md +39 -0
  53. package/skills/auth-implementation-patterns/resources/implementation-playbook.md +618 -0
  54. package/skills/backend-architect/SKILL.md +333 -0
  55. package/skills/backend-development-feature-development/SKILL.md +180 -0
  56. package/skills/backend-security-coder/SKILL.md +156 -0
  57. package/skills/backtesting-frameworks/SKILL.md +39 -0
  58. package/skills/backtesting-frameworks/resources/implementation-playbook.md +647 -0
  59. package/skills/bash-defensive-patterns/SKILL.md +43 -0
  60. package/skills/bash-defensive-patterns/resources/implementation-playbook.md +517 -0
  61. package/skills/bash-pro/SKILL.md +310 -0
  62. package/skills/bats-testing-patterns/SKILL.md +34 -0
  63. package/skills/bats-testing-patterns/resources/implementation-playbook.md +614 -0
  64. package/skills/bazel-build-optimization/SKILL.md +397 -0
  65. package/skills/billing-automation/SKILL.md +42 -0
  66. package/skills/billing-automation/resources/implementation-playbook.md +544 -0
  67. package/skills/binary-analysis-patterns/SKILL.md +450 -0
  68. package/skills/blockchain-developer/SKILL.md +208 -0
  69. package/skills/business-analyst/SKILL.md +182 -0
  70. package/skills/c-pro/SKILL.md +56 -0
  71. package/skills/c4-architecture-c4-architecture/SKILL.md +389 -0
  72. package/skills/c4-code/SKILL.md +244 -0
  73. package/skills/c4-component/SKILL.md +153 -0
  74. package/skills/c4-container/SKILL.md +171 -0
  75. package/skills/c4-context/SKILL.md +150 -0
  76. package/skills/changelog-automation/SKILL.md +38 -0
  77. package/skills/changelog-automation/resources/implementation-playbook.md +538 -0
  78. package/skills/cicd-automation-workflow-automate/SKILL.md +51 -0
  79. package/skills/cicd-automation-workflow-automate/resources/implementation-playbook.md +1333 -0
  80. package/skills/clean-markdown/SKILL.md +23 -0
  81. package/skills/cloud-architect/SKILL.md +135 -0
  82. package/skills/code-documentation-code-explain/SKILL.md +46 -0
  83. package/skills/code-documentation-code-explain/resources/implementation-playbook.md +802 -0
  84. package/skills/code-documentation-doc-generate/SKILL.md +48 -0
  85. package/skills/code-documentation-doc-generate/resources/implementation-playbook.md +640 -0
  86. package/skills/code-refactoring-context-restore/SKILL.md +179 -0
  87. package/skills/code-refactoring-refactor-clean/SKILL.md +51 -0
  88. package/skills/code-refactoring-refactor-clean/resources/implementation-playbook.md +879 -0
  89. package/skills/code-refactoring-tech-debt/SKILL.md +386 -0
  90. package/skills/code-review-ai-ai-review/SKILL.md +450 -0
  91. package/skills/code-review-excellence/SKILL.md +40 -0
  92. package/skills/code-review-excellence/resources/implementation-playbook.md +515 -0
  93. package/skills/code-reviewer/SKILL.md +178 -0
  94. package/skills/codebase-cleanup-deps-audit/SKILL.md +51 -0
  95. package/skills/codebase-cleanup-deps-audit/resources/implementation-playbook.md +766 -0
  96. package/skills/codebase-cleanup-refactor-clean/SKILL.md +51 -0
  97. package/skills/codebase-cleanup-refactor-clean/resources/implementation-playbook.md +879 -0
  98. package/skills/codebase-cleanup-tech-debt/SKILL.md +386 -0
  99. package/skills/competitive-landscape/SKILL.md +34 -0
  100. package/skills/competitive-landscape/resources/implementation-playbook.md +494 -0
  101. package/skills/comprehensive-review-full-review/SKILL.md +146 -0
  102. package/skills/comprehensive-review-pr-enhance/SKILL.md +46 -0
  103. package/skills/comprehensive-review-pr-enhance/resources/implementation-playbook.md +691 -0
  104. package/skills/conductor-implement/SKILL.md +388 -0
  105. package/skills/conductor-manage/SKILL.md +39 -0
  106. package/skills/conductor-manage/resources/implementation-playbook.md +1120 -0
  107. package/skills/conductor-new-track/SKILL.md +433 -0
  108. package/skills/conductor-revert/SKILL.md +372 -0
  109. package/skills/conductor-setup/SKILL.md +426 -0
  110. package/skills/conductor-status/SKILL.md +338 -0
  111. package/skills/conductor-validator/SKILL.md +62 -0
  112. package/skills/content-marketer/SKILL.md +170 -0
  113. package/skills/context-driven-development/SKILL.md +400 -0
  114. package/skills/context-management-context-restore/SKILL.md +179 -0
  115. package/skills/context-management-context-save/SKILL.md +177 -0
  116. package/skills/context-manager/SKILL.md +185 -0
  117. package/skills/cost-optimization/SKILL.md +286 -0
  118. package/skills/cpp-pro/SKILL.md +59 -0
  119. package/skills/cqrs-implementation/SKILL.md +35 -0
  120. package/skills/cqrs-implementation/resources/implementation-playbook.md +540 -0
  121. package/skills/csharp-pro/SKILL.md +59 -0
  122. package/skills/customer-support/SKILL.md +170 -0
  123. package/skills/data-engineer/SKILL.md +224 -0
  124. package/skills/data-engineering-data-driven-feature/SKILL.md +182 -0
  125. package/skills/data-engineering-data-pipeline/SKILL.md +201 -0
  126. package/skills/data-quality-frameworks/SKILL.md +40 -0
  127. package/skills/data-quality-frameworks/resources/implementation-playbook.md +573 -0
  128. package/skills/data-scientist/SKILL.md +199 -0
  129. package/skills/data-storytelling/SKILL.md +465 -0
  130. package/skills/database-admin/SKILL.md +165 -0
  131. package/skills/database-architect/SKILL.md +268 -0
  132. package/skills/database-cloud-optimization-cost-optimize/SKILL.md +44 -0
  133. package/skills/database-cloud-optimization-cost-optimize/resources/implementation-playbook.md +1441 -0
  134. package/skills/database-migration/SKILL.md +436 -0
  135. package/skills/database-migrations-migration-observability/SKILL.md +420 -0
  136. package/skills/database-migrations-sql-migrations/SKILL.md +53 -0
  137. package/skills/database-migrations-sql-migrations/resources/implementation-playbook.md +499 -0
  138. package/skills/database-optimizer/SKILL.md +167 -0
  139. package/skills/dbt-transformation-patterns/SKILL.md +34 -0
  140. package/skills/dbt-transformation-patterns/resources/implementation-playbook.md +547 -0
  141. package/skills/debugger/SKILL.md +49 -0
  142. package/skills/debugging-strategies/SKILL.md +34 -0
  143. package/skills/debugging-strategies/resources/implementation-playbook.md +511 -0
  144. package/skills/debugging-toolkit-smart-debug/SKILL.md +197 -0
  145. package/skills/defi-protocol-templates/SKILL.md +466 -0
  146. package/skills/dependency-management-deps-audit/SKILL.md +44 -0
  147. package/skills/dependency-management-deps-audit/resources/implementation-playbook.md +766 -0
  148. package/skills/dependency-upgrade/SKILL.md +421 -0
  149. package/skills/deployment-engineer/SKILL.md +170 -0
  150. package/skills/deployment-pipeline-design/SKILL.md +371 -0
  151. package/skills/deployment-validation-config-validate/SKILL.md +496 -0
  152. package/skills/devops-troubleshooter/SKILL.md +161 -0
  153. package/skills/distributed-debugging-debug-trace/SKILL.md +44 -0
  154. package/skills/distributed-debugging-debug-trace/resources/implementation-playbook.md +1307 -0
  155. package/skills/distributed-tracing/SKILL.md +450 -0
  156. package/skills/django-pro/SKILL.md +180 -0
  157. package/skills/docs-architect/SKILL.md +98 -0
  158. package/skills/documentation-generation-doc-generate/SKILL.md +48 -0
  159. package/skills/documentation-generation-doc-generate/resources/implementation-playbook.md +640 -0
  160. package/skills/dotnet-architect/SKILL.md +197 -0
  161. package/skills/dotnet-backend-patterns/SKILL.md +37 -0
  162. package/skills/dotnet-backend-patterns/assets/repository-template.cs +523 -0
  163. package/skills/dotnet-backend-patterns/assets/service-template.cs +336 -0
  164. package/skills/dotnet-backend-patterns/references/dapper-patterns.md +544 -0
  165. package/skills/dotnet-backend-patterns/references/ef-core-best-practices.md +355 -0
  166. package/skills/dotnet-backend-patterns/resources/implementation-playbook.md +799 -0
  167. package/skills/dummy-skill/SKILL.md +5 -0
  168. package/skills/dx-optimizer/SKILL.md +83 -0
  169. package/skills/e2e-testing-patterns/SKILL.md +41 -0
  170. package/skills/e2e-testing-patterns/resources/implementation-playbook.md +531 -0
  171. package/skills/elixir-pro/SKILL.md +59 -0
  172. package/skills/embedding-strategies/SKILL.md +491 -0
  173. package/skills/employment-contract-templates/SKILL.md +39 -0
  174. package/skills/employment-contract-templates/resources/implementation-playbook.md +493 -0
  175. package/skills/error-debugging-error-analysis/SKILL.md +47 -0
  176. package/skills/error-debugging-error-analysis/resources/implementation-playbook.md +1143 -0
  177. package/skills/error-debugging-error-trace/SKILL.md +43 -0
  178. package/skills/error-debugging-error-trace/resources/implementation-playbook.md +1361 -0
  179. package/skills/error-debugging-multi-agent-review/SKILL.md +216 -0
  180. package/skills/error-detective/SKILL.md +53 -0
  181. package/skills/error-diagnostics-error-analysis/SKILL.md +47 -0
  182. package/skills/error-diagnostics-error-analysis/resources/implementation-playbook.md +1143 -0
  183. package/skills/error-diagnostics-error-trace/SKILL.md +48 -0
  184. package/skills/error-diagnostics-error-trace/resources/implementation-playbook.md +1371 -0
  185. package/skills/error-diagnostics-smart-debug/SKILL.md +197 -0
  186. package/skills/error-handling-patterns/SKILL.md +35 -0
  187. package/skills/error-handling-patterns/resources/implementation-playbook.md +635 -0
  188. package/skills/event-sourcing-architect/SKILL.md +58 -0
  189. package/skills/event-store-design/SKILL.md +449 -0
  190. package/skills/fastapi-pro/SKILL.md +192 -0
  191. package/skills/fastapi-templates/SKILL.md +32 -0
  192. package/skills/fastapi-templates/resources/implementation-playbook.md +566 -0
  193. package/skills/final-test/SKILL.md +5 -0
  194. package/skills/firmware-analyst/SKILL.md +320 -0
  195. package/skills/flutter-expert/SKILL.md +200 -0
  196. package/skills/framework-migration-code-migrate/SKILL.md +48 -0
  197. package/skills/framework-migration-code-migrate/resources/implementation-playbook.md +1052 -0
  198. package/skills/framework-migration-deps-upgrade/SKILL.md +48 -0
  199. package/skills/framework-migration-deps-upgrade/resources/implementation-playbook.md +755 -0
  200. package/skills/framework-migration-legacy-modernize/SKILL.md +132 -0
  201. package/skills/frontend-developer/SKILL.md +171 -0
  202. package/skills/frontend-mobile-development-component-scaffold/SKILL.md +403 -0
  203. package/skills/frontend-mobile-security-xss-scan/SKILL.md +322 -0
  204. package/skills/frontend-security-coder/SKILL.md +170 -0
  205. package/skills/full-stack-orchestration-full-stack-feature/SKILL.md +135 -0
  206. package/skills/gdpr-data-handling/SKILL.md +33 -0
  207. package/skills/gdpr-data-handling/resources/implementation-playbook.md +615 -0
  208. package/skills/git-advanced-workflows/SKILL.md +412 -0
  209. package/skills/git-pr-workflows-git-workflow/SKILL.md +140 -0
  210. package/skills/git-pr-workflows-onboard/SKILL.md +416 -0
  211. package/skills/git-pr-workflows-pr-enhance/SKILL.md +48 -0
  212. package/skills/git-pr-workflows-pr-enhance/resources/implementation-playbook.md +701 -0
  213. package/skills/github-actions-templates/SKILL.md +345 -0
  214. package/skills/gitlab-ci-patterns/SKILL.md +283 -0
  215. package/skills/gitops-workflow/SKILL.md +303 -0
  216. package/skills/gitops-workflow/references/argocd-setup.md +134 -0
  217. package/skills/gitops-workflow/references/sync-policies.md +131 -0
  218. package/skills/go-concurrency-patterns/SKILL.md +33 -0
  219. package/skills/go-concurrency-patterns/resources/implementation-playbook.md +654 -0
  220. package/skills/godot-gdscript-patterns/SKILL.md +33 -0
  221. package/skills/godot-gdscript-patterns/resources/implementation-playbook.md +804 -0
  222. package/skills/golang-pro/SKILL.md +179 -0
  223. package/skills/grafana-dashboards/SKILL.md +381 -0
  224. package/skills/graphql-architect/SKILL.md +182 -0
  225. package/skills/haskell-pro/SKILL.md +56 -0
  226. package/skills/helm-chart-scaffolding/SKILL.md +34 -0
  227. package/skills/helm-chart-scaffolding/assets/Chart.yaml.template +42 -0
  228. package/skills/helm-chart-scaffolding/assets/values.yaml.template +185 -0
  229. package/skills/helm-chart-scaffolding/references/chart-structure.md +500 -0
  230. package/skills/helm-chart-scaffolding/resources/implementation-playbook.md +543 -0
  231. package/skills/helm-chart-scaffolding/scripts/validate-chart.sh +244 -0
  232. package/skills/hr-pro/SKILL.md +126 -0
  233. package/skills/hybrid-cloud-architect/SKILL.md +168 -0
  234. package/skills/hybrid-cloud-networking/SKILL.md +238 -0
  235. package/skills/hybrid-search-implementation/SKILL.md +32 -0
  236. package/skills/hybrid-search-implementation/resources/implementation-playbook.md +567 -0
  237. package/skills/incident-responder/SKILL.md +213 -0
  238. package/skills/incident-response-incident-response/SKILL.md +168 -0
  239. package/skills/incident-response-smart-fix/SKILL.md +29 -0
  240. package/skills/incident-response-smart-fix/resources/implementation-playbook.md +838 -0
  241. package/skills/incident-runbook-templates/SKILL.md +395 -0
  242. package/skills/ios-developer/SKILL.md +219 -0
  243. package/skills/istio-traffic-management/SKILL.md +337 -0
  244. package/skills/java-pro/SKILL.md +177 -0
  245. package/skills/javascript-pro/SKILL.md +57 -0
  246. package/skills/javascript-testing-patterns/SKILL.md +35 -0
  247. package/skills/javascript-testing-patterns/resources/implementation-playbook.md +1024 -0
  248. package/skills/javascript-typescript-typescript-scaffold/SKILL.md +361 -0
  249. package/skills/julia-pro/SKILL.md +209 -0
  250. package/skills/k8s-manifest-generator/SKILL.md +35 -0
  251. package/skills/k8s-manifest-generator/assets/configmap-template.yaml +296 -0
  252. package/skills/k8s-manifest-generator/assets/deployment-template.yaml +203 -0
  253. package/skills/k8s-manifest-generator/assets/service-template.yaml +171 -0
  254. package/skills/k8s-manifest-generator/references/deployment-spec.md +753 -0
  255. package/skills/k8s-manifest-generator/references/service-spec.md +724 -0
  256. package/skills/k8s-manifest-generator/resources/implementation-playbook.md +510 -0
  257. package/skills/k8s-security-policies/SKILL.md +346 -0
  258. package/skills/k8s-security-policies/assets/network-policy-template.yaml +177 -0
  259. package/skills/k8s-security-policies/references/rbac-patterns.md +187 -0
  260. package/skills/kpi-dashboard-design/SKILL.md +440 -0
  261. package/skills/kubernetes-architect/SKILL.md +170 -0
  262. package/skills/langchain-architecture/SKILL.md +350 -0
  263. package/skills/legacy-modernizer/SKILL.md +53 -0
  264. package/skills/legal-advisor/SKILL.md +70 -0
  265. package/skills/linkerd-patterns/SKILL.md +321 -0
  266. package/skills/llm-application-dev-ai-assistant/SKILL.md +35 -0
  267. package/skills/llm-application-dev-ai-assistant/resources/implementation-playbook.md +1236 -0
  268. package/skills/llm-application-dev-langchain-agent/SKILL.md +246 -0
  269. package/skills/llm-application-dev-prompt-optimize/SKILL.md +37 -0
  270. package/skills/llm-application-dev-prompt-optimize/resources/implementation-playbook.md +591 -0
  271. package/skills/llm-evaluation/SKILL.md +483 -0
  272. package/skills/machine-learning-ops-ml-pipeline/SKILL.md +314 -0
  273. package/skills/malware-analyst/SKILL.md +247 -0
  274. package/skills/market-sizing-analysis/SKILL.md +425 -0
  275. package/skills/market-sizing-analysis/examples/saas-market-sizing.md +349 -0
  276. package/skills/market-sizing-analysis/references/data-sources.md +360 -0
  277. package/skills/memory-forensics/SKILL.md +491 -0
  278. package/skills/memory-safety-patterns/SKILL.md +33 -0
  279. package/skills/memory-safety-patterns/resources/implementation-playbook.md +603 -0
  280. package/skills/mermaid-expert/SKILL.md +59 -0
  281. package/skills/microservices-patterns/SKILL.md +35 -0
  282. package/skills/microservices-patterns/resources/implementation-playbook.md +607 -0
  283. package/skills/minecraft-bukkit-pro/SKILL.md +126 -0
  284. package/skills/ml-engineer/SKILL.md +168 -0
  285. package/skills/ml-pipeline-workflow/SKILL.md +257 -0
  286. package/skills/mlops-engineer/SKILL.md +219 -0
  287. package/skills/mobile-developer/SKILL.md +205 -0
  288. package/skills/mobile-security-coder/SKILL.md +184 -0
  289. package/skills/modern-javascript-patterns/SKILL.md +35 -0
  290. package/skills/modern-javascript-patterns/resources/implementation-playbook.md +910 -0
  291. package/skills/monorepo-architect/SKILL.md +61 -0
  292. package/skills/monorepo-management/SKILL.md +35 -0
  293. package/skills/monorepo-management/resources/implementation-playbook.md +621 -0
  294. package/skills/mtls-configuration/SKILL.md +359 -0
  295. package/skills/multi-cloud-architecture/SKILL.md +189 -0
  296. package/skills/multi-platform-apps-multi-platform/SKILL.md +203 -0
  297. package/skills/network-engineer/SKILL.md +169 -0
  298. package/skills/nextjs-app-router-patterns/SKILL.md +33 -0
  299. package/skills/nextjs-app-router-patterns/resources/implementation-playbook.md +543 -0
  300. package/skills/nft-standards/SKILL.md +395 -0
  301. package/skills/node-expert/SKILL.md +23 -0
  302. package/skills/nodejs-backend-patterns/SKILL.md +35 -0
  303. package/skills/nodejs-backend-patterns/resources/implementation-playbook.md +1019 -0
  304. package/skills/nx-workspace-patterns/SKILL.md +464 -0
  305. package/skills/observability-engineer/SKILL.md +237 -0
  306. package/skills/observability-monitoring-monitor-setup/SKILL.md +48 -0
  307. package/skills/observability-monitoring-monitor-setup/resources/implementation-playbook.md +505 -0
  308. package/skills/observability-monitoring-slo-implement/SKILL.md +43 -0
  309. package/skills/observability-monitoring-slo-implement/resources/implementation-playbook.md +1077 -0
  310. package/skills/on-call-handoff-patterns/SKILL.md +453 -0
  311. package/skills/openapi-spec-generation/SKILL.md +33 -0
  312. package/skills/openapi-spec-generation/resources/implementation-playbook.md +1027 -0
  313. package/skills/payment-integration/SKILL.md +77 -0
  314. package/skills/paypal-integration/SKILL.md +479 -0
  315. package/skills/pci-compliance/SKILL.md +478 -0
  316. package/skills/performance-engineer/SKILL.md +180 -0
  317. package/skills/performance-testing-review-ai-review/SKILL.md +450 -0
  318. package/skills/performance-testing-review-multi-agent-review/SKILL.md +216 -0
  319. package/skills/php-pro/SKILL.md +63 -0
  320. package/skills/posix-shell-pro/SKILL.md +304 -0
  321. package/skills/postgresql/SKILL.md +230 -0
  322. package/skills/postmortem-writing/SKILL.md +386 -0
  323. package/skills/projection-patterns/SKILL.md +33 -0
  324. package/skills/projection-patterns/resources/implementation-playbook.md +501 -0
  325. package/skills/prometheus-configuration/SKILL.md +404 -0
  326. package/skills/prompt-engineer/SKILL.md +272 -0
  327. package/skills/prompt-engineering-patterns/SKILL.md +213 -0
  328. package/skills/prompt-engineering-patterns/assets/few-shot-examples.json +106 -0
  329. package/skills/prompt-engineering-patterns/assets/prompt-template-library.md +246 -0
  330. package/skills/prompt-engineering-patterns/references/chain-of-thought.md +399 -0
  331. package/skills/prompt-engineering-patterns/references/few-shot-learning.md +369 -0
  332. package/skills/prompt-engineering-patterns/references/prompt-optimization.md +414 -0
  333. package/skills/prompt-engineering-patterns/references/prompt-templates.md +470 -0
  334. package/skills/prompt-engineering-patterns/references/system-prompts.md +189 -0
  335. package/skills/prompt-engineering-patterns/scripts/optimize-prompt.py +279 -0
  336. package/skills/protocol-reverse-engineering/SKILL.md +29 -0
  337. package/skills/protocol-reverse-engineering/resources/implementation-playbook.md +509 -0
  338. package/skills/python-development-python-scaffold/SKILL.md +331 -0
  339. package/skills/python-packaging/SKILL.md +36 -0
  340. package/skills/python-packaging/resources/implementation-playbook.md +869 -0
  341. package/skills/python-performance-optimization/SKILL.md +36 -0
  342. package/skills/python-performance-optimization/resources/implementation-playbook.md +868 -0
  343. package/skills/python-pro/SKILL.md +158 -0
  344. package/skills/python-testing-patterns/SKILL.md +37 -0
  345. package/skills/python-testing-patterns/resources/implementation-playbook.md +906 -0
  346. package/skills/quant-analyst/SKILL.md +53 -0
  347. package/skills/rag-implementation/SKILL.md +421 -0
  348. package/skills/react-modernization/SKILL.md +34 -0
  349. package/skills/react-modernization/resources/implementation-playbook.md +512 -0
  350. package/skills/react-native-architecture/SKILL.md +33 -0
  351. package/skills/react-native-architecture/resources/implementation-playbook.md +670 -0
  352. package/skills/react-state-management/SKILL.md +441 -0
  353. package/skills/reference-builder/SKILL.md +188 -0
  354. package/skills/reverse-engineer/SKILL.md +173 -0
  355. package/skills/risk-manager/SKILL.md +61 -0
  356. package/skills/risk-metrics-calculation/SKILL.md +33 -0
  357. package/skills/risk-metrics-calculation/resources/implementation-playbook.md +554 -0
  358. package/skills/ruby-pro/SKILL.md +56 -0
  359. package/skills/rust-async-patterns/SKILL.md +33 -0
  360. package/skills/rust-async-patterns/resources/implementation-playbook.md +516 -0
  361. package/skills/rust-pro/SKILL.md +178 -0
  362. package/skills/saga-orchestration/SKILL.md +496 -0
  363. package/skills/sales-automator/SKILL.md +55 -0
  364. package/skills/sast-configuration/SKILL.md +212 -0
  365. package/skills/scala-pro/SKILL.md +82 -0
  366. package/skills/screen-reader-testing/SKILL.md +33 -0
  367. package/skills/screen-reader-testing/resources/implementation-playbook.md +544 -0
  368. package/skills/search-specialist/SKILL.md +80 -0
  369. package/skills/secrets-management/SKILL.md +364 -0
  370. package/skills/security-auditor/SKILL.md +169 -0
  371. package/skills/security-compliance-compliance-check/SKILL.md +55 -0
  372. package/skills/security-compliance-compliance-check/resources/implementation-playbook.md +963 -0
  373. package/skills/security-requirement-extraction/SKILL.md +33 -0
  374. package/skills/security-requirement-extraction/resources/implementation-playbook.md +676 -0
  375. package/skills/security-scanning-security-dependencies/SKILL.md +43 -0
  376. package/skills/security-scanning-security-dependencies/resources/implementation-playbook.md +544 -0
  377. package/skills/security-scanning-security-hardening/SKILL.md +147 -0
  378. package/skills/security-scanning-security-sast/SKILL.md +495 -0
  379. package/skills/seo-authority-builder/SKILL.md +136 -0
  380. package/skills/seo-cannibalization-detector/SKILL.md +123 -0
  381. package/skills/seo-content-auditor/SKILL.md +83 -0
  382. package/skills/seo-content-planner/SKILL.md +108 -0
  383. package/skills/seo-content-refresher/SKILL.md +118 -0
  384. package/skills/seo-content-writer/SKILL.md +96 -0
  385. package/skills/seo-keyword-strategist/SKILL.md +95 -0
  386. package/skills/seo-meta-optimizer/SKILL.md +92 -0
  387. package/skills/seo-snippet-hunter/SKILL.md +114 -0
  388. package/skills/seo-structure-architect/SKILL.md +108 -0
  389. package/skills/service-mesh-expert/SKILL.md +58 -0
  390. package/skills/service-mesh-observability/SKILL.md +395 -0
  391. package/skills/shellcheck-configuration/SKILL.md +466 -0
  392. package/skills/similarity-search-patterns/SKILL.md +33 -0
  393. package/skills/similarity-search-patterns/resources/implementation-playbook.md +557 -0
  394. package/skills/slo-implementation/SKILL.md +341 -0
  395. package/skills/solidity-security/SKILL.md +34 -0
  396. package/skills/solidity-security/resources/implementation-playbook.md +524 -0
  397. package/skills/spark-optimization/SKILL.md +427 -0
  398. package/skills/sql-optimization-patterns/SKILL.md +35 -0
  399. package/skills/sql-optimization-patterns/resources/implementation-playbook.md +504 -0
  400. package/skills/sql-pro/SKILL.md +173 -0
  401. package/skills/startup-analyst/SKILL.md +328 -0
  402. package/skills/startup-business-analyst-business-case/SKILL.md +487 -0
  403. package/skills/startup-business-analyst-financial-projections/SKILL.md +353 -0
  404. package/skills/startup-business-analyst-market-opportunity/SKILL.md +240 -0
  405. package/skills/startup-financial-modeling/SKILL.md +467 -0
  406. package/skills/startup-metrics-framework/SKILL.md +34 -0
  407. package/skills/startup-metrics-framework/resources/implementation-playbook.md +500 -0
  408. package/skills/stride-analysis-patterns/SKILL.md +33 -0
  409. package/skills/stride-analysis-patterns/resources/implementation-playbook.md +655 -0
  410. package/skills/stripe-integration/SKILL.md +454 -0
  411. package/skills/systems-programming-rust-project/SKILL.md +440 -0
  412. package/skills/tailwind-design-system/SKILL.md +33 -0
  413. package/skills/tailwind-design-system/resources/implementation-playbook.md +665 -0
  414. package/skills/tdd-orchestrator/SKILL.md +205 -0
  415. package/skills/tdd-workflows-tdd-cycle/SKILL.md +221 -0
  416. package/skills/tdd-workflows-tdd-green/SKILL.md +73 -0
  417. package/skills/tdd-workflows-tdd-green/resources/implementation-playbook.md +870 -0
  418. package/skills/tdd-workflows-tdd-red/SKILL.md +164 -0
  419. package/skills/tdd-workflows-tdd-refactor/SKILL.md +187 -0
  420. package/skills/team-collaboration-issue/SKILL.md +37 -0
  421. package/skills/team-collaboration-issue/resources/implementation-playbook.md +640 -0
  422. package/skills/team-collaboration-standup-notes/SKILL.md +44 -0
  423. package/skills/team-collaboration-standup-notes/resources/implementation-playbook.md +768 -0
  424. package/skills/team-composition-analysis/SKILL.md +413 -0
  425. package/skills/temporal-python-pro/SKILL.md +370 -0
  426. package/skills/temporal-python-testing/SKILL.md +170 -0
  427. package/skills/temporal-python-testing/resources/integration-testing.md +455 -0
  428. package/skills/temporal-python-testing/resources/local-setup.md +553 -0
  429. package/skills/temporal-python-testing/resources/replay-testing.md +462 -0
  430. package/skills/temporal-python-testing/resources/unit-testing.md +328 -0
  431. package/skills/terraform-module-library/SKILL.md +261 -0
  432. package/skills/terraform-module-library/references/aws-modules.md +63 -0
  433. package/skills/terraform-specialist/SKILL.md +166 -0
  434. package/skills/test-automator/SKILL.md +224 -0
  435. package/skills/threat-mitigation-mapping/SKILL.md +33 -0
  436. package/skills/threat-mitigation-mapping/resources/implementation-playbook.md +744 -0
  437. package/skills/threat-modeling-expert/SKILL.md +60 -0
  438. package/skills/track-management/SKILL.md +38 -0
  439. package/skills/track-management/resources/implementation-playbook.md +591 -0
  440. package/skills/turborepo-caching/SKILL.md +419 -0
  441. package/skills/tutorial-engineer/SKILL.md +139 -0
  442. package/skills/typescript-advanced-types/SKILL.md +35 -0
  443. package/skills/typescript-advanced-types/resources/implementation-playbook.md +716 -0
  444. package/skills/typescript-pro/SKILL.md +55 -0
  445. package/skills/ui-minimal/SKILL.md +23 -0
  446. package/skills/ui-ux-designer/SKILL.md +209 -0
  447. package/skills/ui-visual-validator/SKILL.md +214 -0
  448. package/skills/unit-testing-test-generate/SKILL.md +319 -0
  449. package/skills/unity-developer/SKILL.md +230 -0
  450. package/skills/unity-ecs-patterns/SKILL.md +33 -0
  451. package/skills/unity-ecs-patterns/resources/implementation-playbook.md +625 -0
  452. package/skills/uv-package-manager/SKILL.md +37 -0
  453. package/skills/uv-package-manager/resources/implementation-playbook.md +830 -0
  454. package/skills/vector-database-engineer/SKILL.md +60 -0
  455. package/skills/vector-index-tuning/SKILL.md +42 -0
  456. package/skills/vector-index-tuning/resources/implementation-playbook.md +507 -0
  457. package/skills/wcag-audit-patterns/SKILL.md +41 -0
  458. package/skills/wcag-audit-patterns/resources/implementation-playbook.md +541 -0
  459. package/skills/web3-testing/SKILL.md +427 -0
  460. package/skills/workflow-orchestration-patterns/SKILL.md +333 -0
  461. package/skills/workflow-patterns/SKILL.md +38 -0
  462. package/skills/workflow-patterns/resources/implementation-playbook.md +621 -0
@@ -0,0 +1,1327 @@
1
+ # API Mocking Implementation Playbook
2
+
3
+ This file contains detailed patterns, checklists, and code samples referenced by the skill.
4
+
5
+ ## Detailed Steps
6
+
7
+ ### 1. Mock Server Setup
8
+
9
+ Create comprehensive mock server infrastructure:
10
+
11
+ **Mock Server Framework**
12
+
13
+ ```python
14
+ from typing import Dict, List, Any, Optional
15
+ import json
16
+ import asyncio
17
+ from datetime import datetime
18
+ from fastapi import FastAPI, Request, Response
19
+ import uvicorn
20
+
21
+ class MockAPIServer:
22
+ def __init__(self, config: Dict[str, Any]):
23
+ self.app = FastAPI(title="Mock API Server")
24
+ self.routes = {}
25
+ self.middleware = []
26
+ self.state_manager = StateManager()
27
+ self.scenario_manager = ScenarioManager()
28
+
29
+ def setup_mock_server(self):
30
+ """Setup comprehensive mock server"""
31
+ # Configure middleware
32
+ self._setup_middleware()
33
+
34
+ # Load mock definitions
35
+ self._load_mock_definitions()
36
+
37
+ # Setup dynamic routes
38
+ self._setup_dynamic_routes()
39
+
40
+ # Initialize scenarios
41
+ self._initialize_scenarios()
42
+
43
+ return self.app
44
+
45
+ def _setup_middleware(self):
46
+ """Configure server middleware"""
47
+ @self.app.middleware("http")
48
+ async def add_mock_headers(request: Request, call_next):
49
+ response = await call_next(request)
50
+ response.headers["X-Mock-Server"] = "true"
51
+ response.headers["X-Mock-Scenario"] = self.scenario_manager.current_scenario
52
+ return response
53
+
54
+ @self.app.middleware("http")
55
+ async def simulate_latency(request: Request, call_next):
56
+ # Simulate network latency
57
+ latency = self._calculate_latency(request.url.path)
58
+ await asyncio.sleep(latency / 1000) # Convert to seconds
59
+ response = await call_next(request)
60
+ return response
61
+
62
+ @self.app.middleware("http")
63
+ async def track_requests(request: Request, call_next):
64
+ # Track request for verification
65
+ self.state_manager.track_request({
66
+ 'method': request.method,
67
+ 'path': str(request.url.path),
68
+ 'headers': dict(request.headers),
69
+ 'timestamp': datetime.now()
70
+ })
71
+ response = await call_next(request)
72
+ return response
73
+
74
+ def _setup_dynamic_routes(self):
75
+ """Setup dynamic route handling"""
76
+ @self.app.api_route("/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "PATCH"])
77
+ async def handle_mock_request(path: str, request: Request):
78
+ # Find matching mock
79
+ mock = self._find_matching_mock(request.method, path, request)
80
+
81
+ if not mock:
82
+ return Response(
83
+ content=json.dumps({"error": "No mock found for this endpoint"}),
84
+ status_code=404,
85
+ media_type="application/json"
86
+ )
87
+
88
+ # Process mock response
89
+ response_data = await self._process_mock_response(mock, request)
90
+
91
+ return Response(
92
+ content=json.dumps(response_data['body']),
93
+ status_code=response_data['status'],
94
+ headers=response_data['headers'],
95
+ media_type="application/json"
96
+ )
97
+
98
+ async def _process_mock_response(self, mock: Dict[str, Any], request: Request):
99
+ """Process and generate mock response"""
100
+ # Check for conditional responses
101
+ if mock.get('conditions'):
102
+ for condition in mock['conditions']:
103
+ if self._evaluate_condition(condition, request):
104
+ return await self._generate_response(condition['response'], request)
105
+
106
+ # Use default response
107
+ return await self._generate_response(mock['response'], request)
108
+
109
+ def _generate_response(self, response_template: Dict[str, Any], request: Request):
110
+ """Generate response from template"""
111
+ response = {
112
+ 'status': response_template.get('status', 200),
113
+ 'headers': response_template.get('headers', {}),
114
+ 'body': self._process_response_body(response_template['body'], request)
115
+ }
116
+
117
+ # Apply response transformations
118
+ if response_template.get('transformations'):
119
+ response = self._apply_transformations(response, response_template['transformations'])
120
+
121
+ return response
122
+ ```
123
+
124
+ ### 2. Request/Response Stubbing
125
+
126
+ Implement flexible stubbing system:
127
+
128
+ **Stubbing Engine**
129
+
130
+ ```python
131
+ class StubbingEngine:
132
+ def __init__(self):
133
+ self.stubs = {}
134
+ self.matchers = self._initialize_matchers()
135
+
136
+ def create_stub(self, method: str, path: str, **kwargs):
137
+ """Create a new stub"""
138
+ stub_id = self._generate_stub_id()
139
+
140
+ stub = {
141
+ 'id': stub_id,
142
+ 'method': method,
143
+ 'path': path,
144
+ 'matchers': self._build_matchers(kwargs),
145
+ 'response': kwargs.get('response', {}),
146
+ 'priority': kwargs.get('priority', 0),
147
+ 'times': kwargs.get('times', -1), # -1 for unlimited
148
+ 'delay': kwargs.get('delay', 0),
149
+ 'scenario': kwargs.get('scenario', 'default')
150
+ }
151
+
152
+ self.stubs[stub_id] = stub
153
+ return stub_id
154
+
155
+ def _build_matchers(self, kwargs):
156
+ """Build request matchers"""
157
+ matchers = []
158
+
159
+ # Path parameter matching
160
+ if 'path_params' in kwargs:
161
+ matchers.append({
162
+ 'type': 'path_params',
163
+ 'params': kwargs['path_params']
164
+ })
165
+
166
+ # Query parameter matching
167
+ if 'query_params' in kwargs:
168
+ matchers.append({
169
+ 'type': 'query_params',
170
+ 'params': kwargs['query_params']
171
+ })
172
+
173
+ # Header matching
174
+ if 'headers' in kwargs:
175
+ matchers.append({
176
+ 'type': 'headers',
177
+ 'headers': kwargs['headers']
178
+ })
179
+
180
+ # Body matching
181
+ if 'body' in kwargs:
182
+ matchers.append({
183
+ 'type': 'body',
184
+ 'body': kwargs['body'],
185
+ 'match_type': kwargs.get('body_match_type', 'exact')
186
+ })
187
+
188
+ return matchers
189
+
190
+ def match_request(self, request: Dict[str, Any]):
191
+ """Find matching stub for request"""
192
+ candidates = []
193
+
194
+ for stub in self.stubs.values():
195
+ if self._matches_stub(request, stub):
196
+ candidates.append(stub)
197
+
198
+ # Sort by priority and return best match
199
+ if candidates:
200
+ return sorted(candidates, key=lambda x: x['priority'], reverse=True)[0]
201
+
202
+ return None
203
+
204
+ def _matches_stub(self, request: Dict[str, Any], stub: Dict[str, Any]):
205
+ """Check if request matches stub"""
206
+ # Check method
207
+ if request['method'] != stub['method']:
208
+ return False
209
+
210
+ # Check path
211
+ if not self._matches_path(request['path'], stub['path']):
212
+ return False
213
+
214
+ # Check all matchers
215
+ for matcher in stub['matchers']:
216
+ if not self._evaluate_matcher(request, matcher):
217
+ return False
218
+
219
+ # Check if stub is still valid
220
+ if stub['times'] == 0:
221
+ return False
222
+
223
+ return True
224
+
225
+ def create_dynamic_stub(self):
226
+ """Create dynamic stub with callbacks"""
227
+ return '''
228
+ class DynamicStub:
229
+ def __init__(self, path_pattern: str):
230
+ self.path_pattern = path_pattern
231
+ self.response_generator = None
232
+ self.state_modifier = None
233
+
234
+ def with_response_generator(self, generator):
235
+ """Set dynamic response generator"""
236
+ self.response_generator = generator
237
+ return self
238
+
239
+ def with_state_modifier(self, modifier):
240
+ """Set state modification callback"""
241
+ self.state_modifier = modifier
242
+ return self
243
+
244
+ async def process_request(self, request: Request, state: Dict[str, Any]):
245
+ """Process request dynamically"""
246
+ # Extract request data
247
+ request_data = {
248
+ 'method': request.method,
249
+ 'path': request.url.path,
250
+ 'headers': dict(request.headers),
251
+ 'query_params': dict(request.query_params),
252
+ 'body': await request.json() if request.method in ['POST', 'PUT'] else None
253
+ }
254
+
255
+ # Modify state if needed
256
+ if self.state_modifier:
257
+ state = self.state_modifier(state, request_data)
258
+
259
+ # Generate response
260
+ if self.response_generator:
261
+ response = self.response_generator(request_data, state)
262
+ else:
263
+ response = {'status': 200, 'body': {}}
264
+
265
+ return response, state
266
+
267
+ # Usage example
268
+ dynamic_stub = DynamicStub('/api/users/{user_id}')
269
+ dynamic_stub.with_response_generator(lambda req, state: {
270
+ 'status': 200,
271
+ 'body': {
272
+ 'id': req['path_params']['user_id'],
273
+ 'name': state.get('users', {}).get(req['path_params']['user_id'], 'Unknown'),
274
+ 'request_count': state.get('request_count', 0)
275
+ }
276
+ }).with_state_modifier(lambda state, req: {
277
+ **state,
278
+ 'request_count': state.get('request_count', 0) + 1
279
+ })
280
+ '''
281
+ ```
282
+
283
+ ### 3. Dynamic Data Generation
284
+
285
+ Generate realistic mock data:
286
+
287
+ **Mock Data Generator**
288
+
289
+ ```python
290
+ from faker import Faker
291
+ import random
292
+ from datetime import datetime, timedelta
293
+
294
+ class MockDataGenerator:
295
+ def __init__(self):
296
+ self.faker = Faker()
297
+ self.templates = {}
298
+ self.generators = self._init_generators()
299
+
300
+ def generate_data(self, schema: Dict[str, Any]):
301
+ """Generate data based on schema"""
302
+ if isinstance(schema, dict):
303
+ if '$ref' in schema:
304
+ # Reference to another schema
305
+ return self.generate_data(self.resolve_ref(schema['$ref']))
306
+
307
+ result = {}
308
+ for key, value in schema.items():
309
+ if key.startswith('$'):
310
+ continue
311
+ result[key] = self._generate_field(value)
312
+ return result
313
+
314
+ elif isinstance(schema, list):
315
+ # Generate array
316
+ count = random.randint(1, 10)
317
+ return [self.generate_data(schema[0]) for _ in range(count)]
318
+
319
+ else:
320
+ return schema
321
+
322
+ def _generate_field(self, field_schema: Dict[str, Any]):
323
+ """Generate field value based on schema"""
324
+ field_type = field_schema.get('type', 'string')
325
+
326
+ # Check for custom generator
327
+ if 'generator' in field_schema:
328
+ return self._use_custom_generator(field_schema['generator'])
329
+
330
+ # Check for enum
331
+ if 'enum' in field_schema:
332
+ return random.choice(field_schema['enum'])
333
+
334
+ # Generate based on type
335
+ generators = {
336
+ 'string': self._generate_string,
337
+ 'number': self._generate_number,
338
+ 'integer': self._generate_integer,
339
+ 'boolean': self._generate_boolean,
340
+ 'array': self._generate_array,
341
+ 'object': lambda s: self.generate_data(s)
342
+ }
343
+
344
+ generator = generators.get(field_type, self._generate_string)
345
+ return generator(field_schema)
346
+
347
+ def _generate_string(self, schema: Dict[str, Any]):
348
+ """Generate string value"""
349
+ # Check for format
350
+ format_type = schema.get('format', '')
351
+
352
+ format_generators = {
353
+ 'email': self.faker.email,
354
+ 'name': self.faker.name,
355
+ 'first_name': self.faker.first_name,
356
+ 'last_name': self.faker.last_name,
357
+ 'phone': self.faker.phone_number,
358
+ 'address': self.faker.address,
359
+ 'url': self.faker.url,
360
+ 'uuid': self.faker.uuid4,
361
+ 'date': lambda: self.faker.date().isoformat(),
362
+ 'datetime': lambda: self.faker.date_time().isoformat(),
363
+ 'password': lambda: self.faker.password()
364
+ }
365
+
366
+ if format_type in format_generators:
367
+ return format_generators[format_type]()
368
+
369
+ # Check for pattern
370
+ if 'pattern' in schema:
371
+ return self._generate_from_pattern(schema['pattern'])
372
+
373
+ # Default string generation
374
+ min_length = schema.get('minLength', 5)
375
+ max_length = schema.get('maxLength', 20)
376
+ return self.faker.text(max_nb_chars=random.randint(min_length, max_length))
377
+
378
+ def create_data_templates(self):
379
+ """Create reusable data templates"""
380
+ return {
381
+ 'user': {
382
+ 'id': {'type': 'string', 'format': 'uuid'},
383
+ 'username': {'type': 'string', 'generator': 'username'},
384
+ 'email': {'type': 'string', 'format': 'email'},
385
+ 'profile': {
386
+ 'type': 'object',
387
+ 'properties': {
388
+ 'firstName': {'type': 'string', 'format': 'first_name'},
389
+ 'lastName': {'type': 'string', 'format': 'last_name'},
390
+ 'avatar': {'type': 'string', 'format': 'url'},
391
+ 'bio': {'type': 'string', 'maxLength': 200}
392
+ }
393
+ },
394
+ 'createdAt': {'type': 'string', 'format': 'datetime'},
395
+ 'status': {'type': 'string', 'enum': ['active', 'inactive', 'suspended']}
396
+ },
397
+ 'product': {
398
+ 'id': {'type': 'string', 'format': 'uuid'},
399
+ 'name': {'type': 'string', 'generator': 'product_name'},
400
+ 'description': {'type': 'string', 'maxLength': 500},
401
+ 'price': {'type': 'number', 'minimum': 0.01, 'maximum': 9999.99},
402
+ 'category': {'type': 'string', 'enum': ['electronics', 'clothing', 'food', 'books']},
403
+ 'inStock': {'type': 'boolean'},
404
+ 'rating': {'type': 'number', 'minimum': 0, 'maximum': 5}
405
+ }
406
+ }
407
+
408
+ def generate_relational_data(self):
409
+ """Generate data with relationships"""
410
+ return '''
411
+ class RelationalDataGenerator:
412
+ def generate_related_entities(self, schema: Dict[str, Any], count: int):
413
+ """Generate related entities maintaining referential integrity"""
414
+ entities = {}
415
+
416
+ # First pass: generate primary entities
417
+ for entity_name, entity_schema in schema['entities'].items():
418
+ entities[entity_name] = []
419
+ for i in range(count):
420
+ entity = self.generate_entity(entity_schema)
421
+ entity['id'] = f"{entity_name}_{i}"
422
+ entities[entity_name].append(entity)
423
+
424
+ # Second pass: establish relationships
425
+ for relationship in schema.get('relationships', []):
426
+ self.establish_relationship(entities, relationship)
427
+
428
+ return entities
429
+
430
+ def establish_relationship(self, entities: Dict[str, List], relationship: Dict):
431
+ """Establish relationships between entities"""
432
+ source = relationship['source']
433
+ target = relationship['target']
434
+ rel_type = relationship['type']
435
+
436
+ if rel_type == 'one-to-many':
437
+ for source_entity in entities[source['entity']]:
438
+ # Select random targets
439
+ num_targets = random.randint(1, 5)
440
+ target_refs = random.sample(
441
+ entities[target['entity']],
442
+ min(num_targets, len(entities[target['entity']]))
443
+ )
444
+ source_entity[source['field']] = [t['id'] for t in target_refs]
445
+
446
+ elif rel_type == 'many-to-one':
447
+ for target_entity in entities[target['entity']]:
448
+ # Select one source
449
+ source_ref = random.choice(entities[source['entity']])
450
+ target_entity[target['field']] = source_ref['id']
451
+ '''
452
+ ```
453
+
454
+ ### 4. Mock Scenarios
455
+
456
+ Implement scenario-based mocking:
457
+
458
+ **Scenario Manager**
459
+
460
+ ```python
461
+ class ScenarioManager:
462
+ def __init__(self):
463
+ self.scenarios = {}
464
+ self.current_scenario = 'default'
465
+ self.scenario_states = {}
466
+
467
+ def define_scenario(self, name: str, definition: Dict[str, Any]):
468
+ """Define a mock scenario"""
469
+ self.scenarios[name] = {
470
+ 'name': name,
471
+ 'description': definition.get('description', ''),
472
+ 'initial_state': definition.get('initial_state', {}),
473
+ 'stubs': definition.get('stubs', []),
474
+ 'sequences': definition.get('sequences', []),
475
+ 'conditions': definition.get('conditions', [])
476
+ }
477
+
478
+ def create_test_scenarios(self):
479
+ """Create common test scenarios"""
480
+ return {
481
+ 'happy_path': {
482
+ 'description': 'All operations succeed',
483
+ 'stubs': [
484
+ {
485
+ 'path': '/api/auth/login',
486
+ 'response': {
487
+ 'status': 200,
488
+ 'body': {
489
+ 'token': 'valid_token',
490
+ 'user': {'id': '123', 'name': 'Test User'}
491
+ }
492
+ }
493
+ },
494
+ {
495
+ 'path': '/api/users/{id}',
496
+ 'response': {
497
+ 'status': 200,
498
+ 'body': {
499
+ 'id': '{id}',
500
+ 'name': 'Test User',
501
+ 'email': 'test@example.com'
502
+ }
503
+ }
504
+ }
505
+ ]
506
+ },
507
+ 'error_scenario': {
508
+ 'description': 'Various error conditions',
509
+ 'sequences': [
510
+ {
511
+ 'name': 'rate_limiting',
512
+ 'steps': [
513
+ {'repeat': 5, 'response': {'status': 200}},
514
+ {'repeat': 10, 'response': {'status': 429, 'body': {'error': 'Rate limit exceeded'}}}
515
+ ]
516
+ }
517
+ ],
518
+ 'stubs': [
519
+ {
520
+ 'path': '/api/auth/login',
521
+ 'conditions': [
522
+ {
523
+ 'match': {'body': {'username': 'locked_user'}},
524
+ 'response': {'status': 423, 'body': {'error': 'Account locked'}}
525
+ }
526
+ ]
527
+ }
528
+ ]
529
+ },
530
+ 'degraded_performance': {
531
+ 'description': 'Slow responses and timeouts',
532
+ 'stubs': [
533
+ {
534
+ 'path': '/api/*',
535
+ 'delay': 5000, # 5 second delay
536
+ 'response': {'status': 200}
537
+ }
538
+ ]
539
+ }
540
+ }
541
+
542
+ def execute_scenario_sequence(self):
543
+ """Execute scenario sequences"""
544
+ return '''
545
+ class SequenceExecutor:
546
+ def __init__(self):
547
+ self.sequence_states = {}
548
+
549
+ def get_sequence_response(self, sequence_name: str, request: Dict):
550
+ """Get response based on sequence state"""
551
+ if sequence_name not in self.sequence_states:
552
+ self.sequence_states[sequence_name] = {'step': 0, 'count': 0}
553
+
554
+ state = self.sequence_states[sequence_name]
555
+ sequence = self.get_sequence_definition(sequence_name)
556
+
557
+ # Get current step
558
+ current_step = sequence['steps'][state['step']]
559
+
560
+ # Check if we should advance to next step
561
+ state['count'] += 1
562
+ if state['count'] >= current_step.get('repeat', 1):
563
+ state['step'] = (state['step'] + 1) % len(sequence['steps'])
564
+ state['count'] = 0
565
+
566
+ return current_step['response']
567
+
568
+ def create_stateful_scenario(self):
569
+ """Create scenario with stateful behavior"""
570
+ return {
571
+ 'shopping_cart': {
572
+ 'initial_state': {
573
+ 'cart': {},
574
+ 'total': 0
575
+ },
576
+ 'stubs': [
577
+ {
578
+ 'method': 'POST',
579
+ 'path': '/api/cart/items',
580
+ 'handler': 'add_to_cart',
581
+ 'modifies_state': True
582
+ },
583
+ {
584
+ 'method': 'GET',
585
+ 'path': '/api/cart',
586
+ 'handler': 'get_cart',
587
+ 'uses_state': True
588
+ }
589
+ ],
590
+ 'handlers': {
591
+ 'add_to_cart': lambda state, request: {
592
+ 'state': {
593
+ **state,
594
+ 'cart': {
595
+ **state['cart'],
596
+ request['body']['product_id']: request['body']['quantity']
597
+ },
598
+ 'total': state['total'] + request['body']['price']
599
+ },
600
+ 'response': {
601
+ 'status': 201,
602
+ 'body': {'message': 'Item added to cart'}
603
+ }
604
+ },
605
+ 'get_cart': lambda state, request: {
606
+ 'response': {
607
+ 'status': 200,
608
+ 'body': {
609
+ 'items': state['cart'],
610
+ 'total': state['total']
611
+ }
612
+ }
613
+ }
614
+ }
615
+ }
616
+ }
617
+ '''
618
+ ```
619
+
620
+ ### 5. Contract Testing
621
+
622
+ Implement contract-based mocking:
623
+
624
+ **Contract Testing Framework**
625
+
626
+ ```python
627
+ class ContractMockServer:
628
+ def __init__(self):
629
+ self.contracts = {}
630
+ self.validators = self._init_validators()
631
+
632
+ def load_contract(self, contract_path: str):
633
+ """Load API contract (OpenAPI, AsyncAPI, etc.)"""
634
+ with open(contract_path, 'r') as f:
635
+ contract = yaml.safe_load(f)
636
+
637
+ # Parse contract
638
+ self.contracts[contract['info']['title']] = {
639
+ 'spec': contract,
640
+ 'endpoints': self._parse_endpoints(contract),
641
+ 'schemas': self._parse_schemas(contract)
642
+ }
643
+
644
+ def generate_mocks_from_contract(self, contract_name: str):
645
+ """Generate mocks from contract specification"""
646
+ contract = self.contracts[contract_name]
647
+ mocks = []
648
+
649
+ for path, methods in contract['endpoints'].items():
650
+ for method, spec in methods.items():
651
+ mock = self._create_mock_from_spec(path, method, spec)
652
+ mocks.append(mock)
653
+
654
+ return mocks
655
+
656
+ def _create_mock_from_spec(self, path: str, method: str, spec: Dict):
657
+ """Create mock from endpoint specification"""
658
+ mock = {
659
+ 'method': method.upper(),
660
+ 'path': self._convert_path_to_pattern(path),
661
+ 'responses': {}
662
+ }
663
+
664
+ # Generate responses for each status code
665
+ for status_code, response_spec in spec.get('responses', {}).items():
666
+ mock['responses'][status_code] = {
667
+ 'status': int(status_code),
668
+ 'headers': self._get_response_headers(response_spec),
669
+ 'body': self._generate_response_body(response_spec)
670
+ }
671
+
672
+ # Add request validation
673
+ if 'requestBody' in spec:
674
+ mock['request_validation'] = self._create_request_validator(spec['requestBody'])
675
+
676
+ return mock
677
+
678
+ def validate_against_contract(self):
679
+ """Validate mock responses against contract"""
680
+ return '''
681
+ class ContractValidator:
682
+ def validate_response(self, contract_spec, actual_response):
683
+ """Validate response against contract"""
684
+ validation_results = {
685
+ 'valid': True,
686
+ 'errors': []
687
+ }
688
+
689
+ # Find response spec for status code
690
+ response_spec = contract_spec['responses'].get(
691
+ str(actual_response['status']),
692
+ contract_spec['responses'].get('default')
693
+ )
694
+
695
+ if not response_spec:
696
+ validation_results['errors'].append({
697
+ 'type': 'unexpected_status',
698
+ 'message': f"Status {actual_response['status']} not defined in contract"
699
+ })
700
+ validation_results['valid'] = False
701
+ return validation_results
702
+
703
+ # Validate headers
704
+ if 'headers' in response_spec:
705
+ header_errors = self.validate_headers(
706
+ response_spec['headers'],
707
+ actual_response['headers']
708
+ )
709
+ validation_results['errors'].extend(header_errors)
710
+
711
+ # Validate body schema
712
+ if 'content' in response_spec:
713
+ body_errors = self.validate_body(
714
+ response_spec['content'],
715
+ actual_response['body']
716
+ )
717
+ validation_results['errors'].extend(body_errors)
718
+
719
+ validation_results['valid'] = len(validation_results['errors']) == 0
720
+ return validation_results
721
+
722
+ def validate_body(self, content_spec, actual_body):
723
+ """Validate response body against schema"""
724
+ errors = []
725
+
726
+ # Get schema for content type
727
+ schema = content_spec.get('application/json', {}).get('schema')
728
+ if not schema:
729
+ return errors
730
+
731
+ # Validate against JSON schema
732
+ try:
733
+ validate(instance=actual_body, schema=schema)
734
+ except ValidationError as e:
735
+ errors.append({
736
+ 'type': 'schema_validation',
737
+ 'path': e.json_path,
738
+ 'message': e.message
739
+ })
740
+
741
+ return errors
742
+ '''
743
+ ```
744
+
745
+ ### 6. Performance Testing
746
+
747
+ Create performance testing mocks:
748
+
749
+ **Performance Mock Server**
750
+
751
+ ```python
752
+ class PerformanceMockServer:
753
+ def __init__(self):
754
+ self.performance_profiles = {}
755
+ self.metrics_collector = MetricsCollector()
756
+
757
+ def create_performance_profile(self, name: str, config: Dict):
758
+ """Create performance testing profile"""
759
+ self.performance_profiles[name] = {
760
+ 'latency': config.get('latency', {'min': 10, 'max': 100}),
761
+ 'throughput': config.get('throughput', 1000), # requests per second
762
+ 'error_rate': config.get('error_rate', 0.01), # 1% errors
763
+ 'response_size': config.get('response_size', {'min': 100, 'max': 10000})
764
+ }
765
+
766
+ async def simulate_performance(self, profile_name: str, request: Request):
767
+ """Simulate performance characteristics"""
768
+ profile = self.performance_profiles[profile_name]
769
+
770
+ # Simulate latency
771
+ latency = random.uniform(profile['latency']['min'], profile['latency']['max'])
772
+ await asyncio.sleep(latency / 1000)
773
+
774
+ # Simulate errors
775
+ if random.random() < profile['error_rate']:
776
+ return self._generate_error_response()
777
+
778
+ # Generate response with specified size
779
+ response_size = random.randint(
780
+ profile['response_size']['min'],
781
+ profile['response_size']['max']
782
+ )
783
+
784
+ response_data = self._generate_data_of_size(response_size)
785
+
786
+ # Track metrics
787
+ self.metrics_collector.record({
788
+ 'latency': latency,
789
+ 'response_size': response_size,
790
+ 'timestamp': datetime.now()
791
+ })
792
+
793
+ return response_data
794
+
795
+ def create_load_test_scenarios(self):
796
+ """Create load testing scenarios"""
797
+ return {
798
+ 'gradual_load': {
799
+ 'description': 'Gradually increase load',
800
+ 'stages': [
801
+ {'duration': 60, 'target_rps': 100},
802
+ {'duration': 120, 'target_rps': 500},
803
+ {'duration': 180, 'target_rps': 1000},
804
+ {'duration': 60, 'target_rps': 100}
805
+ ]
806
+ },
807
+ 'spike_test': {
808
+ 'description': 'Sudden spike in traffic',
809
+ 'stages': [
810
+ {'duration': 60, 'target_rps': 100},
811
+ {'duration': 10, 'target_rps': 5000},
812
+ {'duration': 60, 'target_rps': 100}
813
+ ]
814
+ },
815
+ 'stress_test': {
816
+ 'description': 'Find breaking point',
817
+ 'stages': [
818
+ {'duration': 60, 'target_rps': 100},
819
+ {'duration': 60, 'target_rps': 500},
820
+ {'duration': 60, 'target_rps': 1000},
821
+ {'duration': 60, 'target_rps': 2000},
822
+ {'duration': 60, 'target_rps': 5000},
823
+ {'duration': 60, 'target_rps': 10000}
824
+ ]
825
+ }
826
+ }
827
+
828
+ def implement_throttling(self):
829
+ """Implement request throttling"""
830
+ return '''
831
+ class ThrottlingMiddleware:
832
+ def __init__(self, max_rps: int):
833
+ self.max_rps = max_rps
834
+ self.request_times = deque()
835
+
836
+ async def __call__(self, request: Request, call_next):
837
+ current_time = time.time()
838
+
839
+ # Remove old requests
840
+ while self.request_times and self.request_times[0] < current_time - 1:
841
+ self.request_times.popleft()
842
+
843
+ # Check if we're over limit
844
+ if len(self.request_times) >= self.max_rps:
845
+ return Response(
846
+ content=json.dumps({
847
+ 'error': 'Rate limit exceeded',
848
+ 'retry_after': 1
849
+ }),
850
+ status_code=429,
851
+ headers={'Retry-After': '1'}
852
+ )
853
+
854
+ # Record this request
855
+ self.request_times.append(current_time)
856
+
857
+ # Process request
858
+ response = await call_next(request)
859
+ return response
860
+ '''
861
+ ```
862
+
863
+ ### 7. Mock Data Management
864
+
865
+ Manage mock data effectively:
866
+
867
+ **Mock Data Store**
868
+
869
+ ```python
870
+ class MockDataStore:
871
+ def __init__(self):
872
+ self.collections = {}
873
+ self.indexes = {}
874
+
875
+ def create_collection(self, name: str, schema: Dict = None):
876
+ """Create a new data collection"""
877
+ self.collections[name] = {
878
+ 'data': {},
879
+ 'schema': schema,
880
+ 'counter': 0
881
+ }
882
+
883
+ # Create default index on 'id'
884
+ self.create_index(name, 'id')
885
+
886
+ def insert(self, collection: str, data: Dict):
887
+ """Insert data into collection"""
888
+ collection_data = self.collections[collection]
889
+
890
+ # Validate against schema if exists
891
+ if collection_data['schema']:
892
+ self._validate_data(data, collection_data['schema'])
893
+
894
+ # Generate ID if not provided
895
+ if 'id' not in data:
896
+ collection_data['counter'] += 1
897
+ data['id'] = str(collection_data['counter'])
898
+
899
+ # Store data
900
+ collection_data['data'][data['id']] = data
901
+
902
+ # Update indexes
903
+ self._update_indexes(collection, data)
904
+
905
+ return data['id']
906
+
907
+ def query(self, collection: str, filters: Dict = None):
908
+ """Query collection with filters"""
909
+ collection_data = self.collections[collection]['data']
910
+
911
+ if not filters:
912
+ return list(collection_data.values())
913
+
914
+ # Use indexes if available
915
+ if self._can_use_index(collection, filters):
916
+ return self._query_with_index(collection, filters)
917
+
918
+ # Full scan
919
+ results = []
920
+ for item in collection_data.values():
921
+ if self._matches_filters(item, filters):
922
+ results.append(item)
923
+
924
+ return results
925
+
926
+ def create_relationships(self):
927
+ """Define relationships between collections"""
928
+ return '''
929
+ class RelationshipManager:
930
+ def __init__(self, data_store: MockDataStore):
931
+ self.store = data_store
932
+ self.relationships = {}
933
+
934
+ def define_relationship(self,
935
+ source_collection: str,
936
+ target_collection: str,
937
+ relationship_type: str,
938
+ foreign_key: str):
939
+ """Define relationship between collections"""
940
+ self.relationships[f"{source_collection}->{target_collection}"] = {
941
+ 'type': relationship_type,
942
+ 'source': source_collection,
943
+ 'target': target_collection,
944
+ 'foreign_key': foreign_key
945
+ }
946
+
947
+ def populate_related_data(self, entity: Dict, collection: str, depth: int = 1):
948
+ """Populate related data for entity"""
949
+ if depth <= 0:
950
+ return entity
951
+
952
+ # Find relationships for this collection
953
+ for rel_key, rel in self.relationships.items():
954
+ if rel['source'] == collection:
955
+ # Get related data
956
+ foreign_id = entity.get(rel['foreign_key'])
957
+ if foreign_id:
958
+ related = self.store.get(rel['target'], foreign_id)
959
+ if related:
960
+ # Recursively populate
961
+ related = self.populate_related_data(
962
+ related,
963
+ rel['target'],
964
+ depth - 1
965
+ )
966
+ entity[rel['target']] = related
967
+
968
+ return entity
969
+
970
+ def cascade_operations(self, operation: str, collection: str, entity_id: str):
971
+ """Handle cascade operations"""
972
+ if operation == 'delete':
973
+ # Find dependent relationships
974
+ for rel in self.relationships.values():
975
+ if rel['target'] == collection:
976
+ # Delete dependent entities
977
+ dependents = self.store.query(
978
+ rel['source'],
979
+ {rel['foreign_key']: entity_id}
980
+ )
981
+ for dep in dependents:
982
+ self.store.delete(rel['source'], dep['id'])
983
+ '''
984
+ ```
985
+
986
+ ### 8. Testing Framework Integration
987
+
988
+ Integrate with popular testing frameworks:
989
+
990
+ **Testing Integration**
991
+
992
+ ```python
993
+ class TestingFrameworkIntegration:
994
+ def create_jest_integration(self):
995
+ """Jest testing integration"""
996
+ return '''
997
+ // jest.mock.config.js
998
+ import { MockServer } from './mockServer';
999
+
1000
+ const mockServer = new MockServer();
1001
+
1002
+ beforeAll(async () => {
1003
+ await mockServer.start({ port: 3001 });
1004
+
1005
+ // Load mock definitions
1006
+ await mockServer.loadMocks('./mocks/*.json');
1007
+
1008
+ // Set default scenario
1009
+ await mockServer.setScenario('test');
1010
+ });
1011
+
1012
+ afterAll(async () => {
1013
+ await mockServer.stop();
1014
+ });
1015
+
1016
+ beforeEach(async () => {
1017
+ // Reset mock state
1018
+ await mockServer.reset();
1019
+ });
1020
+
1021
+ // Test helper functions
1022
+ export const setupMock = async (stub) => {
1023
+ return await mockServer.addStub(stub);
1024
+ };
1025
+
1026
+ export const verifyRequests = async (matcher) => {
1027
+ const requests = await mockServer.getRequests(matcher);
1028
+ return requests;
1029
+ };
1030
+
1031
+ // Example test
1032
+ describe('User API', () => {
1033
+ it('should fetch user details', async () => {
1034
+ // Setup mock
1035
+ await setupMock({
1036
+ method: 'GET',
1037
+ path: '/api/users/123',
1038
+ response: {
1039
+ status: 200,
1040
+ body: { id: '123', name: 'Test User' }
1041
+ }
1042
+ });
1043
+
1044
+ // Make request
1045
+ const response = await fetch('http://localhost:3001/api/users/123');
1046
+ const user = await response.json();
1047
+
1048
+ // Verify
1049
+ expect(user.name).toBe('Test User');
1050
+
1051
+ // Verify mock was called
1052
+ const requests = await verifyRequests({ path: '/api/users/123' });
1053
+ expect(requests).toHaveLength(1);
1054
+ });
1055
+ });
1056
+ '''
1057
+
1058
+ def create_pytest_integration(self):
1059
+ """Pytest integration"""
1060
+ return '''
1061
+ # conftest.py
1062
+ import pytest
1063
+ from mock_server import MockServer
1064
+ import asyncio
1065
+
1066
+ @pytest.fixture(scope="session")
1067
+ def event_loop():
1068
+ loop = asyncio.get_event_loop_policy().new_event_loop()
1069
+ yield loop
1070
+ loop.close()
1071
+
1072
+ @pytest.fixture(scope="session")
1073
+ async def mock_server(event_loop):
1074
+ server = MockServer()
1075
+ await server.start(port=3001)
1076
+ yield server
1077
+ await server.stop()
1078
+
1079
+ @pytest.fixture(autouse=True)
1080
+ async def reset_mocks(mock_server):
1081
+ await mock_server.reset()
1082
+ yield
1083
+ # Verify no unexpected calls
1084
+ unmatched = await mock_server.get_unmatched_requests()
1085
+ assert len(unmatched) == 0, f"Unmatched requests: {unmatched}"
1086
+
1087
+ # Test utilities
1088
+ class MockBuilder:
1089
+ def __init__(self, mock_server):
1090
+ self.server = mock_server
1091
+ self.stubs = []
1092
+
1093
+ def when(self, method, path):
1094
+ self.current_stub = {
1095
+ 'method': method,
1096
+ 'path': path
1097
+ }
1098
+ return self
1099
+
1100
+ def with_body(self, body):
1101
+ self.current_stub['body'] = body
1102
+ return self
1103
+
1104
+ def then_return(self, status, body=None, headers=None):
1105
+ self.current_stub['response'] = {
1106
+ 'status': status,
1107
+ 'body': body,
1108
+ 'headers': headers or {}
1109
+ }
1110
+ self.stubs.append(self.current_stub)
1111
+ return self
1112
+
1113
+ async def setup(self):
1114
+ for stub in self.stubs:
1115
+ await self.server.add_stub(stub)
1116
+
1117
+ # Example test
1118
+ @pytest.mark.asyncio
1119
+ async def test_user_creation(mock_server):
1120
+ # Setup mocks
1121
+ mock = MockBuilder(mock_server)
1122
+ mock.when('POST', '/api/users') \
1123
+ .with_body({'name': 'New User'}) \
1124
+ .then_return(201, {'id': '456', 'name': 'New User'})
1125
+
1126
+ await mock.setup()
1127
+
1128
+ # Test code here
1129
+ response = await create_user({'name': 'New User'})
1130
+ assert response['id'] == '456'
1131
+ '''
1132
+ ```
1133
+
1134
+ ### 9. Mock Server Deployment
1135
+
1136
+ Deploy mock servers:
1137
+
1138
+ **Deployment Configuration**
1139
+
1140
+ ```yaml
1141
+ # docker-compose.yml for mock services
1142
+ version: "3.8"
1143
+
1144
+ services:
1145
+ mock-api:
1146
+ build:
1147
+ context: .
1148
+ dockerfile: Dockerfile.mock
1149
+ ports:
1150
+ - "3001:3001"
1151
+ environment:
1152
+ - MOCK_SCENARIO=production
1153
+ - MOCK_DATA_PATH=/data/mocks
1154
+ volumes:
1155
+ - ./mocks:/data/mocks
1156
+ - ./scenarios:/data/scenarios
1157
+ healthcheck:
1158
+ test: ["CMD", "curl", "-f", "http://localhost:3001/health"]
1159
+ interval: 30s
1160
+ timeout: 10s
1161
+ retries: 3
1162
+
1163
+ mock-admin:
1164
+ build:
1165
+ context: .
1166
+ dockerfile: Dockerfile.admin
1167
+ ports:
1168
+ - "3002:3002"
1169
+ environment:
1170
+ - MOCK_SERVER_URL=http://mock-api:3001
1171
+ depends_on:
1172
+ - mock-api
1173
+
1174
+
1175
+ # Kubernetes deployment
1176
+ ---
1177
+ apiVersion: apps/v1
1178
+ kind: Deployment
1179
+ metadata:
1180
+ name: mock-server
1181
+ spec:
1182
+ replicas: 2
1183
+ selector:
1184
+ matchLabels:
1185
+ app: mock-server
1186
+ template:
1187
+ metadata:
1188
+ labels:
1189
+ app: mock-server
1190
+ spec:
1191
+ containers:
1192
+ - name: mock-server
1193
+ image: mock-server:latest
1194
+ ports:
1195
+ - containerPort: 3001
1196
+ env:
1197
+ - name: MOCK_SCENARIO
1198
+ valueFrom:
1199
+ configMapKeyRef:
1200
+ name: mock-config
1201
+ key: scenario
1202
+ volumeMounts:
1203
+ - name: mock-definitions
1204
+ mountPath: /data/mocks
1205
+ volumes:
1206
+ - name: mock-definitions
1207
+ configMap:
1208
+ name: mock-definitions
1209
+ ```
1210
+
1211
+ ### 10. Mock Documentation
1212
+
1213
+ Generate mock API documentation:
1214
+
1215
+ **Documentation Generator**
1216
+
1217
+ ````python
1218
+ class MockDocumentationGenerator:
1219
+ def generate_documentation(self, mock_server):
1220
+ """Generate comprehensive mock documentation"""
1221
+ return f"""
1222
+ # Mock API Documentation
1223
+
1224
+ ## Overview
1225
+ {self._generate_overview(mock_server)}
1226
+
1227
+ ## Available Endpoints
1228
+ {self._generate_endpoints_doc(mock_server)}
1229
+
1230
+ ## Scenarios
1231
+ {self._generate_scenarios_doc(mock_server)}
1232
+
1233
+ ## Data Models
1234
+ {self._generate_models_doc(mock_server)}
1235
+
1236
+ ## Usage Examples
1237
+ {self._generate_examples(mock_server)}
1238
+
1239
+ ## Configuration
1240
+ {self._generate_config_doc(mock_server)}
1241
+ """
1242
+
1243
+ def _generate_endpoints_doc(self, mock_server):
1244
+ """Generate endpoint documentation"""
1245
+ doc = ""
1246
+ for endpoint in mock_server.get_endpoints():
1247
+ doc += f"""
1248
+ ### {endpoint['method']} {endpoint['path']}
1249
+
1250
+ **Description**: {endpoint.get('description', 'No description')}
1251
+
1252
+ **Request**:
1253
+ ```json
1254
+ {json.dumps(endpoint.get('request_example', {}), indent=2)}
1255
+ ````
1256
+
1257
+ **Response**:
1258
+
1259
+ ```json
1260
+ {json.dumps(endpoint.get('response_example', {}), indent=2)}
1261
+ ```
1262
+
1263
+ **Scenarios**:
1264
+ {self.\_format_endpoint_scenarios(endpoint)}
1265
+ """
1266
+ return doc
1267
+
1268
+ def create_interactive_docs(self):
1269
+ """Create interactive API documentation"""
1270
+ return '''
1271
+
1272
+ <!DOCTYPE html>
1273
+ <html>
1274
+ <head>
1275
+ <title>Mock API Interactive Documentation</title>
1276
+ <script src="https://unpkg.com/swagger-ui-dist/swagger-ui-bundle.js"></script>
1277
+ <link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist/swagger-ui.css">
1278
+ </head>
1279
+ <body>
1280
+ <div id="swagger-ui"></div>
1281
+ <script>
1282
+ window.onload = function() {
1283
+ const ui = SwaggerUIBundle({
1284
+ url: "/api/mock/openapi.json",
1285
+ dom_id: '#swagger-ui',
1286
+ presets: [
1287
+ SwaggerUIBundle.presets.apis,
1288
+ SwaggerUIBundle.SwaggerUIStandalonePreset
1289
+ ],
1290
+ layout: "BaseLayout",
1291
+ tryItOutEnabled: true,
1292
+ requestInterceptor: (request) => {
1293
+ request.headers['X-Mock-Scenario'] =
1294
+ document.getElementById('scenario-select').value;
1295
+ return request;
1296
+ }
1297
+ });
1298
+ }
1299
+ </script>
1300
+
1301
+ <div class="scenario-selector">
1302
+ <label>Scenario:</label>
1303
+ <select id="scenario-select">
1304
+ <option value="default">Default</option>
1305
+ <option value="error">Error Conditions</option>
1306
+ <option value="slow">Slow Responses</option>
1307
+ </select>
1308
+ </div>
1309
+ </body>
1310
+ </html>
1311
+ '''
1312
+ ```
1313
+
1314
+ ## Output Format
1315
+
1316
+ 1. **Mock Server Setup**: Complete mock server implementation
1317
+ 2. **Stubbing Configuration**: Flexible request/response stubbing
1318
+ 3. **Data Generation**: Realistic mock data generation
1319
+ 4. **Scenario Definitions**: Comprehensive test scenarios
1320
+ 5. **Contract Testing**: Contract-based mock validation
1321
+ 6. **Performance Simulation**: Performance testing capabilities
1322
+ 7. **Data Management**: Mock data storage and relationships
1323
+ 8. **Testing Integration**: Framework integration examples
1324
+ 9. **Deployment Guide**: Mock server deployment configurations
1325
+ 10. **Documentation**: Auto-generated mock API documentation
1326
+
1327
+ Focus on creating flexible, realistic mock services that enable efficient development, thorough testing, and reliable API simulation for all stages of the development lifecycle.