@skill-graph/cli 0.5.6

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 (330) hide show
  1. package/CHANGELOG.md +247 -0
  2. package/LICENSE +200 -0
  3. package/NOTICE +62 -0
  4. package/README.md +398 -0
  5. package/SKILL_GRAPH.md +443 -0
  6. package/bin/skill-graph.js +374 -0
  7. package/docs/ADOPTION.md +117 -0
  8. package/docs/CONFORMANCE.md +66 -0
  9. package/docs/PRIMER.md +384 -0
  10. package/docs/QUICKSTART-30MIN.md +333 -0
  11. package/docs/ROUTING-METRICS.md +120 -0
  12. package/docs/SKILL-MD-FORMAT-COMPATIBILITY.md +127 -0
  13. package/docs/SKILL_AUDIT_CHECKLIST.md +199 -0
  14. package/docs/SKILL_AUDIT_LOOP.md +195 -0
  15. package/docs/SKILL_METADATA_PROTOCOL.md +609 -0
  16. package/docs/_archived/marketplace-publication-priority-2026-05-18.md +239 -0
  17. package/docs/adr/0001-predicate-set.md +69 -0
  18. package/docs/adr/0002-json-ld-context.md +82 -0
  19. package/docs/adr/0003-ontoclean-rigidity-tags.md +65 -0
  20. package/docs/adr/0004-persistent-identifiers.md +74 -0
  21. package/docs/adr/0005-freshness-consolidation.md +70 -0
  22. package/docs/adr/0006-revise-predicate-rename.md +105 -0
  23. package/docs/adr/0007-audit-loop-cadence.md +99 -0
  24. package/docs/adr/0008-skill-surface-split-and-curation-policy.md +93 -0
  25. package/docs/category-consumers.md +168 -0
  26. package/docs/concept-map.md +194 -0
  27. package/docs/diagrams/drift-states.mmd +21 -0
  28. package/docs/diagrams/manifest-pipeline.mmd +25 -0
  29. package/docs/diagrams/routing-harness.mmd +41 -0
  30. package/docs/diagrams/starter-graph.mmd +53 -0
  31. package/docs/field-decision-guide.md +315 -0
  32. package/docs/field-rationale.md +211 -0
  33. package/docs/field-reference.generated.md +624 -0
  34. package/docs/field-reference.md +1426 -0
  35. package/docs/glossary.md +190 -0
  36. package/docs/head-noun-glossary.md +63 -0
  37. package/docs/images/audit-phases.png +0 -0
  38. package/docs/images/drift-states.png +0 -0
  39. package/docs/images/graded-mode.png +0 -0
  40. package/docs/images/manifest-pipeline.png +0 -0
  41. package/docs/images/routing-harness.png +0 -0
  42. package/docs/images/skill-anatomy.png +0 -0
  43. package/docs/images/starter-graph.png +0 -0
  44. package/docs/images/system-model.png +0 -0
  45. package/docs/integrations/github-actions.md +155 -0
  46. package/docs/manifest-field-mapping.md +443 -0
  47. package/docs/marketplace-publication-queue.generated.md +240 -0
  48. package/docs/marketplace-release-agent-prompt.md +82 -0
  49. package/docs/marketplace-skill-candidate-list.md +272 -0
  50. package/docs/marketplace-syndication.md +222 -0
  51. package/docs/migration-sample-review.md +155 -0
  52. package/docs/migrations/v4-to-v5.md +168 -0
  53. package/docs/migrations/v5-to-v6.md +221 -0
  54. package/docs/name-exceptions.yaml +37 -0
  55. package/docs/plans/marketplace-p1-public-migration-plan.md +41 -0
  56. package/docs/plans/multi-root-workspace.md +148 -0
  57. package/docs/plans/scripts-roadmap.md +107 -0
  58. package/docs/plans/v4-schema-bump.md +160 -0
  59. package/docs/plans/wave-2-extraction.md +122 -0
  60. package/docs/positioning-vs-marketplaces.md +175 -0
  61. package/docs/proposals/skill-audit-loop-positioning.md +160 -0
  62. package/docs/quality-doctrine.md +138 -0
  63. package/docs/recommended-skills.md +150 -0
  64. package/docs/research/skill-comprehension-eval-research.md +1830 -0
  65. package/docs/research/skill-retrieval-evidence.md +66 -0
  66. package/docs/skill-metadata-protocol.md +471 -0
  67. package/docs/skills-sh-maintainer-cleanup-request.md +80 -0
  68. package/examples/audits/a11y/findings.md +52 -0
  69. package/examples/audits/a11y/scorecard.md +21 -0
  70. package/examples/audits/a11y/verdict.md +44 -0
  71. package/examples/audits/debugging/findings.md +59 -0
  72. package/examples/audits/debugging/scorecard.md +22 -0
  73. package/examples/audits/debugging/verdict.md +33 -0
  74. package/examples/audits/documentation/findings.md +59 -0
  75. package/examples/audits/documentation/scorecard.md +22 -0
  76. package/examples/audits/documentation/verdict.md +33 -0
  77. package/examples/evals/a11y.json +140 -0
  78. package/examples/evals/api-design.json +52 -0
  79. package/examples/evals/code-review.json +52 -0
  80. package/examples/evals/data-modeling.json +52 -0
  81. package/examples/evals/database-migration.json +52 -0
  82. package/examples/evals/debugging.json +118 -0
  83. package/examples/evals/dependency-architecture.json +52 -0
  84. package/examples/evals/design-system-architecture.json +52 -0
  85. package/examples/evals/error-tracking.json +52 -0
  86. package/examples/evals/event-contract-design.json +52 -0
  87. package/examples/evals/form-ux-architecture.json +52 -0
  88. package/examples/evals/framework-fit-analysis.json +52 -0
  89. package/examples/evals/graph-audit.json +139 -0
  90. package/examples/evals/information-architecture.json +52 -0
  91. package/examples/evals/interaction-feedback.json +52 -0
  92. package/examples/evals/interaction-patterns.json +52 -0
  93. package/examples/evals/layout-composition.json +52 -0
  94. package/examples/evals/lint-overlay.json +117 -0
  95. package/examples/evals/microcopy.json +52 -0
  96. package/examples/evals/observability-modeling.json +52 -0
  97. package/examples/evals/pattern-recognition.json +96 -0
  98. package/examples/evals/performance-engineering.json +52 -0
  99. package/examples/evals/refactor.json +128 -0
  100. package/examples/evals/semiotics.json +52 -0
  101. package/examples/evals/skill-infrastructure.json +96 -0
  102. package/examples/evals/skill-router.json +140 -0
  103. package/examples/evals/skill-router.routing.json +113 -0
  104. package/examples/evals/system-interface-contracts.json +52 -0
  105. package/examples/evals/task-analysis.json +52 -0
  106. package/examples/evals/testing-strategy.json +118 -0
  107. package/examples/evals/type-safety.json +249 -0
  108. package/examples/evals/visual-design-foundations.json +52 -0
  109. package/examples/evals/webhook-integration.json +52 -0
  110. package/examples/exports/a11y.skill-md.md +80 -0
  111. package/examples/exports/debugging.skill-md.md +80 -0
  112. package/examples/exports/refactor.skill-md.md +78 -0
  113. package/examples/exports/testing-strategy.skill-md.md +81 -0
  114. package/examples/projects/markdown-static-site/README.md +115 -0
  115. package/examples/projects/markdown-static-site/skills/content-source-router/SKILL.md +131 -0
  116. package/examples/projects/markdown-static-site/skills/image-optimization-pipeline-config/SKILL.md +132 -0
  117. package/examples/projects/markdown-static-site/skills/link-rot-detection/SKILL.md +103 -0
  118. package/examples/projects/markdown-static-site/skills/markdown-post-frontmatter-validation/SKILL.md +133 -0
  119. package/examples/projects/markdown-static-site/skills/migrate-posts-to-v2-frontmatter/SKILL.md +140 -0
  120. package/examples/projects/saas-stripe-postgres/README.md +208 -0
  121. package/examples/projects/saas-stripe-postgres/db/migrations/0004_canonicalize_orders.sql +37 -0
  122. package/examples/projects/saas-stripe-postgres/db/schema.sql +112 -0
  123. package/examples/projects/saas-stripe-postgres/skills/migrate-orders-to-canonical-schema/SKILL.md +149 -0
  124. package/examples/projects/saas-stripe-postgres/skills/nextjs-server-action-validation/SKILL.md +154 -0
  125. package/examples/projects/saas-stripe-postgres/skills/payment-provider-router/SKILL.md +153 -0
  126. package/examples/projects/saas-stripe-postgres/skills/postgres-rls-pattern/SKILL.md +163 -0
  127. package/examples/projects/saas-stripe-postgres/skills/stripe-webhook-signature-verification/SKILL.md +137 -0
  128. package/examples/protocol/skill-metadata-template.md +301 -0
  129. package/examples/protocol/skills.manifest.sample.json +13245 -0
  130. package/examples/skill-metadata-template.md +317 -0
  131. package/examples/skills.manifest.sample.json +13519 -0
  132. package/examples/tests/v3-1-skos-fixture/SKILL.md +93 -0
  133. package/marketplace/README.md +17 -0
  134. package/marketplace/skills/a11y/SKILL.md +66 -0
  135. package/marketplace/skills/acid-fundamentals/SKILL.md +106 -0
  136. package/marketplace/skills/agent-engineering/SKILL.md +386 -0
  137. package/marketplace/skills/agent-eval-design/SKILL.md +55 -0
  138. package/marketplace/skills/ai-native-development/SKILL.md +294 -0
  139. package/marketplace/skills/api-design/SKILL.md +60 -0
  140. package/marketplace/skills/architecture-decision-records/SKILL.md +55 -0
  141. package/marketplace/skills/background-jobs/SKILL.md +265 -0
  142. package/marketplace/skills/bounded-context-mapping/SKILL.md +55 -0
  143. package/marketplace/skills/cap-theorem-tradeoffs/SKILL.md +127 -0
  144. package/marketplace/skills/client-server-boundary/SKILL.md +187 -0
  145. package/marketplace/skills/code-review/SKILL.md +120 -0
  146. package/marketplace/skills/color-system-design/SKILL.md +43 -0
  147. package/marketplace/skills/component-architecture/SKILL.md +126 -0
  148. package/marketplace/skills/compression/SKILL.md +112 -0
  149. package/marketplace/skills/conceptual-modeling/SKILL.md +181 -0
  150. package/marketplace/skills/connection-pooling/SKILL.md +105 -0
  151. package/marketplace/skills/constraint-awareness/SKILL.md +287 -0
  152. package/marketplace/skills/content-monitor/SKILL.md +209 -0
  153. package/marketplace/skills/context-engineering/SKILL.md +320 -0
  154. package/marketplace/skills/context-graph/SKILL.md +174 -0
  155. package/marketplace/skills/context-management/SKILL.md +174 -0
  156. package/marketplace/skills/context-window/SKILL.md +239 -0
  157. package/marketplace/skills/contract-testing/SKILL.md +120 -0
  158. package/marketplace/skills/cron-scheduling/SKILL.md +223 -0
  159. package/marketplace/skills/dark-mode-implementation/SKILL.md +47 -0
  160. package/marketplace/skills/data-modeling/SKILL.md +59 -0
  161. package/marketplace/skills/data-modeling-fundamentals/SKILL.md +117 -0
  162. package/marketplace/skills/database-migration/SKILL.md +429 -0
  163. package/marketplace/skills/debugging/SKILL.md +67 -0
  164. package/marketplace/skills/dependency-architecture/SKILL.md +58 -0
  165. package/marketplace/skills/design-module-composition/SKILL.md +43 -0
  166. package/marketplace/skills/design-system-architecture/SKILL.md +61 -0
  167. package/marketplace/skills/design-thinking/SKILL.md +44 -0
  168. package/marketplace/skills/diagnosis/SKILL.md +296 -0
  169. package/marketplace/skills/diff-analysis/SKILL.md +188 -0
  170. package/marketplace/skills/e2e-test-design/SKILL.md +113 -0
  171. package/marketplace/skills/entity-relationship-modeling/SKILL.md +218 -0
  172. package/marketplace/skills/epistemic-grounding/SKILL.md +112 -0
  173. package/marketplace/skills/error-boundary/SKILL.md +235 -0
  174. package/marketplace/skills/error-tracking/SKILL.md +261 -0
  175. package/marketplace/skills/eval-driven-development/SKILL.md +147 -0
  176. package/marketplace/skills/evaluation/SKILL.md +113 -0
  177. package/marketplace/skills/event-contract-design/SKILL.md +60 -0
  178. package/marketplace/skills/event-storming/SKILL.md +56 -0
  179. package/marketplace/skills/form-ux-architecture/SKILL.md +60 -0
  180. package/marketplace/skills/framework-fit-analysis/SKILL.md +59 -0
  181. package/marketplace/skills/frontend-architecture/SKILL.md +43 -0
  182. package/marketplace/skills/generative-ui/SKILL.md +118 -0
  183. package/marketplace/skills/graph-audit/SKILL.md +81 -0
  184. package/marketplace/skills/guardrails/SKILL.md +118 -0
  185. package/marketplace/skills/hooks-patterns/SKILL.md +185 -0
  186. package/marketplace/skills/http-semantics/SKILL.md +136 -0
  187. package/marketplace/skills/ideation/SKILL.md +41 -0
  188. package/marketplace/skills/indexing-strategy/SKILL.md +108 -0
  189. package/marketplace/skills/information-architecture/SKILL.md +59 -0
  190. package/marketplace/skills/integration-test-design/SKILL.md +111 -0
  191. package/marketplace/skills/intent-recognition/SKILL.md +136 -0
  192. package/marketplace/skills/interaction-feedback/SKILL.md +59 -0
  193. package/marketplace/skills/interaction-patterns/SKILL.md +59 -0
  194. package/marketplace/skills/journey-mapping/SKILL.md +41 -0
  195. package/marketplace/skills/keywords/SKILL.md +213 -0
  196. package/marketplace/skills/knowledge-modeling/SKILL.md +232 -0
  197. package/marketplace/skills/layout-composition/SKILL.md +59 -0
  198. package/marketplace/skills/linguistics/SKILL.md +429 -0
  199. package/marketplace/skills/lint-overlay/SKILL.md +76 -0
  200. package/marketplace/skills/mental-models/SKILL.md +126 -0
  201. package/marketplace/skills/merge-queue/SKILL.md +94 -0
  202. package/marketplace/skills/methodology/SKILL.md +317 -0
  203. package/marketplace/skills/microcopy/SKILL.md +232 -0
  204. package/marketplace/skills/middleware-patterns/SKILL.md +363 -0
  205. package/marketplace/skills/mobile-responsive-ux/SKILL.md +287 -0
  206. package/marketplace/skills/mutation-testing/SKILL.md +112 -0
  207. package/marketplace/skills/naming-conventions/SKILL.md +112 -0
  208. package/marketplace/skills/observability-modeling/SKILL.md +59 -0
  209. package/marketplace/skills/ontology-modeling/SKILL.md +67 -0
  210. package/marketplace/skills/owasp-security/SKILL.md +153 -0
  211. package/marketplace/skills/pattern-recognition/SKILL.md +472 -0
  212. package/marketplace/skills/performance-budgets/SKILL.md +185 -0
  213. package/marketplace/skills/performance-engineering/SKILL.md +58 -0
  214. package/marketplace/skills/performance-testing/SKILL.md +125 -0
  215. package/marketplace/skills/printify/SKILL.md +42 -0
  216. package/marketplace/skills/prioritization/SKILL.md +118 -0
  217. package/marketplace/skills/problem-framing/SKILL.md +41 -0
  218. package/marketplace/skills/problem-locating-solving/SKILL.md +203 -0
  219. package/marketplace/skills/project-knowledge-extraction/SKILL.md +54 -0
  220. package/marketplace/skills/prompt-craft/SKILL.md +134 -0
  221. package/marketplace/skills/prompt-injection-defense/SKILL.md +132 -0
  222. package/marketplace/skills/property-based-testing/SKILL.md +100 -0
  223. package/marketplace/skills/prototyping/SKILL.md +43 -0
  224. package/marketplace/skills/query-optimization/SKILL.md +144 -0
  225. package/marketplace/skills/real-time-updates/SKILL.md +324 -0
  226. package/marketplace/skills/ref-patterns/SKILL.md +284 -0
  227. package/marketplace/skills/refactor/SKILL.md +65 -0
  228. package/marketplace/skills/rendering-models/SKILL.md +142 -0
  229. package/marketplace/skills/replication-patterns/SKILL.md +110 -0
  230. package/marketplace/skills/research-synthesis/SKILL.md +41 -0
  231. package/marketplace/skills/route-handler-design/SKILL.md +347 -0
  232. package/marketplace/skills/schema-evolution/SKILL.md +140 -0
  233. package/marketplace/skills/security-fundamentals/SKILL.md +139 -0
  234. package/marketplace/skills/semantic-center/SKILL.md +194 -0
  235. package/marketplace/skills/semantic-relations/SKILL.md +250 -0
  236. package/marketplace/skills/semantics/SKILL.md +366 -0
  237. package/marketplace/skills/semiotics/SKILL.md +230 -0
  238. package/marketplace/skills/seo-strategy/SKILL.md +260 -0
  239. package/marketplace/skills/server-actions-design/SKILL.md +243 -0
  240. package/marketplace/skills/server-components-design/SKILL.md +190 -0
  241. package/marketplace/skills/sharding-strategy/SKILL.md +123 -0
  242. package/marketplace/skills/shopify/SKILL.md +42 -0
  243. package/marketplace/skills/skill-infrastructure/SKILL.md +320 -0
  244. package/marketplace/skills/skill-router/SKILL.md +71 -0
  245. package/marketplace/skills/skill-scaffold/SKILL.md +105 -0
  246. package/marketplace/skills/snapshot-testing/SKILL.md +120 -0
  247. package/marketplace/skills/spec-driven-development/SKILL.md +148 -0
  248. package/marketplace/skills/state-machine-modeling/SKILL.md +56 -0
  249. package/marketplace/skills/state-management/SKILL.md +134 -0
  250. package/marketplace/skills/streaming-architecture/SKILL.md +194 -0
  251. package/marketplace/skills/summarization/SKILL.md +156 -0
  252. package/marketplace/skills/suspense-patterns/SKILL.md +265 -0
  253. package/marketplace/skills/system-interface-contracts/SKILL.md +59 -0
  254. package/marketplace/skills/task-analysis/SKILL.md +201 -0
  255. package/marketplace/skills/taxonomy-design/SKILL.md +66 -0
  256. package/marketplace/skills/test-coverage-strategy/SKILL.md +108 -0
  257. package/marketplace/skills/test-doubles-design/SKILL.md +98 -0
  258. package/marketplace/skills/test-driven-development/SKILL.md +96 -0
  259. package/marketplace/skills/testing-strategy/SKILL.md +67 -0
  260. package/marketplace/skills/theme-system-design/SKILL.md +43 -0
  261. package/marketplace/skills/tool-call-flow/SKILL.md +229 -0
  262. package/marketplace/skills/tool-call-strategy/SKILL.md +292 -0
  263. package/marketplace/skills/transaction-isolation/SKILL.md +98 -0
  264. package/marketplace/skills/type-safety/SKILL.md +177 -0
  265. package/marketplace/skills/typography-system/SKILL.md +43 -0
  266. package/marketplace/skills/usability-testing/SKILL.md +43 -0
  267. package/marketplace/skills/user-research/SKILL.md +43 -0
  268. package/marketplace/skills/vercel-composition-patterns/SKILL.md +157 -0
  269. package/marketplace/skills/version-control/SKILL.md +233 -0
  270. package/marketplace/skills/visual-design-foundations/SKILL.md +59 -0
  271. package/marketplace/skills/visual-hierarchy/SKILL.md +43 -0
  272. package/marketplace/skills/webhook-integration/SKILL.md +331 -0
  273. package/marketplace/skills/writing-humanizer/SKILL.md +380 -0
  274. package/package.json +67 -0
  275. package/schemas/manifest.schema.json +811 -0
  276. package/schemas/manifest.v2.schema.json +164 -0
  277. package/schemas/manifest.v3.schema.json +758 -0
  278. package/schemas/manifest.v4.schema.json +755 -0
  279. package/schemas/manifest.v5.schema.json +755 -0
  280. package/schemas/manifest.v6.schema.json +811 -0
  281. package/schemas/skill.context.jsonld +279 -0
  282. package/schemas/skill.schema.json +919 -0
  283. package/schemas/skill.v2.schema.json +201 -0
  284. package/schemas/skill.v3.schema.json +827 -0
  285. package/schemas/skill.v4.schema.json +822 -0
  286. package/schemas/skill.v5.schema.json +830 -0
  287. package/schemas/skill.v6.schema.json +946 -0
  288. package/schemas/vocabulary/keywords.json +180 -0
  289. package/schemas/vocabulary/workspace_tags.json +23 -0
  290. package/scripts/__tests__/migrate-skill-v2-to-v3.test.js +161 -0
  291. package/scripts/__tests__/migrate-skill-v3-to-v4.test.js +158 -0
  292. package/scripts/__tests__/test-export-parser-drift.js +149 -0
  293. package/scripts/__tests__/test-marketplace-export.js +114 -0
  294. package/scripts/__tests__/test-router-paths.js +82 -0
  295. package/scripts/__tests__/test-stability-promotion.js +244 -0
  296. package/scripts/__tests__/test-v3-1-alias-contract.js +109 -0
  297. package/scripts/__tests__/test-v3-1-skos-runtime.js +116 -0
  298. package/scripts/backfill-schema-version.js +198 -0
  299. package/scripts/build-field-reference.js +160 -0
  300. package/scripts/build-retrieval-baseline.js +511 -0
  301. package/scripts/check-markdown-links.js +211 -0
  302. package/scripts/check-protocol-consistency.js +979 -0
  303. package/scripts/export-marketplace-skills.js +610 -0
  304. package/scripts/export-skill.js +374 -0
  305. package/scripts/generate-manifest.js +787 -0
  306. package/scripts/lib/alias-contract.js +83 -0
  307. package/scripts/lib/audit-prompt-builder.js +771 -0
  308. package/scripts/lib/mock-grader.js +134 -0
  309. package/scripts/lib/parse-frontmatter.js +429 -0
  310. package/scripts/lib/roots.js +119 -0
  311. package/scripts/lint/check-archetype-sections.js +185 -0
  312. package/scripts/lint/check-category-enum.js +83 -0
  313. package/scripts/lint/check-routing-eval.js +146 -0
  314. package/scripts/lint/check-routing-quality.js +211 -0
  315. package/scripts/lint/check-stability-promotion.js +220 -0
  316. package/scripts/lint/format-code-frame.js +206 -0
  317. package/scripts/marketplace-install.js +125 -0
  318. package/scripts/migrate-category-to-enum.js +169 -0
  319. package/scripts/migrate-skill-v2-to-v3.js +424 -0
  320. package/scripts/migrate-skill-v3-to-v4.js +200 -0
  321. package/scripts/migrate-skill-v5-to-v6.js +304 -0
  322. package/scripts/restructure-by-category.js +85 -0
  323. package/scripts/seed-publication-classification.js +282 -0
  324. package/scripts/skill-audit.js +893 -0
  325. package/scripts/skill-graph-drift.js +483 -0
  326. package/scripts/skill-graph-route.js +766 -0
  327. package/scripts/skill-graph-routing-eval.js +393 -0
  328. package/scripts/skill-lint.js +1317 -0
  329. package/scripts/skill-overlap.js +213 -0
  330. package/scripts/verify-skill-md-export.js +201 -0
@@ -0,0 +1,265 @@
1
+ ---
2
+ name: background-jobs
3
+ description: "This skill provides background job patterns for web applications: job queue architecture, long-running sync operations, progress tracking and reporting, failure handling and retry, job prioritization, and concurrency management. Load when implementing async processing, building job queues, designing progress indicators for long operations, or handling failure recovery for background work."
4
+ license: MIT
5
+ compatibility: "Markdown, Git, agent-skill runtimes"
6
+ allowed-tools: Read Grep Bash
7
+ metadata:
8
+ metadata: "{\"schema_version\":6,\"version\":\"1.0.0\",\"type\":\"capability\",\"category\":\"engineering\",\"domain\":\"engineering/async\",\"scope\":\"portable\",\"owner\":\"skill-graph-maintainer\",\"freshness\":\"2026-03-29\",\"drift_check\":\"{\\\\\\\"last_verified\\\\\\\":\\\\\\\"2026-03-29\\\\\\\"}\",\"eval_artifacts\":\"planned\",\"eval_state\":\"unverified\",\"routing_eval\":\"absent\",\"stability\":\"experimental\",\"keywords\":\"[\\\\\\\"background-jobs\\\\\\\",\\\\\\\"background\\\\\\\",\\\\\\\"jobs\\\\\\\"]\",\"triggers\":\"[\\\\\\\"background-jobs-skill\\\\\\\",\\\\\\\"job-queue-skill\\\\\\\",\\\\\\\"async-processing-skill\\\\\\\",\\\\\\\"long-running-task-skill\\\\\\\",\\\\\\\"worker-pattern-skill\\\\\\\"]\",\"relations\":\"{\\\\\\\"related\\\\\\\":[\\\\\\\"cron-scheduling\\\\\\\"],\\\\\\\"boundary\\\\\\\":[\\\\\\\"real-time-updates\\\\\\\"]}\",\"portability\":\"{\\\\\\\"readiness\\\\\\\":\\\\\\\"scripted\\\\\\\",\\\\\\\"targets\\\\\\\":[\\\\\\\"skill-md\\\\\\\"]}\",\"lifecycle\":\"{\\\\\\\"stale_after_days\\\\\\\":90,\\\\\\\"review_cadence\\\\\\\":\\\\\\\"quarterly\\\\\\\"}\",\"skill_graph_source_repo\":\"https://github.com/jacob-balslev/skill-graph\",\"skill_graph_protocol\":\"Skill Metadata Protocol v5\",\"skill_graph_project\":\"Skill Graph\",\"skill_graph_canonical_skill\":\"skills/background-jobs/SKILL.md\"}"
9
+ skill_graph_source_repo: "https://github.com/jacob-balslev/skill-graph"
10
+ skill_graph_protocol: Skill Metadata Protocol v4
11
+ skill_graph_project: Skill Graph
12
+ skill_graph_canonical_skill: skills/background-jobs/SKILL.md
13
+ ---
14
+ # Background Jobs Skill
15
+
16
+ ## Domain Context
17
+
18
+ **What is this skill?** This skill provides background job patterns for web applications: job queue architecture, long-running sync operations, progress tracking and reporting, failure handling and retry, job prioritization, and concurrency management. Load when implementing async processing, building job queues, designing progress indicators for long operations, or handling failure recovery for background work.
19
+ > If it takes longer than 10 seconds, it does not belong in a request handler. Move it to a background job with progress tracking.
20
+
21
+ ## Coverage
22
+
23
+ This skill covers job queue architecture (push-based vs pull-based, priority queues), long-running operation patterns (sync jobs, data migrations, bulk operations), progress tracking and reporting (percentage, stage-based, ETA estimation), failure handling and retry strategies (exponential backoff, dead letter queues, partial failure recovery), job prioritization and concurrency control, the decision framework for inline vs background execution, and user-facing progress communication patterns.
24
+
25
+ ## Philosophy
26
+
27
+ Background jobs are the mechanism that separates a responsive user interface from reliable data processing. The web request lifecycle imposes hard time limits (Vercel: 60-300s, Lambda: 15min), but real-world operations — syncing 50,000 orders, generating monthly reports, reconciling financial data — can take minutes or hours. Agents frequently make two mistakes: putting long operations in request handlers (causing timeouts and poor UX) or moving operations to background jobs without progress tracking (leaving users staring at a spinner with no feedback). Both destroy user trust. This skill enforces the discipline of moving heavy work out of the request path while keeping the user informed of progress.
28
+
29
+ ## Architecture
30
+
31
+ ### Execution Model Decision
32
+
33
+ | Question | If Yes | If No |
34
+ |----------|--------|-------|
35
+ | Does the user need the result immediately? | Keep inline (< 10s) | Background job |
36
+ | Can the operation fail partially? | Background with checkpoint | Simple background |
37
+ | Does the user need progress updates? | Background + progress tracking | Fire-and-forget |
38
+ | Could the operation take > 60 seconds? | Always background | Inline may work |
39
+ | Is the operation triggered by multiple sources? | Job queue with deduplication | Direct invocation OK |
40
+
41
+ ### Job Queue Architecture
42
+
43
+ ```
44
+ Producer (API route, webhook, cron)
45
+ |
46
+ v
47
+ Queue (database table, Redis, Inngest)
48
+ |
49
+ v
50
+ Worker (Inngest function, serverless fn, dedicated process)
51
+ |
52
+ v
53
+ Result Store (database, cache)
54
+ |
55
+ v
56
+ Notification (SSE, polling, email)
57
+ ```
58
+
59
+ **Queue implementation options for serverless environments:**
60
+
61
+ | Option | Pros | Cons | Best For |
62
+ |--------|------|------|----------|
63
+ | **Inngest** | Step functions, retry, dashboard, concurrency control | Vendor dependency | Complex multi-step workflows |
64
+ | **Database table** | No extra infra, transactional with app data | Polling required, no built-in retry | Simple job tracking |
65
+ | **Vercel KV / Redis** | Fast, pub/sub capable | Separate data store, no built-in retry | High-throughput simple jobs |
66
+ | **SQS / Cloud Tasks** | Managed, scalable, dead letter queues | Extra infrastructure, more complex | High-volume production systems |
67
+
68
+ ### Job State Machine
69
+
70
+ Every background job follows this state lifecycle:
71
+
72
+ ```
73
+ PENDING -> RUNNING -> COMPLETED
74
+ -> FAILED -> RETRYING -> RUNNING
75
+ -> DEAD (max retries exceeded)
76
+ -> CANCELLED (user-initiated)
77
+ ```
78
+
79
+ **Database schema pattern:**
80
+
81
+ ```sql
82
+ CREATE TABLE background_jobs (
83
+ id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
84
+ org_id UUID NOT NULL REFERENCES organizations(id),
85
+ type VARCHAR(100) NOT NULL, -- 'order-sync', 'report-generation'
86
+ status VARCHAR(20) NOT NULL DEFAULT 'pending',
87
+ priority INTEGER NOT NULL DEFAULT 5, -- 1 = highest, 10 = lowest
88
+ payload JSONB NOT NULL DEFAULT '{}',
89
+ progress_pct SMALLINT DEFAULT 0, -- 0-100
90
+ progress_message TEXT, -- 'Processing order 1,234 of 5,000'
91
+ result JSONB, -- Output data on completion
92
+ error_message TEXT, -- Error details on failure
93
+ attempts INTEGER NOT NULL DEFAULT 0,
94
+ max_attempts INTEGER NOT NULL DEFAULT 3,
95
+ started_at TIMESTAMPTZ,
96
+ completed_at TIMESTAMPTZ,
97
+ created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
98
+ updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
99
+ );
100
+
101
+ CREATE INDEX idx_jobs_status_priority ON background_jobs(status, priority)
102
+ WHERE status IN ('pending', 'running');
103
+ ```
104
+
105
+ ## Implementation Patterns
106
+
107
+ ### 1. Progress Tracking
108
+
109
+ For any operation processing N items, track progress at regular intervals:
110
+
111
+ ```typescript
112
+ async function processOrders(jobId: string, orders: Order[]) {
113
+ const total = orders.length;
114
+ for (let i = 0; i < total; i++) {
115
+ await processOrder(orders[i]);
116
+
117
+ // Update progress every 10 items or every 5 seconds (whichever comes first)
118
+ if (i % 10 === 0 || i === total - 1) {
119
+ await updateJobProgress(jobId, {
120
+ progress_pct: Math.round(((i + 1) / total) * 100),
121
+ progress_message: `Processing order ${i + 1} of ${total}`,
122
+ });
123
+ }
124
+ }
125
+ }
126
+ ```
127
+
128
+ **Progress reporting to the UI:**
129
+
130
+ | Method | Latency | Complexity | Best For |
131
+ |--------|---------|------------|----------|
132
+ | **Polling** | 2-5s | Low | Simple progress bars, MVP |
133
+ | **SSE** | Real-time | Medium | Dashboard live updates |
134
+ | **WebSocket** | Real-time | High | Bidirectional control (pause/cancel) |
135
+
136
+ ### 2. Retry with Exponential Backoff
137
+
138
+ ```typescript
139
+ function getRetryDelay(attempt: number): number {
140
+ // Base: 1s, 2s, 4s, 8s, 16s... capped at 5 minutes
141
+ const baseDelay = 1000;
142
+ const maxDelay = 5 * 60 * 1000;
143
+ const delay = Math.min(baseDelay * Math.pow(2, attempt), maxDelay);
144
+ // Add jitter to prevent thundering herd
145
+ return delay + Math.random() * 1000;
146
+ }
147
+ ```
148
+
149
+ **Retry decision matrix:**
150
+
151
+ | Error Type | Retry? | Max Attempts | Example |
152
+ |-----------|--------|--------------|---------|
153
+ | Transient (network timeout, 503) | Yes | 3-5 | API rate limit, temporary outage |
154
+ | Rate limit (429) | Yes, with backoff | 3 | Shopify API throttle |
155
+ | Client error (400, 404) | No | 0 | Bad data, missing resource |
156
+ | Auth error (401, 403) | No | 0 | Expired credentials |
157
+ | Partial success | Resume from checkpoint | 3 | 3,000 of 5,000 orders processed |
158
+
159
+ ### 3. Checkpointing for Long Operations
160
+
161
+ Operations processing thousands of items must checkpoint progress so retries resume from the last successful point, not restart from zero:
162
+
163
+ ```typescript
164
+ async function syncAllOrders(jobId: string) {
165
+ // Resume from last checkpoint if retrying
166
+ const checkpoint = await getCheckpoint(jobId);
167
+ const cursor = checkpoint?.lastCursor || null;
168
+
169
+ let page = await fetchOrders({ after: cursor });
170
+ while (page.hasMore) {
171
+ await processOrderBatch(page.orders);
172
+ await saveCheckpoint(jobId, { lastCursor: page.cursor });
173
+ page = await fetchOrders({ after: page.cursor });
174
+ }
175
+ }
176
+ ```
177
+
178
+ ### 4. Job Prioritization
179
+
180
+ Not all background jobs are equal. A user-initiated export should complete before a scheduled overnight sync:
181
+
182
+ | Priority | Level | Examples | Target Completion |
183
+ |----------|-------|---------|-------------------|
184
+ | 1 (Critical) | User-blocked | Data export, report generation user is waiting for | < 30 seconds |
185
+ | 3 (High) | User-initiated | Bulk order sync after store connect | < 5 minutes |
186
+ | 5 (Normal) | System | Scheduled daily sync, digest compilation | < 30 minutes |
187
+ | 8 (Low) | Maintenance | Data cleanup, index rebuild | < 24 hours |
188
+
189
+ ### 5. Concurrency Control
190
+
191
+ Prevent resource exhaustion by limiting concurrent job execution:
192
+
193
+ ```typescript
194
+ // Inngest pattern
195
+ export const orderSync = inngest.createFunction(
196
+ {
197
+ id: 'order-sync',
198
+ concurrency: {
199
+ limit: 5, // Max 5 concurrent syncs across all orgs
200
+ key: 'event.data.orgId', // Max 1 sync per org
201
+ },
202
+ },
203
+ { event: 'orders/sync.requested' },
204
+ async ({ event, step }) => { /* ... */ }
205
+ );
206
+ ```
207
+
208
+ ### 6. User-Facing Progress Communication
209
+
210
+ | Job Duration | UX Pattern | Example |
211
+ |-------------|------------|---------|
212
+ | < 5s | Inline loading state | Button spinner |
213
+ | 5-30s | Progress bar with percentage | "Syncing orders... 45%" |
214
+ | 30s-5min | Progress bar + stage indicator | "Step 2 of 4: Calculating margins" |
215
+ | > 5min | Background notification + email on complete | "We'll email you when your export is ready" |
216
+
217
+ ## Anti-Patterns
218
+
219
+ 1. **Long operations in request handlers.** Putting a 50,000-order sync in an API route handler. The request will timeout, the user gets an error, and partial work may corrupt data.
220
+
221
+ 2. **Fire-and-forget without tracking.** Dispatching a background job with no way to check its status. The user refreshes the page and has no idea if the operation completed, failed, or is still running.
222
+
223
+ 3. **Restarting from zero on retry.** A job that processed 4,000 of 5,000 orders before failing should resume from order 4,001, not restart. Without checkpointing, retries waste time and may cause duplicate processing.
224
+
225
+ 4. **No concurrency limits.** Allowing unlimited concurrent sync jobs. If 100 users trigger syncs simultaneously, the database connection pool is exhausted and all jobs fail.
226
+
227
+ 5. **Identical retry timing.** Retrying failed jobs at fixed intervals (e.g., every 5 seconds). When an external API is down, all retries hit simultaneously (thundering herd). Use exponential backoff with jitter.
228
+
229
+ 6. **Progress updates on every item.** Updating the progress database row for every single item in a 50,000-item batch. This creates 50,000 database writes. Update every N items or every T seconds.
230
+
231
+ 7. **Mixing job queue with business logic.** Putting order validation, margin calculation, and email sending in the job queue infrastructure code. The queue manages execution; business logic belongs in service functions.
232
+
233
+ ## Key Files
234
+
235
+ When working in a project with background jobs:
236
+
237
+ - Inngest function definitions — step functions with retry and concurrency
238
+ - `background_jobs` table (if database-backed queue) — job tracking schema
239
+ - API routes for job status polling — `GET /api/jobs/[id]/status`
240
+ - SSE endpoints for real-time progress — `GET /api/jobs/[id]/progress`
241
+ - Job type registry — mapping job types to handler functions
242
+
243
+ ## Verification
244
+
245
+ After applying this skill, verify:
246
+ - [ ] No request handler performs operations that could exceed 30 seconds
247
+ - [ ] Every background job has a trackable status (pending/running/completed/failed)
248
+ - [ ] Progress is reported to the user for operations exceeding 5 seconds
249
+ - [ ] Retry logic uses exponential backoff with jitter
250
+ - [ ] Long operations checkpoint progress for resumable retries
251
+ - [ ] Concurrency limits prevent resource exhaustion
252
+ - [ ] Failed jobs surface errors through monitoring, not silent swallowing
253
+
254
+ ## Do NOT Use When
255
+
256
+ | Instead of this skill | Use | Why |
257
+ |---|---|---|
258
+ | Scheduling recurring jobs by time | `cron-scheduling` | Cron covers time-based triggers; this skill covers job execution patterns |
259
+ | Inngest-specific event orchestration | `inngest-orchestration` | Inngest has its own patterns beyond generic job queues |
260
+ | Data synchronization strategy | `data-sync` | Data sync covers the what (webhook, polling, reconciliation); this covers the how (queue, retry, progress) |
261
+ | Real-time UI updates | `real-time-updates` | Real-time covers push-to-UI patterns; this covers backend job execution |
262
+
263
+ ---
264
+
265
+ *Version 1.0.0 -- 2026-03-29. Initial creation.*
@@ -0,0 +1,55 @@
1
+ ---
2
+ name: bounded-context-mapping
3
+ description: "Use when drawing Domain-Driven Design boundaries: bounded contexts, context maps, ownership seams, upstream/downstream relationships, anti-corruption layers, shared kernels, and translation boundaries. Do NOT use for pre-DDD entity discovery (use `conceptual-modeling`), database schema design (use `data-modeling`), or HTTP endpoint design (use `api-design`)."
4
+ license: MIT
5
+ compatibility: "Portable DDD boundary-mapping discipline for monoliths, modular monoliths, services, event-driven systems, and agent workspaces."
6
+ allowed-tools: Read Grep
7
+ metadata:
8
+ metadata: "{\"schema_version\":6,\"version\":\"1.0.0\",\"type\":\"capability\",\"category\":\"engineering\",\"domain\":\"architecture/domain-boundaries\",\"scope\":\"portable\",\"owner\":\"skill-graph-maintainer\",\"freshness\":\"2026-05-11\",\"drift_check\":\"{\\\\\\\"last_verified\\\\\\\":\\\\\\\"2026-05-11\\\\\\\"}\",\"eval_artifacts\":\"planned\",\"eval_state\":\"unverified\",\"routing_eval\":\"absent\",\"stability\":\"experimental\",\"keywords\":\"[\\\\\\\"bounded context\\\\\\\",\\\\\\\"context map\\\\\\\",\\\\\\\"domain-driven design\\\\\\\",\\\\\\\"DDD boundary\\\\\\\",\\\\\\\"anti-corruption layer\\\\\\\",\\\\\\\"shared kernel\\\\\\\",\\\\\\\"upstream downstream\\\\\\\",\\\\\\\"conformist\\\\\\\",\\\\\\\"customer supplier\\\\\\\",\\\\\\\"domain boundary\\\\\\\"]\",\"examples\":\"[\\\\\\\"orders, fulfillment, payments, and support all use status differently - where should the bounded contexts be?\\\\\\\",\\\\\\\"map the upstream/downstream relationships before we split this module\\\\\\\",\\\\\\\"do we need an anti-corruption layer between our canonical order model and Shopify?\\\\\\\",\\\\\\\"which concepts belong to a shared kernel and which are context-local?\\\\\\\"]\",\"anti_examples\":\"[\\\\\\\"list entities, attributes, and cardinalities before any architecture decision\\\\\\\",\\\\\\\"create SQL tables, foreign keys, and indexes\\\\\\\",\\\\\\\"design REST routes and response envelopes\\\\\\\",\\\\\\\"write an ADR for the boundary decision after we already chose it\\\\\\\"]\",\"relations\":\"{\\\\\\\"boundary\\\\\\\":[{\\\\\\\"skill\\\\\\\":\\\\\\\"conceptual-modeling\\\\\\\",\\\\\\\"reason\\\\\\\":\\\\\\\"conceptual-modeling discovers domain structure before DDD boundary ownership is assigned\\\\\\\"},{\\\\\\\"skill\\\\\\\":\\\\\\\"data-modeling\\\\\\\",\\\\\\\"reason\\\\\\\":\\\\\\\"data-modeling owns persistence structure after context boundaries inform ownership\\\\\\\"},{\\\\\\\"skill\\\\\\\":\\\\\\\"api-design\\\\\\\",\\\\\\\"reason\\\\\\\":\\\\\\\"api-design owns external endpoint shape; bounded-context-mapping owns domain ownership and translation boundaries\\\\\\\"},{\\\\\\\"skill\\\\\\\":\\\\\\\"architecture-decision-records\\\\\\\",\\\\\\\"reason\\\\\\\":\\\\\\\"architecture-decision-records records a chosen decision; bounded-context-mapping analyzes the boundary before the decision is recorded\\\\\\\"}],\\\\\\\"related\\\\\\\":[\\\\\\\"event-storming\\\\\\\",\\\\\\\"system-interface-contracts\\\\\\\",\\\\\\\"conceptual-modeling\\\\\\\",\\\\\\\"architecture-decision-records\\\\\\\"],\\\\\\\"depends_on\\\\\\\":[\\\\\\\"conceptual-modeling\\\\\\\"],\\\\\\\"verify_with\\\\\\\":[\\\\\\\"semantic-relations\\\\\\\",\\\\\\\"system-interface-contracts\\\\\\\"]}\",\"portability\":\"{\\\\\\\"readiness\\\\\\\":\\\\\\\"scripted\\\\\\\",\\\\\\\"targets\\\\\\\":[\\\\\\\"skill-md\\\\\\\"]}\",\"lifecycle\":\"{\\\\\\\"stale_after_days\\\\\\\":365,\\\\\\\"review_cadence\\\\\\\":\\\\\\\"quarterly\\\\\\\"}\",\"skill_graph_source_repo\":\"https://github.com/jacob-balslev/skill-graph\",\"skill_graph_protocol\":\"Skill Metadata Protocol v5\",\"skill_graph_project\":\"Skill Graph\",\"skill_graph_canonical_skill\":\"skills/bounded-context-mapping/SKILL.md\"}"
9
+ skill_graph_source_repo: "https://github.com/jacob-balslev/skill-graph"
10
+ skill_graph_protocol: Skill Metadata Protocol v4
11
+ skill_graph_project: Skill Graph
12
+ skill_graph_canonical_skill: skills/bounded-context-mapping/SKILL.md
13
+ ---
14
+
15
+ # Bounded Context Mapping
16
+
17
+ ## Coverage
18
+
19
+ Map domain ownership boundaries and relationships between contexts. Covers bounded context naming, context maps, ubiquitous language separation, upstream/downstream relationships, shared kernel, conformist, customer/supplier, partnership, open host service, published language, anti-corruption layer, and boundary validation against real change scenarios.
20
+
21
+ ## Philosophy
22
+
23
+ A bounded context is a language and ownership boundary, not a deployment unit. Splitting services without splitting language creates distributed coupling. Keeping one module while mixing incompatible meanings creates hidden domain bugs.
24
+
25
+ The central question is: "Where does this word mean something different?" Those differences drive boundaries more reliably than folder layout, teams, or database tables.
26
+
27
+ ## Method
28
+
29
+ 1. Extract candidate terms and workflows from requirements, code, docs, and incidents.
30
+ 2. Mark terms whose meaning changes by actor or workflow.
31
+ 3. Group concepts that change together under the same business capability.
32
+ 4. Draw context boundaries around language consistency, not technical layers.
33
+ 5. Label relationships: upstream/downstream, partnership, shared kernel, conformist, or anti-corruption.
34
+ 6. Define translation points and ownership of canonical terms.
35
+ 7. Stress-test with change scenarios: who changes, who breaks, who must approve?
36
+
37
+ ## Verification
38
+
39
+ - [ ] Each context has a coherent language that does not overload key terms
40
+ - [ ] Cross-context communication uses explicit contracts or translation
41
+ - [ ] Shared kernels are intentionally small and high-stability
42
+ - [ ] Upstream/downstream power dynamics are named
43
+ - [ ] Anti-corruption layers protect local language from external models
44
+ - [ ] Boundary decisions were tested against real feature-change scenarios
45
+ - [ ] No boundary is based only on folder, team, or database layout
46
+
47
+ ## Do NOT Use When
48
+
49
+ | Use instead | When |
50
+ |---|---|
51
+ | `conceptual-modeling` | You need to discover entities and relationships before assigning ownership boundaries. |
52
+ | `data-modeling` | You need logical or physical data structures. |
53
+ | `api-design` | You need HTTP route, request, response, status, or versioning design. |
54
+ | `architecture-decision-records` | You need to record a decision that has already been made. |
55
+
@@ -0,0 +1,127 @@
1
+ ---
2
+ name: cap-theorem-tradeoffs
3
+ description: "Use when reasoning about the consistency-availability-partition-tolerance trade-off for distributed data systems: Brewer's CAP conjecture (2000), Gilbert & Lynch's 2002 formal proof, why P is not optional in any real distributed system, the CP-vs-AP dichotomy that follows, PACELC as the extension that names the latency-vs-consistency trade-off that exists even without partition, the relationship between CAP's C and ACID's C (different concepts with the same letter), and the choice procedure of naming what the system must guarantee under partition. Do NOT use for single-node transactional guarantees (use acid-fundamentals), choosing an isolation level (use transaction-isolation), the design of replication topologies (use replication-patterns), or sharding decisions (use sharding-strategy)."
4
+ license: MIT
5
+ allowed-tools: Read Grep
6
+ metadata:
7
+ metadata: "{\"schema_version\":6,\"version\":\"1.0.0\",\"type\":\"capability\",\"category\":\"engineering\",\"domain\":\"engineering/data\",\"scope\":\"reference\",\"owner\":\"skill-graph-maintainer\",\"freshness\":\"2026-05-16\",\"drift_check\":\"{\\\\\\\"last_verified\\\\\\\":\\\\\\\"2026-05-16\\\\\\\"}\",\"eval_artifacts\":\"planned\",\"eval_state\":\"unverified\",\"routing_eval\":\"absent\",\"comprehension_state\":\"present\",\"stability\":\"experimental\",\"keywords\":\"[\\\\\\\"CAP theorem\\\\\\\",\\\\\\\"Brewer\\\\\\\",\\\\\\\"Gilbert Lynch\\\\\\\",\\\\\\\"consistency availability partition\\\\\\\",\\\\\\\"CP system\\\\\\\",\\\\\\\"AP system\\\\\\\",\\\\\\\"PACELC\\\\\\\",\\\\\\\"eventual consistency\\\\\\\",\\\\\\\"linearizability\\\\\\\",\\\\\\\"distributed system\\\\\\\"]\",\"triggers\":\"[\\\\\\\"CAP theorem\\\\\\\",\\\\\\\"CP or AP\\\\\\\",\\\\\\\"what should we do on partition\\\\\\\",\\\\\\\"is this strongly consistent\\\\\\\",\\\\\\\"PACELC\\\\\\\"]\",\"examples\":\"[\\\\\\\"decide whether a new distributed service should be CP or AP given its workload\\\\\\\",\\\\\\\"explain why CAP's C and ACID's C are different concepts despite sharing the letter\\\\\\\",\\\\\\\"diagnose a system claiming 'CA' (consistency + availability without P) — likely confused, since P is not optional\\\\\\\",\\\\\\\"design the partition-mode behavior of a multi-region service\\\\\\\"]\",\"anti_examples\":\"[\\\\\\\"choose a transaction isolation level (use transaction-isolation)\\\\\\\",\\\\\\\"explain the four ACID properties (use acid-fundamentals)\\\\\\\",\\\\\\\"design the replication topology of a database (use replication-patterns)\\\\\\\"]\",\"relations\":\"{\\\\\\\"related\\\\\\\":[\\\\\\\"acid-fundamentals\\\\\\\",\\\\\\\"transaction-isolation\\\\\\\",\\\\\\\"replication-patterns\\\\\\\",\\\\\\\"sharding-strategy\\\\\\\"],\\\\\\\"boundary\\\\\\\":[{\\\\\\\"skill\\\\\\\":\\\\\\\"acid-fundamentals\\\\\\\",\\\\\\\"reason\\\\\\\":\\\\\\\"acid-fundamentals owns the single-system transactional frame; this skill owns the distributed-system frame. CAP's C (replica agreement) is not ACID's C (constraint satisfaction); conflating them is the most common misconception in this space.\\\\\\\"},{\\\\\\\"skill\\\\\\\":\\\\\\\"transaction-isolation\\\\\\\",\\\\\\\"reason\\\\\\\":\\\\\\\"transaction-isolation owns single-cluster concurrency-correctness; this skill owns multi-replica consistency under network partition. The two layers can compose (a CP system may run at serializable isolation locally) but address different threats.\\\\\\\"},{\\\\\\\"skill\\\\\\\":\\\\\\\"replication-patterns\\\\\\\",\\\\\\\"reason\\\\\\\":\\\\\\\"replication-patterns owns the design patterns for multi-replica systems (primary-replica, multi-primary, leaderless quorum); this skill owns the C/A/P trade-off that motivates choosing among them. The two compose: this is the theoretical frame; replication-patterns is the operational realization.\\\\\\\"},{\\\\\\\"skill\\\\\\\":\\\\\\\"sharding-strategy\\\\\\\",\\\\\\\"reason\\\\\\\":\\\\\\\"sharding-strategy owns horizontal partitioning of data across nodes; this skill owns the C/A trade-off when those shards must coordinate or recover from network partition between them.\\\\\\\"}],\\\\\\\"verify_with\\\\\\\":[\\\\\\\"acid-fundamentals\\\\\\\",\\\\\\\"replication-patterns\\\\\\\"]}\",\"mental_model\":\"|\",\"purpose\":\"|\",\"boundary\":\"|\",\"analogy\":\"CAP is to a distributed database what the Heisenberg uncertainty principle is to physics — you cannot simultaneously have a fully consistent reading and a fully available reading when the network has partitioned, just as you cannot simultaneously measure a precise position and a precise momentum. The trade-off is not a limit of the engineering, it is a limit of the physics; pretending otherwise is the source of every 'CA' system that claims to defy CAP and chooses one side anyway on its first partition.\",\"misconception\":\"|\",\"concept\":\"{\\\\\\\"definition\\\\\\\":\\\\\\\"CAP is the theorem (Brewer 2000 as a conjecture; Gilbert & Lynch 2002 as a formal proof) that, in a distributed data system, you cannot simultaneously guarantee all three of: Consistency (every read returns the most recent write or an error), Availability (every request receives a non-error response), Partition tolerance (the system continues despite arbitrary message loss between nodes). Since real-world networks can and do partition, P is not optional — the choice is between C and A *during a partition*. A CP system refuses to serve some requests during partition to preserve consistency; an AP system serves all requests but may return stale data. PACELC (Abadi 2010) extends CAP by naming the *Else* case: even without partition, the system must trade Latency against Consistency, because synchronous replication for strong consistency takes time. The discipline is choosing C-vs-A *intentionally per workload*, knowing that P is given by physics and that even outside partition, latency-vs-consistency is a continuous choice.\\\\\\\",\\\\\\\"mental_model\\\\\\\":\\\\\\\"|\\\\\\\",\\\\\\\"purpose\\\\\\\":\\\\\\\"|\\\\\\\",\\\\\\\"boundary\\\\\\\":\\\\\\\"|\\\\\\\",\\\\\\\"taxonomy\\\\\\\":\\\\\\\"|\\\\\\\",\\\\\\\"analogy\\\\\\\":\\\\\\\"|\\\\\\\",\\\\\\\"misconception\\\\\\\":\\\\\\\"|\\\\\\\"}\",\"skill_graph_source_repo\":\"https://github.com/jacob-balslev/skill-graph\",\"skill_graph_protocol\":\"Skill Metadata Protocol v5\",\"skill_graph_project\":\"Skill Graph\",\"skill_graph_canonical_skill\":\"skills/cap-theorem-tradeoffs/SKILL.md\"}"
8
+ skill_graph_source_repo: "https://github.com/jacob-balslev/skill-graph"
9
+ skill_graph_protocol: Skill Metadata Protocol v4
10
+ skill_graph_project: Skill Graph
11
+ skill_graph_canonical_skill: skills/cap-theorem-tradeoffs/SKILL.md
12
+ ---
13
+
14
+ # CAP-Theorem Tradeoffs
15
+
16
+ ## Coverage
17
+
18
+ The consistency-availability-partition-tolerance trade-off that physics imposes on distributed data systems. Covers Brewer's 2000 conjecture, Gilbert & Lynch's 2002 formal proof, why P is mandatory in real networks (the practical choice is CP vs AP, not "any two of three"), the PACELC extension (Abadi 2010) that names the latency-vs-consistency trade-off in the non-partition case, the CAP-C vs ACID-C confusion that is the most-common misconception in the space, the spectrum of consistency models from linearizability to eventual consistency, the four PACELC quadrants (PA/EL, PA/EC, PC/EL, PC/EC) and the systems that occupy each, and the partition-mode choice procedure.
19
+
20
+ ## Philosophy
21
+
22
+ CAP is the frame that made distributed-systems design honest. Before Brewer's 2000 conjecture and Gilbert & Lynch's 2002 proof, the industry made contradictory claims about consistency, availability, and fault tolerance; after CAP, those claims have shape. Under partition — which physics guarantees will happen — you preserve consistency at the cost of availability, or availability at the cost of consistency.
23
+
24
+ The discipline is making the choice *per workload* and *intentionally*. A banking core ledger is right to be CP. A shopping cart's session state is right to be AP. A multi-region content-delivery system is right to be AP with eventual consistency. A schema registry is right to be CP. The choice is the engineering team's responsibility; CAP names the trade-off; the design realizes the choice.
25
+
26
+ PACELC is the frame that made CAP practical. Most systems spend the overwhelming majority of their time *not* partitioned; PACELC's E (else) case names the latency-vs-consistency trade-off in the common case, which is where most users' actual experience lives. A team that designs for CAP without PACELC has optimized for the rare event and ignored the daily one.
27
+
28
+ ## The CAP Theorem In One Diagram
29
+
30
+ ```
31
+ During a network partition,
32
+ pick at most TWO of:
33
+
34
+ Consistency (C)
35
+ /\
36
+ / \
37
+ / CP \ Common: Spanner, etcd,
38
+ / ↓ \ MongoDB w/ majority,
39
+ / refuse \ ZooKeeper
40
+ / some \
41
+ / requests \
42
+ / \
43
+ / \
44
+ / \
45
+ / \
46
+ / AP \
47
+ / serve all requests \
48
+ / accept stale reads \ Common: Cassandra default,
49
+ / diverge on writes \ DynamoDB default,
50
+ / \ Riak
51
+ / \
52
+ /__________________________________\
53
+ Availability (A) Partition tolerance (P)
54
+
55
+ "CA" is not a real choice — partitions happen.
56
+ ```
57
+
58
+ ## CAP-C vs ACID-C — A Worked Example
59
+
60
+ A multi-region banking system with eventual consistency:
61
+
62
+ | Scenario | CAP-C status | ACID-C status |
63
+ |---|---|---|
64
+ | Both replicas show balance = $500 (constraint: balance ≥ 0) | Consistent | Consistent |
65
+ | Replica A shows $500, replica B shows $400 (constraint: balance ≥ 0) | INconsistent (CAP) | Consistent (no constraint violated) |
66
+ | Both replicas show balance = -$100 (constraint: balance ≥ 0) | Consistent | INconsistent (constraint violated) |
67
+ | Replica A shows balance = -$100, replica B shows $500 | INconsistent (CAP) | INconsistent (replica A violates) |
68
+
69
+ The two C's measure different things. The system needs both to be operationally correct.
70
+
71
+ ## PACELC Quadrants
72
+
73
+ | Quadrant | Partition behavior | Else (steady-state) behavior | Example systems |
74
+ |---|---|---|---|
75
+ | **PA/EL** | AP | Latency over consistency | Cassandra default, DynamoDB default, MongoDB default |
76
+ | **PA/EC** | AP | Consistency over latency | Rare; often misconfiguration |
77
+ | **PC/EL** | CP | Latency over consistency | Some real-world systems (mixed mode) |
78
+ | **PC/EC** | CP | Consistency over latency | Spanner, Cosmos DB strong, MongoDB w/ majority-read |
79
+
80
+ Choosing for the steady-state matters more than choosing for partition in most workloads.
81
+
82
+ ## The Choice Procedure
83
+
84
+ 1. **What does the system do if data goes stale by 10 seconds during a partition?** If the answer is "users see slightly old data; we reconcile later" — AP is viable. If the answer is "we lose money / corrupt records / fail an SLA" — CP is required.
85
+
86
+ 2. **What does the system do if 50% of requests fail for 60 seconds during a partition?** If "users retry; we lose some requests" — CP is viable. If "we churn users / lose orders / break business" — AP is required.
87
+
88
+ 3. **In the steady state, do we want low latency (EL) or strong consistency (EC)?** This is the dominant question for most workloads, since partition is rare. Strong consistency in the common case requires synchronous replication; eventual consistency in the common case allows asynchronous.
89
+
90
+ 4. **Does the workload need linearizability, or is causal consistency / read-your-writes enough?** Many workloads need weaker consistency than CAP's linearizability; the choice of consistency model affects the system's achievable throughput.
91
+
92
+ 5. **Is the system actually distributed?** Single-node or single-region tightly-coupled systems may not have CAP concerns at all. Avoid invoking CAP for systems where it doesn't apply.
93
+
94
+ ## Verification
95
+
96
+ After applying this skill, verify:
97
+ - [ ] The team distinguishes CAP-C (replica agreement) from ACID-C (constraint satisfaction) in design discussions. Using "consistency" without qualifier produces confused decisions.
98
+ - [ ] The system's CP-or-AP choice is explicit, documented, and tied to the workload's tolerance for stale data vs unavailability.
99
+ - [ ] The PACELC quadrant is identified for the system. The steady-state latency-vs-consistency trade-off is treated as the dominant design decision, not as an afterthought to CAP.
100
+ - [ ] Partition-mode behavior is tested, not assumed. The team has actually exercised partition (chaos engineering, network-partition simulation) and verified the system behaves as designed.
101
+ - [ ] Reconciliation logic is in place for AP systems. Eventual consistency requires the team to have a defined convergence strategy (vector clocks, CRDTs, last-write-wins, anti-entropy) and to have tested it.
102
+ - [ ] No system claims "CA" without challenge. CA is not a real choice; systems that claim it have not actually been tested under partition.
103
+ - [ ] For tunable systems (Cassandra, DynamoDB), the per-operation consistency choice is intentional. The default settings are not assumed correct without verification per workload.
104
+ - [ ] The consistency model is named (linearizability, causal, read-your-writes, eventual). "Strong consistency" without specification is imprecise.
105
+
106
+ ## Do NOT Use When
107
+
108
+ | Instead of this skill | Use | Why |
109
+ |---|---|---|
110
+ | Reasoning about single-node transactional guarantees | `acid-fundamentals` | acid-fundamentals owns single-system; this owns distributed |
111
+ | Choosing an isolation level for concurrent transactions | `transaction-isolation` | transaction-isolation owns single-cluster concurrency |
112
+ | Designing replication topology (primary-replica, multi-primary, etc.) | `replication-patterns` | replication-patterns owns the operational realization of CAP choices |
113
+ | Sharding decisions for horizontal scaling | `sharding-strategy` | sharding owns horizontal partitioning; this owns the consistency frame across shards |
114
+ | Tuning a query for performance | `query-optimization` | query-optimization owns retrieval performance |
115
+ | Designing for high availability without distributed concerns | high-availability or reliability skills | HA on a single node is not a CAP concern |
116
+
117
+ ## Key Sources
118
+
119
+ - Brewer, E. (2000). ["Towards Robust Distributed Systems" (PODC 2000 keynote)](https://www.cs.berkeley.edu/~brewer/cs262b-2004/PODC-keynote.pdf). The original CAP conjecture as Brewer presented it.
120
+ - Gilbert, S., & Lynch, N. (2002). ["Brewer's Conjecture and the Feasibility of Consistent, Available, Partition-Tolerant Web Services"](https://www.glassbeam.com/sites/all/themes/glassbeam/images/blog/10.1.1.20.1495.pdf). *ACM SIGACT News*, 33(2), 51-59. The formal proof; the canonical academic reference.
121
+ - Brewer, E. (2012). ["CAP Twelve Years Later: How the 'Rules' Have Changed"](https://ieeexplore.ieee.org/document/6133253). *IEEE Computer*, 45(2), 23-29. Brewer's retrospective; clarifies the misconceptions that grew up around the theorem.
122
+ - Abadi, D. (2010). ["Problems with CAP, and Yahoo's little known NoSQL system"](http://dbmsmusings.blogspot.com/2010/04/problems-with-cap-and-yahoos-little.html) and (2012) ["Consistency Tradeoffs in Modern Distributed Database System Design: CAP is Only Part of the Story"](https://ieeexplore.ieee.org/document/6127847). *IEEE Computer*, 45(2), 37-42. The introduction of PACELC as the extended frame.
123
+ - Kleppmann, M. (2017). *Designing Data-Intensive Applications*. O'Reilly. Chapter 9 (Consistency and Consensus) — modern practitioner treatment of CAP, PACELC, and the consistency model spectrum.
124
+ - Bailis, P., Davidson, A., Fekete, A., Ghodsi, A., Hellerstein, J. M., & Stoica, I. (2014). ["Highly Available Transactions: Virtues and Limitations"](https://dl.acm.org/doi/10.14778/2732232.2732237). *VLDB 2014*. Modern academic treatment of the consistency models that sit between linearizability and eventual consistency.
125
+ - Vogels, W. (2009). ["Eventually Consistent"](https://queue.acm.org/detail.cfm?id=1466448). *ACM Queue*, 6(6). The canonical practitioner essay on eventual consistency, written by Amazon's CTO.
126
+ - Lipton, R. J., & Sandberg, J. S. (1988). ["PRAM: A Scalable Shared Memory"](https://www.cs.princeton.edu/research/techreps/TR-180-88). Princeton technical report. Early work on weak consistency models that inform CAP-era distributed databases.
127
+ - Bailis, P., & Ghodsi, A. (2013). ["Eventual Consistency Today: Limitations, Extensions, and Beyond"](https://queue.acm.org/detail.cfm?id=2462076). *ACM Queue*. Modern survey of the eventual-consistency spectrum.