@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,190 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: server-components-design
|
|
3
|
+
description: "Use when designing or reviewing React Server Components: what an RSC can do (async, data fetching, server-only imports) versus what it cannot (state, effects, event handlers, browser APIs), where to draw the server/client boundary in the tree, and how RSC composes with Suspense to stream content without a separate API layer. Covers Next.js App Router as the canonical implementation, but the discipline is framework-agnostic. Do NOT use for the 'use client' directive mechanics (use client-server-boundary), hook discipline on Client Components (use hooks-patterns), rendering strategy choice (use rendering-models), or the server-action mutation surface (use server-actions-design when authored)."
|
|
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/frontend\",\"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\":\"[\\\\\\\"React Server Components\\\\\\\",\\\\\\\"RSC\\\\\\\",\\\\\\\"Next.js App Router\\\\\\\",\\\\\\\"async components\\\\\\\",\\\\\\\"server-side data fetching\\\\\\\",\\\\\\\"streaming RSC\\\\\\\",\\\\\\\"server/client component tree\\\\\\\",\\\\\\\"RSC payload\\\\\\\",\\\\\\\"Suspense boundaries with RSC\\\\\\\",\\\\\\\"data flow without API layer\\\\\\\"]\",\"triggers\":\"[\\\\\\\"should this be a Server Component or a Client Component\\\\\\\",\\\\\\\"can I fetch data here\\\\\\\",\\\\\\\"why can't I use useState in this file\\\\\\\",\\\\\\\"how does data move from server to client\\\\\\\",\\\\\\\"do I need an API route\\\\\\\",\\\\\\\"why is the bundle so large\\\\\\\"]\",\"examples\":\"[\\\\\\\"decide whether a dashboard widget should be a Server Component (fetches and renders) or a Client Component (interactive)\\\\\\\",\\\\\\\"explain why a Server Component cannot pass a function as a prop to a Client Component\\\\\\\",\\\\\\\"design a page where the layout fetches user data once and child widgets fetch their own data, with Suspense streaming each in\\\\\\\",\\\\\\\"audit a component tree for unnecessary 'use client' boundaries that pull static rendering into the bundle\\\\\\\"]\",\"anti_examples\":\"[\\\\\\\"add a click handler to an existing component (use hooks-patterns and client-server-boundary)\\\\\\\",\\\\\\\"choose between SSR and SSG for a marketing page (use rendering-models)\\\\\\\",\\\\\\\"build the form-submission mutation flow (use server-actions-design when authored)\\\\\\\",\\\\\\\"design the public API for a third-party integration (use api-design)\\\\\\\"]\",\"relations\":\"{\\\\\\\"related\\\\\\\":[\\\\\\\"client-server-boundary\\\\\\\",\\\\\\\"rendering-models\\\\\\\",\\\\\\\"hooks-patterns\\\\\\\",\\\\\\\"streaming-architecture\\\\\\\",\\\\\\\"suspense-patterns\\\\\\\"],\\\\\\\"boundary\\\\\\\":[{\\\\\\\"skill\\\\\\\":\\\\\\\"client-server-boundary\\\\\\\",\\\\\\\"reason\\\\\\\":\\\\\\\"client-server-boundary owns the serialization-and-directive mechanics of the boundary itself ('use client', what can cross, RSC payload format); server-components-design owns the discipline of which work belongs on the server side of that boundary.\\\\\\\"},{\\\\\\\"skill\\\\\\\":\\\\\\\"rendering-models\\\\\\\",\\\\\\\"reason\\\\\\\":\\\\\\\"rendering-models owns the strategic decision among SSR, SSG, ISR, and CSR; server-components-design operates within the App Router / RSC paradigm and is one rendering mode among several.\\\\\\\"},{\\\\\\\"skill\\\\\\\":\\\\\\\"hooks-patterns\\\\\\\",\\\\\\\"reason\\\\\\\":\\\\\\\"hooks-patterns covers state and effect discipline on Client Components; Server Components cannot use those primitives at all, so the two skills cover disjoint surfaces.\\\\\\\"}],\\\\\\\"verify_with\\\\\\\":[\\\\\\\"code-review\\\\\\\",\\\\\\\"rendering-models\\\\\\\"]}\",\"mental_model\":\"|\",\"purpose\":\"|\",\"boundary\":\"|\",\"analogy\":\"A Server Component is to a React tree what a printed page is to a book — the typesetter (server) sets the lead, presses the ink, and ships the printed page (RSC payload); the reader's table lamp (Client Component) is wired and switchable at the reader's end. You do not ship the typesetter to the reader's living room, and you do not ship the lamp's wiring to the printer — the boundary is where 'this never changes once it leaves my workshop' ends and 'this responds to who touches it' begins.\",\"misconception\":\"|\",\"concept\":\"{\\\\\\\"definition\\\\\\\":\\\\\\\"A React Server Component is a component that runs only on the server, never ships to the browser as JavaScript, can be async, and can directly access server-side resources (databases, file system, secrets) — its output is serialized to a wire format (the RSC payload) and reconstituted into the client tree without a separate API layer. Server Components compose with Client Components in a single tree, but the directionality is one-way: a Server Component can render a Client Component, but a Client Component cannot import a Server Component as a child.\\\\\\\",\\\\\\\"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/server-components-design/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/server-components-design/SKILL.md
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# Server Components Design
|
|
15
|
+
|
|
16
|
+
## Coverage
|
|
17
|
+
|
|
18
|
+
The discipline of designing React Server Components (RSC): what an RSC is *for*, what it can do that Client Components cannot, what it cannot do, how the server/client boundary shapes the component graph and the data-flow graph, how RSC composes with Suspense to stream content from the server in chunks, why Server Components remove the need for a separate API layer for read-path data, and the recurring design questions a reviewer asks of any RSC tree. Next.js App Router is the canonical implementation referenced throughout; the discipline applies to any RSC implementation (Remix RSC, Waku, hand-rolled RSC servers) since the underlying primitive is the React RFC, not a single framework.
|
|
19
|
+
|
|
20
|
+
## Philosophy
|
|
21
|
+
|
|
22
|
+
The original React component model collapsed two roles into one function: produce HTML for the initial render, and produce a virtual DOM update in response to client-side state. Server-Side Rendering pre-React-18 tried to make that single function run twice — once on the server to produce HTML, once on the client to produce the interactive tree — and pay for it with hydration: a full re-execution on the client to bind event handlers and reconstruct state.
|
|
23
|
+
|
|
24
|
+
Hydration has two costs the industry tolerated for a decade: every component must ship to the client (bundle size grows with the page), and every component re-runs on the client (CPU cost grows with the page). React Server Components separate the two roles into different *kinds* of component. A Server Component runs once, on the server, and produces a serialized output that the client uses directly — no shipping, no re-execution. A Client Component is what we used to call "a component": ships to the browser, runs on render and on every interaction.
|
|
25
|
+
|
|
26
|
+
The discipline of RSC design is to push as much of the tree as possible to the server side of the boundary, and to draw the line as close to the actual interactive leaves as possible. A button needs `useState`; the dashboard surrounding the button does not. A chart that responds to filter clicks is interactive; the page header above it is not. The win is real: bundle size shrinks toward "only the interactive parts," and the server has direct access to databases, file systems, and secrets without an intermediating API layer.
|
|
27
|
+
|
|
28
|
+
But the boundary is unforgiving. A Server Component cannot use hooks. It cannot read state. It cannot attach event handlers. Anything that crosses to a Client Component must be serializable — strings, numbers, plain objects, arrays, Promises (in React 19), JSX, and React elements; not functions, not class instances, not symbols, not Maps. The discipline is to express the work in shapes that respect that constraint, and to use Suspense boundaries to let the server-rendered tree stream piece by piece rather than blocking on the slowest piece.
|
|
29
|
+
|
|
30
|
+
## What a Server Component Can Do (And What a Client Component Cannot)
|
|
31
|
+
|
|
32
|
+
| Capability | Server Component | Client Component |
|
|
33
|
+
|---|---|---|
|
|
34
|
+
| `async` / `await` at the component level | Yes | No (React 18); promises must be unwrapped via `use()` (React 19) |
|
|
35
|
+
| Direct database queries, file reads, secret access | Yes | No — would leak to the browser |
|
|
36
|
+
| Read environment variables (including `PROCESS_SECRET`-style) | Yes | No — only `NEXT_PUBLIC_*` vars are safe |
|
|
37
|
+
| Import server-only libraries (Postgres driver, file system) | Yes | No — bundling would fail (or worse, succeed and leak) |
|
|
38
|
+
| Subscribe to browser events (`onClick`, `onChange`) | No | Yes |
|
|
39
|
+
| Manage state (`useState`, `useReducer`) | No | Yes |
|
|
40
|
+
| Side effects (`useEffect`) | No | Yes |
|
|
41
|
+
| Read browser APIs (`window`, `localStorage`) | No | Yes |
|
|
42
|
+
| Render Client Components as children | Yes — boundary crosses here | Yes |
|
|
43
|
+
| Be rendered *as a child* of a Client Component | Only via the `children` prop pattern | n/a |
|
|
44
|
+
|
|
45
|
+
The boundary is not just about what's available; it's about what makes sense. A Server Component that renders the same output regardless of any client state is doing the right thing. A Server Component that wants to know "what tab did the user click on" is asking the wrong primitive — that's Client Component territory.
|
|
46
|
+
|
|
47
|
+
## The Composition Pattern: Client at the Leaves, Server Everywhere Else
|
|
48
|
+
|
|
49
|
+
A naive boundary draws the line at the page level: "this page needs interactivity, so the whole page is a Client Component." This loses most of the RSC benefit.
|
|
50
|
+
|
|
51
|
+
A disciplined boundary draws the line at the *interactive leaves*: the button that toggles a dropdown is a Client Component; the dropdown's structure, the surrounding layout, the data feeding it — all Server Components.
|
|
52
|
+
|
|
53
|
+
The enabling pattern is **passing Server Components as `children` to Client Components**:
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
// app/dashboard/page.tsx — Server Component
|
|
57
|
+
import { ServerData } from './ServerData'
|
|
58
|
+
import { ClientFilterBar } from './ClientFilterBar'
|
|
59
|
+
|
|
60
|
+
export default async function Dashboard() {
|
|
61
|
+
const data = await db.getDashboardData()
|
|
62
|
+
return (
|
|
63
|
+
<ClientFilterBar>
|
|
64
|
+
<ServerData data={data} />
|
|
65
|
+
</ClientFilterBar>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// ClientFilterBar.tsx — Client Component with state
|
|
70
|
+
'use client'
|
|
71
|
+
import { useState } from 'react'
|
|
72
|
+
|
|
73
|
+
export function ClientFilterBar({ children }: { children: React.ReactNode }) {
|
|
74
|
+
const [filter, setFilter] = useState('all')
|
|
75
|
+
return (
|
|
76
|
+
<div>
|
|
77
|
+
<select onChange={e => setFilter(e.target.value)}>...</select>
|
|
78
|
+
{children} {/* Server Component renders here */}
|
|
79
|
+
</div>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
The `children` prop is *content*, not *components-to-import*. The Client Component receives the already-rendered React element from the server tree. This is the only way to put a Server Component "inside" a Client Component visually without violating the import rule.
|
|
85
|
+
|
|
86
|
+
## The Import Rule and Why It Matters
|
|
87
|
+
|
|
88
|
+
A Client Component cannot `import` a Server Component. Not "should not" — *cannot*, because the bundler running on the client would have to bundle the Server Component, and Server Components are not allowed to ship.
|
|
89
|
+
|
|
90
|
+
But a Server Component *can* `import` a Client Component. The Client Component file is marked `'use client'` at its top, the bundler treats it as a client-bundle entry point, and the Server Component renders a reference to it (in the RSC payload) that the client runtime resolves to the bundled component.
|
|
91
|
+
|
|
92
|
+
The directionality matters for tree design:
|
|
93
|
+
|
|
94
|
+
- Top-down: Server → Server → Server → Client → (only more Client below this point).
|
|
95
|
+
- Pierce-through via children: Server → Client → (children prop receives) → Server → Server.
|
|
96
|
+
|
|
97
|
+
A tree that follows the first pattern naturally pushes work to the server. A tree that violates it (a Client Component near the root that needs to render a Server Component as a non-children child) cannot be expressed; you'll be forced to restructure.
|
|
98
|
+
|
|
99
|
+
## Data Flow Without an API Layer
|
|
100
|
+
|
|
101
|
+
The classic React data-fetching pattern:
|
|
102
|
+
|
|
103
|
+
1. Browser requests page → SSR returns HTML
|
|
104
|
+
2. Browser hydrates page
|
|
105
|
+
3. Client Component mounts, runs `useEffect`, calls `/api/data`
|
|
106
|
+
4. API route handler runs, queries database, returns JSON
|
|
107
|
+
5. Component re-renders with data
|
|
108
|
+
|
|
109
|
+
RSC collapses steps 1–5 to:
|
|
110
|
+
|
|
111
|
+
1. Browser requests page → Server Component runs, queries database directly, returns RSC payload (with data already baked in)
|
|
112
|
+
|
|
113
|
+
The `/api/data` route does not need to exist. The Server Component reaches into the database, passes the result to a child component as a prop, and the prop arrives at the client *as the rendered output* — serialized in the RSC payload, never round-tripped through a JSON API.
|
|
114
|
+
|
|
115
|
+
When does an API route still make sense? When something *outside* this app needs to read the data: a mobile app, a third-party integration, a server-to-server call. The API layer is no longer the only way to get data into the page; it's only what you need when there are multiple consumers.
|
|
116
|
+
|
|
117
|
+
## Suspense and Streaming RSC
|
|
118
|
+
|
|
119
|
+
A Server Component that awaits a slow query blocks the entire HTML response. Suspense unblocks the pattern: wrap the slow component in `<Suspense fallback={...}>` and the server flushes the surrounding tree immediately, then streams in the slow component's output when it resolves.
|
|
120
|
+
|
|
121
|
+
```tsx
|
|
122
|
+
// app/dashboard/page.tsx — Server Component
|
|
123
|
+
export default async function Dashboard() {
|
|
124
|
+
return (
|
|
125
|
+
<>
|
|
126
|
+
<Header />
|
|
127
|
+
<Suspense fallback={<SkeletonChart />}>
|
|
128
|
+
<SlowChartData /> {/* awaits a 2-second query */}
|
|
129
|
+
</Suspense>
|
|
130
|
+
<Suspense fallback={<SkeletonTable />}>
|
|
131
|
+
<SlowTableData /> {/* awaits a 1.5-second query */}
|
|
132
|
+
</Suspense>
|
|
133
|
+
</>
|
|
134
|
+
)
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Both `SlowChartData` and `SlowTableData` start their queries in parallel (the Server Component renders both subtrees, and each `await` is a Promise that the renderer holds open). The chart and table fallback HTML ships immediately; the actual content streams in as each query resolves. Time-to-first-byte is bounded by the fastest non-Suspended path; time-to-interactive of each section is bounded by that section's own query.
|
|
139
|
+
|
|
140
|
+
Two design rules:
|
|
141
|
+
|
|
142
|
+
1. **Co-locate the Suspense boundary with the slow data, not above it.** A boundary too high makes more of the page wait; a boundary too low produces visible layout shift as content pops in.
|
|
143
|
+
2. **Trigger parallel data fetches at the same level.** If two queries don't depend on each other, render their components as siblings (not parent/child) so their awaits happen in parallel.
|
|
144
|
+
|
|
145
|
+
See `suspense-patterns` (when authored) for the wider Suspense discipline including error boundaries, nested fallbacks, and the relationship to React's transition APIs.
|
|
146
|
+
|
|
147
|
+
## Common Anti-Patterns
|
|
148
|
+
|
|
149
|
+
| Anti-pattern | Why it's wrong | Fix |
|
|
150
|
+
|---|---|---|
|
|
151
|
+
| Whole page marked `'use client'` to use one button | Loses all RSC benefit; ships entire page as client bundle | Move `'use client'` to the leaf component that actually needs it |
|
|
152
|
+
| `useEffect` to fetch data on mount | Hydration delay + double-fetch + lost streaming | Fetch in a Server Component ancestor and pass data as prop |
|
|
153
|
+
| Importing a Client Component that wraps `children` and trying to put a Server Component import inside | Bundler treats the Server Component as client code | Pass the Server Component as `children` from a Server Component parent |
|
|
154
|
+
| `await fetch('/api/data')` in a Server Component | Spending a round-trip for data you could query directly | Query the database directly; the API route is now redundant |
|
|
155
|
+
| Passing a function (`onClick`) from Server Component to Client Component | Not serializable across the boundary | Define the handler in the Client Component, pass primitive props instead |
|
|
156
|
+
| Reading `window` or `document` in a Server Component | Will crash at render time | Move browser-API code to a Client Component or to a `useEffect` |
|
|
157
|
+
| One giant Suspense boundary at the page root | All slow content blocks together — no streaming benefit | Place boundaries near the slow data, one per independent slow section |
|
|
158
|
+
|
|
159
|
+
## Verification
|
|
160
|
+
|
|
161
|
+
After applying this skill, verify:
|
|
162
|
+
|
|
163
|
+
- [ ] `'use client'` appears at the leaf where interactivity actually starts, not higher in the tree.
|
|
164
|
+
- [ ] No Server Component imports a Client Component's internals; the Client Component imports from `'use client'`-marked files only at its top level.
|
|
165
|
+
- [ ] No serialization-breaking values cross the boundary (no functions, no class instances, no Maps/Sets unless explicitly supported).
|
|
166
|
+
- [ ] Slow data fetches are wrapped in Suspense boundaries co-located with the data.
|
|
167
|
+
- [ ] No `useEffect` fetches for data that could be fetched server-side.
|
|
168
|
+
- [ ] Server Components do not call hooks, do not attach event handlers, and do not read browser APIs.
|
|
169
|
+
- [ ] Client Components do not import server-only libraries (DB drivers, file system modules, secret-reading helpers).
|
|
170
|
+
- [ ] The component tree expresses the actual interactivity boundary; rebuild it if a Client Component is forced to wrap Server Components it should be a sibling of.
|
|
171
|
+
|
|
172
|
+
## Grounding Sources
|
|
173
|
+
|
|
174
|
+
- React RFC — [Server Components RFC](https://github.com/reactjs/rfcs/blob/main/text/0188-server-components.md). The original proposal and the formal model.
|
|
175
|
+
- React docs — [Server Components](https://react.dev/reference/rsc/server-components). Official reference for the runtime contract.
|
|
176
|
+
- React docs — [`'use client'`](https://react.dev/reference/rsc/use-client) and [`'use server'`](https://react.dev/reference/rsc/use-server). The directive semantics.
|
|
177
|
+
- Next.js docs — [Server and Client Components](https://nextjs.org/docs/app/building-your-application/rendering/server-components) and [Composition Patterns](https://nextjs.org/docs/app/building-your-application/rendering/composition-patterns). The canonical working implementation.
|
|
178
|
+
- Vercel — [How React Server Components Work](https://vercel.com/blog/understanding-react-server-components). Walk-through of the RSC payload and rendering pipeline.
|
|
179
|
+
- Markbåge, S. et al. — [Introducing Zero-Bundle-Size React Server Components](https://legacy.reactjs.org/blog/2020/12/21/data-fetching-with-react-server-components.html). The first public introduction; useful for the design rationale.
|
|
180
|
+
- Akinmade Adeleke, A. — [The Forensics of React Server Components](https://www.smashingmagazine.com/2024/05/forensics-react-server-components/). Deep dive on the RSC payload format and tree reconstruction.
|
|
181
|
+
|
|
182
|
+
## Do NOT Use When
|
|
183
|
+
|
|
184
|
+
| Instead of this skill | Use | Why |
|
|
185
|
+
|---|---|---|
|
|
186
|
+
| The mechanics of the `'use client'` / `'use server'` directive boundary itself (serialization rules, what crosses, RSC payload format) | `client-server-boundary` | client-server-boundary owns the boundary as a serialization mechanism; this skill owns the *design discipline* of where to draw the boundary in your component graph. |
|
|
187
|
+
| Hook discipline on the Client Component side (Rules of Hooks, useEffect, useMemo) | `hooks-patterns` | hooks-patterns covers what Client Components do correctly. Server Components cannot use hooks at all. |
|
|
188
|
+
| Choosing between SSR, SSG, ISR, and CSR rendering strategies | `rendering-models` | rendering-models owns the strategic rendering choice. RSC is one rendering mode among several. |
|
|
189
|
+
| Designing the Server Actions / form-mutation surface | `server-actions-design` (when authored) | Server Actions are the *write* path; Server Components are the *read* path. They share infrastructure but have distinct design concerns. |
|
|
190
|
+
| Streaming patterns broader than RSC (HTTP/2 push, SSE, WebSockets, AI streaming) | `streaming-architecture` | streaming-architecture covers streaming as a general protocol concern. RSC streaming is one application of that toolkit. |
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sharding-strategy
|
|
3
|
+
description: "Use when reasoning about horizontal partitioning of data across nodes for storage capacity and write throughput beyond a single node: the three foundational partitioning schemes (range, hash, directory/lookup), the shard-key choice that determines whether the system scales or hotspots, the resharding problem and how consistent hashing addresses it, cross-shard queries and the joins-and-transactions trade-off, the relationship to replication (sharding partitions data; replication copies each shard), and the failure modes (hot shard, skewed distribution, cross-shard transactions, range-end overload). Do NOT use for replicating the same data across nodes (use replication-patterns), the CAP/PACELC frame (use cap-theorem-tradeoffs), single-node performance tuning (use query-optimization), or indexing within a shard (use indexing-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\":\"[\\\\\\\"sharding\\\\\\\",\\\\\\\"partitioning\\\\\\\",\\\\\\\"horizontal partitioning\\\\\\\",\\\\\\\"shard key\\\\\\\",\\\\\\\"hash partitioning\\\\\\\",\\\\\\\"range partitioning\\\\\\\",\\\\\\\"consistent hashing\\\\\\\",\\\\\\\"hot shard\\\\\\\",\\\\\\\"resharding\\\\\\\",\\\\\\\"cross-shard query\\\\\\\"]\",\"triggers\":\"[\\\\\\\"how should we shard\\\\\\\",\\\\\\\"what's the right shard key\\\\\\\",\\\\\\\"hot shard\\\\\\\",\\\\\\\"cross-shard transaction\\\\\\\",\\\\\\\"consistent hashing\\\\\\\"]\",\"examples\":\"[\\\\\\\"choose a shard key for a multi-tenant system where 90% of queries are tenant-scoped\\\\\\\",\\\\\\\"diagnose a hot shard caused by skewed shard-key distribution\\\\\\\",\\\\\\\"design the resharding strategy when adding nodes to a hash-sharded cluster\\\\\\\",\\\\\\\"decide whether to accept cross-shard JOIN complexity or denormalize\\\\\\\"]\",\"anti_examples\":\"[\\\\\\\"design replication topology for the same data (use replication-patterns)\\\\\\\",\\\\\\\"tune a single slow query (use query-optimization)\\\\\\\",\\\\\\\"design indexes within one shard (use indexing-strategy)\\\\\\\"]\",\"relations\":\"{\\\\\\\"related\\\\\\\":[\\\\\\\"replication-patterns\\\\\\\",\\\\\\\"cap-theorem-tradeoffs\\\\\\\",\\\\\\\"indexing-strategy\\\\\\\",\\\\\\\"data-modeling\\\\\\\"],\\\\\\\"boundary\\\\\\\":[{\\\\\\\"skill\\\\\\\":\\\\\\\"replication-patterns\\\\\\\",\\\\\\\"reason\\\\\\\":\\\\\\\"replication-patterns owns copying the same data across nodes; this skill owns splitting different data across nodes. The two compose: a sharded system can replicate each shard. They answer different questions.\\\\\\\"},{\\\\\\\"skill\\\\\\\":\\\\\\\"cap-theorem-tradeoffs\\\\\\\",\\\\\\\"reason\\\\\\\":\\\\\\\"cap-theorem-tradeoffs owns the theoretical consistency-availability frame; this skill owns the operational partitioning that often interacts with it (cross-shard transactions have stronger consistency requirements than single-shard ones).\\\\\\\"},{\\\\\\\"skill\\\\\\\":\\\\\\\"indexing-strategy\\\\\\\",\\\\\\\"reason\\\\\\\":\\\\\\\"indexing-strategy owns within-node retrieval; this skill owns how data is divided across nodes. Indexes within a shard are designed normally; cross-shard secondary indexes are a separate, harder problem.\\\\\\\"},{\\\\\\\"skill\\\\\\\":\\\\\\\"data-modeling\\\\\\\",\\\\\\\"reason\\\\\\\":\\\\\\\"data-modeling owns schema and access-pattern design; this skill owns the partitioning of that schema across nodes. The shard key is a schema design decision with operational consequences.\\\\\\\"}],\\\\\\\"verify_with\\\\\\\":[\\\\\\\"replication-patterns\\\\\\\",\\\\\\\"data-modeling\\\\\\\"]}\",\"mental_model\":\"|\",\"purpose\":\"|\",\"boundary\":\"|\",\"analogy\":\"Sharding is to a database what tenant-based building partitioning is to a multinational corporation — replicating each office to multiple cities is fault tolerance (replication); putting *Sales* in Building A and *Engineering* in Building B *because they do not talk to each other* is sharding. The shard key is the rule that decides who goes in which building, and the most catastrophic operational outcome is choosing a rule that puts everyone in Building A on Monday morning and Building B on Tuesday morning — the hot shard, where the structure was right but the routing rule was wrong.\",\"misconception\":\"|\",\"concept\":\"{\\\\\\\"definition\\\\\\\":\\\\\\\"Sharding (horizontal partitioning) is the discipline of dividing a database's data across multiple nodes such that each node holds a subset (a shard) of the data. The unit of judgment is the *shard key*: the column or columns the system uses to route each row to a specific shard. Three foundational schemes exist — **range partitioning** (rows with shard-key values in a contiguous range go to the same shard), **hash partitioning** (the shard-key value is hashed; the hash determines the shard), and **directory / lookup partitioning** (an explicit map records which shard owns each key or key-range). Each scheme has its own access-pattern fit, resharding complexity, and hot-shard risk profile. The strategic discipline of sharding is choosing the shard key and scheme such that (a) the per-shard load is balanced, (b) common queries can be answered by a single shard (no cross-shard scatter-gather), and (c) the system can be resharded (add nodes, rebalance data) without unacceptable downtime.\\\\\\\",\\\\\\\"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/sharding-strategy/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/sharding-strategy/SKILL.md
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# Sharding Strategy
|
|
15
|
+
|
|
16
|
+
## Coverage
|
|
17
|
+
|
|
18
|
+
The discipline of dividing a database's data across multiple nodes through horizontal partitioning. Covers the three foundational partitioning schemes (range, hash, directory), consistent hashing as the refinement that solves the resharding problem, the shard-key choice as the most consequential design decision, the cross-shard query and transaction trade-offs, the catalog of failure modes (hot shard, skewed distribution, range-boundary overload), the relationship to replication (sharding divides; replication copies; they compose), and the rule that sharding is one of the last optimizations to reach for after replication, caching, and denormalization.
|
|
19
|
+
|
|
20
|
+
## Philosophy
|
|
21
|
+
|
|
22
|
+
Sharding is the scaling tool of last resort. Replication scales reads; caching reduces load; denormalization eliminates joins; vertical scaling adds capacity. When write throughput, storage capacity, or geographic data placement exceeds what those tools provide, sharding becomes the answer.
|
|
23
|
+
|
|
24
|
+
The shard key is the most consequential design decision. It determines which queries are fast (single-shard) and which are slow (scatter-gather), which operations are atomic (single-shard) and which require distributed commit (cross-shard), which growth patterns hotspot and which balance. A team that chooses the shard key well gains nearly linear scaling; a team that chooses it poorly pays operational complexity without capacity gain.
|
|
25
|
+
|
|
26
|
+
The schema must be designed with sharding in mind from the start, or significant refactoring is required when sharding is later introduced. Queries must filter on the shard key; related data must be co-located on the same shard; cross-shard operations must be rare or accepted as slow. Sharding is a schema architecture, not just an operational technique.
|
|
27
|
+
|
|
28
|
+
## The Three Partitioning Schemes
|
|
29
|
+
|
|
30
|
+
| Scheme | How it routes | Strong for | Weak for |
|
|
31
|
+
|---|---|---|---|
|
|
32
|
+
| Range | Contiguous key ranges per shard | Range queries (`BETWEEN x AND y`) | Hotspots at range boundaries; resharding by split |
|
|
33
|
+
| Hash | Hash(key) % N | Even balance; no range hotspots | Range queries become scatter-gather; resharding rehashes |
|
|
34
|
+
| Consistent hashing | Hash ring; key → nearest clockwise shard | Adding shards moves only 1/N of data | Range queries still scatter-gather |
|
|
35
|
+
| Directory | Explicit map per key | Flexibility; arbitrary routing | The directory itself becomes a bottleneck |
|
|
36
|
+
|
|
37
|
+
Hash with consistent hashing is the default for most large-scale systems; range partitioning is used for time-series and naturally-ordered data; directory is rare but useful for arbitrary placement.
|
|
38
|
+
|
|
39
|
+
## The Shard-Key Selection Rules
|
|
40
|
+
|
|
41
|
+
A good shard key:
|
|
42
|
+
|
|
43
|
+
1. **Appears in nearly every query's WHERE clause** — for shard-locality.
|
|
44
|
+
2. **Distributes data evenly** — high cardinality; no value dominates traffic.
|
|
45
|
+
3. **Is immutable for a row** — moving a row between shards is expensive.
|
|
46
|
+
4. **Has predictable growth** — won't shift hotspots over time.
|
|
47
|
+
5. **Matches the natural grain of operations** — common transactions are single-shard.
|
|
48
|
+
|
|
49
|
+
Common keys:
|
|
50
|
+
- **Multi-tenant SaaS**: `tenant_id`. Most queries are tenant-scoped; tenants are independent.
|
|
51
|
+
- **Per-user data**: `user_id`. Most queries are user-scoped.
|
|
52
|
+
- **Time-series**: `time_bucket(timestamp)`. Recent shards hot; older shards cold (often acceptable for time-series).
|
|
53
|
+
- **Geographic**: `region`. Latency benefit; regulatory benefit.
|
|
54
|
+
|
|
55
|
+
Bad keys:
|
|
56
|
+
- `created_at` (range hotspot at latest range).
|
|
57
|
+
- `status` (low cardinality; one value dominates).
|
|
58
|
+
- A column not in most query WHERE clauses (scatter-gather every query).
|
|
59
|
+
|
|
60
|
+
## Cross-Shard Query Trade-offs
|
|
61
|
+
|
|
62
|
+
| Operation | Single-shard | Cross-shard |
|
|
63
|
+
|---|---|---|
|
|
64
|
+
| Lookup by shard key | Fast | n/a (must include shard key) |
|
|
65
|
+
| Lookup not using shard key | Single-shard if data co-located | Scatter to every shard |
|
|
66
|
+
| JOIN | Fast within shard | Slow or unavailable |
|
|
67
|
+
| Aggregation | Fast | Scatter-gather; partial-aggregate-then-combine |
|
|
68
|
+
| Transaction | ACID via single-shard primary | Two-phase commit or distributed consensus; slow and failure-prone |
|
|
69
|
+
|
|
70
|
+
Schema design under sharding co-locates related data (store user's orders on user's shard) to make JOINs and transactions single-shard.
|
|
71
|
+
|
|
72
|
+
## When Sharding Is The Right Tool
|
|
73
|
+
|
|
74
|
+
| Workload property | Tool |
|
|
75
|
+
|---|---|
|
|
76
|
+
| Read load too high | Replication (read replicas) |
|
|
77
|
+
| Cache hit rate possible | Caching layer |
|
|
78
|
+
| Joins / aggregations slow | Denormalization, materialized views |
|
|
79
|
+
| Single-node CPU/memory exceeded | Vertical scaling |
|
|
80
|
+
| Storage approaching node limit | Sharding (or larger disks first) |
|
|
81
|
+
| Write throughput exceeds primary | Sharding |
|
|
82
|
+
| Geographic latency required | Sharding by region (with replication within region) |
|
|
83
|
+
| Multi-tenant isolation required | Sharding by tenant |
|
|
84
|
+
|
|
85
|
+
Sharding is the answer when write throughput or storage exceeds single-node capacity. Before that, simpler tools suffice.
|
|
86
|
+
|
|
87
|
+
## Verification
|
|
88
|
+
|
|
89
|
+
After applying this skill, verify:
|
|
90
|
+
- [ ] Sharding is being considered after replication, caching, denormalization, and vertical scaling — not as a first response.
|
|
91
|
+
- [ ] The shard key is chosen against the criteria: appears in queries, distributes evenly, immutable, predictable, matches operation grain.
|
|
92
|
+
- [ ] Most production queries are single-shard. Scatter-gather queries are recognized as expensive and made rare.
|
|
93
|
+
- [ ] Related data is co-located on the same shard for JOIN and transaction locality.
|
|
94
|
+
- [ ] Cross-shard transactions are rare. Application design avoids them where possible.
|
|
95
|
+
- [ ] Resharding plan exists before launch: how shards are added, how data moves, what downtime is expected.
|
|
96
|
+
- [ ] Hot-shard detection is in place. Per-shard load metrics surface hotspots before they become incidents.
|
|
97
|
+
- [ ] Consistent hashing is used over modulo hash where resharding is anticipated. Naive hash modulo locks the shard count.
|
|
98
|
+
- [ ] The cross-shard query cost is documented and accepted. Reports and analytics that scatter-gather are run on read replicas or designed for the cost.
|
|
99
|
+
- [ ] Sharding interacts with replication intentionally — each shard's replication strategy is designed, not defaulted.
|
|
100
|
+
|
|
101
|
+
## Do NOT Use When
|
|
102
|
+
|
|
103
|
+
| Instead of this skill | Use | Why |
|
|
104
|
+
|---|---|---|
|
|
105
|
+
| Copying the same data to multiple nodes | `replication-patterns` | replication copies; sharding partitions |
|
|
106
|
+
| The CAP / PACELC theoretical frame | `cap-theorem-tradeoffs` | CAP names the trade-off |
|
|
107
|
+
| Tuning a slow query | `query-optimization` | query-optimization is single-query |
|
|
108
|
+
| Designing indexes within a shard | `indexing-strategy` | indexing is within-node |
|
|
109
|
+
| Designing schema | `data-modeling` | data-modeling is the schema design; this is the partitioning of the schema |
|
|
110
|
+
| Single-node transactional behavior | `acid-fundamentals` | ACID is the single-system frame |
|
|
111
|
+
|
|
112
|
+
## Key Sources
|
|
113
|
+
|
|
114
|
+
- Karger, D., Lehman, E., Leighton, T., Panigrahy, R., Levine, M., & Lewin, D. (1997). ["Consistent Hashing and Random Trees: Distributed Caching Protocols for Relieving Hot Spots on the World Wide Web"](https://dl.acm.org/doi/10.1145/258533.258660). *STOC 1997*. The foundational paper on consistent hashing.
|
|
115
|
+
- DeCandia, G., Hastorun, D., Jampani, M., et al. (2007). ["Dynamo: Amazon's Highly Available Key-Value Store"](https://www.allthingsdistributed.com/files/amazon-dynamo-sosp2007.pdf). *SOSP 2007*. Industrial application of consistent hashing in sharded systems; basis of Cassandra and DynamoDB.
|
|
116
|
+
- Chang, F., Dean, J., Ghemawat, S., et al. (2006). ["Bigtable: A Distributed Storage System for Structured Data"](https://research.google/pubs/pub27898/). *OSDI 2006*. Google's range-partitioning-based sharded store; basis of HBase and many others.
|
|
117
|
+
- Corbett, J. C., Dean, J., Epstein, M., et al. (2012). ["Spanner: Google's Globally-Distributed Database"](https://research.google/pubs/pub39966/). *OSDI 2012*. Modern globally-distributed database with automatic sharding and consensus-based cross-shard transactions.
|
|
118
|
+
- Kleppmann, M. (2017). *Designing Data-Intensive Applications*. O'Reilly. Chapter 6 (Partitioning) — modern comprehensive treatment of all three schemes.
|
|
119
|
+
- MongoDB Manual. ["Sharding"](https://www.mongodb.com/docs/manual/sharding/). Reference for MongoDB's sharded cluster architecture.
|
|
120
|
+
- Citus Data. ["Citus Documentation — Distributed Tables"](https://docs.citusdata.com/en/stable/sharding/data_modeling.html). Reference for Postgres + Citus distributed sharding.
|
|
121
|
+
- Vitess. ["Vitess Documentation — Sharding"](https://vitess.io/docs/user-guides/configuration-basic/sharding/). Reference for Vitess's MySQL-based sharded architecture (YouTube, Slack, others).
|
|
122
|
+
- Lakshman, A., & Malik, P. (2010). ["Cassandra: a decentralized structured storage system"](https://www.cs.cornell.edu/projects/ladis2009/papers/lakshman-ladis2009.pdf). The Cassandra paper; consistent-hashing-based leaderless sharded store.
|
|
123
|
+
- Sadalage, P. J., & Fowler, M. (2012). *NoSQL Distilled*. Addison-Wesley. Practitioner reference covering sharding patterns across NoSQL system types.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: shopify
|
|
3
|
+
description: "Use when working with Shopify — Admin API, Storefront API, OAuth scopes, HMAC SHA-256 webhook verification, GraphQL query-cost handling, Online Store 2.0 themes (sections, blocks, Liquid), metafields and metaobjects, and App Proxy. Do NOT use for generic e-commerce design, non-Shopify storefronts, or internal event-contract design."
|
|
4
|
+
license: CC-BY-4.0
|
|
5
|
+
metadata:
|
|
6
|
+
metadata: "{\"schema_version\":6,\"version\":\"1.0.0\",\"type\":\"capability\",\"category\":\"engineering\",\"domain\":\"engineering/integrations\",\"scope\":\"portable\",\"owner\":\"skill-graph-maintainer\",\"freshness\":\"2026-05-12\",\"drift_check\":\"{\\\\\\\"last_verified\\\\\\\":\\\\\\\"2026-05-12\\\\\\\"}\",\"eval_artifacts\":\"planned\",\"eval_state\":\"unverified\",\"routing_eval\":\"absent\",\"stability\":\"experimental\",\"keywords\":\"[\\\\\\\"shopify admin api\\\\\\\",\\\\\\\"shopify storefront api\\\\\\\",\\\\\\\"shopify webhooks\\\\\\\",\\\\\\\"shopify oauth scopes\\\\\\\",\\\\\\\"shopify hmac verification\\\\\\\",\\\\\\\"online store 2.0 sections\\\\\\\",\\\\\\\"liquid templates\\\\\\\",\\\\\\\"shopify graphql query cost\\\\\\\",\\\\\\\"shopify metafields\\\\\\\",\\\\\\\"shopify rate limits\\\\\\\",\\\\\\\"shopify app proxy\\\\\\\"]\",\"triggers\":\"[\\\\\\\"shopify\\\\\\\",\\\\\\\"shopify webhook\\\\\\\",\\\\\\\"shopify api\\\\\\\",\\\\\\\"shopify theme\\\\\\\",\\\\\\\"shopify app\\\\\\\"]\",\"examples\":\"[\\\\\\\"Verify an incoming Shopify webhook by computing HMAC SHA-256 over the raw body and comparing against the X-Shopify-Hmac-Sha256 header\\\\\\\",\\\\\\\"Query the Shopify Admin GraphQL API for product variants with their metafields and handle query cost throttling\\\\\\\",\\\\\\\"Build an Online Store 2.0 section schema with block types and dynamic settings\\\\\\\"]\",\"anti_examples\":\"[\\\\\\\"Design the event payload schema for our internal order-processing pipeline\\\\\\\",\\\\\\\"Implement Stripe Connect onboarding for a marketplace\\\\\\\",\\\\\\\"Refactor a generic shopping cart component that isn't Shopify-specific\\\\\\\"]\",\"relations\":\"{\\\\\\\"related\\\\\\\":[\\\\\\\"webhook-integration\\\\\\\",\\\\\\\"api-design\\\\\\\",\\\\\\\"printify\\\\\\\"],\\\\\\\"boundary\\\\\\\":[{\\\\\\\"skill\\\\\\\":\\\\\\\"webhook-integration\\\\\\\",\\\\\\\"reason\\\\\\\":\\\\\\\"webhook-integration covers vendor-agnostic delivery, retries, and signing; this skill handles Shopify's specific topic names, X-Shopify-* header contract, and the 5-second response deadline before retry.\\\\\\\"},{\\\\\\\"skill\\\\\\\":\\\\\\\"event-contract-design\\\\\\\",\\\\\\\"reason\\\\\\\":\\\\\\\"Hand off to event-contract-design when modeling internal events downstream of Shopify webhooks — the contract surface there is your own system, not Shopify's.\\\\\\\"}]}\",\"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/shopify/SKILL.md\"}"
|
|
7
|
+
skill_graph_source_repo: "https://github.com/jacob-balslev/skill-graph"
|
|
8
|
+
skill_graph_protocol: Skill Metadata Protocol v4
|
|
9
|
+
skill_graph_project: Skill Graph
|
|
10
|
+
skill_graph_canonical_skill: skills/shopify/SKILL.md
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Shopify
|
|
14
|
+
|
|
15
|
+
## Coverage
|
|
16
|
+
Shopify exposes four primary integration surfaces: the Admin API (REST and GraphQL, used by apps acting on the merchant's behalf), the Storefront API (GraphQL, customer-facing, unauthenticated by default with a public access token), themes (Liquid templating plus Online Store 2.0 JSON templates with sections and blocks), and webhooks (signed event delivery over HTTPS). Each surface has distinct authentication, rate-limit, and versioning rules. This skill covers all four and the seams between them.
|
|
17
|
+
|
|
18
|
+
Authentication for public apps follows OAuth 2.0 authorization code flow: the merchant approves a comma-separated scope list (read_products, write_orders, etc.), the app receives a permanent offline access token, and that token is sent as the X-Shopify-Access-Token header. Webhooks are verified by computing HMAC SHA-256 over the raw request body using the app's API secret key (for app-managed webhooks) or the shop's webhook signature key (for shop-managed webhooks) and base64-comparing against the X-Shopify-Hmac-Sha256 header. The webhook handler must respond with 2xx within five seconds or Shopify retries with exponential backoff for up to 48 hours before disabling the subscription.
|
|
19
|
+
|
|
20
|
+
Rate limits differ per surface. REST Admin API uses a leaky-bucket model — 40 requests with a 2/sec leak rate on standard plans, 80/4 on Shopify Plus. GraphQL Admin API uses a query-cost model: each request is scored before execution (1000-point bucket, 50/sec leak), and the response includes extensions.cost with actualQueryCost and throttleStatus so the client can pace itself. The Storefront API has separate, more generous limits. Online Store 2.0 themes organize content into sections (reusable, merchant-configurable blocks defined in JSON schema) and templates (JSON files referencing sections), replacing the older static Liquid-include model.
|
|
21
|
+
|
|
22
|
+
Metafields and metaobjects extend native resources with typed custom data. Metafields attach to a parent resource (product, variant, customer, order, etc.) with a namespace.key path and a defined type (single_line_text_field, number_integer, json, file_reference, metaobject_reference, etc.). Metaobjects are standalone typed records and are queryable via GraphQL like first-class resources. App Proxy routes a path on the merchant's storefront domain to the app's backend with a signed query string, enabling authenticated storefront experiences without CORS.
|
|
23
|
+
|
|
24
|
+
## Philosophy
|
|
25
|
+
Shopify's APIs are explicit about cost and explicit about contract. The query-cost model, the HMAC requirement, the five-second webhook deadline, and the API versioning calendar (one stable version per quarter, four supported simultaneously) all push toward integrations that observe their own load and respond to drift rather than assume forever-availability. Treat each surface's contract as load-bearing: don't catch HMAC failures and proceed, don't skip query-cost inspection, don't pin to a soon-to-be-unsupported API version.
|
|
26
|
+
|
|
27
|
+
The theme surface and the API surface should remain separable. Online Store 2.0 lets merchants customize themes without code; an app that imposes UI through Liquid edits will conflict with merchant theme updates and theme-store apps. Prefer App Blocks and App Embeds (theme app extensions) over Liquid injection wherever the integration needs to render storefront UI.
|
|
28
|
+
|
|
29
|
+
## Verification
|
|
30
|
+
- The webhook handler computes HMAC SHA-256 over the raw, undecoded request body — not the parsed JSON — and uses a constant-time comparison against the header value.
|
|
31
|
+
- OAuth scopes requested match scopes actually used. Audit by listing every API endpoint called and confirming the minimum scope per the Shopify REST Admin API reference.
|
|
32
|
+
- GraphQL Admin clients read extensions.cost.throttleStatus on every response and back off when currentlyAvailable drops below the next expected query cost.
|
|
33
|
+
- The integration declares a target API version (e.g., 2026-01) and a planned upgrade path; calls without an explicit version pin fall back to the oldest supported version and break unpredictably.
|
|
34
|
+
- Webhook subscriptions are recreated on app reinstall — uninstall deletes them. The install flow re-registers all required topics.
|
|
35
|
+
- For theme app extensions, blocks are testable in the merchant's theme editor and respect the merchant's existing section group layout.
|
|
36
|
+
|
|
37
|
+
## Do NOT Use When
|
|
38
|
+
- The integration target is a generic e-commerce platform (WooCommerce, BigCommerce, Magento, custom). Use the platform-specific skill or api-design for a vendor-neutral approach.
|
|
39
|
+
- You are designing internal event contracts that happen to be triggered by Shopify webhooks — the contract surface is yours. Use event-contract-design.
|
|
40
|
+
- The task is generic webhook signing and retry semantics across multiple providers. Use webhook-integration.
|
|
41
|
+
- The work is product strategy, merchandising, or marketing for a Shopify store rather than technical work on the platform.
|
|
42
|
+
- You are building a storefront UI component that does not touch Shopify APIs or themes directly. Use frontend-architecture or design-module-composition.
|