@kinqs/brainrouter-mcp-server 0.3.4

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 (337) hide show
  1. package/.env.example +144 -0
  2. package/README.md +56 -0
  3. package/agents/README.md +120 -0
  4. package/agents/code-reviewer.md +97 -0
  5. package/agents/security-auditor.md +101 -0
  6. package/agents/test-engineer.md +95 -0
  7. package/dist/__tests__/agent_mode.test.d.ts +1 -0
  8. package/dist/__tests__/api-routes.test.d.ts +1 -0
  9. package/dist/__tests__/api-routes.test.js +170 -0
  10. package/dist/__tests__/crypto.test.d.ts +1 -0
  11. package/dist/__tests__/crypto.test.js +28 -0
  12. package/dist/__tests__/host-integrations.test.d.ts +1 -0
  13. package/dist/__tests__/host-integrations.test.js +82 -0
  14. package/dist/__tests__/integration.test.d.ts +1 -0
  15. package/dist/__tests__/integration.test.js +50 -0
  16. package/dist/__tests__/loader.test.d.ts +1 -0
  17. package/dist/__tests__/loader.test.js +89 -0
  18. package/dist/__tests__/neural-spark.test.d.ts +1 -0
  19. package/dist/__tests__/neural-spark.test.js +112 -0
  20. package/dist/__tests__/pagination.test.d.ts +1 -0
  21. package/dist/__tests__/pagination.test.js +23 -0
  22. package/dist/__tests__/redaction.test.d.ts +1 -0
  23. package/dist/__tests__/redaction.test.js +17 -0
  24. package/dist/__tests__/registry.test.d.ts +1 -0
  25. package/dist/__tests__/registry.test.js +56 -0
  26. package/dist/__tests__/retry.test.d.ts +1 -0
  27. package/dist/__tests__/retry.test.js +30 -0
  28. package/dist/__tests__/skill-activation.test.d.ts +1 -0
  29. package/dist/__tests__/skill-activation.test.js +112 -0
  30. package/dist/__tests__/working-memory.test.d.ts +1 -0
  31. package/dist/__tests__/working-memory.test.js +200 -0
  32. package/dist/__tests__/workspace-paths.test.d.ts +1 -0
  33. package/dist/__tests__/workspace-paths.test.js +56 -0
  34. package/dist/__tests__/writer.test.d.ts +1 -0
  35. package/dist/__tests__/writer.test.js +94 -0
  36. package/dist/api/auth/crypto.d.ts +4 -0
  37. package/dist/api/auth/crypto.js +54 -0
  38. package/dist/api/middleware/auth.d.ts +12 -0
  39. package/dist/api/middleware/auth.js +90 -0
  40. package/dist/api/pagination.d.ts +18 -0
  41. package/dist/api/pagination.js +32 -0
  42. package/dist/api/routes/auth.d.ts +1 -0
  43. package/dist/api/routes/auth.js +130 -0
  44. package/dist/api/routes/chat-completions.d.ts +7 -0
  45. package/dist/api/routes/chat-completions.js +474 -0
  46. package/dist/api/routes/contradictions.d.ts +1 -0
  47. package/dist/api/routes/contradictions.js +28 -0
  48. package/dist/api/routes/evidence.d.ts +1 -0
  49. package/dist/api/routes/evidence.js +59 -0
  50. package/dist/api/routes/governance.d.ts +1 -0
  51. package/dist/api/routes/governance.js +95 -0
  52. package/dist/api/routes/graph.d.ts +1 -0
  53. package/dist/api/routes/graph.js +25 -0
  54. package/dist/api/routes/hooks.d.ts +1 -0
  55. package/dist/api/routes/hooks.js +88 -0
  56. package/dist/api/routes/memories.d.ts +1 -0
  57. package/dist/api/routes/memories.js +92 -0
  58. package/dist/api/routes/persona.d.ts +1 -0
  59. package/dist/api/routes/persona.js +9 -0
  60. package/dist/api/routes/scenes.d.ts +1 -0
  61. package/dist/api/routes/scenes.js +35 -0
  62. package/dist/api/routes/skills.d.ts +1 -0
  63. package/dist/api/routes/skills.js +14 -0
  64. package/dist/api/routes/stats.d.ts +1 -0
  65. package/dist/api/routes/stats.js +8 -0
  66. package/dist/api/routes/users.d.ts +1 -0
  67. package/dist/api/routes/users.js +82 -0
  68. package/dist/api/routes/working.d.ts +1 -0
  69. package/dist/api/routes/working.js +88 -0
  70. package/dist/index.d.ts +2 -0
  71. package/dist/index.js +492 -0
  72. package/dist/integrations/claude-code.d.ts +12 -0
  73. package/dist/integrations/claude-code.js +35 -0
  74. package/dist/integrations/codex.d.ts +12 -0
  75. package/dist/integrations/codex.js +34 -0
  76. package/dist/integrations/generic-mcp.d.ts +52 -0
  77. package/dist/integrations/generic-mcp.js +118 -0
  78. package/dist/loader.d.ts +29 -0
  79. package/dist/loader.js +200 -0
  80. package/dist/memory/capture.d.ts +35 -0
  81. package/dist/memory/capture.js +230 -0
  82. package/dist/memory/config.d.ts +2 -0
  83. package/dist/memory/config.js +3 -0
  84. package/dist/memory/engine.d.ts +203 -0
  85. package/dist/memory/engine.js +626 -0
  86. package/dist/memory/llm-semaphore.d.ts +41 -0
  87. package/dist/memory/llm-semaphore.js +81 -0
  88. package/dist/memory/memory-type-config.d.ts +11 -0
  89. package/dist/memory/memory-type-config.js +65 -0
  90. package/dist/memory/pipeline/cognitive-contradiction.d.ts +7 -0
  91. package/dist/memory/pipeline/cognitive-contradiction.js +59 -0
  92. package/dist/memory/pipeline/cognitive-dedup.d.ts +23 -0
  93. package/dist/memory/pipeline/cognitive-dedup.js +38 -0
  94. package/dist/memory/pipeline/cognitive-extractor.d.ts +21 -0
  95. package/dist/memory/pipeline/cognitive-extractor.js +183 -0
  96. package/dist/memory/pipeline/contextual-focus-builder.d.ts +13 -0
  97. package/dist/memory/pipeline/contextual-focus-builder.js +135 -0
  98. package/dist/memory/pipeline/focus-direction-shift.d.ts +10 -0
  99. package/dist/memory/pipeline/focus-direction-shift.js +27 -0
  100. package/dist/memory/pipeline/graph-builder.d.ts +11 -0
  101. package/dist/memory/pipeline/graph-builder.js +88 -0
  102. package/dist/memory/pipeline/graph-recall.d.ts +13 -0
  103. package/dist/memory/pipeline/graph-recall.js +55 -0
  104. package/dist/memory/pipeline/identity-distiller.d.ts +15 -0
  105. package/dist/memory/pipeline/identity-distiller.js +40 -0
  106. package/dist/memory/pipeline/l1-contradiction.d.ts +7 -0
  107. package/dist/memory/pipeline/l1-contradiction.js +66 -0
  108. package/dist/memory/pipeline/l1-dedup.d.ts +23 -0
  109. package/dist/memory/pipeline/l1-dedup.js +39 -0
  110. package/dist/memory/pipeline/l1-extractor.d.ts +21 -0
  111. package/dist/memory/pipeline/l1-extractor.js +180 -0
  112. package/dist/memory/pipeline/l2-direction-shift.d.ts +10 -0
  113. package/dist/memory/pipeline/l2-direction-shift.js +27 -0
  114. package/dist/memory/pipeline/l2-scene.d.ts +15 -0
  115. package/dist/memory/pipeline/l2-scene.js +140 -0
  116. package/dist/memory/pipeline/l3-distiller.d.ts +15 -0
  117. package/dist/memory/pipeline/l3-distiller.js +40 -0
  118. package/dist/memory/pipeline/neural-spark.d.ts +27 -0
  119. package/dist/memory/pipeline/neural-spark.js +78 -0
  120. package/dist/memory/pipeline/skill-prewarm.d.ts +63 -0
  121. package/dist/memory/pipeline/skill-prewarm.js +127 -0
  122. package/dist/memory/pipeline/task-queue.d.ts +54 -0
  123. package/dist/memory/pipeline/task-queue.js +117 -0
  124. package/dist/memory/prompts/cognitive-contradiction.d.ts +1 -0
  125. package/dist/memory/prompts/cognitive-contradiction.js +25 -0
  126. package/dist/memory/prompts/cognitive-extraction.d.ts +10 -0
  127. package/dist/memory/prompts/cognitive-extraction.js +114 -0
  128. package/dist/memory/prompts/core-identity.d.ts +6 -0
  129. package/dist/memory/prompts/core-identity.js +60 -0
  130. package/dist/memory/prompts/focus-direction-shift.d.ts +5 -0
  131. package/dist/memory/prompts/focus-direction-shift.js +32 -0
  132. package/dist/memory/prompts/focus-scene-cluster.d.ts +2 -0
  133. package/dist/memory/prompts/focus-scene-cluster.js +33 -0
  134. package/dist/memory/prompts/focus-scene.d.ts +7 -0
  135. package/dist/memory/prompts/focus-scene.js +40 -0
  136. package/dist/memory/prompts/graph-extraction-batch.d.ts +14 -0
  137. package/dist/memory/prompts/graph-extraction-batch.js +54 -0
  138. package/dist/memory/prompts/graph-extraction.d.ts +2 -0
  139. package/dist/memory/prompts/graph-extraction.js +53 -0
  140. package/dist/memory/prompts/l1-contradiction-batch.d.ts +16 -0
  141. package/dist/memory/prompts/l1-contradiction-batch.js +47 -0
  142. package/dist/memory/prompts/l1-contradiction.d.ts +1 -0
  143. package/dist/memory/prompts/l1-contradiction.js +25 -0
  144. package/dist/memory/prompts/l1-extraction.d.ts +10 -0
  145. package/dist/memory/prompts/l1-extraction.js +114 -0
  146. package/dist/memory/prompts/l2-direction-shift.d.ts +5 -0
  147. package/dist/memory/prompts/l2-direction-shift.js +32 -0
  148. package/dist/memory/prompts/l2-scene-cluster.d.ts +2 -0
  149. package/dist/memory/prompts/l2-scene-cluster.js +33 -0
  150. package/dist/memory/prompts/l2-scene.d.ts +7 -0
  151. package/dist/memory/prompts/l2-scene.js +40 -0
  152. package/dist/memory/prompts/l3-persona.d.ts +6 -0
  153. package/dist/memory/prompts/l3-persona.js +60 -0
  154. package/dist/memory/recall.d.ts +47 -0
  155. package/dist/memory/recall.js +427 -0
  156. package/dist/memory/redaction.d.ts +1 -0
  157. package/dist/memory/redaction.js +24 -0
  158. package/dist/memory/retry.d.ts +13 -0
  159. package/dist/memory/retry.js +53 -0
  160. package/dist/memory/scheduler.d.ts +9 -0
  161. package/dist/memory/scheduler.js +16 -0
  162. package/dist/memory/skill-hints-loader.d.ts +30 -0
  163. package/dist/memory/skill-hints-loader.js +100 -0
  164. package/dist/memory/store/embedding.d.ts +16 -0
  165. package/dist/memory/store/embedding.js +68 -0
  166. package/dist/memory/store/reranker.d.ts +24 -0
  167. package/dist/memory/store/reranker.js +83 -0
  168. package/dist/memory/store/sqlite.d.ts +167 -0
  169. package/dist/memory/store/sqlite.js +1816 -0
  170. package/dist/memory/store/types.d.ts +101 -0
  171. package/dist/memory/store/types.js +1 -0
  172. package/dist/memory/types.d.ts +207 -0
  173. package/dist/memory/types.js +7 -0
  174. package/dist/memory/validation.d.ts +441 -0
  175. package/dist/memory/validation.js +129 -0
  176. package/dist/memory/working/canvas.d.ts +5 -0
  177. package/dist/memory/working/canvas.js +43 -0
  178. package/dist/memory/working/offload.d.ts +71 -0
  179. package/dist/memory/working/offload.js +211 -0
  180. package/dist/memory/working/step-log.d.ts +16 -0
  181. package/dist/memory/working/step-log.js +35 -0
  182. package/dist/registry.d.ts +34 -0
  183. package/dist/registry.js +305 -0
  184. package/dist/resolver.d.ts +17 -0
  185. package/dist/resolver.js +126 -0
  186. package/dist/scripts/validate-foreign-workspace-path.d.ts +1 -0
  187. package/dist/scripts/validate-foreign-workspace-path.js +39 -0
  188. package/dist/tools/agent_memory_tools.d.ts +485 -0
  189. package/dist/tools/agent_memory_tools.js +793 -0
  190. package/dist/tools/create_skill.d.ts +46 -0
  191. package/dist/tools/create_skill.js +46 -0
  192. package/dist/tools/get_doc.d.ts +21 -0
  193. package/dist/tools/get_doc.js +24 -0
  194. package/dist/tools/get_persona.d.ts +15 -0
  195. package/dist/tools/get_persona.js +20 -0
  196. package/dist/tools/get_reference.d.ts +15 -0
  197. package/dist/tools/get_reference.js +20 -0
  198. package/dist/tools/get_skill.d.ts +34 -0
  199. package/dist/tools/get_skill.js +65 -0
  200. package/dist/tools/get_template_doc.d.ts +21 -0
  201. package/dist/tools/get_template_doc.js +24 -0
  202. package/dist/tools/list_docs.d.ts +15 -0
  203. package/dist/tools/list_docs.js +16 -0
  204. package/dist/tools/list_skills.d.ts +18 -0
  205. package/dist/tools/list_skills.js +17 -0
  206. package/dist/tools/list_template_docs.d.ts +15 -0
  207. package/dist/tools/list_template_docs.js +16 -0
  208. package/dist/tools/memory-engineering.d.ts +225 -0
  209. package/dist/tools/memory-engineering.js +284 -0
  210. package/dist/tools/memory-explain.d.ts +34 -0
  211. package/dist/tools/memory-explain.js +109 -0
  212. package/dist/tools/memory-governance.d.ts +171 -0
  213. package/dist/tools/memory-governance.js +224 -0
  214. package/dist/tools/memory-hooks.d.ts +67 -0
  215. package/dist/tools/memory-hooks.js +102 -0
  216. package/dist/tools/memory-working.d.ts +98 -0
  217. package/dist/tools/memory-working.js +101 -0
  218. package/dist/tools/memory_capture_turn.d.ts +66 -0
  219. package/dist/tools/memory_capture_turn.js +85 -0
  220. package/dist/tools/memory_consolidate.d.ts +55 -0
  221. package/dist/tools/memory_consolidate.js +176 -0
  222. package/dist/tools/memory_contradictions.d.ts +53 -0
  223. package/dist/tools/memory_contradictions.js +52 -0
  224. package/dist/tools/memory_graph_query.d.ts +51 -0
  225. package/dist/tools/memory_graph_query.js +35 -0
  226. package/dist/tools/memory_mark_cited.d.ts +43 -0
  227. package/dist/tools/memory_mark_cited.js +63 -0
  228. package/dist/tools/memory_recall.d.ts +77 -0
  229. package/dist/tools/memory_recall.js +81 -0
  230. package/dist/tools/memory_register_skill_hints.d.ts +49 -0
  231. package/dist/tools/memory_register_skill_hints.js +55 -0
  232. package/dist/tools/memory_resolve_session.d.ts +24 -0
  233. package/dist/tools/memory_resolve_session.js +133 -0
  234. package/dist/tools/memory_search.d.ts +146 -0
  235. package/dist/tools/memory_search.js +84 -0
  236. package/dist/tools/search_skills.d.ts +18 -0
  237. package/dist/tools/search_skills.js +17 -0
  238. package/dist/tools/update_doc.d.ts +24 -0
  239. package/dist/tools/update_doc.js +35 -0
  240. package/dist/tools/update_skill.d.ts +30 -0
  241. package/dist/tools/update_skill.js +80 -0
  242. package/dist/types.d.ts +81 -0
  243. package/dist/types.js +4 -0
  244. package/dist/writer.d.ts +30 -0
  245. package/dist/writer.js +220 -0
  246. package/docs/TEMPLATE ONLY +1 -0
  247. package/docs/api/API.md +64 -0
  248. package/docs/api/security/SECURITY.md +58 -0
  249. package/docs/deployment/DockerDeployment.md +30 -0
  250. package/docs/design/Design.md +59 -0
  251. package/docs/design/themes/apple.md +101 -0
  252. package/docs/design/themes/dieter-grid.md +100 -0
  253. package/docs/design/themes/gallery-white.md +100 -0
  254. package/docs/design/themes/pinterest.md +101 -0
  255. package/docs/design/themes/realty-open-house.md +101 -0
  256. package/docs/design/themes/vodafone.md +101 -0
  257. package/docs/hooks/Hooks.md +30 -0
  258. package/docs/schema/Schema.md +35 -0
  259. package/docs/strategy/ScalingStrategy.md +19 -0
  260. package/package.json +88 -0
  261. package/references/accessibility-checklist.md +160 -0
  262. package/references/orchestration-patterns.md +370 -0
  263. package/references/performance-checklist.md +153 -0
  264. package/references/security-checklist.md +134 -0
  265. package/references/testing-patterns.md +236 -0
  266. package/skills/agent/adr-skill/SKILL.md +299 -0
  267. package/skills/agent/agentic-engineering-workflow/SKILL.md +95 -0
  268. package/skills/agent/bootstrap-skill/SKILL.md +103 -0
  269. package/skills/agent/context-engineering/SKILL.md +307 -0
  270. package/skills/agent/debugging-and-error-recovery/SKILL.md +308 -0
  271. package/skills/agent/developer-growth-analysis/SKILL.md +328 -0
  272. package/skills/agent/doubt-driven-skill/SKILL.md +249 -0
  273. package/skills/agent/handover-skill/SKILL.md +112 -0
  274. package/skills/agent/idea-refine-skill/SKILL.md +185 -0
  275. package/skills/agent/idea-refine-skill/examples.md +238 -0
  276. package/skills/agent/idea-refine-skill/frameworks.md +99 -0
  277. package/skills/agent/idea-refine-skill/refinement-criteria.md +113 -0
  278. package/skills/agent/interview-skill/SKILL.md +226 -0
  279. package/skills/agent/planning-skill/SKILL.md +270 -0
  280. package/skills/agent/skill-authoring/SKILL.md +189 -0
  281. package/skills/agent/source-driven-skill/SKILL.md +197 -0
  282. package/skills/agent/spec-driven-skill/SKILL.md +221 -0
  283. package/skills/agent/sync-skill/SKILL.md +92 -0
  284. package/skills/agent/using-agent-skills/SKILL.md +189 -0
  285. package/skills/api/a11y-skill/SKILL.md +88 -0
  286. package/skills/api/api-skill/SKILL.md +123 -0
  287. package/skills/api/auth-skill/SKILL.md +80 -0
  288. package/skills/api/debug-skill/SKILL.md +535 -0
  289. package/skills/api/performance-skill/SKILL.md +100 -0
  290. package/skills/api/testing-skill/SKILL.md +100 -0
  291. package/skills/codebase/code-review-and-quality/SKILL.md +228 -0
  292. package/skills/codebase/code-simplification/SKILL.md +352 -0
  293. package/skills/codebase/code-structure-cleanup/SKILL.md +142 -0
  294. package/skills/codebase/concerns-skill/SKILL.md +89 -0
  295. package/skills/codebase/conventions-skill/SKILL.md +95 -0
  296. package/skills/codebase/doc-management-skill/SKILL.md +47 -0
  297. package/skills/codebase/git-workflow-skill/SKILL.md +312 -0
  298. package/skills/communication/1-3-1-rule/SKILL.md +120 -0
  299. package/skills/design/brutalist-skill/SKILL.md +131 -0
  300. package/skills/design/concept-diagrams/SKILL.md +387 -0
  301. package/skills/design/concept-diagrams/examples/apartment-floor-plan-conversion.md +244 -0
  302. package/skills/design/concept-diagrams/examples/automated-password-reset-flow.md +276 -0
  303. package/skills/design/concept-diagrams/examples/autonomous-llm-research-agent-flow.md +240 -0
  304. package/skills/design/concept-diagrams/examples/banana-journey-tree-to-smoothie.md +161 -0
  305. package/skills/design/concept-diagrams/examples/commercial-aircraft-structure.md +209 -0
  306. package/skills/design/concept-diagrams/examples/cpu-ooo-microarchitecture.md +236 -0
  307. package/skills/design/concept-diagrams/examples/electricity-grid-flow.md +182 -0
  308. package/skills/design/concept-diagrams/examples/feature-film-production-pipeline.md +172 -0
  309. package/skills/design/concept-diagrams/examples/hospital-emergency-department-flow.md +165 -0
  310. package/skills/design/concept-diagrams/examples/ml-benchmark-grouped-bar-chart.md +114 -0
  311. package/skills/design/concept-diagrams/examples/place-order-uml-sequence.md +325 -0
  312. package/skills/design/concept-diagrams/examples/smart-city-infrastructure.md +173 -0
  313. package/skills/design/concept-diagrams/examples/smartphone-layer-anatomy.md +154 -0
  314. package/skills/design/concept-diagrams/examples/sn2-reaction-mechanism.md +247 -0
  315. package/skills/design/concept-diagrams/examples/wind-turbine-structure.md +338 -0
  316. package/skills/design/concept-diagrams/references/dashboard-patterns.md +43 -0
  317. package/skills/design/concept-diagrams/references/infrastructure-patterns.md +144 -0
  318. package/skills/design/concept-diagrams/references/physical-shape-cookbook.md +42 -0
  319. package/skills/design/concept-diagrams/templates/template.html +174 -0
  320. package/skills/design/gpt-tasteskill/SKILL.md +114 -0
  321. package/skills/design/minimalist-skill/SKILL.md +116 -0
  322. package/skills/design/output-skill/SKILL.md +87 -0
  323. package/skills/design/redesign-skill/SKILL.md +213 -0
  324. package/skills/design/soft-skill/SKILL.md +132 -0
  325. package/skills/design/stitch-skill/EXAMPLE.md +121 -0
  326. package/skills/design/stitch-skill/SKILL.md +222 -0
  327. package/skills/design/taste-skill/SKILL.md +269 -0
  328. package/skills/devops/ci-cd-skill/SKILL.md +402 -0
  329. package/skills/devops/docker-skill/SKILL.md +297 -0
  330. package/skills/devops/domain-skill/SKILL.md +234 -0
  331. package/skills/lifecycle/changelog-generator/SKILL.md +135 -0
  332. package/skills/lifecycle/incremental-skill/SKILL.md +257 -0
  333. package/skills/lifecycle/migration-skill/SKILL.md +218 -0
  334. package/skills/lifecycle/shipping-skill/SKILL.md +321 -0
  335. package/skills/memory/agent-memory/SKILL.md +122 -0
  336. package/skills/qa/browser-testing-skill/SKILL.md +314 -0
  337. package/skills/ux/adversarial-ux-skill/SKILL.md +168 -0
@@ -0,0 +1,402 @@
1
+ ---
2
+ name: ci-cd-skill
3
+ description: Automates CI/CD pipeline setup. Use when setting up or modifying build and deployment pipelines. Use when you need to automate quality gates, configure test runners in CI, or establish deployment strategies.
4
+ hints:
5
+ - Check openSrc/ or existing workflows (e.g., .github/workflows/, .gitlab-ci.yml) for pipeline patterns if available.
6
+ - Structure CI pipelines to run checks in parallel (lint, typecheck, test, build) to reduce feedback loop times.
7
+ - Implement package manager caching (e.g. actions/setup-node cache option) to optimize dependency installs.
8
+ - Avoid hardcoding credentials or configuration secrets; mandate repository/environment secret variables instead.
9
+ - Enforce branch protection rules that require green CI pipelines to pass before merging into the main branch.
10
+ ---
11
+
12
+ # CI/CD and Automation
13
+
14
+ ## Overview
15
+
16
+ Automate quality gates so that no change reaches production without passing tests, lint, type checking, and build. CI/CD is the enforcement mechanism for every other skill — it catches what humans and agents miss, and it does so consistently on every single change.
17
+
18
+ **Shift Left:** Catch problems as early in the pipeline as possible. A bug caught in linting costs minutes; the same bug caught in production costs hours. Move checks upstream — static analysis before tests, tests before staging, staging before production.
19
+
20
+ **Faster is Safer:** Smaller batches and more frequent releases reduce risk, not increase it. A deployment with 3 changes is easier to debug than one with 30. Frequent releases build confidence in the release process itself.
21
+
22
+ ## When to Use
23
+
24
+ - Setting up a new project's CI pipeline
25
+ - Adding or modifying automated checks
26
+ - Configuring deployment pipelines
27
+ - When a change should trigger automated verification
28
+ - Debugging CI failures
29
+
30
+ ## Workflow
31
+
32
+ Every change goes through these gates before merge:
33
+
34
+ ```
35
+ Pull Request Opened
36
+
37
+
38
+ ┌─────────────────┐
39
+ │ LINT CHECK │ eslint, prettier
40
+ │ ↓ pass │
41
+ │ TYPE CHECK │ tsc --noEmit
42
+ │ ↓ pass │
43
+ │ UNIT TESTS │ jest/vitest
44
+ │ ↓ pass │
45
+ │ BUILD │ npm run build
46
+ │ ↓ pass │
47
+ │ INTEGRATION │ API/DB tests
48
+ │ ↓ pass │
49
+ │ E2E (optional) │ Playwright/Cypress
50
+ │ ↓ pass │
51
+ │ SECURITY AUDIT │ npm audit
52
+ │ ↓ pass │
53
+ │ BUNDLE SIZE │ bundlesize check
54
+ └─────────────────┘
55
+
56
+
57
+ Ready for review
58
+ ```
59
+
60
+ **No gate can be skipped.** If lint fails, fix lint — don't disable the rule. If a test fails, fix the code — don't skip the test.
61
+
62
+ ## GitHub Actions Configuration
63
+
64
+ ### Basic CI Pipeline
65
+
66
+ ```yaml
67
+ # .github/workflows/ci.yml
68
+ name: CI
69
+
70
+ on:
71
+ pull_request:
72
+ branches: [main]
73
+ push:
74
+ branches: [main]
75
+
76
+ jobs:
77
+ quality:
78
+ runs-on: ubuntu-latest
79
+ steps:
80
+ - uses: actions/checkout@v4
81
+
82
+ - uses: actions/setup-node@v4
83
+ with:
84
+ node-version: '22'
85
+ cache: 'npm'
86
+
87
+ - name: Install dependencies
88
+ run: npm ci
89
+
90
+ - name: Lint
91
+ run: npm run lint
92
+
93
+ - name: Type check
94
+ run: npx tsc --noEmit
95
+
96
+ - name: Test
97
+ run: npm test -- --coverage
98
+
99
+ - name: Build
100
+ run: npm run build
101
+
102
+ - name: Security audit
103
+ run: npm audit --audit-level=high
104
+ ```
105
+
106
+ ### With Database Integration Tests
107
+
108
+ ```yaml
109
+ integration:
110
+ runs-on: ubuntu-latest
111
+ services:
112
+ postgres:
113
+ image: postgres:16
114
+ env:
115
+ POSTGRES_DB: testdb
116
+ POSTGRES_USER: ci_user
117
+ POSTGRES_PASSWORD: ${{ secrets.CI_DB_PASSWORD }}
118
+ ports:
119
+ - 5432:5432
120
+ options: >-
121
+ --health-cmd pg_isready
122
+ --health-interval 10s
123
+ --health-timeout 5s
124
+ --health-retries 5
125
+
126
+ steps:
127
+ - uses: actions/checkout@v4
128
+ - uses: actions/setup-node@v4
129
+ with:
130
+ node-version: '22'
131
+ cache: 'npm'
132
+ - run: npm ci
133
+ - name: Run migrations
134
+ run: npx prisma migrate deploy
135
+ env:
136
+ DATABASE_URL: postgresql://ci_user:${{ secrets.CI_DB_PASSWORD }}@localhost:5432/testdb
137
+ - name: Integration tests
138
+ run: npm run test:integration
139
+ env:
140
+ DATABASE_URL: postgresql://ci_user:${{ secrets.CI_DB_PASSWORD }}@localhost:5432/testdb
141
+ ```
142
+
143
+ > **Note:** Even for CI-only test databases, use GitHub Secrets for credentials rather than hardcoding values. This builds good habits and prevents accidental reuse of test credentials in other contexts.
144
+
145
+ ### E2E Tests
146
+
147
+ ```yaml
148
+ e2e:
149
+ runs-on: ubuntu-latest
150
+ steps:
151
+ - uses: actions/checkout@v4
152
+ - uses: actions/setup-node@v4
153
+ with:
154
+ node-version: '22'
155
+ cache: 'npm'
156
+ - run: npm ci
157
+ - name: Install Playwright
158
+ run: npx playwright install --with-deps chromium
159
+ - name: Build
160
+ run: npm run build
161
+ - name: Run E2E tests
162
+ run: npx playwright test
163
+ - uses: actions/upload-artifact@v4
164
+ if: failure()
165
+ with:
166
+ name: playwright-report
167
+ path: playwright-report/
168
+ ```
169
+
170
+ ## Feeding CI Failures Back to Agents
171
+
172
+ The power of CI with AI agents is the feedback loop. When CI fails:
173
+
174
+ ```
175
+ CI fails
176
+
177
+
178
+ Copy the failure output
179
+
180
+
181
+ Feed it to the agent:
182
+ "The CI pipeline failed with this error:
183
+ [paste specific error]
184
+ Fix the issue and verify locally before pushing again."
185
+
186
+
187
+ Agent fixes → pushes → CI runs again
188
+ ```
189
+
190
+ **Key patterns:**
191
+
192
+ ```
193
+ Lint failure → Agent runs `npm run lint --fix` and commits
194
+ Type error → Agent reads the error location and fixes the type
195
+ Test failure → Agent follows debugging-and-error-recovery skill
196
+ Build error → Agent checks config and dependencies
197
+ ```
198
+
199
+ ## Deployment Strategies
200
+
201
+ ### Preview Deployments
202
+
203
+ Every PR gets a preview deployment for manual testing:
204
+
205
+ ```yaml
206
+ # Deploy preview on PR (Vercel/Netlify/etc.)
207
+ deploy-preview:
208
+ runs-on: ubuntu-latest
209
+ if: github.event_name == 'pull_request'
210
+ steps:
211
+ - uses: actions/checkout@v4
212
+ - name: Deploy preview
213
+ run: npx vercel --token=${{ secrets.VERCEL_TOKEN }}
214
+ ```
215
+
216
+ ### Feature Flags
217
+
218
+ Feature flags decouple deployment from release. Deploy incomplete or risky features behind flags so you can:
219
+
220
+ - **Ship code without enabling it.** Merge to main early, enable when ready.
221
+ - **Roll back without redeploying.** Disable the flag instead of reverting code.
222
+ - **Canary new features.** Enable for 1% of users, then 10%, then 100%.
223
+ - **Run A/B tests.** Compare behavior with and without the feature.
224
+
225
+ ```typescript
226
+ // Simple feature flag pattern
227
+ if (featureFlags.isEnabled('new-checkout-flow', { userId })) {
228
+ return renderNewCheckout();
229
+ }
230
+ return renderLegacyCheckout();
231
+ ```
232
+
233
+ **Flag lifecycle:** Create → Enable for testing → Canary → Full rollout → Remove the flag and dead code. Flags that live forever become technical debt — set a cleanup date when you create them.
234
+
235
+ ### Staged Rollouts
236
+
237
+ ```
238
+ PR merged to main
239
+
240
+
241
+ Staging deployment (auto)
242
+ │ Manual verification
243
+
244
+ Production deployment (manual trigger or auto after staging)
245
+
246
+
247
+ Monitor for errors (15-minute window)
248
+
249
+ ├── Errors detected → Rollback
250
+ └── Clean → Done
251
+ ```
252
+
253
+ ### Rollback Plan
254
+
255
+ Every deployment should be reversible:
256
+
257
+ ```yaml
258
+ # Manual rollback workflow
259
+ name: Rollback
260
+ on:
261
+ workflow_dispatch:
262
+ inputs:
263
+ version:
264
+ description: 'Version to rollback to'
265
+ required: true
266
+
267
+ jobs:
268
+ rollback:
269
+ runs-on: ubuntu-latest
270
+ steps:
271
+ - name: Rollback deployment
272
+ run: |
273
+ # Deploy the specified previous version
274
+ npx vercel rollback ${{ inputs.version }}
275
+ ```
276
+
277
+ ## Environment Management
278
+
279
+ ```
280
+ .env.example → Committed (template for developers)
281
+ .env → NOT committed (local development)
282
+ .env.test → Committed (test environment, no real secrets)
283
+ CI secrets → Stored in GitHub Secrets / vault
284
+ Production secrets → Stored in deployment platform / vault
285
+ ```
286
+
287
+ CI should never have production secrets. Use separate secrets for CI testing.
288
+
289
+ ## Automation Beyond CI
290
+
291
+ ### Dependabot / Renovate
292
+
293
+ ```yaml
294
+ # .github/dependabot.yml
295
+ version: 2
296
+ updates:
297
+ - package-ecosystem: npm
298
+ directory: /
299
+ schedule:
300
+ interval: weekly
301
+ open-pull-requests-limit: 5
302
+ ```
303
+
304
+ ### Build Cop Role
305
+
306
+ Designate someone responsible for keeping CI green. When the build breaks, the Build Cop's job is to fix or revert — not the person whose change caused the break. This prevents broken builds from accumulating while everyone assumes someone else will fix it.
307
+
308
+ ### PR Checks
309
+
310
+ - **Required reviews:** At least 1 approval before merge
311
+ - **Required status checks:** CI must pass before merge
312
+ - **Branch protection:** No force-pushes to main
313
+ - **Auto-merge:** If all checks pass and approved, merge automatically
314
+
315
+ ## CI Optimization
316
+
317
+ When the pipeline exceeds 10 minutes, apply these strategies in order of impact:
318
+
319
+ ```
320
+ Slow CI pipeline?
321
+ ├── Cache dependencies
322
+ │ └── Use actions/cache or setup-node cache option for node_modules
323
+ ├── Run jobs in parallel
324
+ │ └── Split lint, typecheck, test, build into separate parallel jobs
325
+ ├── Only run what changed
326
+ │ └── Use path filters to skip unrelated jobs (e.g., skip e2e for docs-only PRs)
327
+ ├── Use matrix builds
328
+ │ └── Shard test suites across multiple runners
329
+ ├── Optimize the test suite
330
+ │ └── Remove slow tests from the critical path, run them on a schedule instead
331
+ └── Use larger runners
332
+ └── GitHub-hosted larger runners or self-hosted for CPU-heavy builds
333
+ ```
334
+
335
+ **Example: caching and parallelism**
336
+ ```yaml
337
+ jobs:
338
+ lint:
339
+ runs-on: ubuntu-latest
340
+ steps:
341
+ - uses: actions/checkout@v4
342
+ - uses: actions/setup-node@v4
343
+ with: { node-version: '22', cache: 'npm' }
344
+ - run: npm ci
345
+ - run: npm run lint
346
+
347
+ typecheck:
348
+ runs-on: ubuntu-latest
349
+ steps:
350
+ - uses: actions/checkout@v4
351
+ - uses: actions/setup-node@v4
352
+ with: { node-version: '22', cache: 'npm' }
353
+ - run: npm ci
354
+ - run: npx tsc --noEmit
355
+
356
+ test:
357
+ runs-on: ubuntu-latest
358
+ steps:
359
+ - uses: actions/checkout@v4
360
+ - uses: actions/setup-node@v4
361
+ with: { node-version: '22', cache: 'npm' }
362
+ - run: npm ci
363
+ - run: npm test -- --coverage
364
+ ```
365
+
366
+ ## Common Rationalizations
367
+
368
+ | Rationalization | Reality |
369
+ |---|---|
370
+ | "CI is too slow" | Optimize the pipeline (see CI Optimization below), don't skip it. A 5-minute pipeline prevents hours of debugging. |
371
+ | "This change is trivial, skip CI" | Trivial changes break builds. CI is fast for trivial changes anyway. |
372
+ | "The test is flaky, just re-run" | Flaky tests mask real bugs and waste everyone's time. Fix the flakiness. |
373
+ | "We'll add CI later" | Projects without CI accumulate broken states. Set it up on day one. |
374
+ | "Manual testing is enough" | Manual testing doesn't scale and isn't repeatable. Automate what you can. |
375
+
376
+ ## Red Flags
377
+
378
+ - No CI pipeline in the project
379
+ - CI failures ignored or silenced
380
+ - Tests disabled in CI to make the pipeline pass
381
+ - Production deploys without staging verification
382
+ - No rollback mechanism
383
+ - Secrets stored in code or CI config files (not secrets manager)
384
+ - Long CI times with no optimization effort
385
+
386
+ ## Required Checks
387
+
388
+ After setting up or modifying CI:
389
+
390
+ - [ ] All quality gates are present (lint, types, tests, build, audit)
391
+ - [ ] Pipeline runs on every PR and push to main
392
+ - [ ] Failures block merge (branch protection configured)
393
+ - [ ] CI results feed back into the development loop
394
+ - [ ] Secrets are stored in the secrets manager, not in code
395
+ - [ ] Deployment has a rollback mechanism
396
+ - [ ] Pipeline runs in under 10 minutes for the test suite
397
+
398
+ ## Verification
399
+ After completing the skill, confirm:
400
+ - [ ] Newly configured/updated workflow syntax is linted and validates successfully.
401
+ - [ ] Caching blocks are verified locally to confirm they cache package directories correctly.
402
+ - [ ] Branch protection status checks are confirmed active and secrets are decoupled from codebase source files.
@@ -0,0 +1,297 @@
1
+ ---
2
+ name: docker-skill
3
+ description: Containerize applications using Docker. Enforce production-grade security, multi-stage builds, and optimized resource allocation.
4
+ hints:
5
+ - Check openSrc/ or existing project files for Dockerfiles or docker-compose.yml files if available.
6
+ - Employ multi-stage builds and slim/alpine base images to produce compact, secure final images.
7
+ - Order Dockerfile instructions strategically: install dependencies before copying source files to optimize cache hits.
8
+ - Implement security best practices by defining a non-root USER and mounting secrets securely rather than embedding them.
9
+ - Use docker system df to inspect disk space before running prunes; never delete volumes without human confirmation.
10
+ ---
11
+
12
+ # Docker Management
13
+
14
+ ## Overview
15
+
16
+ Manage Docker containers, images, volumes, networks, and Compose stacks using standard Docker CLI commands. No additional dependencies beyond Docker itself.
17
+
18
+ ## When to Use
19
+
20
+ - Run, stop, restart, remove, or inspect containers
21
+ - Build, pull, push, tag, or clean up Docker images
22
+ - Work with Docker Compose (multi-service stacks)
23
+ - Manage volumes or networks
24
+ - Debug a crashing container or analyze logs
25
+ - Check Docker disk usage or free up space
26
+ - Review or optimize a Dockerfile
27
+
28
+ ## Prerequisites
29
+
30
+ - Docker Engine installed and running
31
+ - User added to the `docker` group (or use `sudo`)
32
+ - Docker Compose v2 (included with modern Docker installations)
33
+
34
+ Quick check:
35
+
36
+ ```bash
37
+ docker --version && docker compose version
38
+ ```
39
+
40
+ ## Quick Reference
41
+
42
+ | Task | Command |
43
+ |------|---------|
44
+ | Run container (background) | `docker run -d --name NAME IMAGE` |
45
+ | Stop + remove | `docker stop NAME && docker rm NAME` |
46
+ | View logs (follow) | `docker logs --tail 50 -f NAME` |
47
+ | Shell into container | `docker exec -it NAME /bin/sh` |
48
+ | List all containers | `docker ps -a` |
49
+ | Build image | `docker build -t TAG .` |
50
+ | Compose up | `docker compose up -d` |
51
+ | Compose down | `docker compose down` |
52
+ | Disk usage | `docker system df` |
53
+ | Cleanup dangling | `docker image prune && docker container prune` |
54
+
55
+ ## Workflow
56
+
57
+ ### 1. Identify the domain
58
+
59
+ Figure out which area the request falls into:
60
+
61
+ - **Container lifecycle** → run, stop, start, restart, rm, pause/unpause
62
+ - **Container interaction** → exec, cp, logs, inspect, stats
63
+ - **Image management** → build, pull, push, tag, rmi, save/load
64
+ - **Docker Compose** → up, down, ps, logs, exec, build, config
65
+ - **Volumes & networks** → create, inspect, rm, prune, connect
66
+ - **Troubleshooting** → log analysis, exit codes, resource issues
67
+
68
+ ### 2. Container operations
69
+
70
+ **Run a new container:**
71
+
72
+ ```bash
73
+ # Detached service with port mapping
74
+ docker run -d --name web -p 8080:80 nginx
75
+
76
+ # With environment variables
77
+ docker run -d -e POSTGRES_PASSWORD=secret -e POSTGRES_DB=mydb --name db postgres:16
78
+
79
+ # With persistent data (named volume)
80
+ docker run -d -v pgdata:/var/lib/postgresql/data --name db postgres:16
81
+
82
+ # For development (bind mount source code)
83
+ docker run -d -v $(pwd)/src:/app/src -p 3000:3000 --name dev my-app
84
+
85
+ # Interactive debugging (auto-remove on exit)
86
+ docker run -it --rm ubuntu:22.04 /bin/bash
87
+
88
+ # With resource limits and restart policy
89
+ docker run -d --memory=512m --cpus=1.5 --restart=unless-stopped --name app my-app
90
+ ```
91
+
92
+ Key flags: `-d` detached, `-it` interactive+tty, `--rm` auto-remove, `-p` port (host:container), `-e` env var, `-v` volume, `--name` name, `--restart` restart policy.
93
+
94
+ **Manage running containers:**
95
+
96
+ ```bash
97
+ docker ps # running containers
98
+ docker ps -a # all (including stopped)
99
+ docker stop NAME # graceful stop
100
+ docker start NAME # start stopped container
101
+ docker restart NAME # stop + start
102
+ docker rm NAME # remove stopped container
103
+ docker rm -f NAME # force remove running container
104
+ docker container prune # remove ALL stopped containers
105
+ ```
106
+
107
+ **Interact with containers:**
108
+
109
+ ```bash
110
+ docker exec -it NAME /bin/sh # shell access (use /bin/bash if available)
111
+ docker exec NAME env # view environment variables
112
+ docker exec -u root NAME apt update # run as specific user
113
+ docker logs --tail 100 -f NAME # follow last 100 lines
114
+ docker logs --since 2h NAME # logs from last 2 hours
115
+ docker cp NAME:/path/file ./local # copy file from container
116
+ docker cp ./file NAME:/path/ # copy file to container
117
+ docker inspect NAME # full container details (JSON)
118
+ docker stats --no-stream # resource usage snapshot
119
+ docker top NAME # running processes
120
+ ```
121
+
122
+ ### 3. Image management
123
+
124
+ ```bash
125
+ # Build
126
+ docker build -t my-app:latest .
127
+ docker build -t my-app:prod -f Dockerfile.prod .
128
+ docker build --no-cache -t my-app . # clean rebuild
129
+ DOCKER_BUILDKIT=1 docker build -t my-app . # faster with BuildKit
130
+
131
+ # Pull and push
132
+ docker pull node:20-alpine
133
+ docker login ghcr.io
134
+ docker tag my-app:latest registry/my-app:v1.0
135
+ docker push registry/my-app:v1.0
136
+
137
+ # Inspect
138
+ docker images # list local images
139
+ docker history IMAGE # see layers
140
+ docker inspect IMAGE # full details
141
+
142
+ # Cleanup
143
+ docker image prune # remove dangling (untagged) images
144
+ docker image prune -a # remove ALL unused images (careful!)
145
+ docker image prune -a --filter "until=168h" # unused images older than 7 days
146
+ ```
147
+
148
+ ### 4. Docker Compose
149
+
150
+ ```bash
151
+ # Start/stop
152
+ docker compose up -d # start all services detached
153
+ docker compose up -d --build # rebuild images before starting
154
+ docker compose down # stop and remove containers
155
+ docker compose down -v # also remove volumes (DESTROYS DATA)
156
+
157
+ # Monitoring
158
+ docker compose ps # list services
159
+ docker compose logs -f api # follow logs for specific service
160
+ docker compose logs --tail 50 # last 50 lines all services
161
+
162
+ # Interaction
163
+ docker compose exec api /bin/sh # shell into running service
164
+ docker compose run --rm api npm test # one-off command (new container)
165
+ docker compose restart api # restart specific service
166
+
167
+ # Validation
168
+ docker compose config # validate and view resolved config
169
+ ```
170
+
171
+ **Minimal compose.yml example:**
172
+
173
+ ```yaml
174
+ services:
175
+ api:
176
+ build: .
177
+ ports:
178
+ - "3000:3000"
179
+ environment:
180
+ - DATABASE_URL=postgres://user:pass@db:5432/mydb
181
+ depends_on:
182
+ db:
183
+ condition: service_healthy
184
+
185
+ db:
186
+ image: postgres:16-alpine
187
+ environment:
188
+ POSTGRES_USER: user
189
+ POSTGRES_PASSWORD: pass
190
+ POSTGRES_DB: mydb
191
+ volumes:
192
+ - pgdata:/var/lib/postgresql/data
193
+ healthcheck:
194
+ test: ["CMD-SHELL", "pg_isready -U user"]
195
+ interval: 10s
196
+ timeout: 5s
197
+ retries: 5
198
+
199
+ volumes:
200
+ pgdata:
201
+ ```
202
+
203
+ ### 5. Volumes and networks
204
+
205
+ ```bash
206
+ # Volumes
207
+ docker volume ls # list volumes
208
+ docker volume create mydata # create named volume
209
+ docker volume inspect mydata # details (mount point, etc.)
210
+ docker volume rm mydata # remove (fails if in use)
211
+ docker volume prune # remove unused volumes
212
+
213
+ # Networks
214
+ docker network ls # list networks
215
+ docker network create mynet # create bridge network
216
+ docker network inspect mynet # details (connected containers)
217
+ docker network connect mynet NAME # attach container to network
218
+ docker network disconnect mynet NAME # detach container
219
+ docker network rm mynet # remove network
220
+ docker network prune # remove unused networks
221
+ ```
222
+
223
+ ### 6. Disk usage and cleanup
224
+
225
+ Always start with a diagnostic before cleaning:
226
+
227
+ ```bash
228
+ # Check what's using space
229
+ docker system df # summary
230
+ docker system df -v # detailed breakdown
231
+
232
+ # Targeted cleanup (safe)
233
+ docker container prune # stopped containers
234
+ docker image prune # dangling images
235
+ docker volume prune # unused volumes
236
+ docker network prune # unused networks
237
+
238
+ # Aggressive cleanup (confirm with user first!)
239
+ docker system prune # containers + images + networks
240
+ docker system prune -a # also unused images
241
+ docker system prune -a --volumes # EVERYTHING — named volumes too
242
+ ```
243
+
244
+ **Warning:** Never run `docker system prune -a --volumes` without confirming with the user. This removes named volumes with potentially important data.
245
+
246
+ ## Pitfalls
247
+
248
+ | Problem | Cause | Fix |
249
+ |---------|-------|-----|
250
+ | Container exits immediately | Main process finished or crashed | Check `docker logs NAME`, try `docker run -it --entrypoint /bin/sh IMAGE` |
251
+ | "port is already allocated" | Another process using that port | `docker ps` or `lsof -i :PORT` to find it |
252
+ | "no space left on device" | Docker disk full | `docker system df` then targeted prune |
253
+ | Can't connect to container | App binds to 127.0.0.1 inside container | App must bind to `0.0.0.0`, check `-p` mapping |
254
+ | Permission denied on volume | UID/GID mismatch host vs container | Use `--user $(id -u):$(id -g)` or fix permissions |
255
+ | Compose services can't reach each other | Wrong network or service name | Services use service name as hostname, check `docker compose config` |
256
+ | Build cache not working | Layer order wrong in Dockerfile | Put rarely-changing layers first (deps before source code) |
257
+ | Image too large | No multi-stage build, no .dockerignore | Use multi-stage builds, add `.dockerignore` |
258
+
259
+ ## Required Checks
260
+
261
+ After any Docker operation, verify the result:
262
+
263
+ - **Container started?** → `docker ps` (check status is "Up")
264
+ - **Logs clean?** → `docker logs --tail 20 NAME` (no errors)
265
+ - **Port accessible?** → `curl -s http://localhost:PORT` or `docker port NAME`
266
+ - **Image built?** → `docker images | grep TAG`
267
+ - **Compose stack healthy?** → `docker compose ps` (all services "running" or "healthy")
268
+ - **Disk freed?** → `docker system df` (compare before/after)
269
+
270
+ ## Dockerfile Optimization Tips
271
+
272
+ When reviewing or creating a Dockerfile, suggest these improvements:
273
+
274
+ 1. **Multi-stage builds** — separate build environment from runtime to reduce final image size
275
+ 2. **Layer ordering** — put dependencies before source code so changes don't invalidate cached layers
276
+ 3. **Combine RUN commands** — fewer layers, smaller image
277
+ 4. **Use .dockerignore** — exclude `node_modules`, `.git`, `__pycache__`, etc.
278
+ 5. **Pin base image versions** — `node:20-alpine` not `node:latest`
279
+ 6. **Run as non-root** — add `USER` instruction for security
280
+ 7. **Use slim/alpine bases** — `python:3.12-slim` not `python:3.12`
281
+
282
+ ## Common Rationalizations
283
+ | Rationalization | Reality |
284
+ |---|---|
285
+ | I'll clean up the build cache later. | Docker build caches can quickly consume dozens of gigabytes of disk space, leading to system hangs. |
286
+ | Pinned image tags aren't necessary. | Using `latest` tag breaks build predictability and can introduce silent upstream bugs. |
287
+
288
+ ## Red Flags
289
+ - Hardcoded database passwords or secrets in Dockerfiles or `docker-compose.yml` configs.
290
+ - Giant image sizes (e.g. >1GB) due to lack of multi-stage builds or missing `.dockerignore`.
291
+ - Running containers as the root user inside production environments.
292
+
293
+ ## Verification
294
+ After completing the skill, confirm:
295
+ - [ ] Newly written Dockerfiles or compose setups are linted/validated via `docker compose config`.
296
+ - [ ] Final built images have been inspected for size and layers.
297
+ - [ ] No local configuration volumes are deleted without explicit backup or manual consent.