@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.
- package/CHANGELOG.md +247 -0
- package/LICENSE +200 -0
- package/NOTICE +62 -0
- package/README.md +398 -0
- package/SKILL_GRAPH.md +443 -0
- package/bin/skill-graph.js +374 -0
- package/docs/ADOPTION.md +117 -0
- package/docs/CONFORMANCE.md +66 -0
- package/docs/PRIMER.md +384 -0
- package/docs/QUICKSTART-30MIN.md +333 -0
- package/docs/ROUTING-METRICS.md +120 -0
- package/docs/SKILL-MD-FORMAT-COMPATIBILITY.md +127 -0
- package/docs/SKILL_AUDIT_CHECKLIST.md +199 -0
- package/docs/SKILL_AUDIT_LOOP.md +195 -0
- package/docs/SKILL_METADATA_PROTOCOL.md +609 -0
- package/docs/_archived/marketplace-publication-priority-2026-05-18.md +239 -0
- package/docs/adr/0001-predicate-set.md +69 -0
- package/docs/adr/0002-json-ld-context.md +82 -0
- package/docs/adr/0003-ontoclean-rigidity-tags.md +65 -0
- package/docs/adr/0004-persistent-identifiers.md +74 -0
- package/docs/adr/0005-freshness-consolidation.md +70 -0
- package/docs/adr/0006-revise-predicate-rename.md +105 -0
- package/docs/adr/0007-audit-loop-cadence.md +99 -0
- package/docs/adr/0008-skill-surface-split-and-curation-policy.md +93 -0
- package/docs/category-consumers.md +168 -0
- package/docs/concept-map.md +194 -0
- package/docs/diagrams/drift-states.mmd +21 -0
- package/docs/diagrams/manifest-pipeline.mmd +25 -0
- package/docs/diagrams/routing-harness.mmd +41 -0
- package/docs/diagrams/starter-graph.mmd +53 -0
- package/docs/field-decision-guide.md +315 -0
- package/docs/field-rationale.md +211 -0
- package/docs/field-reference.generated.md +624 -0
- package/docs/field-reference.md +1426 -0
- package/docs/glossary.md +190 -0
- package/docs/head-noun-glossary.md +63 -0
- package/docs/images/audit-phases.png +0 -0
- package/docs/images/drift-states.png +0 -0
- package/docs/images/graded-mode.png +0 -0
- package/docs/images/manifest-pipeline.png +0 -0
- package/docs/images/routing-harness.png +0 -0
- package/docs/images/skill-anatomy.png +0 -0
- package/docs/images/starter-graph.png +0 -0
- package/docs/images/system-model.png +0 -0
- package/docs/integrations/github-actions.md +155 -0
- package/docs/manifest-field-mapping.md +443 -0
- package/docs/marketplace-publication-queue.generated.md +240 -0
- package/docs/marketplace-release-agent-prompt.md +82 -0
- package/docs/marketplace-skill-candidate-list.md +272 -0
- package/docs/marketplace-syndication.md +222 -0
- package/docs/migration-sample-review.md +155 -0
- package/docs/migrations/v4-to-v5.md +168 -0
- package/docs/migrations/v5-to-v6.md +221 -0
- package/docs/name-exceptions.yaml +37 -0
- package/docs/plans/marketplace-p1-public-migration-plan.md +41 -0
- package/docs/plans/multi-root-workspace.md +148 -0
- package/docs/plans/scripts-roadmap.md +107 -0
- package/docs/plans/v4-schema-bump.md +160 -0
- package/docs/plans/wave-2-extraction.md +122 -0
- package/docs/positioning-vs-marketplaces.md +175 -0
- package/docs/proposals/skill-audit-loop-positioning.md +160 -0
- package/docs/quality-doctrine.md +138 -0
- package/docs/recommended-skills.md +150 -0
- package/docs/research/skill-comprehension-eval-research.md +1830 -0
- package/docs/research/skill-retrieval-evidence.md +66 -0
- package/docs/skill-metadata-protocol.md +471 -0
- package/docs/skills-sh-maintainer-cleanup-request.md +80 -0
- package/examples/audits/a11y/findings.md +52 -0
- package/examples/audits/a11y/scorecard.md +21 -0
- package/examples/audits/a11y/verdict.md +44 -0
- package/examples/audits/debugging/findings.md +59 -0
- package/examples/audits/debugging/scorecard.md +22 -0
- package/examples/audits/debugging/verdict.md +33 -0
- package/examples/audits/documentation/findings.md +59 -0
- package/examples/audits/documentation/scorecard.md +22 -0
- package/examples/audits/documentation/verdict.md +33 -0
- package/examples/evals/a11y.json +140 -0
- package/examples/evals/api-design.json +52 -0
- package/examples/evals/code-review.json +52 -0
- package/examples/evals/data-modeling.json +52 -0
- package/examples/evals/database-migration.json +52 -0
- package/examples/evals/debugging.json +118 -0
- package/examples/evals/dependency-architecture.json +52 -0
- package/examples/evals/design-system-architecture.json +52 -0
- package/examples/evals/error-tracking.json +52 -0
- package/examples/evals/event-contract-design.json +52 -0
- package/examples/evals/form-ux-architecture.json +52 -0
- package/examples/evals/framework-fit-analysis.json +52 -0
- package/examples/evals/graph-audit.json +139 -0
- package/examples/evals/information-architecture.json +52 -0
- package/examples/evals/interaction-feedback.json +52 -0
- package/examples/evals/interaction-patterns.json +52 -0
- package/examples/evals/layout-composition.json +52 -0
- package/examples/evals/lint-overlay.json +117 -0
- package/examples/evals/microcopy.json +52 -0
- package/examples/evals/observability-modeling.json +52 -0
- package/examples/evals/pattern-recognition.json +96 -0
- package/examples/evals/performance-engineering.json +52 -0
- package/examples/evals/refactor.json +128 -0
- package/examples/evals/semiotics.json +52 -0
- package/examples/evals/skill-infrastructure.json +96 -0
- package/examples/evals/skill-router.json +140 -0
- package/examples/evals/skill-router.routing.json +113 -0
- package/examples/evals/system-interface-contracts.json +52 -0
- package/examples/evals/task-analysis.json +52 -0
- package/examples/evals/testing-strategy.json +118 -0
- package/examples/evals/type-safety.json +249 -0
- package/examples/evals/visual-design-foundations.json +52 -0
- package/examples/evals/webhook-integration.json +52 -0
- package/examples/exports/a11y.skill-md.md +80 -0
- package/examples/exports/debugging.skill-md.md +80 -0
- package/examples/exports/refactor.skill-md.md +78 -0
- package/examples/exports/testing-strategy.skill-md.md +81 -0
- package/examples/projects/markdown-static-site/README.md +115 -0
- package/examples/projects/markdown-static-site/skills/content-source-router/SKILL.md +131 -0
- package/examples/projects/markdown-static-site/skills/image-optimization-pipeline-config/SKILL.md +132 -0
- package/examples/projects/markdown-static-site/skills/link-rot-detection/SKILL.md +103 -0
- package/examples/projects/markdown-static-site/skills/markdown-post-frontmatter-validation/SKILL.md +133 -0
- package/examples/projects/markdown-static-site/skills/migrate-posts-to-v2-frontmatter/SKILL.md +140 -0
- package/examples/projects/saas-stripe-postgres/README.md +208 -0
- package/examples/projects/saas-stripe-postgres/db/migrations/0004_canonicalize_orders.sql +37 -0
- package/examples/projects/saas-stripe-postgres/db/schema.sql +112 -0
- package/examples/projects/saas-stripe-postgres/skills/migrate-orders-to-canonical-schema/SKILL.md +149 -0
- package/examples/projects/saas-stripe-postgres/skills/nextjs-server-action-validation/SKILL.md +154 -0
- package/examples/projects/saas-stripe-postgres/skills/payment-provider-router/SKILL.md +153 -0
- package/examples/projects/saas-stripe-postgres/skills/postgres-rls-pattern/SKILL.md +163 -0
- package/examples/projects/saas-stripe-postgres/skills/stripe-webhook-signature-verification/SKILL.md +137 -0
- package/examples/protocol/skill-metadata-template.md +301 -0
- package/examples/protocol/skills.manifest.sample.json +13245 -0
- package/examples/skill-metadata-template.md +317 -0
- package/examples/skills.manifest.sample.json +13519 -0
- package/examples/tests/v3-1-skos-fixture/SKILL.md +93 -0
- package/marketplace/README.md +17 -0
- package/marketplace/skills/a11y/SKILL.md +66 -0
- package/marketplace/skills/acid-fundamentals/SKILL.md +106 -0
- package/marketplace/skills/agent-engineering/SKILL.md +386 -0
- package/marketplace/skills/agent-eval-design/SKILL.md +55 -0
- package/marketplace/skills/ai-native-development/SKILL.md +294 -0
- package/marketplace/skills/api-design/SKILL.md +60 -0
- package/marketplace/skills/architecture-decision-records/SKILL.md +55 -0
- package/marketplace/skills/background-jobs/SKILL.md +265 -0
- package/marketplace/skills/bounded-context-mapping/SKILL.md +55 -0
- package/marketplace/skills/cap-theorem-tradeoffs/SKILL.md +127 -0
- package/marketplace/skills/client-server-boundary/SKILL.md +187 -0
- package/marketplace/skills/code-review/SKILL.md +120 -0
- package/marketplace/skills/color-system-design/SKILL.md +43 -0
- package/marketplace/skills/component-architecture/SKILL.md +126 -0
- package/marketplace/skills/compression/SKILL.md +112 -0
- package/marketplace/skills/conceptual-modeling/SKILL.md +181 -0
- package/marketplace/skills/connection-pooling/SKILL.md +105 -0
- package/marketplace/skills/constraint-awareness/SKILL.md +287 -0
- package/marketplace/skills/content-monitor/SKILL.md +209 -0
- package/marketplace/skills/context-engineering/SKILL.md +320 -0
- package/marketplace/skills/context-graph/SKILL.md +174 -0
- package/marketplace/skills/context-management/SKILL.md +174 -0
- package/marketplace/skills/context-window/SKILL.md +239 -0
- package/marketplace/skills/contract-testing/SKILL.md +120 -0
- package/marketplace/skills/cron-scheduling/SKILL.md +223 -0
- package/marketplace/skills/dark-mode-implementation/SKILL.md +47 -0
- package/marketplace/skills/data-modeling/SKILL.md +59 -0
- package/marketplace/skills/data-modeling-fundamentals/SKILL.md +117 -0
- package/marketplace/skills/database-migration/SKILL.md +429 -0
- package/marketplace/skills/debugging/SKILL.md +67 -0
- package/marketplace/skills/dependency-architecture/SKILL.md +58 -0
- package/marketplace/skills/design-module-composition/SKILL.md +43 -0
- package/marketplace/skills/design-system-architecture/SKILL.md +61 -0
- package/marketplace/skills/design-thinking/SKILL.md +44 -0
- package/marketplace/skills/diagnosis/SKILL.md +296 -0
- package/marketplace/skills/diff-analysis/SKILL.md +188 -0
- package/marketplace/skills/e2e-test-design/SKILL.md +113 -0
- package/marketplace/skills/entity-relationship-modeling/SKILL.md +218 -0
- package/marketplace/skills/epistemic-grounding/SKILL.md +112 -0
- package/marketplace/skills/error-boundary/SKILL.md +235 -0
- package/marketplace/skills/error-tracking/SKILL.md +261 -0
- package/marketplace/skills/eval-driven-development/SKILL.md +147 -0
- package/marketplace/skills/evaluation/SKILL.md +113 -0
- package/marketplace/skills/event-contract-design/SKILL.md +60 -0
- package/marketplace/skills/event-storming/SKILL.md +56 -0
- package/marketplace/skills/form-ux-architecture/SKILL.md +60 -0
- package/marketplace/skills/framework-fit-analysis/SKILL.md +59 -0
- package/marketplace/skills/frontend-architecture/SKILL.md +43 -0
- package/marketplace/skills/generative-ui/SKILL.md +118 -0
- package/marketplace/skills/graph-audit/SKILL.md +81 -0
- package/marketplace/skills/guardrails/SKILL.md +118 -0
- package/marketplace/skills/hooks-patterns/SKILL.md +185 -0
- package/marketplace/skills/http-semantics/SKILL.md +136 -0
- package/marketplace/skills/ideation/SKILL.md +41 -0
- package/marketplace/skills/indexing-strategy/SKILL.md +108 -0
- package/marketplace/skills/information-architecture/SKILL.md +59 -0
- package/marketplace/skills/integration-test-design/SKILL.md +111 -0
- package/marketplace/skills/intent-recognition/SKILL.md +136 -0
- package/marketplace/skills/interaction-feedback/SKILL.md +59 -0
- package/marketplace/skills/interaction-patterns/SKILL.md +59 -0
- package/marketplace/skills/journey-mapping/SKILL.md +41 -0
- package/marketplace/skills/keywords/SKILL.md +213 -0
- package/marketplace/skills/knowledge-modeling/SKILL.md +232 -0
- package/marketplace/skills/layout-composition/SKILL.md +59 -0
- package/marketplace/skills/linguistics/SKILL.md +429 -0
- package/marketplace/skills/lint-overlay/SKILL.md +76 -0
- package/marketplace/skills/mental-models/SKILL.md +126 -0
- package/marketplace/skills/merge-queue/SKILL.md +94 -0
- package/marketplace/skills/methodology/SKILL.md +317 -0
- package/marketplace/skills/microcopy/SKILL.md +232 -0
- package/marketplace/skills/middleware-patterns/SKILL.md +363 -0
- package/marketplace/skills/mobile-responsive-ux/SKILL.md +287 -0
- package/marketplace/skills/mutation-testing/SKILL.md +112 -0
- package/marketplace/skills/naming-conventions/SKILL.md +112 -0
- package/marketplace/skills/observability-modeling/SKILL.md +59 -0
- package/marketplace/skills/ontology-modeling/SKILL.md +67 -0
- package/marketplace/skills/owasp-security/SKILL.md +153 -0
- package/marketplace/skills/pattern-recognition/SKILL.md +472 -0
- package/marketplace/skills/performance-budgets/SKILL.md +185 -0
- package/marketplace/skills/performance-engineering/SKILL.md +58 -0
- package/marketplace/skills/performance-testing/SKILL.md +125 -0
- package/marketplace/skills/printify/SKILL.md +42 -0
- package/marketplace/skills/prioritization/SKILL.md +118 -0
- package/marketplace/skills/problem-framing/SKILL.md +41 -0
- package/marketplace/skills/problem-locating-solving/SKILL.md +203 -0
- package/marketplace/skills/project-knowledge-extraction/SKILL.md +54 -0
- package/marketplace/skills/prompt-craft/SKILL.md +134 -0
- package/marketplace/skills/prompt-injection-defense/SKILL.md +132 -0
- package/marketplace/skills/property-based-testing/SKILL.md +100 -0
- package/marketplace/skills/prototyping/SKILL.md +43 -0
- package/marketplace/skills/query-optimization/SKILL.md +144 -0
- package/marketplace/skills/real-time-updates/SKILL.md +324 -0
- package/marketplace/skills/ref-patterns/SKILL.md +284 -0
- package/marketplace/skills/refactor/SKILL.md +65 -0
- package/marketplace/skills/rendering-models/SKILL.md +142 -0
- package/marketplace/skills/replication-patterns/SKILL.md +110 -0
- package/marketplace/skills/research-synthesis/SKILL.md +41 -0
- package/marketplace/skills/route-handler-design/SKILL.md +347 -0
- package/marketplace/skills/schema-evolution/SKILL.md +140 -0
- package/marketplace/skills/security-fundamentals/SKILL.md +139 -0
- package/marketplace/skills/semantic-center/SKILL.md +194 -0
- package/marketplace/skills/semantic-relations/SKILL.md +250 -0
- package/marketplace/skills/semantics/SKILL.md +366 -0
- package/marketplace/skills/semiotics/SKILL.md +230 -0
- package/marketplace/skills/seo-strategy/SKILL.md +260 -0
- package/marketplace/skills/server-actions-design/SKILL.md +243 -0
- package/marketplace/skills/server-components-design/SKILL.md +190 -0
- package/marketplace/skills/sharding-strategy/SKILL.md +123 -0
- package/marketplace/skills/shopify/SKILL.md +42 -0
- package/marketplace/skills/skill-infrastructure/SKILL.md +320 -0
- package/marketplace/skills/skill-router/SKILL.md +71 -0
- package/marketplace/skills/skill-scaffold/SKILL.md +105 -0
- package/marketplace/skills/snapshot-testing/SKILL.md +120 -0
- package/marketplace/skills/spec-driven-development/SKILL.md +148 -0
- package/marketplace/skills/state-machine-modeling/SKILL.md +56 -0
- package/marketplace/skills/state-management/SKILL.md +134 -0
- package/marketplace/skills/streaming-architecture/SKILL.md +194 -0
- package/marketplace/skills/summarization/SKILL.md +156 -0
- package/marketplace/skills/suspense-patterns/SKILL.md +265 -0
- package/marketplace/skills/system-interface-contracts/SKILL.md +59 -0
- package/marketplace/skills/task-analysis/SKILL.md +201 -0
- package/marketplace/skills/taxonomy-design/SKILL.md +66 -0
- package/marketplace/skills/test-coverage-strategy/SKILL.md +108 -0
- package/marketplace/skills/test-doubles-design/SKILL.md +98 -0
- package/marketplace/skills/test-driven-development/SKILL.md +96 -0
- package/marketplace/skills/testing-strategy/SKILL.md +67 -0
- package/marketplace/skills/theme-system-design/SKILL.md +43 -0
- package/marketplace/skills/tool-call-flow/SKILL.md +229 -0
- package/marketplace/skills/tool-call-strategy/SKILL.md +292 -0
- package/marketplace/skills/transaction-isolation/SKILL.md +98 -0
- package/marketplace/skills/type-safety/SKILL.md +177 -0
- package/marketplace/skills/typography-system/SKILL.md +43 -0
- package/marketplace/skills/usability-testing/SKILL.md +43 -0
- package/marketplace/skills/user-research/SKILL.md +43 -0
- package/marketplace/skills/vercel-composition-patterns/SKILL.md +157 -0
- package/marketplace/skills/version-control/SKILL.md +233 -0
- package/marketplace/skills/visual-design-foundations/SKILL.md +59 -0
- package/marketplace/skills/visual-hierarchy/SKILL.md +43 -0
- package/marketplace/skills/webhook-integration/SKILL.md +331 -0
- package/marketplace/skills/writing-humanizer/SKILL.md +380 -0
- package/package.json +67 -0
- package/schemas/manifest.schema.json +811 -0
- package/schemas/manifest.v2.schema.json +164 -0
- package/schemas/manifest.v3.schema.json +758 -0
- package/schemas/manifest.v4.schema.json +755 -0
- package/schemas/manifest.v5.schema.json +755 -0
- package/schemas/manifest.v6.schema.json +811 -0
- package/schemas/skill.context.jsonld +279 -0
- package/schemas/skill.schema.json +919 -0
- package/schemas/skill.v2.schema.json +201 -0
- package/schemas/skill.v3.schema.json +827 -0
- package/schemas/skill.v4.schema.json +822 -0
- package/schemas/skill.v5.schema.json +830 -0
- package/schemas/skill.v6.schema.json +946 -0
- package/schemas/vocabulary/keywords.json +180 -0
- package/schemas/vocabulary/workspace_tags.json +23 -0
- package/scripts/__tests__/migrate-skill-v2-to-v3.test.js +161 -0
- package/scripts/__tests__/migrate-skill-v3-to-v4.test.js +158 -0
- package/scripts/__tests__/test-export-parser-drift.js +149 -0
- package/scripts/__tests__/test-marketplace-export.js +114 -0
- package/scripts/__tests__/test-router-paths.js +82 -0
- package/scripts/__tests__/test-stability-promotion.js +244 -0
- package/scripts/__tests__/test-v3-1-alias-contract.js +109 -0
- package/scripts/__tests__/test-v3-1-skos-runtime.js +116 -0
- package/scripts/backfill-schema-version.js +198 -0
- package/scripts/build-field-reference.js +160 -0
- package/scripts/build-retrieval-baseline.js +511 -0
- package/scripts/check-markdown-links.js +211 -0
- package/scripts/check-protocol-consistency.js +979 -0
- package/scripts/export-marketplace-skills.js +610 -0
- package/scripts/export-skill.js +374 -0
- package/scripts/generate-manifest.js +787 -0
- package/scripts/lib/alias-contract.js +83 -0
- package/scripts/lib/audit-prompt-builder.js +771 -0
- package/scripts/lib/mock-grader.js +134 -0
- package/scripts/lib/parse-frontmatter.js +429 -0
- package/scripts/lib/roots.js +119 -0
- package/scripts/lint/check-archetype-sections.js +185 -0
- package/scripts/lint/check-category-enum.js +83 -0
- package/scripts/lint/check-routing-eval.js +146 -0
- package/scripts/lint/check-routing-quality.js +211 -0
- package/scripts/lint/check-stability-promotion.js +220 -0
- package/scripts/lint/format-code-frame.js +206 -0
- package/scripts/marketplace-install.js +125 -0
- package/scripts/migrate-category-to-enum.js +169 -0
- package/scripts/migrate-skill-v2-to-v3.js +424 -0
- package/scripts/migrate-skill-v3-to-v4.js +200 -0
- package/scripts/migrate-skill-v5-to-v6.js +304 -0
- package/scripts/restructure-by-category.js +85 -0
- package/scripts/seed-publication-classification.js +282 -0
- package/scripts/skill-audit.js +893 -0
- package/scripts/skill-graph-drift.js +483 -0
- package/scripts/skill-graph-route.js +766 -0
- package/scripts/skill-graph-routing-eval.js +393 -0
- package/scripts/skill-lint.js +1317 -0
- package/scripts/skill-overlap.js +213 -0
- package/scripts/verify-skill-md-export.js +201 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: compression
|
|
3
|
+
description: "This skill provides expertise in data and context compression: SaaS payload optimization (Zstd, Brotli, Gzip), database storage compression, and AI context window compression (Semantic Summarization, Token Pruning). Use when optimizing API latency, reducing storage costs, or managing long-running agent sessions near context limits. Do NOT use for image/video lossy compression (use product-photo) or file archiving."
|
|
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/data\",\"scope\":\"portable\",\"owner\":\"skill-graph-maintainer\",\"freshness\":\"2026-03-28\",\"drift_check\":\"{\\\\\\\"last_verified\\\\\\\":\\\\\\\"2026-03-28\\\\\\\"}\",\"eval_artifacts\":\"planned\",\"eval_state\":\"unverified\",\"routing_eval\":\"absent\",\"stability\":\"experimental\",\"keywords\":\"[\\\\\\\"compression\\\\\\\",\\\\\\\"Zstd\\\\\\\",\\\\\\\"Brotli\\\\\\\",\\\\\\\"Gzip\\\\\\\",\\\\\\\"context window\\\\\\\",\\\\\\\"token efficiency\\\\\\\",\\\\\\\"semantic summarization\\\\\\\",\\\\\\\"payload reduction\\\\\\\",\\\\\\\"DB TOAST\\\\\\\"]\",\"triggers\":\"[\\\\\\\"compression-skill\\\\\\\",\\\\\\\"context-compression\\\\\\\",\\\\\\\"payload-optimization\\\\\\\"]\",\"relations\":\"{\\\\\\\"related\\\\\\\":[\\\\\\\"context-window\\\\\\\"],\\\\\\\"boundary\\\\\\\":[\\\\\\\"context-management\\\\\\\",\\\\\\\"summarization\\\\\\\"]}\",\"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/compression/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/compression/SKILL.md
|
|
13
|
+
---
|
|
14
|
+
# Compression
|
|
15
|
+
|
|
16
|
+
## Domain Context
|
|
17
|
+
|
|
18
|
+
**What is this skill?** This skill provides expertise in data and context compression: SaaS payload optimization (Zstd, Brotli, Gzip), database storage compression, and AI context window compression (Semantic Summarization, Token Pruning). Use when optimizing API latency, reducing storage costs, or managing long-running agent sessions near context limits. Do NOT use for image/video lossy compression (use product-photo) or file archiving.
|
|
19
|
+
|
|
20
|
+
## Key Files
|
|
21
|
+
|
|
22
|
+
| File | Purpose |
|
|
23
|
+
| ---------------------------------------------------- | ---------------------------------------------------------------------------------------- |
|
|
24
|
+
| `skills/token-efficiency/SKILL.md` | Adjacent authority for prompt and token-budget compression strategy. |
|
|
25
|
+
| `skills/context-window/SKILL.md` | Adjacent authority for compaction timing and context-budget math. |
|
|
26
|
+
| `scripts/hooks/pre-compact-hook.py` | Pre-compaction persistence hook that preserves state before context compression. |
|
|
27
|
+
| `scripts/session/session-ctl.js` | Session-control CLI that exposes wrap, clear, and continue operations around compaction. |
|
|
28
|
+
| `docs/reference/session-control-wrapper-contract.md` | Canonical session-control contract covering wrap, clear, compact, and resume semantics. |
|
|
29
|
+
| `agent-orchestration/ONBOARDING.md` | Workflow context for how session-control and continuation fit the orchestration flow. |
|
|
30
|
+
|
|
31
|
+
## Coverage
|
|
32
|
+
|
|
33
|
+
SaaS payload compression (Zstd, Brotli, Gzip algorithm selection, level tuning, content negotiation), PostgreSQL storage compression (TOAST with Zstd, application-layer blob compression), and AI context window compression (semantic summarization, token pruning, dead context identification, state re-injection). Covers the decision tree for matching algorithms to data types, the `Accept-Encoding` negotiation order, and the three-phase token pruning workflow.
|
|
34
|
+
|
|
35
|
+
## Philosophy
|
|
36
|
+
|
|
37
|
+
Compression is the science of increasing information density. In a modern SaaS, it applies at two layers: the **Infrastructure Layer** (reducing bytes on the wire/disk) and the **Intelligence Layer** (reducing tokens in the context window). Without this skill, agents default to generic compression advice that ignores the specific algorithm-to-data-type mapping (e.g., using Gzip everywhere instead of Zstd for dynamic API payloads) and fail to recognize that sub-1KB payloads should skip compression entirely. On the intelligence side, agents routinely let context windows bloat with dead research turns instead of applying structured summarization that preserves evidence paths.
|
|
38
|
+
|
|
39
|
+
## 1. SaaS Data Compression Decision Tree
|
|
40
|
+
|
|
41
|
+
Match the compression algorithm to the data type and lifecycle.
|
|
42
|
+
|
|
43
|
+
| Data Type | Recommended | Why? |
|
|
44
|
+
| -------------------------- | ------------------------ | ---------------------------------------------------------- |
|
|
45
|
+
| **Static Assets** (JS/CSS) | Brotli (Level 11) | Highest ratio for web strings; slow build-time OK. |
|
|
46
|
+
| **Dynamic API** (JSON) | Zstd (Level 3) | Fastest decompression; lower TTFB than Gzip. |
|
|
47
|
+
| **Small Payloads** (<1KB) | None / Custom Dictionary | Compression overhead often increases size for small items. |
|
|
48
|
+
| **Large DB Columns** | Zstd (TOAST) | Postgres 14+ native support; high speed/low I/O. |
|
|
49
|
+
|
|
50
|
+
### Implementation Rules
|
|
51
|
+
|
|
52
|
+
- **Negotiation**: Always check `Accept-Encoding` header. Order: `zstd` > `br` > `gzip`.
|
|
53
|
+
- **Level Selection**: Use Level 3 for dynamic runtime; Level 11 for static build-time.
|
|
54
|
+
- **Header Safety**: Ensure `Vary: Accept-Encoding` is set to prevent cache pollution.
|
|
55
|
+
|
|
56
|
+
## 2. AI Context Compression
|
|
57
|
+
|
|
58
|
+
Protect the context window by maximizing token density.
|
|
59
|
+
|
|
60
|
+
### Semantic Summarization
|
|
61
|
+
|
|
62
|
+
- **Pattern**: Replace raw logs/code with high-density Markdown summaries.
|
|
63
|
+
- **Rule**: A summary must preserve **Intent**, **Outcome**, and **Evidence Paths** while removing boilerplate.
|
|
64
|
+
|
|
65
|
+
### Token Pruning (The "Surgical Cut")
|
|
66
|
+
|
|
67
|
+
- **Phase 1**: Identify "Dead Context" (e.g., redundant file reads, failed research turns).
|
|
68
|
+
- **Phase 2**: Use `/clear` or `/compact` to drop the bottom 50% of the session history.
|
|
69
|
+
- **Phase 3**: Re-inject the "State of the Union" summary via Memory MCP.
|
|
70
|
+
|
|
71
|
+
> **Source**: `skills/token-efficiency/SKILL.md` (Adjacent)
|
|
72
|
+
|
|
73
|
+
## 3. Storage Compression (Postgres)
|
|
74
|
+
|
|
75
|
+
Optimize for cost and performance at the database layer.
|
|
76
|
+
|
|
77
|
+
- **TOAST Compression**: Set `default_toast_compression = 'zstd'` for large JSONB fields.
|
|
78
|
+
- **Blob Compression**: For extremely large blobs (>10MB), compress in the application layer (Node.js `zstd` bindings) before storing as `BYTEA`.
|
|
79
|
+
|
|
80
|
+
## 4. Verification Checklist
|
|
81
|
+
|
|
82
|
+
```text
|
|
83
|
+
COMPRESSION CHECK
|
|
84
|
+
=================
|
|
85
|
+
[ ] Static assets pre-compressed with Brotli (Level 11)
|
|
86
|
+
[ ] API middleware supports Zstd with Gzip fallback
|
|
87
|
+
[ ] Vary: Accept-Encoding header present
|
|
88
|
+
[ ] AI context summary preserves Evidence Paths
|
|
89
|
+
[ ] redundant research/file reads pruned from session
|
|
90
|
+
[ ] DB compression matches Postgres version (Zstd if 14+)
|
|
91
|
+
[ ] Payloads < 1KB skip compression to avoid overhead
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Verification
|
|
95
|
+
|
|
96
|
+
After applying this skill, verify:
|
|
97
|
+
|
|
98
|
+
- [ ] Algorithm matches data type per the decision tree (static=Brotli, dynamic API=Zstd, DB=TOAST Zstd)
|
|
99
|
+
- [ ] `Accept-Encoding` negotiation respects the `zstd > br > gzip` priority order
|
|
100
|
+
- [ ] `Vary: Accept-Encoding` header is set to prevent cache pollution
|
|
101
|
+
- [ ] Small payloads (<1KB) are not compressed (overhead exceeds savings)
|
|
102
|
+
- [ ] Context summaries preserve Intent, Outcome, and Evidence Paths
|
|
103
|
+
- [ ] Token pruning removes dead context (failed research turns, redundant reads) before injecting fresh state
|
|
104
|
+
|
|
105
|
+
## Do NOT Use When
|
|
106
|
+
|
|
107
|
+
| Instead of this skill | Use | Why |
|
|
108
|
+
| ------------------------------------------------------------------------------- | ----------------------- | ----------------------------------------------------------------------------------- |
|
|
109
|
+
| Image/video lossy compression (JPEG quality, WebP, AVIF format selection) | `product-photo` | product-photo owns the image pipeline and format selection logic |
|
|
110
|
+
| Agent session lifecycle (when to compact, context budgets, compaction triggers) | `context-management` | context-management owns session-level compaction strategy and budget allocation |
|
|
111
|
+
| Token budget allocation and prompt compression techniques | `token-efficiency` | token-efficiency owns the token budget framework; compression handles the mechanics |
|
|
112
|
+
| Credential encryption at rest | `credential-encryption` | credential-encryption covers AES-256-GCM patterns, not data compression |
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: conceptual-modeling
|
|
3
|
+
description: "Use when translating business requirements into a structured domain model before database schemas, API endpoints, or DDD aggregates are named. Covers entities, attributes, relationships, cardinality, specialization/generalization, aggregation/composition, roles, abstraction levels, stakeholder validation, and modeling anti-patterns such as implementation leakage, god entities, phantom relationships, premature normalization, attribute-as-entity, and unnamed relationships. Do NOT use for database ER diagrams with keys and normalization, formal ontology axioms with OWL/RDFS, or DDD tactical design; use those dedicated skills instead."
|
|
4
|
+
license: MIT
|
|
5
|
+
compatibility: "Domain- and language-agnostic. The conceptual / logical / physical ladder applies across relational, document, graph, and event-sourced systems."
|
|
6
|
+
allowed-tools: Read Grep
|
|
7
|
+
metadata:
|
|
8
|
+
metadata: "{\"schema_version\":6,\"version\":\"1.0.0\",\"type\":\"capability\",\"category\":\"engineering\",\"domain\":\"engineering/modeling\",\"scope\":\"portable\",\"owner\":\"skill-graph-maintainer\",\"freshness\":\"2026-05-06\",\"drift_check\":\"{\\\\\\\"last_verified\\\\\\\":\\\\\\\"2026-05-06\\\\\\\"}\",\"eval_artifacts\":\"planned\",\"eval_state\":\"unverified\",\"routing_eval\":\"absent\",\"stability\":\"experimental\",\"keywords\":\"[\\\\\\\"conceptual model\\\\\\\",\\\\\\\"conceptual modeling methodology\\\\\\\",\\\\\\\"domain abstraction\\\\\\\",\\\\\\\"entity relationship cardinality\\\\\\\",\\\\\\\"conceptual schema before implementation\\\\\\\",\\\\\\\"business model to system model\\\\\\\",\\\\\\\"generalization specialization\\\\\\\",\\\\\\\"aggregation composition relationship\\\\\\\",\\\\\\\"reify relationship to entity\\\\\\\",\\\\\\\"conceptual logical physical layers\\\\\\\",\\\\\\\"implementation leakage anti-pattern\\\\\\\",\\\\\\\"unnamed relationship anti-pattern\\\\\\\",\\\\\\\"god entity anti-pattern\\\\\\\",\\\\\\\"missing entity anti-pattern\\\\\\\",\\\\\\\"validate model with stakeholders\\\\\\\",\\\\\\\"UML class diagram conceptual\\\\\\\",\\\\\\\"role modeling pattern\\\\\\\",\\\\\\\"is-a vs has-a vs owns\\\\\\\"]\",\"examples\":\"[\\\\\\\"a stakeholder says 'users place orders that ship in multiple boxes' — how do I capture this as a model before naming tables?\\\\\\\",\\\\\\\"is a refund its own entity or just a payment status — what conceptual test decides that?\\\\\\\",\\\\\\\"two business stakeholders disagree on whether a cart and an order are the same thing — how should the conceptual model resolve that?\\\\\\\",\\\\\\\"our domain diagram already mentions UUIDs and cascade-delete — what anti-pattern is that and how do I pull it back?\\\\\\\",\\\\\\\"this relationship has a date, an amount, and a status — should it stay as a line between entities or become its own entity?\\\\\\\",\\\\\\\"should this attribute live on the Customer entity or on Order — what's the rule?\\\\\\\",\\\\\\\"we have Physical, Digital, and Subscription products — how do I model that as generalization without lying about totality?\\\\\\\"]\",\"anti_examples\":\"[\\\\\\\"give me the physical table design with PKs, FKs, and normalization forms\\\\\\\",\\\\\\\"I need OWL class axioms and reasoning constraints for these concepts\\\\\\\",\\\\\\\"build the DDD aggregate boundaries and anti-corruption layer\\\\\\\",\\\\\\\"what hypernymy / meronymy labels apply between these terms\\\\\\\",\\\\\\\"review this ORM model class for code correctness\\\\\\\",\\\\\\\"name the entities and fields once we agree on the conceptual model\\\\\\\"]\",\"relations\":\"{\\\\\\\"boundary\\\\\\\":[{\\\\\\\"skill\\\\\\\":\\\\\\\"code-review\\\\\\\",\\\\\\\"reason\\\\\\\":\\\\\\\"code-review evaluates implementation output; conceptual-modeling is the pre-implementation domain analysis above it\\\\\\\"},{\\\\\\\"skill\\\\\\\":\\\\\\\"naming-conventions\\\\\\\",\\\\\\\"reason\\\\\\\":\\\\\\\"naming-conventions decides what to call entities and fields; conceptual-modeling decides what entities and fields exist in the first place\\\\\\\"},{\\\\\\\"skill\\\\\\\":\\\\\\\"refactor\\\\\\\",\\\\\\\"reason\\\\\\\":\\\\\\\"refactor preserves behavior while restructuring code; conceptual-modeling restructures the domain abstraction itself, which usually requires non-behavior-preserving change\\\\\\\"}],\\\\\\\"related\\\\\\\":[\\\\\\\"naming-conventions\\\\\\\"],\\\\\\\"verify_with\\\\\\\":[]}\",\"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/conceptual-modeling/SKILL.md\",\"skill_graph_export_description\":\"shortened for Agent Skills 1024-character description limit; canonical source keeps the full routing contract\",\"skill_graph_canonical_description_length\":\"1044\"}"
|
|
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/conceptual-modeling/SKILL.md
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# Conceptual Modeling
|
|
16
|
+
|
|
17
|
+
## Coverage
|
|
18
|
+
|
|
19
|
+
Methodology for abstracting a real-world domain into a structured representation _before_ any database table, API endpoint, or aggregate boundary is named. Identifies entities (distinguishable things the business tracks), attributes (properties that describe an entity), and relationships (meaningful connections between entities). Specifies cardinality (1:1, 1:N, M:N, 0..1, 1..\*); distinguishes association from aggregation from composition; uses generalization / specialization with disjoint / overlapping and total / partial constraints; recognizes when an associative relationship needs to be reified into its own entity (e.g. an enrollment between Student and Course that carries grade and date). Walks the conceptual → logical → physical abstraction ladder. Validates models against business stakeholders' mental models via walk-through, scenario testing, negative testing, and terminology audit. Names the seven anti-patterns: implementation leakage, missing entity, god entity, phantom relationship, premature normalization, attribute-as-entity, unnamed relationship.
|
|
20
|
+
|
|
21
|
+
## Philosophy
|
|
22
|
+
|
|
23
|
+
Every software system is a model of some real-world domain. The quality of that model determines whether the system helps or hinders its users. Without explicit conceptual modeling, the team jumps directly from requirements to code — encoding implicit assumptions that surface later as architectural debt. A requirement like "users can place orders" hides dozens of decisions: is a cart an order? can an order have multiple shipments? is a refund a new entity or a state of a payment? Conceptual modeling forces those decisions to the surface _before_ code exists, so rework happens on a whiteboard rather than across a migration.
|
|
24
|
+
|
|
25
|
+
The discipline is anti-rigid in a specific way. Conceptual modeling stays one layer _above_ logical modeling (tables, foreign keys, normalization) and one layer _above_ DDD tactical design (aggregates, bounded contexts, anti-corruption layers). The moment the model speaks of UUIDs, indexes, or cascade behavior, it has fallen into logical modeling. The moment it prescribes aggregates or anti-corruption layers, it has crossed into DDD. Conceptual modeling's job is earlier and narrower: capture the domain structure clearly enough that those later design layers can proceed without guessing about the business.
|
|
26
|
+
|
|
27
|
+
## 1. The Three-Level Architecture
|
|
28
|
+
|
|
29
|
+
| Level | Purpose | Audience | Notation |
|
|
30
|
+
| -------------- | ------------------------------------------------ | --------------------------------------- | -------------------------------------------------------------- |
|
|
31
|
+
| **Conceptual** | What exists in the business domain | Business stakeholders, product managers | Simplified UML class diagrams, entity lists, relationship maps |
|
|
32
|
+
| **Logical** | How the data is structured, platform-independent | Architects, senior developers | Normalized schemas, interface contracts, type hierarchies |
|
|
33
|
+
| **Physical** | How the data is stored and accessed | Database engineers, backend developers | SQL DDL, index strategies, partition schemes |
|
|
34
|
+
|
|
35
|
+
Rules:
|
|
36
|
+
|
|
37
|
+
- Always build conceptual _before_ logical. Jumping straight to physical (tables, columns) from raw requirements produces brittle, business-disconnected schemas that fail their first feature change.
|
|
38
|
+
- Conceptual models must be readable by non-technical stakeholders. If a business user cannot validate the model, the model is too detailed.
|
|
39
|
+
- Each level _adds_ implementation detail. None should _remove_ business meaning. If something disappears as you move down, the lower layer has dropped a constraint that the business actually has.
|
|
40
|
+
|
|
41
|
+
## 2. Core Modeling Constructs
|
|
42
|
+
|
|
43
|
+
### 2.1 Entities and attributes
|
|
44
|
+
|
|
45
|
+
| Element | Definition | Modeling rule |
|
|
46
|
+
| -------------------------- | ------------------------------------------- | --------------------------------------------------------------------------------- |
|
|
47
|
+
| **Entity** | A distinguishable thing the business tracks | Must have identity criteria — what makes two X's "the same"? |
|
|
48
|
+
| **Attribute** | A property that describes an entity | Belongs to exactly one entity; if it's shared, you've discovered a missing entity |
|
|
49
|
+
| **Derived attribute** | A value computed from other attributes | Mark explicitly; never store without documenting the derivation |
|
|
50
|
+
| **Multi-valued attribute** | An attribute with multiple values | Usually signals a missing child entity or collection |
|
|
51
|
+
|
|
52
|
+
### 2.2 Relationships
|
|
53
|
+
|
|
54
|
+
| Type | Notation (UML) | When to use |
|
|
55
|
+
| ------------------------- | ------------------------------- | ----------------------------------------------------------- |
|
|
56
|
+
| **Association** | Plain line between entities | Two entities are meaningfully connected |
|
|
57
|
+
| **Aggregation** (has-a) | Open diamond | Whole-part where parts can exist independently of the whole |
|
|
58
|
+
| **Composition** (owns) | Filled diamond | Whole-part where parts cannot exist without the whole |
|
|
59
|
+
| **Generalization** (is-a) | Triangle arrow toward supertype | Subtype inherits supertype properties |
|
|
60
|
+
| **Dependency** | Dashed arrow | One entity uses another without owning it |
|
|
61
|
+
|
|
62
|
+
### 2.3 Cardinality
|
|
63
|
+
|
|
64
|
+
| Pattern | Reading | Example |
|
|
65
|
+
| ------- | -------------------------- | -------------------------------------------------------------------- |
|
|
66
|
+
| 1:1 | Exactly one to exactly one | User has one Profile |
|
|
67
|
+
| 1:N | One to many | Customer places many Orders |
|
|
68
|
+
| M:N | Many to many | Products belong to many Categories; Categories contain many Products |
|
|
69
|
+
| 0..1 | Optional one | Order may have zero or one Refund |
|
|
70
|
+
| 1..\* | One or more (mandatory) | Order has at least one LineItem |
|
|
71
|
+
|
|
72
|
+
Rules:
|
|
73
|
+
|
|
74
|
+
- Every relationship must have explicit cardinality. Unmarked relationships are ambiguous and will be implemented incorrectly half the time.
|
|
75
|
+
- M:N relationships in the conceptual model often become junction entities in the logical model — especially once they acquire their own attributes.
|
|
76
|
+
- Optional vs mandatory is a _business_ decision, not a technical one. Validate with stakeholders who actually know which orders can ship without addresses.
|
|
77
|
+
|
|
78
|
+
## 3. Generalization and Specialization
|
|
79
|
+
|
|
80
|
+
### When to generalize (bottom-up)
|
|
81
|
+
|
|
82
|
+
- Multiple entities share roughly 70%+ of their attributes
|
|
83
|
+
- Business users refer to them with a common name ("all our products, whether physical or digital")
|
|
84
|
+
- Operations apply uniformly ("ship any order, regardless of type")
|
|
85
|
+
|
|
86
|
+
### When to specialize (top-down)
|
|
87
|
+
|
|
88
|
+
- A single entity has attributes or behaviors that apply only to some of its instances
|
|
89
|
+
- Business rules differ by subtype ("digital products don't need shipping addresses")
|
|
90
|
+
- The type distinction drives different processing paths
|
|
91
|
+
|
|
92
|
+
### Specialization constraints
|
|
93
|
+
|
|
94
|
+
| Constraint | Meaning | Example |
|
|
95
|
+
| --------------- | ---------------------------------------------------------- | ----------------------------------------------------------------- |
|
|
96
|
+
| **Disjoint** | An instance belongs to _exactly one_ subtype | A payment is either a CardPayment or a BankTransfer, never both |
|
|
97
|
+
| **Overlapping** | An instance can belong to _multiple_ subtypes | A user can be both a Seller and a Buyer |
|
|
98
|
+
| **Total** | Every supertype instance belongs to _at least one_ subtype | Every Product is either Physical or Digital — no untyped Products |
|
|
99
|
+
| **Partial** | Some supertype instances may not be specialized | A User may not yet be a Seller or a Buyer |
|
|
100
|
+
|
|
101
|
+
Each pair (disjoint vs overlapping) and (total vs partial) is independent — pick one from each pair for every generalization.
|
|
102
|
+
|
|
103
|
+
## 4. Abstraction Strategies
|
|
104
|
+
|
|
105
|
+
| Strategy | When to use | Risk if skipped |
|
|
106
|
+
| ------------------ | ------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
|
|
107
|
+
| **Classification** | Grouping instances into types | Too many ad-hoc types; inconsistent behavior |
|
|
108
|
+
| **Aggregation** | Composing wholes from parts | Flat structures that lose structural meaning |
|
|
109
|
+
| **Generalization** | Finding common supertypes | Duplicated attributes and logic across subtypes |
|
|
110
|
+
| **Association** | Connecting related entities | Implicit relationships buried in code |
|
|
111
|
+
| **Reification** | Promoting a relationship to an entity | Important relationship attributes get lost (e.g., an Enrollment between Student and Course that carries grade and date) |
|
|
112
|
+
|
|
113
|
+
Rules:
|
|
114
|
+
|
|
115
|
+
- Reify a relationship when it has its _own_ attributes, lifecycle, or identity.
|
|
116
|
+
- If an association carries a date, status, or amount, it is probably an entity in disguise.
|
|
117
|
+
|
|
118
|
+
## 5. Validating the Model with Stakeholders
|
|
119
|
+
|
|
120
|
+
| Method | What it catches |
|
|
121
|
+
| --------------------- | ------------------------------------------------------------------------------------------------------------------ |
|
|
122
|
+
| **Walk-through** | Read each relationship aloud: "A Customer places one or more Orders." If it sounds wrong, the model is wrong. |
|
|
123
|
+
| **Scenario testing** | Trace a real business scenario through the model. Every step should map to a model element. |
|
|
124
|
+
| **Negative testing** | Try to represent something the business says is impossible. If the model permits it, a constraint is missing. |
|
|
125
|
+
| **Terminology audit** | Every entity name should match what business users actually call it. Rename to match — never the other way around. |
|
|
126
|
+
|
|
127
|
+
If a business user can't read the model and recognise their own domain, the model is documentation theatre. Re-do it.
|
|
128
|
+
|
|
129
|
+
## 6. Anti-Patterns
|
|
130
|
+
|
|
131
|
+
| Anti-pattern | Symptom | Fix |
|
|
132
|
+
| --------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
|
|
133
|
+
| **Implementation leakage** | Conceptual model talks about tables, columns, indexes, foreign keys | Strip all physical terminology; use entity / attribute / relationship |
|
|
134
|
+
| **Missing entity** | An attribute stores a comma-separated list, encoded compound, or JSON blob | Extract into a proper entity with its own identity |
|
|
135
|
+
| **God entity** | One entity with 30+ attributes spanning multiple business concerns | Decompose by business responsibility |
|
|
136
|
+
| **Phantom relationship** | Two entities are connected and no one can explain why | Remove it — relationships must serve a stated business purpose |
|
|
137
|
+
| **Premature normalization** | The conceptual model is already in 3NF | Normalization belongs in the logical model, not here |
|
|
138
|
+
| **Attribute-as-entity** | "Color" has its own entity with just a name attribute | Keep as an attribute or enum unless it has its own properties or lifecycle |
|
|
139
|
+
| **Unnamed relationship** | Lines between entities with no verb / role label | Every relationship needs a name a business user can validate |
|
|
140
|
+
|
|
141
|
+
## 7. From Conceptual to Implementation
|
|
142
|
+
|
|
143
|
+
The conceptual model is consumed by downstream layers. Track the typical translations so the conceptual model stays implementation-neutral:
|
|
144
|
+
|
|
145
|
+
| Conceptual element | Logical / physical translation |
|
|
146
|
+
| ---------------------------- | --------------------------------------------------------------------------- |
|
|
147
|
+
| Entity | Type / class / interface, database table, API resource |
|
|
148
|
+
| Attribute | Property / field, database column |
|
|
149
|
+
| 1:N relationship | Foreign key on the N side |
|
|
150
|
+
| M:N relationship | Junction table with two foreign keys (often itself an entity at this layer) |
|
|
151
|
+
| Generalization (disjoint) | Discriminated union, single-table inheritance, or class-table inheritance |
|
|
152
|
+
| Generalization (overlapping) | Multiple junction tables or role-based flags |
|
|
153
|
+
| Composition | Cascade-delete on parent, nested API resource |
|
|
154
|
+
| Aggregation | Set-null on parent, independent API resource |
|
|
155
|
+
| Derived attribute | Computed column, getter, or materialized view |
|
|
156
|
+
|
|
157
|
+
These translations are _informational_ — the conceptual model itself stays neutral. Naming the translations explicitly avoids the trap of authoring a "conceptual" model that has already pre-decided the physical layer.
|
|
158
|
+
|
|
159
|
+
## Verification
|
|
160
|
+
|
|
161
|
+
- [ ] Every relationship has a name (verb or role label) — not just lines between boxes
|
|
162
|
+
- [ ] Cardinality is specified on every relationship (1:1, 1:N, M:N, 0..1, 1..\*)
|
|
163
|
+
- [ ] Aggregation, composition, and plain association are explicitly distinguished where relevant
|
|
164
|
+
- [ ] The model is free of physical terminology (no tables, columns, indexes, foreign keys, cascade, normalization)
|
|
165
|
+
- [ ] Generalization / specialization uses the correct disjoint / overlapping and total / partial pair
|
|
166
|
+
- [ ] Business stakeholders have read the model and validated it against their domain
|
|
167
|
+
- [ ] No M:N relationship hides an entity-worthy junction concept (i.e., one with its own attributes)
|
|
168
|
+
- [ ] No attribute stores compound, multi-valued, or encoded data
|
|
169
|
+
- [ ] Every entity has explicit identity criteria — "what makes two X's the same"
|
|
170
|
+
- [ ] Every entity name matches the term the business actually uses
|
|
171
|
+
|
|
172
|
+
## Do NOT Use When
|
|
173
|
+
|
|
174
|
+
| Use instead | When |
|
|
175
|
+
| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
|
|
176
|
+
| A logical / physical modeling skill (database-specific ER) | You need PKs, FKs, normalization forms, index strategies — the layer below conceptual |
|
|
177
|
+
| An ontology skill | You need OWL axioms, RDFS class hierarchies, formal reasoning constraints — the layer above human-readable conceptual |
|
|
178
|
+
| A DDD / domain-modeling skill | You need bounded-context boundaries, aggregates, anti-corruption layers — DDD tactical design |
|
|
179
|
+
| `naming-conventions` | The conceptual model is settled; you now need to decide what to _call_ the entities and fields in code |
|
|
180
|
+
| `code-review` | You are reviewing code that already implements the model — conceptual modeling is the upstream activity |
|
|
181
|
+
| `documentation` | You need to _describe_ an existing system in prose for a human reader, not abstract a new domain into a structured model |
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: connection-pooling
|
|
3
|
+
description: "Use when reasoning about how an application manages its database connections: why every connection has a server-side cost, the difference between application-level pools (HikariCP, pgx pool, node-postgres Pool) and proxy-level pools (PgBouncer, Pgpool, ProxySQL), the three PgBouncer modes (session, transaction, statement) and their feature compatibility, the canonical pool-sizing math (Little's Law applied to database concurrency; Wooldridge's analyses), the failure modes (connection exhaustion, hot-loop reconnects, prepared-statement breakage under transaction pooling, idle-in-transaction leaks), and the diagnostic procedure when a workload is contending on connections instead of query work. Do NOT use for query-level performance (use query-optimization), for index design (use indexing-strategy), for read/write replica routing (use replication-patterns), or for cross-shard query coordination (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\":\"[\\\\\\\"connection pooling\\\\\\\",\\\\\\\"PgBouncer\\\\\\\",\\\\\\\"HikariCP\\\\\\\",\\\\\\\"pool sizing\\\\\\\",\\\\\\\"session pooling\\\\\\\",\\\\\\\"transaction pooling\\\\\\\",\\\\\\\"statement pooling\\\\\\\",\\\\\\\"prepared statements\\\\\\\",\\\\\\\"idle in transaction\\\\\\\",\\\\\\\"Little's Law\\\\\\\",\\\\\\\"max_connections\\\\\\\",\\\\\\\"serverless databases\\\\\\\"]\",\"triggers\":\"[\\\\\\\"what should max pool size be\\\\\\\",\\\\\\\"PgBouncer transaction mode\\\\\\\",\\\\\\\"too many connections error\\\\\\\",\\\\\\\"connection exhaustion\\\\\\\",\\\\\\\"prepared statements not working with PgBouncer\\\\\\\"]\",\"examples\":\"[\\\\\\\"size a connection pool for a workload with N application servers and M cores per database\\\\\\\",\\\\\\\"diagnose why a workload is bottlenecked on connections rather than query performance\\\\\\\",\\\\\\\"decide between PgBouncer session mode and transaction mode for an application\\\\\\\",\\\\\\\"explain why HikariCP recommends small pools instead of large ones\\\\\\\"]\",\"anti_examples\":\"[\\\\\\\"tune a slow query (use query-optimization)\\\\\\\",\\\\\\\"design indexes (use indexing-strategy)\\\\\\\",\\\\\\\"route reads to a replica (use replication-patterns)\\\\\\\",\\\\\\\"design partitioning across shards (use sharding-strategy)\\\\\\\"]\",\"relations\":\"{\\\\\\\"related\\\\\\\":[\\\\\\\"query-optimization\\\\\\\",\\\\\\\"replication-patterns\\\\\\\",\\\\\\\"sharding-strategy\\\\\\\",\\\\\\\"transaction-isolation\\\\\\\"],\\\\\\\"boundary\\\\\\\":[{\\\\\\\"skill\\\\\\\":\\\\\\\"query-optimization\\\\\\\",\\\\\\\"reason\\\\\\\":\\\\\\\"query-optimization owns the cost of individual query work; this skill owns the cost of having a connection at all. A workload contending on connections has different symptoms than a workload contending on query work, and the diagnostic discipline differs.\\\\\\\"},{\\\\\\\"skill\\\\\\\":\\\\\\\"replication-patterns\\\\\\\",\\\\\\\"reason\\\\\\\":\\\\\\\"replication-patterns owns the routing of reads and writes across replicas; this skill owns the connection layer beneath that routing. They compose: a pooled architecture often pools to each replica separately.\\\\\\\"},{\\\\\\\"skill\\\\\\\":\\\\\\\"sharding-strategy\\\\\\\",\\\\\\\"reason\\\\\\\":\\\\\\\"sharding-strategy owns how data is partitioned across nodes; this skill owns how application connections to those nodes are pooled. A sharded architecture multiplies the pool-sizing surface — one pool per shard.\\\\\\\"},{\\\\\\\"skill\\\\\\\":\\\\\\\"transaction-isolation\\\\\\\",\\\\\\\"reason\\\\\\\":\\\\\\\"transaction-isolation owns the per-transaction concurrency-correctness contract; this skill owns the connection-level mechanics that determine whether a transaction's connection is held, released, or shared. PgBouncer's transaction mode in particular interacts with isolation level and session state.\\\\\\\"}],\\\\\\\"verify_with\\\\\\\":[\\\\\\\"query-optimization\\\\\\\",\\\\\\\"replication-patterns\\\\\\\"]}\",\"mental_model\":\"|\",\"purpose\":\"|\",\"boundary\":\"|\",\"analogy\":\"A connection pool is to a database what a taxi rank is to an airport — every taxi has a standing cost (driver salary, fuel, parking space); a rank with too few taxis leaves passengers queuing on the curb; a rank with too many burns money on idle taxis and clogs the access road. The right number is the smallest that doesn't queue under peak arrival rate, sized by how long each taxi trip actually takes — and adding more taxis doesn't make the trips faster, it just lets more start at once.\",\"misconception\":\"|\",\"concept\":\"{\\\\\\\"definition\\\\\\\":\\\\\\\"Connection pooling is the discipline of managing a finite set of database connections shared across many application threads, requests, or processes, because opening a database connection is expensive (network round-trips, authentication, session setup) and every open connection consumes server resources (a process or thread, memory for buffers and catalog state, locks on shared structures). The pool's job is to keep a small, sized-for-workload number of connections open, hand them out to application units of work for the brief time they need them, and return them to the pool. Pooling can happen at the application layer (in-process pool like HikariCP, pgx pool, node-postgres Pool) or at the proxy layer (an external service like PgBouncer or ProxySQL that multiplexes many client connections onto a smaller set of upstream database connections). The pooling mode (session, transaction, statement) determines what feature compatibility the pool preserves and what failure modes the application must handle. The pool size is a *throughput cap*, not a resource budget; sizing it correctly per Little's Law (concurrency = throughput × latency) is the central operational decision.\\\\\\\",\\\\\\\"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/connection-pooling/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/connection-pooling/SKILL.md
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# Connection Pooling
|
|
15
|
+
|
|
16
|
+
## Coverage
|
|
17
|
+
|
|
18
|
+
The discipline of managing a finite set of database connections shared across many application threads, requests, or processes. Covers the connection cost (server-side process/thread, memory, locks), why pooling is required (open-cost amortization, throughput cap, load-shedding), application-level vs proxy-level pools, the three PgBouncer modes (session, transaction, statement) and their feature compatibility, the canonical pool-sizing math via Little's Law and HikariCP's analyses, the failure modes catalog (connection exhaustion, idle-in-transaction, hot-loop reconnect, prepared-statement breakage, cross-connection state leaks, long-tail accumulation), the operational concerns (wait-time monitoring, connection rotation, reconnect backoff, health checks), and the database-specific connection models (Postgres process-per-connection, MySQL thread-per-connection, serverless variants).
|
|
19
|
+
|
|
20
|
+
## Philosophy
|
|
21
|
+
|
|
22
|
+
The pool is a throughput throttle, not a resource budget. Sizing too large doesn't make slow queries faster — it makes the database thrash and shifts the symptom from "queue waiting for connection" to "queue waiting for CPU, buffer cache, or locks." Sizing too small produces queue waits. The right size is the smallest pool that doesn't queue under peak load — typically much smaller than teams initially set.
|
|
23
|
+
|
|
24
|
+
Pooling mode determines feature surface. The choice between session, transaction, and statement pooling is not just operational — it determines what features the application is allowed to use at the database. Transaction pooling buys multiplexing in exchange for session-feature loss; statement pooling buys further multiplexing in exchange for transaction loss. Knowing which features the application uses, and the cross-product against the pooling mode, is preconditional to choosing a mode.
|
|
25
|
+
|
|
26
|
+
The pool is the place where database-level health becomes application-level latency. A workload contending on the pool surfaces as request queueing in the application, not as slow queries in the database log. Pool instrumentation (`pool.active`, `pool.idle`, `pool.waiting`, `pool.acquire_time`) is the operational hygiene that makes contention legible.
|
|
27
|
+
|
|
28
|
+
## Sizing — Little's Law in Practice
|
|
29
|
+
|
|
30
|
+
**Little's Law:** concurrency = arrival rate × average service time.
|
|
31
|
+
|
|
32
|
+
| Workload | Arrival rate | Avg query time | Concurrency | Pool size |
|
|
33
|
+
|---|---|---|---|---|
|
|
34
|
+
| OLTP point query | 10,000 req/sec | 1 ms | 10 | 12–15 |
|
|
35
|
+
| OLTP transaction | 1,000 req/sec | 10 ms | 10 | 12–15 |
|
|
36
|
+
| Mixed read/write | 2,000 req/sec | 25 ms | 50 | 60–80 |
|
|
37
|
+
| Analytical | 100 req/sec | 500 ms | 50 | Pool partitioning recommended |
|
|
38
|
+
|
|
39
|
+
The pool size is *peak concurrency + small headroom*. Teams that size by request rate (treating pool size as a per-app-server quota) over-size by 10x or more, then discover the database is thrashing.
|
|
40
|
+
|
|
41
|
+
**HikariCP's documented advice:** start with `cores * 2 + effective_spindle_count` (e.g., 8 cores → pool size 18); raise only when measured queue waits prove a larger pool helps. Most OLTP pools are <20 per app instance.
|
|
42
|
+
|
|
43
|
+
## PgBouncer Mode Matrix
|
|
44
|
+
|
|
45
|
+
| Feature | Session | Transaction | Statement |
|
|
46
|
+
|---|---|---|---|
|
|
47
|
+
| Prepared statements (server-side) | ✅ | ✅ (1.21+) / ❌ (pre-1.21) | ❌ |
|
|
48
|
+
| `SET` session variables | ✅ | ❌ (use `SET LOCAL`) | ❌ |
|
|
49
|
+
| `SET LOCAL` (transaction-scoped) | ✅ | ✅ | ❌ |
|
|
50
|
+
| Advisory locks | ✅ | ❌ | ❌ |
|
|
51
|
+
| `LISTEN` / `NOTIFY` | ✅ | ❌ | ❌ |
|
|
52
|
+
| `WITH HOLD` cursors | ✅ | ❌ | ❌ |
|
|
53
|
+
| Temporary tables across transactions | ✅ | ❌ | ❌ |
|
|
54
|
+
| Transactions | ✅ | ✅ | ❌ |
|
|
55
|
+
| Multiplexing benefit | 1x | High (10–100x) | Highest |
|
|
56
|
+
|
|
57
|
+
**Default rule:** Transaction mode for production scale; verify the application uses no session-spanning features (or, if it does, audit each one). Session mode when full Postgres feature surface is required.
|
|
58
|
+
|
|
59
|
+
## The Failure Modes Catalog
|
|
60
|
+
|
|
61
|
+
| Symptom | Likely cause | First diagnostic |
|
|
62
|
+
|---|---|---|
|
|
63
|
+
| `too many connections` error | Pool size × instances > `max_connections`; reconnect storm | Sum app pools + replica pools; check reconnect rate |
|
|
64
|
+
| Request latency spike, query latency normal | Pool exhaustion (queries holding connections too long) | `pool.acquire_time_p99` vs query latency |
|
|
65
|
+
| Intermittent "prepared statement does not exist" | PgBouncer transaction mode, pre-1.21 | Upgrade PgBouncer or disable server-side prepares |
|
|
66
|
+
| Random session-variable values | `SET` (not `SET LOCAL`) under transaction pooling | Audit `SET` use; switch to `SET LOCAL` |
|
|
67
|
+
| Connections held for hours; transaction-id age growing | Idle-in-transaction | `pg_stat_activity` for long `idle in transaction` |
|
|
68
|
+
| Brief outage during deploy | Reconnect storm | Stagger app startup; add reconnect backoff |
|
|
69
|
+
| Slow degradation over weeks | Long-tail connection age (memory bloat, stale prepared statements) | Enable `maxLifetime` rotation |
|
|
70
|
+
|
|
71
|
+
## Verification
|
|
72
|
+
|
|
73
|
+
After applying this skill, verify:
|
|
74
|
+
- [ ] Pool size has been calculated against Little's Law for the workload — not copied from advice columns. Peak concurrency × small headroom, not request rate.
|
|
75
|
+
- [ ] Sum of (app pool size × app instances) + replica pools + admin connections fits inside the database's `max_connections` with headroom. The database-side total is bounded, not just the per-instance pool.
|
|
76
|
+
- [ ] If PgBouncer transaction mode is enabled, the application's use of prepared statements, `SET`, advisory locks, `LISTEN/NOTIFY`, and WITH HOLD cursors has been audited. Compatible patterns confirmed; incompatible patterns refactored.
|
|
77
|
+
- [ ] Pool instrumentation is in place: `pool.acquire_time`, `pool.active`, `pool.waiting`. Connection contention shows up as a first-class signal, not as opaque application latency.
|
|
78
|
+
- [ ] `idle_in_transaction_session_timeout` is set (Postgres) so leaked transactions don't hold pool slots indefinitely. Application code does not perform external service calls inside database transactions.
|
|
79
|
+
- [ ] Connection rotation (`maxLifetime` / `server_lifetime`) is configured so connections refresh and don't accumulate long-tail bloat.
|
|
80
|
+
- [ ] Reconnect backoff and circuit-breaking are configured so deploy churn or brief network partitions don't produce reconnect storms.
|
|
81
|
+
- [ ] If serverless or auto-scaled application instances are used, a proxy pool (PgBouncer, Supavisor, RDS Proxy) caps the database-side connection total. Client count and server connection count are decoupled.
|
|
82
|
+
- [ ] Long-running queries (>1s) and short-running queries are not in the same pool. Pool partitioning prevents one class from starving the other.
|
|
83
|
+
|
|
84
|
+
## Do NOT Use When
|
|
85
|
+
|
|
86
|
+
| Instead of this skill | Use | Why |
|
|
87
|
+
|---|---|---|
|
|
88
|
+
| Tuning a slow query | `query-optimization` | query-optimization owns query-level cost; this owns connection-level cost |
|
|
89
|
+
| Designing indexes | `indexing-strategy` | indexing-strategy owns access-path design |
|
|
90
|
+
| Routing reads vs writes across replicas | `replication-patterns` | replication-patterns owns the routing layer above pooling |
|
|
91
|
+
| Partitioning data across shards | `sharding-strategy` | sharding-strategy owns the data-partition layer; pooling sits beneath it per shard |
|
|
92
|
+
| Choosing transaction isolation level | `transaction-isolation` | isolation owns the per-transaction concurrency contract |
|
|
93
|
+
| Designing the schema | `data-modeling` | data-modeling owns design; pooling is operational |
|
|
94
|
+
|
|
95
|
+
## Key Sources
|
|
96
|
+
|
|
97
|
+
- Brett Wooldridge. ["About Pool Sizing"](https://github.com/brettwooldridge/HikariCP/wiki/About-Pool-Sizing). HikariCP maintainer's canonical analysis; the source of the "small pools" doctrine. Cites Oracle Real-World Performance Group's empirical findings.
|
|
98
|
+
- Brett Wooldridge. ["HikariCP — Down the Rabbit Hole"](https://github.com/brettwooldridge/HikariCP/wiki/Down-the-Rabbit-Hole). Deep dive on connection pool implementation choices and overhead.
|
|
99
|
+
- PgBouncer Project. ["PgBouncer Documentation"](https://www.pgbouncer.org/usage.html). Reference for the three pooling modes and their feature compatibility. The 1.21 release notes document the prepared-statement support in transaction mode.
|
|
100
|
+
- PostgreSQL Global Development Group. ["PostgreSQL Documentation — Connection Pooling"](https://www.postgresql.org/docs/current/runtime-config-connection.html). Reference for `max_connections`, `idle_in_transaction_session_timeout`, and related configuration.
|
|
101
|
+
- Little, J. D. C. (1961). ["A Proof for the Queuing Formula: L = λW"](https://www.jstor.org/stable/167570). *Operations Research*, 9(3). The original Little's Law paper; basis for concurrency-based pool sizing.
|
|
102
|
+
- Kleppmann, M. (2017). *Designing Data-Intensive Applications*. O'Reilly. Discussion of database concurrency limits and their interaction with application architecture.
|
|
103
|
+
- Amazon Web Services. ["Amazon RDS Proxy"](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/rds-proxy.html). Managed proxy pool documentation; surfaces the serverless-vs-pool tension and the proxy's role.
|
|
104
|
+
- Supabase. ["Supavisor — Scalable Postgres Connection Pooler"](https://github.com/supabase/supavisor). Open-source proxy pool documentation; the recommended pooler for Neon and Supabase serverless workloads.
|
|
105
|
+
- Markus Winand. ["Performance — Open Source Database Pool Sizing"](https://use-the-index-luke.com/). Practitioner reference cross-cited from `indexing-strategy`; the chapter on operational concerns.
|