agent-skill-kit 3.9.135
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/.agent/global.d.ts +80 -0
- package/.agent/rules/GEMINI.md +210 -0
- package/.agent/rules/autopilot.md +287 -0
- package/.agent/rules/code-rules.md +227 -0
- package/.agent/scripts/audit_workflows.ts +23 -0
- package/.agent/scripts/auto_preview.ts +170 -0
- package/.agent/scripts/checklist.ts +180 -0
- package/.agent/scripts/compile-agents.ts +237 -0
- package/.agent/scripts/fix_skills.ts +49 -0
- package/.agent/scripts/session_manager.ts +222 -0
- package/.agent/scripts/skill-audit.ts +255 -0
- package/.agent/scripts/sync_workflows.ts +54 -0
- package/.agent/scripts/utils/colors.ts +58 -0
- package/.agent/scripts/utils/process-manager.ts +131 -0
- package/.agent/scripts/utils/reporter.ts +192 -0
- package/.agent/scripts/utils/runner.ts +128 -0
- package/.agent/scripts/verify_all.ts +243 -0
- package/.agent/scripts/version-sync.ts +256 -0
- package/.agent/skills/SKILL_INDEX.md +129 -0
- package/.agent/skills/agent-browser/AGENTS.md +728 -0
- package/.agent/skills/agent-browser/SKILL.md +193 -0
- package/.agent/skills/agent-browser/rules/_sections.md +15 -0
- package/.agent/skills/agent-browser/rules/_template.md +32 -0
- package/.agent/skills/agent-browser/rules/engineering-spec.md +528 -0
- package/.agent/skills/agent-browser/scripts/browser_cli.ts +52 -0
- package/.agent/skills/agent-browser/scripts/session_manager.ts +166 -0
- package/.agent/skills/ai-artist/AGENTS.md +1082 -0
- package/.agent/skills/ai-artist/SKILL.md +186 -0
- package/.agent/skills/ai-artist/rules/_sections.md +30 -0
- package/.agent/skills/ai-artist/rules/_template.md +32 -0
- package/.agent/skills/ai-artist/rules/domain-code.md +118 -0
- package/.agent/skills/ai-artist/rules/domain-marketing.md +105 -0
- package/.agent/skills/ai-artist/rules/engineering-spec.md +519 -0
- package/.agent/skills/ai-artist/rules/image-prompts.md +195 -0
- package/.agent/skills/ai-artist/rules/model-syntax.md +115 -0
- package/.agent/skills/ai-artist/scripts/prompt_compiler.ts +72 -0
- package/.agent/skills/ai-artist/templates/image-core.txt +1 -0
- package/.agent/skills/ai-artist/templates/llm-core.txt +6 -0
- package/.agent/skills/api-architect/AGENTS.md +1896 -0
- package/.agent/skills/api-architect/SKILL.md +173 -0
- package/.agent/skills/api-architect/rules/_sections.md +35 -0
- package/.agent/skills/api-architect/rules/_template.md +32 -0
- package/.agent/skills/api-architect/rules/api-style.md +115 -0
- package/.agent/skills/api-architect/rules/auth.md +134 -0
- package/.agent/skills/api-architect/rules/documentation.md +131 -0
- package/.agent/skills/api-architect/rules/engineering-spec.md +505 -0
- package/.agent/skills/api-architect/rules/graphql.md +154 -0
- package/.agent/skills/api-architect/rules/rate-limiting.md +76 -0
- package/.agent/skills/api-architect/rules/response.md +138 -0
- package/.agent/skills/api-architect/rules/rest.md +113 -0
- package/.agent/skills/api-architect/rules/security-testing.md +146 -0
- package/.agent/skills/api-architect/rules/trpc.md +129 -0
- package/.agent/skills/api-architect/rules/versioning.md +100 -0
- package/.agent/skills/api-architect/scripts/api_validator.ts +413 -0
- package/.agent/skills/auth-patterns/AGENTS.md +1830 -0
- package/.agent/skills/auth-patterns/SKILL.md +163 -0
- package/.agent/skills/auth-patterns/rules/_sections.md +30 -0
- package/.agent/skills/auth-patterns/rules/_template.md +32 -0
- package/.agent/skills/auth-patterns/rules/engineering-spec.md +515 -0
- package/.agent/skills/auth-patterns/rules/jwt-deep.md +196 -0
- package/.agent/skills/auth-patterns/rules/mfa.md +174 -0
- package/.agent/skills/auth-patterns/rules/oauth2.md +134 -0
- package/.agent/skills/auth-patterns/rules/passkey.md +243 -0
- package/.agent/skills/auth-patterns/rules/rbac-abac.md +206 -0
- package/.agent/skills/auth-patterns/rules/session.md +183 -0
- package/.agent/skills/auth-patterns/scripts/auth_validator.ts +121 -0
- package/.agent/skills/chrome-devtools/AGENTS.md +952 -0
- package/.agent/skills/chrome-devtools/SKILL.md +160 -0
- package/.agent/skills/chrome-devtools/rules/_sections.md +25 -0
- package/.agent/skills/chrome-devtools/rules/_template.md +32 -0
- package/.agent/skills/chrome-devtools/rules/aria-snapshot.md +95 -0
- package/.agent/skills/chrome-devtools/rules/engineering-spec.md +510 -0
- package/.agent/skills/chrome-devtools/rules/scripts-guide.md +174 -0
- package/.agent/skills/chrome-devtools/scripts/aria-snapshot.ts +3 -0
- package/.agent/skills/chrome-devtools/scripts/click.ts +3 -0
- package/.agent/skills/chrome-devtools/scripts/console.ts +3 -0
- package/.agent/skills/chrome-devtools/scripts/core_cli.ts +79 -0
- package/.agent/skills/chrome-devtools/scripts/evaluate.ts +3 -0
- package/.agent/skills/chrome-devtools/scripts/fill.ts +3 -0
- package/.agent/skills/chrome-devtools/scripts/navigate.ts +3 -0
- package/.agent/skills/chrome-devtools/scripts/network.ts +3 -0
- package/.agent/skills/chrome-devtools/scripts/performance.ts +3 -0
- package/.agent/skills/chrome-devtools/scripts/screenshot.ts +3 -0
- package/.agent/skills/chrome-devtools/scripts/select-ref.ts +3 -0
- package/.agent/skills/cicd-pipeline/AGENTS.md +809 -0
- package/.agent/skills/cicd-pipeline/SKILL.md +164 -0
- package/.agent/skills/cicd-pipeline/rules/_sections.md +15 -0
- package/.agent/skills/cicd-pipeline/rules/_template.md +32 -0
- package/.agent/skills/cicd-pipeline/rules/engineering-spec.md +477 -0
- package/.agent/skills/cicd-pipeline/scripts/flag-manager.ts +253 -0
- package/.agent/skills/cicd-pipeline/scripts/pipeline_validator.ts +133 -0
- package/.agent/skills/code-constitution/AGENTS.md +597 -0
- package/.agent/skills/code-constitution/CHANGELOG.md +216 -0
- package/.agent/skills/code-constitution/SKILL.md +191 -0
- package/.agent/skills/code-constitution/VERSION +3 -0
- package/.agent/skills/code-constitution/examples/violation-backend-mutation/after.tsx +59 -0
- package/.agent/skills/code-constitution/examples/violation-backend-mutation/before.tsx +42 -0
- package/.agent/skills/code-constitution/examples/violation-backend-mutation/explanation.md +91 -0
- package/.agent/skills/code-constitution/examples/violation-chart-injection/after.tsx +99 -0
- package/.agent/skills/code-constitution/examples/violation-chart-injection/before.tsx +57 -0
- package/.agent/skills/code-constitution/examples/violation-chart-injection/explanation.md +120 -0
- package/.agent/skills/code-constitution/knowledge/lessons-learned.yaml +3 -0
- package/.agent/skills/code-constitution/metadata/precedence.yaml +117 -0
- package/.agent/skills/code-constitution/metadata/scope-map.yaml +156 -0
- package/.agent/skills/code-constitution/proposals/v1.1-change-proposal-template.md +201 -0
- package/.agent/skills/code-constitution/resources/AUTHORITY_MODEL.md +115 -0
- package/.agent/skills/code-constitution/resources/ENFORCEMENT_GUIDE.md +246 -0
- package/.agent/skills/code-constitution/resources/LOAD_ORDER.md +86 -0
- package/.agent/skills/code-constitution/rules/_sections.md +15 -0
- package/.agent/skills/code-constitution/rules/_template.md +32 -0
- package/.agent/skills/code-constitution/rules/constitution/master-constitution.md +210 -0
- package/.agent/skills/code-constitution/rules/doctrines/architecture/architecture-doctrine.md +188 -0
- package/.agent/skills/code-constitution/rules/doctrines/backend/backend-data-engine-doctrine.md +218 -0
- package/.agent/skills/code-constitution/rules/doctrines/commercial/commercial-guardrails-doctrine.md +196 -0
- package/.agent/skills/code-constitution/rules/doctrines/data/data-integrity-doctrine.md +202 -0
- package/.agent/skills/code-constitution/rules/doctrines/frontend/frontend-mobile-doctrine.md +169 -0
- package/.agent/skills/code-constitution/rules/doctrines/frontend/interaction-patterns-doctrine.md +176 -0
- package/.agent/skills/code-constitution/rules/doctrines/learning/learning-engine-doctrine.md +192 -0
- package/.agent/skills/code-constitution/rules/doctrines/performance/performance-doctrine.md +180 -0
- package/.agent/skills/code-constitution/rules/doctrines/review/code-review-doctrine.md +174 -0
- package/.agent/skills/code-constitution/rules/enforcement/agents/agent-enforcement-protocol.md +218 -0
- package/.agent/skills/code-constitution/rules/enforcement/agents/agent-system-prompt.md +196 -0
- package/.agent/skills/code-constitution/rules/enforcement/checklists/backend-api-review-checklist.md +131 -0
- package/.agent/skills/code-constitution/rules/enforcement/checklists/chart-component-review-checklist.md +147 -0
- package/.agent/skills/code-constitution/rules/enforcement/checklists/frontend-review-checklist.md +194 -0
- package/.agent/skills/code-constitution/rules/enforcement/playbooks/doctrine-violation-playbook.md +236 -0
- package/.agent/skills/code-constitution/rules/engineering-spec.md +561 -0
- package/.agent/skills/code-constitution/scripts/audit_pr.ts +219 -0
- package/.agent/skills/code-constitution/scripts/check_boundaries.ts +134 -0
- package/.agent/skills/code-constitution/scripts/learn.ts +202 -0
- package/.agent/skills/code-constitution/scripts/validate_doctrine.ts +287 -0
- package/.agent/skills/code-craft/AGENTS.md +803 -0
- package/.agent/skills/code-craft/SKILL.md +170 -0
- package/.agent/skills/code-craft/rules/_sections.md +20 -0
- package/.agent/skills/code-craft/rules/_template.md +32 -0
- package/.agent/skills/code-craft/rules/engineering-spec.md +447 -0
- package/.agent/skills/code-craft/rules/verification-scripts.md +83 -0
- package/.agent/skills/code-craft/scripts/code_quality_checker.ts +193 -0
- package/.agent/skills/code-review/AGENTS.md +1664 -0
- package/.agent/skills/code-review/SKILL.md +152 -0
- package/.agent/skills/code-review/rules/_sections.md +15 -0
- package/.agent/skills/code-review/rules/_template.md +32 -0
- package/.agent/skills/code-review/rules/engineering-spec.md +466 -0
- package/.agent/skills/code-review/scripts/lint_runner.ts +213 -0
- package/.agent/skills/code-review/scripts/type_coverage.ts +118 -0
- package/.agent/skills/context-engineering/AGENTS.md +499 -0
- package/.agent/skills/context-engineering/SKILL.md +147 -0
- package/.agent/skills/context-engineering/rules/_sections.md +15 -0
- package/.agent/skills/context-engineering/rules/_template.md +32 -0
- package/.agent/skills/context-engineering/rules/engineering-spec.md +463 -0
- package/.agent/skills/context-engineering/scripts/context_analyzer.ts +127 -0
- package/.agent/skills/copywriting/AGENTS.md +501 -0
- package/.agent/skills/copywriting/SKILL.md +188 -0
- package/.agent/skills/copywriting/rules/_sections.md +15 -0
- package/.agent/skills/copywriting/rules/_template.md +32 -0
- package/.agent/skills/copywriting/rules/engineering-spec.md +465 -0
- package/.agent/skills/copywriting/scripts/copy_validator.ts +185 -0
- package/.agent/skills/data-modeler/AGENTS.md +814 -0
- package/.agent/skills/data-modeler/SKILL.md +195 -0
- package/.agent/skills/data-modeler/rules/_sections.md +15 -0
- package/.agent/skills/data-modeler/rules/_template.md +32 -0
- package/.agent/skills/data-modeler/rules/database-selection.md +124 -0
- package/.agent/skills/data-modeler/rules/engineering-spec.md +479 -0
- package/.agent/skills/data-modeler/rules/indexing.md +166 -0
- package/.agent/skills/data-modeler/rules/migrations.md +176 -0
- package/.agent/skills/data-modeler/rules/optimization.md +161 -0
- package/.agent/skills/data-modeler/rules/orm-selection.md +155 -0
- package/.agent/skills/data-modeler/rules/schema-design.md +162 -0
- package/.agent/skills/data-modeler/scripts/schema_validator.ts +357 -0
- package/.agent/skills/debug-pro/AGENTS.md +798 -0
- package/.agent/skills/debug-pro/SKILL.md +193 -0
- package/.agent/skills/debug-pro/defense-in-depth/SKILL.md +148 -0
- package/.agent/skills/debug-pro/root-cause-tracing/SKILL.md +196 -0
- package/.agent/skills/debug-pro/root-cause-tracing/find-polluter.sh +63 -0
- package/.agent/skills/debug-pro/rules/_sections.md +15 -0
- package/.agent/skills/debug-pro/rules/_template.md +32 -0
- package/.agent/skills/debug-pro/rules/engineering-spec.md +491 -0
- package/.agent/skills/debug-pro/scripts/debug_verifier.ts +148 -0
- package/.agent/skills/debug-pro/verification-before-completion/SKILL.md +160 -0
- package/.agent/skills/design-system/AGENTS.md +4216 -0
- package/.agent/skills/design-system/SKILL.md +186 -0
- package/.agent/skills/design-system/rules/_sections.md +65 -0
- package/.agent/skills/design-system/rules/_template.md +32 -0
- package/.agent/skills/design-system/rules/animation-guide.md +355 -0
- package/.agent/skills/design-system/rules/color-system.md +335 -0
- package/.agent/skills/design-system/rules/color-systems.md +133 -0
- package/.agent/skills/design-system/rules/decision-trees.md +442 -0
- package/.agent/skills/design-system/rules/design-extraction.md +152 -0
- package/.agent/skills/design-system/rules/engineering-spec.md +484 -0
- package/.agent/skills/design-system/rules/motion-design.md +161 -0
- package/.agent/skills/design-system/rules/motion-graphics.md +330 -0
- package/.agent/skills/design-system/rules/spatial-composition.md +184 -0
- package/.agent/skills/design-system/rules/typography-system.md +369 -0
- package/.agent/skills/design-system/rules/typography.md +124 -0
- package/.agent/skills/design-system/rules/ux-psychology.md +565 -0
- package/.agent/skills/design-system/rules/visual-effects.md +407 -0
- package/.agent/skills/design-system/scripts/accessibility_checker.ts +292 -0
- package/.agent/skills/design-system/scripts/ux_audit.ts +356 -0
- package/.agent/skills/doc-templates/AGENTS.md +820 -0
- package/.agent/skills/doc-templates/SKILL.md +260 -0
- package/.agent/skills/doc-templates/rules/_sections.md +20 -0
- package/.agent/skills/doc-templates/rules/_template.md +32 -0
- package/.agent/skills/doc-templates/rules/doc.md +355 -0
- package/.agent/skills/doc-templates/rules/engineering-spec.md +422 -0
- package/.agent/skills/doc-templates/scripts/editor-server.ts +162 -0
- package/.agent/skills/doc-templates/scripts/inject_otel.ts +22 -0
- package/.agent/skills/doc-templates/scripts/kanban-server.ts +171 -0
- package/.agent/skills/doc-templates/scripts/markdown-server.ts +185 -0
- package/.agent/skills/e2e-automation/AGENTS.md +882 -0
- package/.agent/skills/e2e-automation/SKILL.md +175 -0
- package/.agent/skills/e2e-automation/rules/_sections.md +20 -0
- package/.agent/skills/e2e-automation/rules/_template.md +32 -0
- package/.agent/skills/e2e-automation/rules/aria-snapshot.md +185 -0
- package/.agent/skills/e2e-automation/rules/engineering-spec.md +501 -0
- package/.agent/skills/e2e-automation/scripts/playwright_runner.ts +208 -0
- package/.agent/skills/execution-reporter/AGENTS.md +419 -0
- package/.agent/skills/execution-reporter/SKILL.md +152 -0
- package/.agent/skills/execution-reporter/rules/_sections.md +15 -0
- package/.agent/skills/execution-reporter/rules/_template.md +32 -0
- package/.agent/skills/execution-reporter/rules/engineering-spec.md +389 -0
- package/.agent/skills/game-development/2d-games/SKILL.md +140 -0
- package/.agent/skills/game-development/3d-games/SKILL.md +156 -0
- package/.agent/skills/game-development/AGENTS.md +783 -0
- package/.agent/skills/game-development/SKILL.md +178 -0
- package/.agent/skills/game-development/game-art/SKILL.md +207 -0
- package/.agent/skills/game-development/game-audio/SKILL.md +211 -0
- package/.agent/skills/game-development/game-design/SKILL.md +151 -0
- package/.agent/skills/game-development/mobile-games/SKILL.md +130 -0
- package/.agent/skills/game-development/multiplayer/SKILL.md +154 -0
- package/.agent/skills/game-development/pc-games/SKILL.md +167 -0
- package/.agent/skills/game-development/rules/_sections.md +15 -0
- package/.agent/skills/game-development/rules/_template.md +32 -0
- package/.agent/skills/game-development/rules/engineering-spec.md +480 -0
- package/.agent/skills/game-development/vr-ar/SKILL.md +144 -0
- package/.agent/skills/game-development/web-games/SKILL.md +173 -0
- package/.agent/skills/git-workflow/AGENTS.md +554 -0
- package/.agent/skills/git-workflow/SKILL.md +181 -0
- package/.agent/skills/git-workflow/rules/_sections.md +15 -0
- package/.agent/skills/git-workflow/rules/_template.md +32 -0
- package/.agent/skills/git-workflow/rules/engineering-spec.md +518 -0
- package/.agent/skills/gitops/AGENTS.md +921 -0
- package/.agent/skills/gitops/SKILL.md +163 -0
- package/.agent/skills/gitops/rules/_sections.md +25 -0
- package/.agent/skills/gitops/rules/_template.md +32 -0
- package/.agent/skills/gitops/rules/argocd-setup.md +148 -0
- package/.agent/skills/gitops/rules/engineering-spec.md +450 -0
- package/.agent/skills/gitops/rules/sync-policies.md +145 -0
- package/.agent/skills/google-adk-python/AGENTS.md +1054 -0
- package/.agent/skills/google-adk-python/SKILL.md +168 -0
- package/.agent/skills/google-adk-python/rules/_sections.md +25 -0
- package/.agent/skills/google-adk-python/rules/_template.md +32 -0
- package/.agent/skills/google-adk-python/rules/deployment.md +138 -0
- package/.agent/skills/google-adk-python/rules/engineering-spec.md +451 -0
- package/.agent/skills/google-adk-python/rules/multi-agent.md +146 -0
- package/.agent/skills/google-adk-python/rules/tools.md +131 -0
- package/.agent/skills/idea-storm/AGENTS.md +995 -0
- package/.agent/skills/idea-storm/SKILL.md +160 -0
- package/.agent/skills/idea-storm/rules/_sections.md +25 -0
- package/.agent/skills/idea-storm/rules/_template.md +32 -0
- package/.agent/skills/idea-storm/rules/architecture-debate.md +122 -0
- package/.agent/skills/idea-storm/rules/dynamic-questioning.md +374 -0
- package/.agent/skills/idea-storm/rules/engineering-spec.md +466 -0
- package/.agent/skills/knowledge-compiler/SKILL.md +320 -0
- package/.agent/skills/knowledge-graph/AGENTS.md +762 -0
- package/.agent/skills/knowledge-graph/SKILL.md +157 -0
- package/.agent/skills/knowledge-graph/rules/_sections.md +15 -0
- package/.agent/skills/knowledge-graph/rules/_template.md +32 -0
- package/.agent/skills/knowledge-graph/rules/engineering-spec.md +439 -0
- package/.agent/skills/knowledge-linter/SKILL.md +217 -0
- package/.agent/skills/lifecycle-orchestrator/AGENTS.md +989 -0
- package/.agent/skills/lifecycle-orchestrator/SKILL.md +169 -0
- package/.agent/skills/lifecycle-orchestrator/rules/_sections.md +15 -0
- package/.agent/skills/lifecycle-orchestrator/rules/_template.md +32 -0
- package/.agent/skills/lifecycle-orchestrator/rules/engineering-spec.md +525 -0
- package/.agent/skills/lifecycle-orchestrator/scripts/state_manager.ts +189 -0
- package/.agent/skills/mcp-builder/AGENTS.md +1653 -0
- package/.agent/skills/mcp-builder/SKILL.md +166 -0
- package/.agent/skills/mcp-builder/rules/_sections.md +40 -0
- package/.agent/skills/mcp-builder/rules/_template.md +32 -0
- package/.agent/skills/mcp-builder/rules/best-practices.md +157 -0
- package/.agent/skills/mcp-builder/rules/design-principles.md +105 -0
- package/.agent/skills/mcp-builder/rules/engineering-spec.md +473 -0
- package/.agent/skills/mcp-builder/rules/evaluation.md +103 -0
- package/.agent/skills/mcp-builder/rules/python-implementation.md +249 -0
- package/.agent/skills/mcp-builder/rules/quickstart.md +111 -0
- package/.agent/skills/mcp-builder/rules/typescript-implementation.md +280 -0
- package/.agent/skills/mcp-management/AGENTS.md +837 -0
- package/.agent/skills/mcp-management/SKILL.md +164 -0
- package/.agent/skills/mcp-management/rules/_sections.md +25 -0
- package/.agent/skills/mcp-management/rules/_template.md +32 -0
- package/.agent/skills/mcp-management/rules/cli-usage.md +146 -0
- package/.agent/skills/mcp-management/rules/engineering-spec.md +501 -0
- package/.agent/skills/mcp-management/rules/protocol.md +159 -0
- package/.agent/skills/media-processing/AGENTS.md +479 -0
- package/.agent/skills/media-processing/SKILL.md +176 -0
- package/.agent/skills/media-processing/rules/_sections.md +15 -0
- package/.agent/skills/media-processing/rules/_template.md +32 -0
- package/.agent/skills/media-processing/rules/engineering-spec.md +452 -0
- package/.agent/skills/media-processing/scripts/convert-video.ts +155 -0
- package/.agent/skills/media-processing/scripts/optimize-image.ts +127 -0
- package/.agent/skills/mobile-design/AGENTS.md +6531 -0
- package/.agent/skills/mobile-design/SKILL.md +165 -0
- package/.agent/skills/mobile-design/rules/_sections.md +45 -0
- package/.agent/skills/mobile-design/rules/_template.md +32 -0
- package/.agent/skills/mobile-design/rules/decision-trees.md +540 -0
- package/.agent/skills/mobile-design/rules/engineering-spec.md +467 -0
- package/.agent/skills/mobile-design/rules/mobile-backend.md +516 -0
- package/.agent/skills/mobile-design/rules/mobile-color-system.md +436 -0
- package/.agent/skills/mobile-design/rules/mobile-debugging.md +146 -0
- package/.agent/skills/mobile-design/rules/mobile-design-thinking.md +381 -0
- package/.agent/skills/mobile-design/rules/mobile-navigation.md +474 -0
- package/.agent/skills/mobile-design/rules/mobile-performance.md +783 -0
- package/.agent/skills/mobile-design/rules/mobile-testing.md +380 -0
- package/.agent/skills/mobile-design/rules/mobile-typography.md +449 -0
- package/.agent/skills/mobile-design/rules/platform-android.md +682 -0
- package/.agent/skills/mobile-design/rules/platform-ios.md +577 -0
- package/.agent/skills/mobile-design/rules/touch-psychology.md +553 -0
- package/.agent/skills/mobile-design/scripts/mobile_audit.ts +309 -0
- package/.agent/skills/mobile-developer/AGENTS.md +904 -0
- package/.agent/skills/mobile-developer/SKILL.md +194 -0
- package/.agent/skills/mobile-developer/rules/_sections.md +75 -0
- package/.agent/skills/mobile-developer/rules/_template.md +32 -0
- package/.agent/skills/mobile-developer/rules/anti-patterns.md +70 -0
- package/.agent/skills/mobile-developer/rules/app-store-optimization.md +319 -0
- package/.agent/skills/mobile-developer/rules/decision-trees.md +545 -0
- package/.agent/skills/mobile-developer/rules/deep-linking.md +441 -0
- package/.agent/skills/mobile-developer/rules/engineering-spec.md +477 -0
- package/.agent/skills/mobile-developer/rules/flutter.md +475 -0
- package/.agent/skills/mobile-developer/rules/mobile-backend.md +516 -0
- package/.agent/skills/mobile-developer/rules/mobile-color-system.md +444 -0
- package/.agent/skills/mobile-developer/rules/mobile-debugging.md +428 -0
- package/.agent/skills/mobile-developer/rules/mobile-design-thinking.md +367 -0
- package/.agent/skills/mobile-developer/rules/mobile-navigation.md +483 -0
- package/.agent/skills/mobile-developer/rules/mobile-performance.md +778 -0
- package/.agent/skills/mobile-developer/rules/mobile-testing.md +382 -0
- package/.agent/skills/mobile-developer/rules/mobile-typography.md +457 -0
- package/.agent/skills/mobile-developer/rules/native.md +572 -0
- package/.agent/skills/mobile-developer/rules/platform-android.md +676 -0
- package/.agent/skills/mobile-developer/rules/platform-ios.md +571 -0
- package/.agent/skills/mobile-developer/rules/push-notifications.md +599 -0
- package/.agent/skills/mobile-developer/rules/react-native.md +422 -0
- package/.agent/skills/mobile-developer/rules/touch-psychology.md +547 -0
- package/.agent/skills/mobile-developer/scripts/mobile_audit.ts +701 -0
- package/.agent/skills/nextjs-pro/AGENTS.md +3932 -0
- package/.agent/skills/nextjs-pro/SKILL.md +171 -0
- package/.agent/skills/nextjs-pro/rules/_sections.md +50 -0
- package/.agent/skills/nextjs-pro/rules/_template.md +32 -0
- package/.agent/skills/nextjs-pro/rules/advanced-event-handler-refs.md +59 -0
- package/.agent/skills/nextjs-pro/rules/advanced-init-once.md +46 -0
- package/.agent/skills/nextjs-pro/rules/advanced-use-latest.md +43 -0
- package/.agent/skills/nextjs-pro/rules/async-api-routes.md +42 -0
- package/.agent/skills/nextjs-pro/rules/async-defer-await.md +84 -0
- package/.agent/skills/nextjs-pro/rules/async-dependencies.md +55 -0
- package/.agent/skills/nextjs-pro/rules/async-parallel.md +32 -0
- package/.agent/skills/nextjs-pro/rules/async-suspense-boundaries.md +103 -0
- package/.agent/skills/nextjs-pro/rules/bundle-barrel-imports.md +63 -0
- package/.agent/skills/nextjs-pro/rules/bundle-conditional.md +35 -0
- package/.agent/skills/nextjs-pro/rules/bundle-defer-third-party.md +53 -0
- package/.agent/skills/nextjs-pro/rules/bundle-dynamic-imports.md +39 -0
- package/.agent/skills/nextjs-pro/rules/bundle-preload.md +54 -0
- package/.agent/skills/nextjs-pro/rules/client-event-listeners.md +78 -0
- package/.agent/skills/nextjs-pro/rules/client-localstorage-schema.md +75 -0
- package/.agent/skills/nextjs-pro/rules/client-passive-event-listeners.md +52 -0
- package/.agent/skills/nextjs-pro/rules/client-swr-dedup.md +60 -0
- package/.agent/skills/nextjs-pro/rules/engineering-spec.md +440 -0
- package/.agent/skills/nextjs-pro/rules/js-batch-dom-css.md +111 -0
- package/.agent/skills/nextjs-pro/rules/js-cache-function-results.md +84 -0
- package/.agent/skills/nextjs-pro/rules/js-cache-property-access.md +32 -0
- package/.agent/skills/nextjs-pro/rules/js-cache-storage.md +74 -0
- package/.agent/skills/nextjs-pro/rules/js-combine-iterations.md +36 -0
- package/.agent/skills/nextjs-pro/rules/js-early-exit.md +54 -0
- package/.agent/skills/nextjs-pro/rules/js-hoist-regexp.md +49 -0
- package/.agent/skills/nextjs-pro/rules/js-index-maps.md +41 -0
- package/.agent/skills/nextjs-pro/rules/js-length-check-first.md +53 -0
- package/.agent/skills/nextjs-pro/rules/js-min-max-loop.md +86 -0
- package/.agent/skills/nextjs-pro/rules/js-set-map-lookups.md +28 -0
- package/.agent/skills/nextjs-pro/rules/js-tosorted-immutable.md +61 -0
- package/.agent/skills/nextjs-pro/rules/rendering-activity.md +30 -0
- package/.agent/skills/nextjs-pro/rules/rendering-animate-svg-wrapper.md +51 -0
- package/.agent/skills/nextjs-pro/rules/rendering-conditional-render.md +44 -0
- package/.agent/skills/nextjs-pro/rules/rendering-content-visibility.md +42 -0
- package/.agent/skills/nextjs-pro/rules/rendering-hoist-jsx.md +50 -0
- package/.agent/skills/nextjs-pro/rules/rendering-hydration-no-flicker.md +86 -0
- package/.agent/skills/nextjs-pro/rules/rendering-hydration-suppress-warning.md +34 -0
- package/.agent/skills/nextjs-pro/rules/rendering-svg-precision.md +32 -0
- package/.agent/skills/nextjs-pro/rules/rendering-usetransition-loading.md +79 -0
- package/.agent/skills/nextjs-pro/rules/rerender-defer-reads.md +43 -0
- package/.agent/skills/nextjs-pro/rules/rerender-dependencies.md +49 -0
- package/.agent/skills/nextjs-pro/rules/rerender-derived-state-no-effect.md +44 -0
- package/.agent/skills/nextjs-pro/rules/rerender-derived-state.md +33 -0
- package/.agent/skills/nextjs-pro/rules/rerender-functional-setstate.md +78 -0
- package/.agent/skills/nextjs-pro/rules/rerender-lazy-state-init.md +62 -0
- package/.agent/skills/nextjs-pro/rules/rerender-memo-with-default-value.md +42 -0
- package/.agent/skills/nextjs-pro/rules/rerender-memo.md +48 -0
- package/.agent/skills/nextjs-pro/rules/rerender-move-effect-to-event.md +49 -0
- package/.agent/skills/nextjs-pro/rules/rerender-simple-expression-in-memo.md +39 -0
- package/.agent/skills/nextjs-pro/rules/rerender-transitions.md +44 -0
- package/.agent/skills/nextjs-pro/rules/rerender-use-ref-transient-values.md +77 -0
- package/.agent/skills/nextjs-pro/rules/schema.json +34 -0
- package/.agent/skills/nextjs-pro/rules/server-after-nonblocking.md +77 -0
- package/.agent/skills/nextjs-pro/rules/server-auth-actions.md +100 -0
- package/.agent/skills/nextjs-pro/rules/server-cache-lru.md +45 -0
- package/.agent/skills/nextjs-pro/rules/server-cache-react.md +80 -0
- package/.agent/skills/nextjs-pro/rules/server-dedup-props.md +69 -0
- package/.agent/skills/nextjs-pro/rules/server-parallel-fetching.md +87 -0
- package/.agent/skills/nextjs-pro/rules/server-serialization.md +42 -0
- package/.agent/skills/nodejs-pro/AGENTS.md +866 -0
- package/.agent/skills/nodejs-pro/SKILL.md +172 -0
- package/.agent/skills/nodejs-pro/rules/_sections.md +50 -0
- package/.agent/skills/nodejs-pro/rules/_template.md +32 -0
- package/.agent/skills/nodejs-pro/rules/architecture-patterns.md +229 -0
- package/.agent/skills/nodejs-pro/rules/async-patterns.md +246 -0
- package/.agent/skills/nodejs-pro/rules/engineering-spec.md +438 -0
- package/.agent/skills/nodejs-pro/rules/error-handling.md +257 -0
- package/.agent/skills/nodejs-pro/rules/framework-selection.md +220 -0
- package/.agent/skills/nodejs-pro/rules/runtime-modules.md +176 -0
- package/.agent/skills/nodejs-pro/rules/testing-strategy.md +266 -0
- package/.agent/skills/nodejs-pro/rules/validation-security.md +205 -0
- package/.agent/skills/observability/AGENTS.md +607 -0
- package/.agent/skills/observability/SKILL.md +178 -0
- package/.agent/skills/observability/rules/_sections.md +15 -0
- package/.agent/skills/observability/rules/_template.md +32 -0
- package/.agent/skills/observability/rules/engineering-spec.md +440 -0
- package/.agent/skills/offensive-sec/AGENTS.md +849 -0
- package/.agent/skills/offensive-sec/SKILL.md +191 -0
- package/.agent/skills/offensive-sec/rules/_sections.md +15 -0
- package/.agent/skills/offensive-sec/rules/_template.md +32 -0
- package/.agent/skills/offensive-sec/rules/engineering-spec.md +470 -0
- package/.agent/skills/perf-optimizer/AGENTS.md +870 -0
- package/.agent/skills/perf-optimizer/SKILL.md +189 -0
- package/.agent/skills/perf-optimizer/rules/_sections.md +15 -0
- package/.agent/skills/perf-optimizer/rules/_template.md +32 -0
- package/.agent/skills/perf-optimizer/rules/backend-patterns.md +312 -0
- package/.agent/skills/perf-optimizer/rules/engineering-spec.md +428 -0
- package/.agent/skills/perf-optimizer/scripts/lighthouse_audit.ts +201 -0
- package/.agent/skills/problem-checker/AGENTS.md +519 -0
- package/.agent/skills/problem-checker/SKILL.md +189 -0
- package/.agent/skills/problem-checker/rules/_sections.md +15 -0
- package/.agent/skills/problem-checker/rules/_template.md +32 -0
- package/.agent/skills/problem-checker/rules/engineering-spec.md +483 -0
- package/.agent/skills/problem-checker/scripts/check_problems.ts +396 -0
- package/.agent/skills/project-planner/AGENTS.md +2698 -0
- package/.agent/skills/project-planner/SKILL.md +166 -0
- package/.agent/skills/project-planner/rules/_sections.md +15 -0
- package/.agent/skills/project-planner/rules/_template.md +32 -0
- package/.agent/skills/project-planner/rules/engineering-spec.md +420 -0
- package/.agent/skills/python-pro/AGENTS.md +1871 -0
- package/.agent/skills/python-pro/SKILL.md +182 -0
- package/.agent/skills/python-pro/rules/_sections.md +50 -0
- package/.agent/skills/python-pro/rules/_template.md +32 -0
- package/.agent/skills/python-pro/rules/async-patterns.md +168 -0
- package/.agent/skills/python-pro/rules/django-patterns.md +194 -0
- package/.agent/skills/python-pro/rules/engineering-spec.md +442 -0
- package/.agent/skills/python-pro/rules/fastapi-patterns.md +179 -0
- package/.agent/skills/python-pro/rules/framework-selection.md +167 -0
- package/.agent/skills/python-pro/rules/project-structure.md +181 -0
- package/.agent/skills/python-pro/rules/testing-patterns.md +212 -0
- package/.agent/skills/python-pro/rules/type-hints.md +159 -0
- package/.agent/skills/react-pro/AGENTS.md +963 -0
- package/.agent/skills/react-pro/SKILL.md +232 -0
- package/.agent/skills/react-pro/rules/_sections.md +40 -0
- package/.agent/skills/react-pro/rules/_template.md +32 -0
- package/.agent/skills/react-pro/rules/component-patterns.md +145 -0
- package/.agent/skills/react-pro/rules/composition-compound.md +82 -0
- package/.agent/skills/react-pro/rules/data-fetching.md +133 -0
- package/.agent/skills/react-pro/rules/engineering-spec.md +453 -0
- package/.agent/skills/react-pro/rules/error-boundary.md +61 -0
- package/.agent/skills/react-pro/rules/file-organization.md +158 -0
- package/.agent/skills/react-pro/rules/hooks-custom.md +61 -0
- package/.agent/skills/react-pro/rules/mui-styling.md +138 -0
- package/.agent/skills/react-pro/rules/patterns.md +24 -0
- package/.agent/skills/react-pro/rules/performance-optimization.md +65 -0
- package/.agent/skills/react-pro/rules/performance.md +137 -0
- package/.agent/skills/react-pro/rules/react19-hooks.md +85 -0
- package/.agent/skills/react-pro/rules/state-management.md +90 -0
- package/.agent/skills/react-pro/rules/testing-patterns.md +52 -0
- package/.agent/skills/registry.json +1251 -0
- package/.agent/skills/security-scanner/AGENTS.md +851 -0
- package/.agent/skills/security-scanner/SKILL.md +182 -0
- package/.agent/skills/security-scanner/rules/_sections.md +15 -0
- package/.agent/skills/security-scanner/rules/_template.md +32 -0
- package/.agent/skills/security-scanner/rules/auth-patterns.md +281 -0
- package/.agent/skills/security-scanner/rules/checklists.md +186 -0
- package/.agent/skills/security-scanner/rules/engineering-spec.md +440 -0
- package/.agent/skills/security-scanner/scripts/security_scan.ts +513 -0
- package/.agent/skills/seo-optimizer/AGENTS.md +839 -0
- package/.agent/skills/seo-optimizer/SKILL.md +180 -0
- package/.agent/skills/seo-optimizer/rules/_sections.md +15 -0
- package/.agent/skills/seo-optimizer/rules/_template.md +32 -0
- package/.agent/skills/seo-optimizer/rules/engineering-spec.md +433 -0
- package/.agent/skills/seo-optimizer/scripts/geo_checker.ts +109 -0
- package/.agent/skills/seo-optimizer/scripts/seo_checker.ts +308 -0
- package/.agent/skills/server-ops/AGENTS.md +643 -0
- package/.agent/skills/server-ops/SKILL.md +194 -0
- package/.agent/skills/server-ops/rules/_sections.md +15 -0
- package/.agent/skills/server-ops/rules/_template.md +32 -0
- package/.agent/skills/server-ops/rules/engineering-spec.md +450 -0
- package/.agent/skills/shell-script/AGENTS.md +499 -0
- package/.agent/skills/shell-script/SKILL.md +205 -0
- package/.agent/skills/shell-script/rules/_sections.md +15 -0
- package/.agent/skills/shell-script/rules/_template.md +32 -0
- package/.agent/skills/shell-script/rules/engineering-spec.md +463 -0
- package/.agent/skills/skill-generator/SKILL.md +147 -0
- package/.agent/skills/smart-router/SKILL.md +95 -0
- package/.agent/skills/studio/AGENTS.md +636 -0
- package/.agent/skills/studio/SKILL.md +178 -0
- package/.agent/skills/studio/data/charts.csv +26 -0
- package/.agent/skills/studio/data/colors.csv +97 -0
- package/.agent/skills/studio/data/icons.csv +101 -0
- package/.agent/skills/studio/data/landing.csv +31 -0
- package/.agent/skills/studio/data/products.csv +97 -0
- package/.agent/skills/studio/data/prompts.csv +24 -0
- package/.agent/skills/studio/data/react-performance.csv +45 -0
- package/.agent/skills/studio/data/stacks/flutter.csv +52 -0
- package/.agent/skills/studio/data/stacks/html-tailwind.csv +56 -0
- package/.agent/skills/studio/data/stacks/jetpack-compose.csv +53 -0
- package/.agent/skills/studio/data/stacks/nextjs.csv +53 -0
- package/.agent/skills/studio/data/stacks/nuxt-ui.csv +51 -0
- package/.agent/skills/studio/data/stacks/nuxtjs.csv +59 -0
- package/.agent/skills/studio/data/stacks/react-native.csv +52 -0
- package/.agent/skills/studio/data/stacks/react.csv +54 -0
- package/.agent/skills/studio/data/stacks/shadcn.csv +61 -0
- package/.agent/skills/studio/data/stacks/svelte.csv +54 -0
- package/.agent/skills/studio/data/stacks/swiftui.csv +51 -0
- package/.agent/skills/studio/data/stacks/vue.csv +50 -0
- package/.agent/skills/studio/data/styles.csv +59 -0
- package/.agent/skills/studio/data/typography.csv +58 -0
- package/.agent/skills/studio/data/ui-reasoning.csv +101 -0
- package/.agent/skills/studio/data/ux-guidelines.csv +100 -0
- package/.agent/skills/studio/data/web-interface.csv +31 -0
- package/.agent/skills/studio/rules/_sections.md +15 -0
- package/.agent/skills/studio/rules/_template.md +32 -0
- package/.agent/skills/studio/rules/engineering-spec.md +455 -0
- package/.agent/skills/studio/scripts/core.ts +345 -0
- package/.agent/skills/studio/scripts/design_system.ts +953 -0
- package/.agent/skills/studio/scripts/search.ts +197 -0
- package/.agent/skills/studio/scripts/types.ts +147 -0
- package/.agent/skills/studio/scripts/utils/component-specs.ts +154 -0
- package/.agent/skills/studio/scripts/utils/config-loader.ts +165 -0
- package/.agent/skills/studio/scripts/utils/css-templates.ts +169 -0
- package/.agent/skills/studio/scripts/utils/css-validator.ts +95 -0
- package/.agent/skills/studio/scripts/utils/csv-loader.ts +52 -0
- package/.agent/skills/studio/scripts/utils/intelligent-overrides.ts +129 -0
- package/.agent/skills/studio/scripts/utils/page-override-formatter.ts +143 -0
- package/.agent/skills/studio/scripts/utils/page-type-detector.ts +124 -0
- package/.agent/skills/studio/scripts/utils/search-cache.ts +165 -0
- package/.agent/skills/studio/scripts/utils/text-utils.ts +44 -0
- package/.agent/skills/system-design/AGENTS.md +597 -0
- package/.agent/skills/system-design/SKILL.md +153 -0
- package/.agent/skills/system-design/rules/_sections.md +15 -0
- package/.agent/skills/system-design/rules/_template.md +32 -0
- package/.agent/skills/system-design/rules/context-discovery.md +117 -0
- package/.agent/skills/system-design/rules/engineering-spec.md +437 -0
- package/.agent/skills/system-design/rules/examples.md +180 -0
- package/.agent/skills/system-design/rules/pattern-selection.md +130 -0
- package/.agent/skills/system-design/rules/patterns-reference.md +110 -0
- package/.agent/skills/system-design/rules/trade-off-analysis.md +169 -0
- package/.agent/skills/tailwind-kit/AGENTS.md +1135 -0
- package/.agent/skills/tailwind-kit/SKILL.md +171 -0
- package/.agent/skills/tailwind-kit/rules/_sections.md +20 -0
- package/.agent/skills/tailwind-kit/rules/_template.md +32 -0
- package/.agent/skills/tailwind-kit/rules/components.md +232 -0
- package/.agent/skills/tailwind-kit/rules/engineering-spec.md +435 -0
- package/.agent/skills/tailwind-kit/rules/responsive.md +221 -0
- package/.agent/skills/tailwind-kit/rules/v4-config.md +72 -0
- package/.agent/skills/test-architect/AGENTS.md +851 -0
- package/.agent/skills/test-architect/SKILL.md +176 -0
- package/.agent/skills/test-architect/rules/_sections.md +15 -0
- package/.agent/skills/test-architect/rules/_template.md +32 -0
- package/.agent/skills/test-architect/rules/engineering-spec.md +434 -0
- package/.agent/skills/test-architect/scripts/test_runner.ts +265 -0
- package/.agent/skills/typescript-expert/AGENTS.md +1045 -0
- package/.agent/skills/typescript-expert/SKILL.md +200 -0
- package/.agent/skills/typescript-expert/rules/_sections.md +20 -0
- package/.agent/skills/typescript-expert/rules/_template.md +32 -0
- package/.agent/skills/typescript-expert/rules/engineering-spec.md +433 -0
- package/.agent/skills/typescript-expert/rules/tsconfig-strict.json +92 -0
- package/.agent/skills/typescript-expert/rules/typescript-cheatsheet.md +407 -0
- package/.agent/skills/typescript-expert/rules/utility-types.ts +264 -0
- package/.agent/skills/typescript-expert/scripts/ts_diagnostic.ts +321 -0
- package/.agent/skills/vercel-deploy/AGENTS.md +490 -0
- package/.agent/skills/vercel-deploy/SKILL.md +175 -0
- package/.agent/skills/vercel-deploy/rules/_sections.md +15 -0
- package/.agent/skills/vercel-deploy/rules/_template.md +32 -0
- package/.agent/skills/vercel-deploy/rules/engineering-spec.md +463 -0
- package/.agent/skills/vercel-deploy/scripts/deploy.sh +310 -0
- package/.agent/workflows/api.md +377 -0
- package/.agent/workflows/autopilot.md +344 -0
- package/.agent/workflows/build.md +338 -0
- package/.agent/workflows/chronicle.md +279 -0
- package/.agent/workflows/cook.md +217 -0
- package/.agent/workflows/diagnose.md +302 -0
- package/.agent/workflows/fix.md +253 -0
- package/.agent/workflows/game.md +329 -0
- package/.agent/workflows/inspect.md +276 -0
- package/.agent/workflows/knowledge.md +212 -0
- package/.agent/workflows/launch.md +345 -0
- package/.agent/workflows/mobile.md +354 -0
- package/.agent/workflows/monitor.md +239 -0
- package/.agent/workflows/optimize.md +269 -0
- package/.agent/workflows/plan.md +278 -0
- package/.agent/workflows/stage.md +286 -0
- package/.agent/workflows/studio.md +276 -0
- package/.agent/workflows/think.md +262 -0
- package/.agent/workflows/validate.md +289 -0
- package/.agentignore +161 -0
- package/.gitattributes +16 -0
- package/CHANGELOG.md +198 -0
- package/LICENSE +40 -0
- package/README.md +173 -0
- package/docs/SKILL_DESIGN_GUIDE.md +561 -0
- package/docs/The-Complete-Guide-to-Building-Skills-for-Claude.md +1207 -0
- package/docs/WORKFLOW_DESIGN_GUIDE.md +325 -0
- package/package.json +33 -0
- package/tsconfig.json +28 -0
|
@@ -0,0 +1,1896 @@
|
|
|
1
|
+
# api-architect
|
|
2
|
+
|
|
3
|
+
**Version 1.0.0**
|
|
4
|
+
Engineering
|
|
5
|
+
March 2026
|
|
6
|
+
|
|
7
|
+
> **Note:**
|
|
8
|
+
> This document is for agents and LLMs to follow when working on api-architect domain.
|
|
9
|
+
> Optimized for automation and consistency by AI-assisted workflows.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Observability Requirements
|
|
14
|
+
|
|
15
|
+
- **OpenTelemetry Integration (MANDATORY)**: EVERY API endpoint MUST propagate tracing headers (e.g., X-B3-TraceId or W3C raceparent). JSON outputs from validation MUST contain race_id.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
# API Architect
|
|
20
|
+
|
|
21
|
+
> Context-aware API design decisions. Learn to THINK about API style for THIS project, not default to REST.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Prerequisites
|
|
26
|
+
|
|
27
|
+
**Required:** None — API Architect is a knowledge-based skill with no external dependencies.
|
|
28
|
+
|
|
29
|
+
**Optional:**
|
|
30
|
+
- `scripts/api_validator.ts` — run `node scripts/api_validator.ts <project_path>` for endpoint validation
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## When to Use
|
|
35
|
+
|
|
36
|
+
| Situation | Reference |
|
|
37
|
+
|-----------|-----------|
|
|
38
|
+
| Choosing API style (REST/GraphQL/tRPC) | `rules/api-style.md` |
|
|
39
|
+
| Designing REST endpoints | `rules/rest.md` |
|
|
40
|
+
| Response format / error envelope | `rules/response.md` |
|
|
41
|
+
| GraphQL schema design | `rules/graphql.md` |
|
|
42
|
+
| tRPC for TypeScript fullstack | `rules/trpc.md` |
|
|
43
|
+
| API versioning strategy | `rules/versioning.md` |
|
|
44
|
+
| Auth pattern selection | `rules/auth.md` |
|
|
45
|
+
| Rate limiting strategy | `rules/rate-limiting.md` |
|
|
46
|
+
| OpenAPI documentation | `rules/documentation.md` |
|
|
47
|
+
| OWASP API security audit | `rules/security-testing.md` |
|
|
48
|
+
| Architecture review, contracts | `rules/engineering-spec.md` |
|
|
49
|
+
|
|
50
|
+
**Selective Reading Rule:** Read ONLY the file matching the current request. Do not read all files.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## System Boundaries
|
|
55
|
+
|
|
56
|
+
| Owned by This Skill | NOT Owned |
|
|
57
|
+
|---------------------|-----------|
|
|
58
|
+
| API style selection (REST/GraphQL/tRPC) | API implementation code (→ backend-specialist) |
|
|
59
|
+
| Response format and envelope design | Database schema (→ data-modeler) |
|
|
60
|
+
| Versioning strategy selection | Auth implementation (→ auth-patterns) |
|
|
61
|
+
| Rate limiting pattern selection | Security pen testing (→ security-scanner) |
|
|
62
|
+
| OWASP API Top 10 checklist | Infrastructure / deployment (→ server-ops) |
|
|
63
|
+
| OpenAPI documentation standards | Client-side consumption |
|
|
64
|
+
|
|
65
|
+
**Pure decision skill:** Produces design documents and specifications. Zero code generation, zero network calls.
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Execution Model — 4-Phase Lifecycle
|
|
70
|
+
|
|
71
|
+
| Phase | Action | Output |
|
|
72
|
+
|-------|--------|--------|
|
|
73
|
+
| **Classify** | Validate request type and project context | Validated input or error |
|
|
74
|
+
| **Evaluate** | Traverse decision tree (project_type → consumers → complexity → scale) | Selected pattern |
|
|
75
|
+
| **Enrich** | Attach checklist, anti-patterns, related decisions | Complete decision |
|
|
76
|
+
| **Emit** | Return structured output with rationale | Decision with metadata |
|
|
77
|
+
|
|
78
|
+
All phases synchronous. Decision tree ordering is fixed and deterministic.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## API Style Decision Tree
|
|
83
|
+
|
|
84
|
+
| Project Context | Recommended Style | Rationale |
|
|
85
|
+
|----------------|-------------------|-----------|
|
|
86
|
+
| TypeScript monorepo, internal consumers only | **tRPC** | End-to-end type safety, zero serialization overhead |
|
|
87
|
+
| Complex relational data, multiple consumer types | **GraphQL** | Client-specific queries, no over-fetching |
|
|
88
|
+
| Public API, third-party consumers | **REST** | Widest compatibility, cacheable, well-understood |
|
|
89
|
+
| Simple CRUD, single consumer | **REST** | Minimal complexity, HTTP semantics sufficient |
|
|
90
|
+
| Real-time data requirements | **GraphQL** (subscriptions) or **WebSocket** | Native subscription support |
|
|
91
|
+
|
|
92
|
+
**Constraint:** `existing_api` context field takes precedence — avoid mixing styles unless justified.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Error Taxonomy
|
|
97
|
+
|
|
98
|
+
| Code | Recoverable | Trigger |
|
|
99
|
+
|------|-------------|---------|
|
|
100
|
+
| `ERR_INVALID_REQUEST_TYPE` | No | Request type not one of the 8 supported types |
|
|
101
|
+
| `ERR_MISSING_CONTEXT` | Yes | Required context field is null or empty |
|
|
102
|
+
| `ERR_CONSTRAINT_CONFLICT` | Yes | Contradictory constraints in input |
|
|
103
|
+
| `ERR_INVALID_CONSUMER` | Yes | Consumer type not recognized |
|
|
104
|
+
| `ERR_REFERENCE_NOT_FOUND` | No | Rule file missing from rules/ directory |
|
|
105
|
+
| `ERR_VALIDATOR_FAILED` | Yes | api_validator.ts exited with non-zero code |
|
|
106
|
+
| `ERR_INVALID_SCALE` | No | Scale not one of: prototype, startup, growth, enterprise |
|
|
107
|
+
|
|
108
|
+
**Zero internal retries.** Deterministic output; same context = same decision.
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## Decision Checklist
|
|
113
|
+
|
|
114
|
+
Before designing an API, confirm:
|
|
115
|
+
|
|
116
|
+
- [ ] **Consumers identified?** (web-spa, mobile, third-party, internal-service, cli)
|
|
117
|
+
- [ ] **API style chosen for THIS context?** (REST/GraphQL/tRPC — not defaulted)
|
|
118
|
+
- [ ] **Response envelope format defined?** (consistent across all endpoints)
|
|
119
|
+
- [ ] **Versioning strategy selected?** (URI/Header/Query — before first endpoint)
|
|
120
|
+
- [ ] **Auth pattern selected?** (JWT/OAuth/Passkey/API Key)
|
|
121
|
+
- [ ] **Rate limiting strategy defined?** (token bucket/sliding window)
|
|
122
|
+
- [ ] **OpenAPI documentation approach set?**
|
|
123
|
+
- [ ] **OWASP API Top 10 reviewed?**
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## Anti-Patterns
|
|
128
|
+
|
|
129
|
+
| ❌ Don't | ✅ Do |
|
|
130
|
+
|---------|-------|
|
|
131
|
+
| Default to REST for every project | Choose API style based on project context |
|
|
132
|
+
| Use verbs in REST endpoints (`/getUsers`) | Use resource nouns (`/users`) with HTTP methods |
|
|
133
|
+
| Different response formats per endpoint | Define one envelope pattern, apply uniformly |
|
|
134
|
+
| Expose internal error details to clients | Map internal errors to safe client-facing codes |
|
|
135
|
+
| Skip rate limiting on public APIs | Define rate limits before deployment |
|
|
136
|
+
| Version after breaking changes occur | Define versioning strategy before first endpoint |
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## 📑 Content Map
|
|
141
|
+
|
|
142
|
+
| File | Description | When to Read |
|
|
143
|
+
|------|-------------|--------------|
|
|
144
|
+
| [api-style.md](rules/api-style.md) | REST vs GraphQL vs tRPC decision tree | Choosing API type |
|
|
145
|
+
| [rest.md](rules/rest.md) | Resource naming, HTTP methods, status codes | REST API design |
|
|
146
|
+
| [response.md](rules/response.md) | Envelope pattern, error format, pagination | Response structure |
|
|
147
|
+
| [graphql.md](rules/graphql.md) | Schema design, security, when to use | GraphQL consideration |
|
|
148
|
+
| [trpc.md](rules/trpc.md) | TypeScript monorepo, type safety | TS fullstack projects |
|
|
149
|
+
| [versioning.md](rules/versioning.md) | URI/Header/Query versioning strategies | API evolution |
|
|
150
|
+
| [auth.md](rules/auth.md) | JWT, OAuth, Passkey, API Keys | Auth selection |
|
|
151
|
+
| [rate-limiting.md](rules/rate-limiting.md) | Token bucket, sliding window | API protection |
|
|
152
|
+
| [documentation.md](rules/documentation.md) | OpenAPI/Swagger standards | API documentation |
|
|
153
|
+
| [security-testing.md](rules/security-testing.md) | OWASP API Top 10, auth/authz testing | Security audits |
|
|
154
|
+
| [engineering-spec.md](rules/engineering-spec.md) | Full engineering spec: contracts, security, scalability | Architecture review |
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## Script
|
|
159
|
+
|
|
160
|
+
| Script | Purpose | Command |
|
|
161
|
+
|--------|---------|---------|
|
|
162
|
+
| `scripts/api_validator.ts` | API endpoint validation | `node scripts/api_validator.ts <project_path>` |
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## 🔗 Related
|
|
167
|
+
|
|
168
|
+
| Item | Type | Purpose |
|
|
169
|
+
|------|------|---------|
|
|
170
|
+
| `data-modeler` | Skill | Database schema design for API data |
|
|
171
|
+
| `security-scanner` | Skill | Security vulnerability scanning |
|
|
172
|
+
| `auth-patterns` | Skill | Authentication implementation patterns |
|
|
173
|
+
| `nodejs-pro` | Skill | Node.js API implementation |
|
|
174
|
+
| `/api` | Workflow | Full API build workflow |
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## Detailed Rules
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
### Rule: api-style
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
name: api-style
|
|
191
|
+
description: REST vs GraphQL vs tRPC decision tree with code comparisons
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
# API Style Selection
|
|
195
|
+
|
|
196
|
+
> Choose API style for THIS project's context — don't default to REST.
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## Decision Tree
|
|
201
|
+
|
|
202
|
+
```
|
|
203
|
+
Who are the API consumers?
|
|
204
|
+
│
|
|
205
|
+
├── Public API / Multiple platforms
|
|
206
|
+
│ └── REST + OpenAPI (widest compatibility)
|
|
207
|
+
│
|
|
208
|
+
├── Complex data needs / Multiple frontends
|
|
209
|
+
│ └── GraphQL (flexible queries)
|
|
210
|
+
│
|
|
211
|
+
├── TypeScript frontend + backend (monorepo)
|
|
212
|
+
│ └── tRPC (end-to-end type safety)
|
|
213
|
+
│
|
|
214
|
+
├── Real-time / Event-driven
|
|
215
|
+
│ └── WebSocket + AsyncAPI
|
|
216
|
+
│
|
|
217
|
+
└── Internal microservices
|
|
218
|
+
└── gRPC (performance) or REST (simplicity)
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## Comparison
|
|
222
|
+
|
|
223
|
+
| Factor | REST | GraphQL | tRPC |
|
|
224
|
+
|--------|------|---------|------|
|
|
225
|
+
| **Best for** | Public APIs | Complex apps | TS monorepos |
|
|
226
|
+
| **Learning curve** | Low | Medium | Low (if TS) |
|
|
227
|
+
| **Over/under fetching** | Common | Solved | Solved |
|
|
228
|
+
| **Type safety** | Manual (OpenAPI) | Schema-based | Automatic |
|
|
229
|
+
| **Caching** | HTTP native | Complex | Client-based |
|
|
230
|
+
| **File uploads** | Native | Complex | Needs adapter |
|
|
231
|
+
| **Versioning** | URI/Header | Schema evolution | Type inference |
|
|
232
|
+
| **Tooling maturity** | Excellent | Good | Growing |
|
|
233
|
+
|
|
234
|
+
## Code Comparison — Same Endpoint
|
|
235
|
+
|
|
236
|
+
### REST
|
|
237
|
+
|
|
238
|
+
```typescript
|
|
239
|
+
// GET /api/users/123
|
|
240
|
+
app.get('/api/users/:id', async (req, res) => {
|
|
241
|
+
const user = await db.user.findUnique({ where: { id: req.params.id } });
|
|
242
|
+
res.json({ data: user });
|
|
243
|
+
});
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### GraphQL
|
|
247
|
+
|
|
248
|
+
```typescript
|
|
249
|
+
// query { user(id: "123") { name email } }
|
|
250
|
+
const resolvers = {
|
|
251
|
+
Query: {
|
|
252
|
+
user: (_: unknown, { id }: { id: string }) =>
|
|
253
|
+
db.user.findUnique({ where: { id } }),
|
|
254
|
+
},
|
|
255
|
+
};
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### tRPC
|
|
259
|
+
|
|
260
|
+
```typescript
|
|
261
|
+
// client.user.getById.query("123")
|
|
262
|
+
export const userRouter = router({
|
|
263
|
+
getById: publicProcedure
|
|
264
|
+
.input(z.string())
|
|
265
|
+
.query(({ input }) => db.user.findUnique({ where: { id: input } })),
|
|
266
|
+
});
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
## Anti-Patterns
|
|
270
|
+
|
|
271
|
+
| ❌ Don't | ✅ Do |
|
|
272
|
+
|---------|-------|
|
|
273
|
+
| Default to REST for every project | Evaluate consumers + context first |
|
|
274
|
+
| Mix API styles without justification | Pick one, document reasoning |
|
|
275
|
+
| Choose GraphQL for simple CRUD | Use REST or tRPC for simple cases |
|
|
276
|
+
| Use tRPC for public APIs | Use REST + OpenAPI for public APIs |
|
|
277
|
+
|
|
278
|
+
## Selection Questions
|
|
279
|
+
|
|
280
|
+
1. Who are the API consumers? (web, mobile, third-party, internal)
|
|
281
|
+
2. Is the frontend TypeScript?
|
|
282
|
+
3. How complex are the data relationships?
|
|
283
|
+
4. Is HTTP caching critical?
|
|
284
|
+
5. Public or internal API?
|
|
285
|
+
|
|
286
|
+
---
|
|
287
|
+
|
|
288
|
+
## 🔗 Related
|
|
289
|
+
|
|
290
|
+
| File | When to Read |
|
|
291
|
+
|------|-------------|
|
|
292
|
+
| [rest.md](rest.md) | REST endpoint design |
|
|
293
|
+
| [graphql.md](graphql.md) | GraphQL schema design |
|
|
294
|
+
| [trpc.md](trpc.md) | tRPC for TS monorepos |
|
|
295
|
+
| [SKILL.md](../SKILL.md) | Full decision framework |
|
|
296
|
+
|
|
297
|
+
---
|
|
298
|
+
|
|
299
|
+
### Rule: auth
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
name: auth
|
|
303
|
+
description: API authentication patterns — JWT, OAuth2 PKCE, API Keys, Passkeys, token refresh
|
|
304
|
+
---
|
|
305
|
+
|
|
306
|
+
# Authentication Patterns
|
|
307
|
+
|
|
308
|
+
> Choose auth pattern based on consumers and security requirements.
|
|
309
|
+
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
## Selection Guide
|
|
313
|
+
|
|
314
|
+
| Pattern | Best For | Security Level |
|
|
315
|
+
|---------|----------|:--------------:|
|
|
316
|
+
| **JWT** | Stateless APIs, microservices | Medium |
|
|
317
|
+
| **Session** | Traditional web, server-rendered | High |
|
|
318
|
+
| **OAuth 2.0 PKCE** | Third-party login, SPA/mobile | High |
|
|
319
|
+
| **API Keys** | Server-to-server, public APIs | Low-Medium |
|
|
320
|
+
| **Passkey** | Modern passwordless (2025+) | Very High |
|
|
321
|
+
|
|
322
|
+
## JWT Pattern
|
|
323
|
+
|
|
324
|
+
```typescript
|
|
325
|
+
import jwt from 'jsonwebtoken';
|
|
326
|
+
|
|
327
|
+
// Sign — keep payload minimal
|
|
328
|
+
function signTokens(userId: string) {
|
|
329
|
+
const accessToken = jwt.sign(
|
|
330
|
+
{ sub: userId, type: 'access' },
|
|
331
|
+
process.env.JWT_SECRET!,
|
|
332
|
+
{ expiresIn: '15m' } // Short-lived
|
|
333
|
+
);
|
|
334
|
+
|
|
335
|
+
const refreshToken = jwt.sign(
|
|
336
|
+
{ sub: userId, type: 'refresh' },
|
|
337
|
+
process.env.JWT_REFRESH_SECRET!,
|
|
338
|
+
{ expiresIn: '7d' }
|
|
339
|
+
);
|
|
340
|
+
|
|
341
|
+
return { accessToken, refreshToken };
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// Verify middleware
|
|
345
|
+
function authMiddleware(req: Request, res: Response, next: NextFunction) {
|
|
346
|
+
const token = req.headers.authorization?.replace('Bearer ', '');
|
|
347
|
+
if (!token) return res.status(401).json({ error: 'Missing token' });
|
|
348
|
+
|
|
349
|
+
try {
|
|
350
|
+
const payload = jwt.verify(token, process.env.JWT_SECRET!);
|
|
351
|
+
req.user = payload as JwtPayload;
|
|
352
|
+
next();
|
|
353
|
+
} catch {
|
|
354
|
+
res.status(401).json({ error: 'Invalid or expired token' });
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
## Token Refresh Flow
|
|
360
|
+
|
|
361
|
+
```
|
|
362
|
+
Client Server
|
|
363
|
+
│ │
|
|
364
|
+
├── Request + Access Token ──→ │
|
|
365
|
+
│ ├── Verify token
|
|
366
|
+
│ ←── 401 Token Expired ──────┤
|
|
367
|
+
│ │
|
|
368
|
+
├── POST /auth/refresh ──────→ │
|
|
369
|
+
│ { refreshToken } ├── Verify refresh token
|
|
370
|
+
│ ├── Issue new access + refresh
|
|
371
|
+
│ ←── { accessToken, │
|
|
372
|
+
│ refreshToken } ───────┤
|
|
373
|
+
│ │
|
|
374
|
+
├── Retry original request ──→ │
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
## OAuth 2.0 PKCE (for SPAs/Mobile)
|
|
378
|
+
|
|
379
|
+
```typescript
|
|
380
|
+
// 1. Generate PKCE challenge
|
|
381
|
+
const codeVerifier = crypto.randomBytes(32).toString('base64url');
|
|
382
|
+
const codeChallenge = crypto
|
|
383
|
+
.createHash('sha256')
|
|
384
|
+
.update(codeVerifier)
|
|
385
|
+
.digest('base64url');
|
|
386
|
+
|
|
387
|
+
// 2. Redirect to provider
|
|
388
|
+
const authUrl = `https://provider.com/authorize?` +
|
|
389
|
+
`client_id=${CLIENT_ID}&` +
|
|
390
|
+
`code_challenge=${codeChallenge}&` +
|
|
391
|
+
`code_challenge_method=S256&` +
|
|
392
|
+
`redirect_uri=${REDIRECT_URI}&` +
|
|
393
|
+
`response_type=code&scope=openid+email`;
|
|
394
|
+
|
|
395
|
+
// 3. Exchange code for tokens (server-side)
|
|
396
|
+
const tokens = await fetch('https://provider.com/token', {
|
|
397
|
+
method: 'POST',
|
|
398
|
+
body: new URLSearchParams({
|
|
399
|
+
grant_type: 'authorization_code',
|
|
400
|
+
code: authorizationCode,
|
|
401
|
+
code_verifier: codeVerifier,
|
|
402
|
+
client_id: CLIENT_ID,
|
|
403
|
+
redirect_uri: REDIRECT_URI,
|
|
404
|
+
}),
|
|
405
|
+
});
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
## Anti-Patterns
|
|
409
|
+
|
|
410
|
+
| ❌ Don't | ✅ Do |
|
|
411
|
+
|---------|-------|
|
|
412
|
+
| Store sensitive data in JWT payload | Include only `sub`, `type`, `exp` |
|
|
413
|
+
| Use long-lived access tokens (>1h) | Short access (15m) + refresh (7d) |
|
|
414
|
+
| Send tokens in URL query params | Use `Authorization: Bearer` header |
|
|
415
|
+
| Use OAuth implicit flow | Use PKCE for SPAs and mobile |
|
|
416
|
+
| Skip token revocation | Maintain a revocation list for refresh tokens |
|
|
417
|
+
|
|
418
|
+
---
|
|
419
|
+
|
|
420
|
+
## 🔗 Related
|
|
421
|
+
|
|
422
|
+
| File | When to Read |
|
|
423
|
+
|------|-------------|
|
|
424
|
+
| [security-testing.md](security-testing.md) | Auth testing patterns |
|
|
425
|
+
| [rate-limiting.md](rate-limiting.md) | Rate limit auth endpoints |
|
|
426
|
+
| [SKILL.md](../SKILL.md) | Full decision framework |
|
|
427
|
+
|
|
428
|
+
---
|
|
429
|
+
|
|
430
|
+
### Rule: documentation
|
|
431
|
+
|
|
432
|
+
---
|
|
433
|
+
name: documentation
|
|
434
|
+
description: OpenAPI 3.1 specs, Swagger UI setup, API documentation best practices
|
|
435
|
+
---
|
|
436
|
+
|
|
437
|
+
# API Documentation Principles
|
|
438
|
+
|
|
439
|
+
> Good docs = happy developers = API adoption.
|
|
440
|
+
|
|
441
|
+
---
|
|
442
|
+
|
|
443
|
+
## OpenAPI 3.1 Example
|
|
444
|
+
|
|
445
|
+
```yaml
|
|
446
|
+
openapi: 3.1.0
|
|
447
|
+
info:
|
|
448
|
+
title: Users API
|
|
449
|
+
version: 1.0.0
|
|
450
|
+
description: User management endpoints
|
|
451
|
+
|
|
452
|
+
paths:
|
|
453
|
+
/users:
|
|
454
|
+
get:
|
|
455
|
+
summary: List users
|
|
456
|
+
operationId: listUsers
|
|
457
|
+
parameters:
|
|
458
|
+
- name: page
|
|
459
|
+
in: query
|
|
460
|
+
schema: { type: integer, default: 1 }
|
|
461
|
+
- name: limit
|
|
462
|
+
in: query
|
|
463
|
+
schema: { type: integer, default: 20, maximum: 100 }
|
|
464
|
+
responses:
|
|
465
|
+
'200':
|
|
466
|
+
description: Paginated user list
|
|
467
|
+
content:
|
|
468
|
+
application/json:
|
|
469
|
+
schema:
|
|
470
|
+
$ref: '#/components/schemas/UserListResponse'
|
|
471
|
+
|
|
472
|
+
post:
|
|
473
|
+
summary: Create user
|
|
474
|
+
operationId: createUser
|
|
475
|
+
requestBody:
|
|
476
|
+
required: true
|
|
477
|
+
content:
|
|
478
|
+
application/json:
|
|
479
|
+
schema:
|
|
480
|
+
$ref: '#/components/schemas/CreateUserInput'
|
|
481
|
+
responses:
|
|
482
|
+
'201':
|
|
483
|
+
description: User created
|
|
484
|
+
'422':
|
|
485
|
+
description: Validation error
|
|
486
|
+
content:
|
|
487
|
+
application/json:
|
|
488
|
+
schema:
|
|
489
|
+
$ref: '#/components/schemas/ErrorResponse'
|
|
490
|
+
|
|
491
|
+
components:
|
|
492
|
+
schemas:
|
|
493
|
+
User:
|
|
494
|
+
type: object
|
|
495
|
+
properties:
|
|
496
|
+
id: { type: string, format: uuid }
|
|
497
|
+
name: { type: string }
|
|
498
|
+
email: { type: string, format: email }
|
|
499
|
+
required: [id, name, email]
|
|
500
|
+
|
|
501
|
+
ErrorResponse:
|
|
502
|
+
type: object
|
|
503
|
+
properties:
|
|
504
|
+
success: { type: boolean, enum: [false] }
|
|
505
|
+
error:
|
|
506
|
+
type: object
|
|
507
|
+
properties:
|
|
508
|
+
code: { type: string }
|
|
509
|
+
message: { type: string }
|
|
510
|
+
requestId: { type: string }
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
## Swagger UI Setup (Express)
|
|
514
|
+
|
|
515
|
+
```typescript
|
|
516
|
+
import swaggerUi from 'swagger-ui-express';
|
|
517
|
+
import spec from './openapi.json';
|
|
518
|
+
|
|
519
|
+
app.use('/docs', swaggerUi.serve, swaggerUi.setup(spec, {
|
|
520
|
+
customCss: '.swagger-ui .topbar { display: none }',
|
|
521
|
+
customSiteTitle: 'API Documentation',
|
|
522
|
+
}));
|
|
523
|
+
```
|
|
524
|
+
|
|
525
|
+
## Good Documentation Includes
|
|
526
|
+
|
|
527
|
+
| Section | Purpose |
|
|
528
|
+
|---------|---------|
|
|
529
|
+
| **Quick Start** | Get running in 5 minutes |
|
|
530
|
+
| **Authentication** | How to get and use tokens |
|
|
531
|
+
| **API Reference** | Every endpoint with examples |
|
|
532
|
+
| **Error Handling** | Error codes and recovery |
|
|
533
|
+
| **Rate Limits** | Limits and headers |
|
|
534
|
+
| **Changelog** | Breaking changes and deprecations |
|
|
535
|
+
| **Code Examples** | Multiple languages (curl, JS, Python) |
|
|
536
|
+
|
|
537
|
+
## Anti-Patterns
|
|
538
|
+
|
|
539
|
+
| ❌ Don't | ✅ Do |
|
|
540
|
+
|---------|-------|
|
|
541
|
+
| Write docs after shipping | Generate from OpenAPI spec |
|
|
542
|
+
| Skip request/response examples | Include full JSON examples |
|
|
543
|
+
| Documentation-only errors | Use consistent error schema |
|
|
544
|
+
| Outdated examples | Auto-generate from tests |
|
|
545
|
+
|
|
546
|
+
---
|
|
547
|
+
|
|
548
|
+
## 🔗 Related
|
|
549
|
+
|
|
550
|
+
| File | When to Read |
|
|
551
|
+
|------|-------------|
|
|
552
|
+
| [response.md](response.md) | Response format for docs |
|
|
553
|
+
| [versioning.md](versioning.md) | Documenting API versions |
|
|
554
|
+
| [SKILL.md](../SKILL.md) | Full decision framework |
|
|
555
|
+
|
|
556
|
+
---
|
|
557
|
+
|
|
558
|
+
### Rule: engineering-spec
|
|
559
|
+
|
|
560
|
+
---
|
|
561
|
+
title: API Architect — Engineering Specification
|
|
562
|
+
impact: MEDIUM
|
|
563
|
+
tags: api-architect
|
|
564
|
+
---
|
|
565
|
+
|
|
566
|
+
# API Architect — Engineering Specification
|
|
567
|
+
|
|
568
|
+
> Production-grade specification for API design decision-making and pattern selection at FAANG scale.
|
|
569
|
+
|
|
570
|
+
---
|
|
571
|
+
|
|
572
|
+
## 1. Overview
|
|
573
|
+
|
|
574
|
+
API Architect provides structured decision frameworks for API design: style selection (REST vs GraphQL vs tRPC), response formats, versioning strategies, authentication patterns, rate limiting, and documentation standards. The skill operates as an expert knowledge base that produces architectural decisions and API specifications, not runtime code.
|
|
575
|
+
|
|
576
|
+
The skill codifies API design into deterministic decision trees backed by 10 reference documents covering style selection, REST patterns, GraphQL, tRPC, response formats, versioning, auth, rate limiting, documentation, and security testing.
|
|
577
|
+
|
|
578
|
+
---
|
|
579
|
+
|
|
580
|
+
## 2. Problem Statement
|
|
581
|
+
|
|
582
|
+
API design at scale faces four quantified problems:
|
|
583
|
+
|
|
584
|
+
| Problem | Measurement | Impact |
|
|
585
|
+
|---------|-------------|--------|
|
|
586
|
+
| Wrong API style selection | REST chosen for 100% of projects regardless of context | Unnecessary complexity for internal TS monorepos; insufficient for complex data graphs |
|
|
587
|
+
| Inconsistent response formats | Different envelope patterns across endpoints within same API | Client-side parsing failures, increased integration cost |
|
|
588
|
+
| No versioning strategy | Breaking changes deployed without versioning | Client breakage, forced upgrades, SLA violations |
|
|
589
|
+
| Security gaps in API design | OWASP API Top 10 violations in 60%+ of first-design APIs | Vulnerability exposure, compliance failures |
|
|
590
|
+
|
|
591
|
+
API Architect eliminates these by providing context-aware decision trees that produce documented, justified API design choices.
|
|
592
|
+
|
|
593
|
+
---
|
|
594
|
+
|
|
595
|
+
## 3. Design Goals
|
|
596
|
+
|
|
597
|
+
| ID | Goal | Measurable Constraint |
|
|
598
|
+
|----|------|-----------------------|
|
|
599
|
+
| G1 | Context-aware style selection | Decision tree produces one of REST/GraphQL/tRPC based on ≤ 5 input criteria |
|
|
600
|
+
| G2 | Consistent response format | Single envelope pattern per API; format documented before first endpoint |
|
|
601
|
+
| G3 | Versioning from day one | Versioning strategy defined and documented before API implementation begins |
|
|
602
|
+
| G4 | Security-first design | OWASP API Top 10 checklist completed before API goes to production |
|
|
603
|
+
| G5 | Decision traceability | Every design choice includes rationale that references project context |
|
|
604
|
+
|
|
605
|
+
---
|
|
606
|
+
|
|
607
|
+
## 4. Non-Goals
|
|
608
|
+
|
|
609
|
+
| ID | Excluded | Rationale |
|
|
610
|
+
|----|----------|-----------|
|
|
611
|
+
| NG1 | API implementation / code generation | This skill produces design decisions, not code; implementation is `backend-specialist` territory |
|
|
612
|
+
| NG2 | Runtime API validation | Owned by `scripts/api_validator.ts`; SKILL.md defines design-time patterns |
|
|
613
|
+
| NG3 | Database schema design | Owned by `data-modeler` skill |
|
|
614
|
+
| NG4 | Authentication implementation | Owned by `auth-patterns` skill; this skill selects auth strategy |
|
|
615
|
+
| NG5 | Infrastructure / deployment | Owned by `server-ops` and `cicd-pipeline` skills |
|
|
616
|
+
| NG6 | Client-side API consumption | Out of scope; this skill designs the API surface, not its consumers |
|
|
617
|
+
|
|
618
|
+
---
|
|
619
|
+
|
|
620
|
+
## 5. System Boundaries
|
|
621
|
+
|
|
622
|
+
| Boundary | Owned | Not Owned |
|
|
623
|
+
|----------|-------|-----------|
|
|
624
|
+
| API style selection | REST/GraphQL/tRPC decision tree | Implementation framework selection |
|
|
625
|
+
| Response format design | Envelope pattern, error format, pagination | Serialization libraries |
|
|
626
|
+
| Versioning strategy | URI/Header/Query versioning decision | Version deployment mechanics |
|
|
627
|
+
| Auth pattern selection | JWT/OAuth/Passkey/API Key decision | Auth implementation (→ auth-patterns) |
|
|
628
|
+
| Rate limiting strategy | Token bucket/sliding window selection | Rate limiter implementation |
|
|
629
|
+
| API documentation | OpenAPI/Swagger structure standards | Doc hosting/rendering |
|
|
630
|
+
| Security design | OWASP API Top 10 checklist | Penetration testing execution (→ security-scanner) |
|
|
631
|
+
|
|
632
|
+
**Side-effect boundary:** API Architect produces design documents, decision records, and API specifications. It does not create API endpoints, modify server configurations, or make network requests.
|
|
633
|
+
|
|
634
|
+
---
|
|
635
|
+
|
|
636
|
+
## 6. Integration Model
|
|
637
|
+
|
|
638
|
+
### 6.1 Agent Contract
|
|
639
|
+
|
|
640
|
+
#### Input Schema
|
|
641
|
+
|
|
642
|
+
```
|
|
643
|
+
Request_Type: string # One of: "style-selection" | "endpoint-design" | "response-format" |
|
|
644
|
+
# "versioning" | "auth-selection" | "rate-limiting" |
|
|
645
|
+
# "documentation" | "security-audit" | "full-design"
|
|
646
|
+
Context: {
|
|
647
|
+
project_type: string # "monorepo-ts" | "microservice" | "public-api" | "internal-api" | "bff"
|
|
648
|
+
consumers: Array<string> # ["web-spa", "mobile", "third-party", "internal-service", "cli"]
|
|
649
|
+
data_complexity: string # "simple-crud" | "relational" | "graph" | "real-time"
|
|
650
|
+
team_expertise: string # "typescript-fullstack" | "polyglot" | "backend-only"
|
|
651
|
+
scale: string # "prototype" | "startup" | "growth" | "enterprise"
|
|
652
|
+
existing_api: string | null # Existing API style if evolving, null if greenfield
|
|
653
|
+
constraints: Array<string> | null # ["no-graphql", "must-version", "public-facing"]
|
|
654
|
+
}
|
|
655
|
+
contract_version: string # "2.0.0"
|
|
656
|
+
```
|
|
657
|
+
|
|
658
|
+
#### Output Schema
|
|
659
|
+
|
|
660
|
+
```
|
|
661
|
+
Status: "success" | "error"
|
|
662
|
+
Data: {
|
|
663
|
+
decision: string # The selected pattern/approach
|
|
664
|
+
rationale: string # Context-specific justification (references input criteria)
|
|
665
|
+
reference_file: string # Path to the detailed reference document
|
|
666
|
+
checklist: Array<string> # Action items before implementation
|
|
667
|
+
anti_patterns: Array<string> # Context-specific things to avoid
|
|
668
|
+
related_decisions: Array<{topic: string, reference: string}> # Adjacent decisions to make
|
|
669
|
+
metadata: {
|
|
670
|
+
request_type: string
|
|
671
|
+
context_hash: string # Hash of input context for reproducibility
|
|
672
|
+
version: string # Skill version
|
|
673
|
+
contract_version: string # "2.0.0"
|
|
674
|
+
backward_compatibility: string # "breaking"
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
Error: ErrorSchema | null
|
|
678
|
+
```
|
|
679
|
+
|
|
680
|
+
**Contract Version:** 2.0.0
|
|
681
|
+
**Backward Compatibility:** breaking (first hardened version)
|
|
682
|
+
**Breaking Changes:** None — new spec for first hardening
|
|
683
|
+
|
|
684
|
+
#### Error Schema
|
|
685
|
+
|
|
686
|
+
```
|
|
687
|
+
Code: string # From Error Taxonomy (Section 11)
|
|
688
|
+
Message: string # Human-readable, single line
|
|
689
|
+
Request_Type: string
|
|
690
|
+
Recoverable: boolean
|
|
691
|
+
```
|
|
692
|
+
|
|
693
|
+
#### Deterministic Guarantees
|
|
694
|
+
|
|
695
|
+
- Same `Request_Type` + `Context` = identical `decision` + `rationale` output.
|
|
696
|
+
- Decision trees follow fixed evaluation order (project_type → consumers → data_complexity → team_expertise → scale).
|
|
697
|
+
- Reference file selection is deterministic based on request_type.
|
|
698
|
+
- No randomization, no A/B selection, no heuristic weighting.
|
|
699
|
+
|
|
700
|
+
#### What Agents May Assume
|
|
701
|
+
|
|
702
|
+
- Output `decision` is valid for the given `Context` and follows industry standards.
|
|
703
|
+
- `reference_file` points to a file that exists in the skill's `rules/` directory.
|
|
704
|
+
- `checklist` items are actionable and ordered by priority.
|
|
705
|
+
- The skill is stateless; no prior invocation affects current output.
|
|
706
|
+
|
|
707
|
+
#### What Agents Must NOT Assume
|
|
708
|
+
|
|
709
|
+
- The decision is the only valid choice (multiple valid API styles may exist for a given context).
|
|
710
|
+
- The decision accounts for undisclosed constraints (only explicit `Context` inputs affect output).
|
|
711
|
+
- Implementation details are included (the skill produces design decisions, not code).
|
|
712
|
+
- Security audit output replaces a full security review (it covers OWASP API Top 10, not exhaustive pen testing).
|
|
713
|
+
|
|
714
|
+
#### Side-Effect Boundaries
|
|
715
|
+
|
|
716
|
+
| Operation | Side Effects |
|
|
717
|
+
|-----------|-------------|
|
|
718
|
+
| Style selection | None; pure decision output |
|
|
719
|
+
| Endpoint design | None; specification output |
|
|
720
|
+
| Security audit | None; checklist output |
|
|
721
|
+
| Validator script | Read-only filesystem scan; no modifications |
|
|
722
|
+
|
|
723
|
+
### 6.2 Workflow Contract
|
|
724
|
+
|
|
725
|
+
#### Invocation Pattern
|
|
726
|
+
|
|
727
|
+
```
|
|
728
|
+
1. Define project context (type, consumers, complexity, scale)
|
|
729
|
+
2. Select request type (style-selection → response-format → versioning → auth → documentation)
|
|
730
|
+
3. Receive decision with rationale and checklist
|
|
731
|
+
4. Review and apply decision (caller's responsibility)
|
|
732
|
+
5. Run api_validator.ts for implementation validation (optional)
|
|
733
|
+
6. Repeat for adjacent decisions referenced in related_decisions
|
|
734
|
+
```
|
|
735
|
+
|
|
736
|
+
**Recommended ordering:** style-selection → endpoint-design → response-format → versioning → auth-selection → rate-limiting → documentation → security-audit.
|
|
737
|
+
|
|
738
|
+
#### Execution Guarantees
|
|
739
|
+
|
|
740
|
+
- Each invocation produces a complete, self-contained decision.
|
|
741
|
+
- No background processes, no deferred execution.
|
|
742
|
+
- Output includes all necessary context for the caller to act without re-invoking.
|
|
743
|
+
|
|
744
|
+
#### Failure Propagation Model
|
|
745
|
+
|
|
746
|
+
| Failure Severity | Propagation | Workflow Action |
|
|
747
|
+
|-----------------|-------------|-----------------|
|
|
748
|
+
| Invalid request type | Return error to caller | Use supported request type |
|
|
749
|
+
| Missing context field | Return error to caller | Supply missing context |
|
|
750
|
+
| Conflicting constraints | Return error to caller | Resolve constraint conflict |
|
|
751
|
+
| Reference file missing | Return error to caller | Verify skill installation |
|
|
752
|
+
|
|
753
|
+
Failures are isolated to the current invocation. No state carries between invocations.
|
|
754
|
+
|
|
755
|
+
#### Retry Boundaries
|
|
756
|
+
|
|
757
|
+
- Zero internal retries. Deterministic output makes retrying identical inputs meaningless.
|
|
758
|
+
- Callers should modify `Context` between invocations to explore alternative decisions.
|
|
759
|
+
|
|
760
|
+
#### Isolation Model
|
|
761
|
+
|
|
762
|
+
- Each invocation is stateless and independent.
|
|
763
|
+
- No shared state between invocations, sessions, or agents.
|
|
764
|
+
- Reference files in `rules/` are read-only resources.
|
|
765
|
+
|
|
766
|
+
#### Idempotency Expectations
|
|
767
|
+
|
|
768
|
+
| Operation | Idempotent | Notes |
|
|
769
|
+
|-----------|-----------|-------|
|
|
770
|
+
| Decision generation | Yes | Same context = same decision |
|
|
771
|
+
| Reference lookup | Yes | Read-only, no mutation |
|
|
772
|
+
| Validator script | Yes | Read-only filesystem scan |
|
|
773
|
+
|
|
774
|
+
---
|
|
775
|
+
|
|
776
|
+
## 7. Execution Model
|
|
777
|
+
|
|
778
|
+
### 4-Phase Lifecycle
|
|
779
|
+
|
|
780
|
+
| Phase | Action | Output |
|
|
781
|
+
|-------|--------|--------|
|
|
782
|
+
| **Classify** | Validate request type and context | Validated input or error |
|
|
783
|
+
| **Evaluate** | Traverse decision tree for request type | Selected pattern with rationale |
|
|
784
|
+
| **Enrich** | Attach checklist, anti-patterns, related decisions | Complete decision package |
|
|
785
|
+
| **Emit** | Return structured output with metadata | Complete output schema |
|
|
786
|
+
|
|
787
|
+
All phases execute synchronously in a single invocation. No async pipeline.
|
|
788
|
+
|
|
789
|
+
---
|
|
790
|
+
|
|
791
|
+
## 8. Deterministic Design Principles
|
|
792
|
+
|
|
793
|
+
| Principle | Enforcement |
|
|
794
|
+
|-----------|-------------|
|
|
795
|
+
| Fixed decision tree ordering | project_type → consumers → data_complexity → team_expertise → scale |
|
|
796
|
+
| No external calls | Decisions use only local reference files and input context |
|
|
797
|
+
| No ambient state | Each invocation operates solely on explicit inputs |
|
|
798
|
+
| No randomization | Decision trees are deterministic if-then-else chains |
|
|
799
|
+
| Reproducible output | Input context hash echoed in output for audit trail |
|
|
800
|
+
|
|
801
|
+
---
|
|
802
|
+
|
|
803
|
+
## 9. State & Idempotency Model
|
|
804
|
+
|
|
805
|
+
### State Machine
|
|
806
|
+
|
|
807
|
+
```
|
|
808
|
+
States: IDLE (single state — skill is stateless)
|
|
809
|
+
Transitions: None — each invocation is independent
|
|
810
|
+
```
|
|
811
|
+
|
|
812
|
+
API Architect maintains zero persistent state. Every invocation starts from a clean state. Invoking N times with identical inputs produces N identical outputs.
|
|
813
|
+
|
|
814
|
+
### Decision Versioning
|
|
815
|
+
|
|
816
|
+
- Decision trees are versioned via `metadata.version` in SKILL.md frontmatter.
|
|
817
|
+
- Reference file changes that alter decision outcomes require a version bump.
|
|
818
|
+
- Callers can reference specific versions for decision auditability.
|
|
819
|
+
|
|
820
|
+
---
|
|
821
|
+
|
|
822
|
+
## 10. Failure Handling Strategy
|
|
823
|
+
|
|
824
|
+
| Failure Class | Behavior | Caller Recovery |
|
|
825
|
+
|---------------|----------|-----------------|
|
|
826
|
+
| Unknown request type | Return `ERR_INVALID_REQUEST_TYPE` | Use supported request type |
|
|
827
|
+
| Missing context field | Return `ERR_MISSING_CONTEXT` with field name | Supply missing field |
|
|
828
|
+
| Conflicting constraints | Return `ERR_CONSTRAINT_CONFLICT` with conflicting items | Resolve conflict |
|
|
829
|
+
| Invalid consumer type | Return `ERR_INVALID_CONSUMER` | Use supported consumer type |
|
|
830
|
+
| Reference file missing | Return `ERR_REFERENCE_NOT_FOUND` | Verify skill installation |
|
|
831
|
+
| Validator script failure | Return `ERR_VALIDATOR_FAILED` with exit code | Check project path |
|
|
832
|
+
|
|
833
|
+
**Invariant:** Every failure returns a structured error. No invocation fails silently or returns partial decisions.
|
|
834
|
+
|
|
835
|
+
---
|
|
836
|
+
|
|
837
|
+
## 11. Error Taxonomy
|
|
838
|
+
|
|
839
|
+
| Code | Category | Recoverable | Description |
|
|
840
|
+
|------|----------|-------------|-------------|
|
|
841
|
+
| `ERR_INVALID_REQUEST_TYPE` | Validation | No | Request type not one of the 8 supported types |
|
|
842
|
+
| `ERR_MISSING_CONTEXT` | Validation | Yes | Required context field is null or empty |
|
|
843
|
+
| `ERR_CONSTRAINT_CONFLICT` | Validation | Yes | Two constraints contradict each other |
|
|
844
|
+
| `ERR_INVALID_CONSUMER` | Validation | Yes | Consumer type not recognized |
|
|
845
|
+
| `ERR_REFERENCE_NOT_FOUND` | Infrastructure | No | Reference file missing from rules/ directory |
|
|
846
|
+
| `ERR_VALIDATOR_FAILED` | Runtime | Yes | api_validator.ts exited with non-zero code |
|
|
847
|
+
| `ERR_INVALID_SCALE` | Validation | No | Scale value not one of: prototype, startup, growth, enterprise |
|
|
848
|
+
|
|
849
|
+
---
|
|
850
|
+
|
|
851
|
+
## 12. Timeout & Retry Policy
|
|
852
|
+
|
|
853
|
+
| Parameter | Value | Rationale |
|
|
854
|
+
|-----------|-------|-----------|
|
|
855
|
+
| Decision generation timeout | N/A | Synchronous decision tree traversal; completes in < 50ms |
|
|
856
|
+
| Internal retries | Zero | Deterministic output makes retries meaningless |
|
|
857
|
+
| Validator script timeout | 30,000 ms | Filesystem scan; fail if project is inaccessible |
|
|
858
|
+
| Reference file read timeout | 1,000 ms | Local filesystem; fail immediately if inaccessible |
|
|
859
|
+
|
|
860
|
+
**Retry policy:** Zero internal retries. Callers should modify context between invocations to explore alternatives.
|
|
861
|
+
|
|
862
|
+
---
|
|
863
|
+
|
|
864
|
+
## 13. Observability & Logging Schema
|
|
865
|
+
|
|
866
|
+
### Log Entry Format
|
|
867
|
+
|
|
868
|
+
```json
|
|
869
|
+
{
|
|
870
|
+
"trace_id": "uuid",
|
|
871
|
+
"skill_name": "api-architect",
|
|
872
|
+
"contract_version": "2.0.0",
|
|
873
|
+
"execution_id": "uuid",
|
|
874
|
+
"timestamp": "ISO-8601",
|
|
875
|
+
"request_type": "string",
|
|
876
|
+
"decision": "string",
|
|
877
|
+
"context_hash": "string",
|
|
878
|
+
"status": "success|error",
|
|
879
|
+
"error_code": "string|null",
|
|
880
|
+
"reference_files_read": ["string"],
|
|
881
|
+
"duration_ms": "number"
|
|
882
|
+
}
|
|
883
|
+
```
|
|
884
|
+
|
|
885
|
+
### Required Log Points
|
|
886
|
+
|
|
887
|
+
| Event | Log Level | Fields |
|
|
888
|
+
|-------|-----------|--------|
|
|
889
|
+
| Decision generated | INFO | All fields |
|
|
890
|
+
| Decision failed | ERROR | All fields + error_code |
|
|
891
|
+
| Reference file read | DEBUG | file path, read duration |
|
|
892
|
+
| Constraint conflict detected | WARN | conflicting constraints |
|
|
893
|
+
| Validator script executed | INFO | project_path, exit_code, duration |
|
|
894
|
+
|
|
895
|
+
### Metrics
|
|
896
|
+
|
|
897
|
+
| Metric | Type | Unit |
|
|
898
|
+
|--------|------|------|
|
|
899
|
+
| `api.decision.duration` | Histogram | ms |
|
|
900
|
+
| `api.decision.error_rate` | Counter | per error_code |
|
|
901
|
+
| `api.request_type.usage` | Counter | per request_type |
|
|
902
|
+
| `api.style.selected` | Counter | per style (REST/GraphQL/tRPC) |
|
|
903
|
+
| `api.validator.duration` | Histogram | ms |
|
|
904
|
+
| `api.validator.pass_rate` | Counter | pass/fail |
|
|
905
|
+
|
|
906
|
+
---
|
|
907
|
+
|
|
908
|
+
## 14. Security & Trust Model
|
|
909
|
+
|
|
910
|
+
### Design-Time Security
|
|
911
|
+
|
|
912
|
+
- API Architect enforces OWASP API Top 10 awareness through the `security-audit` request type.
|
|
913
|
+
- Security checklist is generated before API implementation, not after.
|
|
914
|
+
- Auth pattern selection references `rules/auth.md` for current industry standards.
|
|
915
|
+
|
|
916
|
+
### Credential Handling
|
|
917
|
+
|
|
918
|
+
- API Architect does not store, process, or transmit credentials.
|
|
919
|
+
- Auth pattern selection produces strategy recommendations, not credential configurations.
|
|
920
|
+
|
|
921
|
+
### Reference Integrity
|
|
922
|
+
|
|
923
|
+
- Reference files in `rules/` are read-only resources.
|
|
924
|
+
- Modifications require a version bump in SKILL.md frontmatter.
|
|
925
|
+
- No runtime code injection; reference files are static markdown, not executable.
|
|
926
|
+
|
|
927
|
+
### Input Sanitization
|
|
928
|
+
|
|
929
|
+
- Context parameters are used for decision tree traversal, not code execution.
|
|
930
|
+
- No eval, no template injection, no dynamic code generation from inputs.
|
|
931
|
+
|
|
932
|
+
### Multi-Tenant Boundaries
|
|
933
|
+
|
|
934
|
+
- Each invocation is stateless; no data persists between invocations.
|
|
935
|
+
- No invocation can access context or outputs from another invocation.
|
|
936
|
+
|
|
937
|
+
---
|
|
938
|
+
|
|
939
|
+
## 15. Scalability Model
|
|
940
|
+
|
|
941
|
+
| Dimension | Constraint | Mitigation |
|
|
942
|
+
|-----------|-----------|------------|
|
|
943
|
+
| Throughput | CPU-bound decision tree traversal | Completes in < 50ms; scales linearly with CPU |
|
|
944
|
+
| Concurrency | Stateless invocations | Unlimited parallel invocations |
|
|
945
|
+
| Reference storage | 10 rule files (~12 KB total) | Static files; no growth concern |
|
|
946
|
+
| Memory per invocation | < 1 MB | No accumulation |
|
|
947
|
+
| Network | Zero network calls (except validator against local filesystem) | No external dependency |
|
|
948
|
+
|
|
949
|
+
### Capacity Planning
|
|
950
|
+
|
|
951
|
+
| Metric | Per Invocation | Per Node |
|
|
952
|
+
|--------|---------------|----------|
|
|
953
|
+
| CPU | < 10 ms computation | 100,000+ invocations/second |
|
|
954
|
+
| Memory | < 1 MB | Bound only by concurrent invocations |
|
|
955
|
+
| Disk I/O | 1–2 rule file reads (~1–3 KB each) | Cached by OS after first read |
|
|
956
|
+
| Network | Zero | Zero |
|
|
957
|
+
|
|
958
|
+
---
|
|
959
|
+
|
|
960
|
+
## 16. Concurrency Model
|
|
961
|
+
|
|
962
|
+
| Scope | Model | Behavior |
|
|
963
|
+
|-------|-------|----------|
|
|
964
|
+
| Within invocation | Sequential | Classify → Evaluate → Enrich → Emit |
|
|
965
|
+
| Across invocations | Fully parallel | No shared state, no coordination |
|
|
966
|
+
| Reference access | Read-only shared | Multiple concurrent reads safe |
|
|
967
|
+
| Validator script | Isolated per invocation | Each run scans independently |
|
|
968
|
+
|
|
969
|
+
**No undefined behavior:** Stateless skill with read-only resource access; any concurrency level is safe.
|
|
970
|
+
|
|
971
|
+
---
|
|
972
|
+
|
|
973
|
+
## 17. Resource Lifecycle Management
|
|
974
|
+
|
|
975
|
+
| Resource | Created By | Destroyed By | Max Lifetime |
|
|
976
|
+
|----------|-----------|-------------|--------------|
|
|
977
|
+
| Decision output | Emit phase | Caller (after consumption) | Invocation scope |
|
|
978
|
+
| Rule file handle | Evaluate phase | Auto-close after read | < 10 ms |
|
|
979
|
+
| Validator process | Caller (script invocation) | Process exit | 30,000 ms max |
|
|
980
|
+
| Input context | Caller | Invocation completion | Invocation scope |
|
|
981
|
+
|
|
982
|
+
**Leak prevention:** All resources scoped to single invocation. Validator script is a separate process with its own lifecycle.
|
|
983
|
+
|
|
984
|
+
---
|
|
985
|
+
|
|
986
|
+
## 18. Performance Constraints
|
|
987
|
+
|
|
988
|
+
| Operation | P50 Target | P99 Target | Hard Limit |
|
|
989
|
+
|-----------|-----------|-----------|------------|
|
|
990
|
+
| Decision generation | < 5 ms | < 20 ms | 50 ms |
|
|
991
|
+
| Rule file read | < 1 ms | < 5 ms | 1,000 ms |
|
|
992
|
+
| Full design (8 request types) | < 40 ms | < 160 ms | 400 ms |
|
|
993
|
+
| Validator script execution | < 5,000 ms | < 15,000 ms | 30,000 ms |
|
|
994
|
+
| Output decision size | ≤ 500 chars | ≤ 2,000 chars | 5,000 chars |
|
|
995
|
+
|
|
996
|
+
---
|
|
997
|
+
|
|
998
|
+
## 19. Operational Risks
|
|
999
|
+
|
|
1000
|
+
| Risk | Likelihood | Impact | Mitigation |
|
|
1001
|
+
|------|-----------|--------|------------|
|
|
1002
|
+
| Decision tree staleness | Medium | Recommends outdated patterns | Version bumps with periodic review; rules/ files track dates |
|
|
1003
|
+
| Context under-specification | High | Generic decision instead of context-specific | `ERR_MISSING_CONTEXT` for required fields; checklist prompts for common gaps |
|
|
1004
|
+
| Over-reliance on single decision | Medium | Team skips alternative evaluation | Output includes `related_decisions` to prompt adjacent thinking |
|
|
1005
|
+
| Validator script false positives | Low | Flags correct implementations | Validator results are advisory; caller makes final judgment |
|
|
1006
|
+
| Rule file conflicts | Low | Contradictory guidance across files | Each file owns a single concern; cross-references are explicit |
|
|
1007
|
+
|
|
1008
|
+
---
|
|
1009
|
+
|
|
1010
|
+
## 20. Compliance with skill-design-guide.md
|
|
1011
|
+
|
|
1012
|
+
| Requirement | Status | Evidence |
|
|
1013
|
+
|-------------|--------|----------|
|
|
1014
|
+
| YAML frontmatter complete | ✅ | name, description, metadata with category, version, triggers, coordinates_with, success_metrics |
|
|
1015
|
+
| SKILL.md < 200 lines | ✅ | Entry point under 200 lines; details in rules/ |
|
|
1016
|
+
| Prerequisites documented | ✅ | No external dependencies |
|
|
1017
|
+
| When to Use section | ✅ | Request-type-based decision matrix |
|
|
1018
|
+
| Quick Reference | ✅ | Decision checklist and content map |
|
|
1019
|
+
| Core content matches skill type | ✅ | Expert type: decision trees, checklists |
|
|
1020
|
+
| Troubleshooting section | ✅ | Anti-patterns table |
|
|
1021
|
+
| Related section | ✅ | Cross-links to data-modeler, security-scanner, auth-patterns |
|
|
1022
|
+
| Content Map for multi-file | ✅ | Links to 10 rule files + engineering-spec.md |
|
|
1023
|
+
| Scripts documented | ✅ | api_validator.ts with command example |
|
|
1024
|
+
| Contract versioning | ✅ | contract_version, backward_compatibility, breaking_changes |
|
|
1025
|
+
| Compliance matrix structured | ✅ | This table with ✅/❌ + evidence |
|
|
1026
|
+
|
|
1027
|
+
---
|
|
1028
|
+
|
|
1029
|
+
## 21. Production Readiness Checklist
|
|
1030
|
+
|
|
1031
|
+
| Category | Check | Status |
|
|
1032
|
+
|----------|-------|--------|
|
|
1033
|
+
| **Functionality** | 8 request types specified | ✅ |
|
|
1034
|
+
| **Functionality** | 3 API styles (REST/GraphQL/tRPC) with decision tree | ✅ |
|
|
1035
|
+
| **Functionality** | 10 reference files covering all API design concerns | ✅ |
|
|
1036
|
+
| **Contracts** | Input/output/error schemas defined | ✅ |
|
|
1037
|
+
| **Contracts** | Agent assumptions and non-assumptions documented | ✅ |
|
|
1038
|
+
| **Contracts** | Workflow invocation pattern with recommended ordering | ✅ |
|
|
1039
|
+
| **Failure** | Error taxonomy with 7 categorized error codes | ✅ |
|
|
1040
|
+
| **Failure** | No silent failures; every error returns structured response | ✅ |
|
|
1041
|
+
| **Failure** | Retry policy: zero internal retries | ✅ |
|
|
1042
|
+
| **Determinism** | Fixed decision tree ordering | ✅ |
|
|
1043
|
+
| **Determinism** | No randomization, no external calls | ✅ |
|
|
1044
|
+
| **Security** | OWASP API Top 10 checklist integrated | ✅ |
|
|
1045
|
+
| **Security** | No credential handling; design-time only | ✅ |
|
|
1046
|
+
| **Observability** | Structured log schema with 5 log points | ✅ |
|
|
1047
|
+
| **Observability** | 6 metrics defined with types and units | ✅ |
|
|
1048
|
+
| **Performance** | P50/P99 targets for all operations | ✅ |
|
|
1049
|
+
| **Scalability** | Stateless; unlimited parallel invocations | ✅ |
|
|
1050
|
+
| **Concurrency** | No shared state; read-only reference access | ✅ |
|
|
1051
|
+
| **Resources** | All resources scoped to invocation lifetime | ✅ |
|
|
1052
|
+
| **Idempotency** | Fully idempotent — all operations are pure functions | ✅ |
|
|
1053
|
+
| **Compliance** | All skill-design-guide.md sections present | ✅ |
|
|
1054
|
+
|
|
1055
|
+
---
|
|
1056
|
+
|
|
1057
|
+
|
|
1058
|
+
|
|
1059
|
+
---
|
|
1060
|
+
|
|
1061
|
+
### Rule: graphql
|
|
1062
|
+
|
|
1063
|
+
---
|
|
1064
|
+
name: graphql
|
|
1065
|
+
description: GraphQL schema design, resolver patterns, N+1 prevention, security
|
|
1066
|
+
---
|
|
1067
|
+
|
|
1068
|
+
# GraphQL Principles
|
|
1069
|
+
|
|
1070
|
+
> Flexible queries for complex, interconnected data.
|
|
1071
|
+
|
|
1072
|
+
---
|
|
1073
|
+
|
|
1074
|
+
## When to Use
|
|
1075
|
+
|
|
1076
|
+
```
|
|
1077
|
+
✅ Good fit:
|
|
1078
|
+
├── Complex, interconnected data
|
|
1079
|
+
├── Multiple frontend platforms
|
|
1080
|
+
├── Clients need flexible queries
|
|
1081
|
+
├── Evolving data requirements
|
|
1082
|
+
└── Reducing over-fetching matters
|
|
1083
|
+
|
|
1084
|
+
❌ Poor fit:
|
|
1085
|
+
├── Simple CRUD operations
|
|
1086
|
+
├── File upload heavy
|
|
1087
|
+
├── HTTP caching important
|
|
1088
|
+
└── Team unfamiliar with GraphQL
|
|
1089
|
+
```
|
|
1090
|
+
|
|
1091
|
+
## Schema Design
|
|
1092
|
+
|
|
1093
|
+
```graphql
|
|
1094
|
+
# Think in graphs, not endpoints
|
|
1095
|
+
type User {
|
|
1096
|
+
id: ID!
|
|
1097
|
+
name: String!
|
|
1098
|
+
email: String!
|
|
1099
|
+
posts(first: Int = 10, after: String): PostConnection!
|
|
1100
|
+
createdAt: DateTime!
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
type Post {
|
|
1104
|
+
id: ID!
|
|
1105
|
+
title: String!
|
|
1106
|
+
content: String!
|
|
1107
|
+
author: User!
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
# Relay-style pagination (recommended)
|
|
1111
|
+
type PostConnection {
|
|
1112
|
+
edges: [PostEdge!]!
|
|
1113
|
+
pageInfo: PageInfo!
|
|
1114
|
+
totalCount: Int!
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
type PostEdge {
|
|
1118
|
+
node: Post!
|
|
1119
|
+
cursor: String!
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
type PageInfo {
|
|
1123
|
+
hasNextPage: Boolean!
|
|
1124
|
+
hasPreviousPage: Boolean!
|
|
1125
|
+
startCursor: String
|
|
1126
|
+
endCursor: String
|
|
1127
|
+
}
|
|
1128
|
+
```
|
|
1129
|
+
|
|
1130
|
+
## Resolver Pattern
|
|
1131
|
+
|
|
1132
|
+
```typescript
|
|
1133
|
+
const resolvers = {
|
|
1134
|
+
Query: {
|
|
1135
|
+
user: (_: unknown, { id }: { id: string }, ctx: Context) =>
|
|
1136
|
+
ctx.dataSources.users.getById(id),
|
|
1137
|
+
|
|
1138
|
+
users: (_: unknown, args: PaginationArgs, ctx: Context) =>
|
|
1139
|
+
ctx.dataSources.users.getConnection(args),
|
|
1140
|
+
},
|
|
1141
|
+
|
|
1142
|
+
// Field resolver — handles N+1 via DataLoader
|
|
1143
|
+
User: {
|
|
1144
|
+
posts: (parent: User, args: PaginationArgs, ctx: Context) =>
|
|
1145
|
+
ctx.dataSources.posts.getByAuthor(parent.id, args),
|
|
1146
|
+
},
|
|
1147
|
+
};
|
|
1148
|
+
```
|
|
1149
|
+
|
|
1150
|
+
## N+1 Prevention — DataLoader
|
|
1151
|
+
|
|
1152
|
+
```typescript
|
|
1153
|
+
import DataLoader from 'dataloader';
|
|
1154
|
+
|
|
1155
|
+
// Batch function: receives array of IDs, returns array of results
|
|
1156
|
+
const userLoader = new DataLoader<string, User>(async (ids) => {
|
|
1157
|
+
const users = await db.user.findMany({ where: { id: { in: [...ids] } } });
|
|
1158
|
+
const map = new Map(users.map(u => [u.id, u]));
|
|
1159
|
+
return ids.map(id => map.get(id)!);
|
|
1160
|
+
});
|
|
1161
|
+
|
|
1162
|
+
// In resolver — automatically batched
|
|
1163
|
+
const resolvers = {
|
|
1164
|
+
Post: {
|
|
1165
|
+
author: (post: Post) => userLoader.load(post.authorId),
|
|
1166
|
+
},
|
|
1167
|
+
};
|
|
1168
|
+
```
|
|
1169
|
+
|
|
1170
|
+
## Security
|
|
1171
|
+
|
|
1172
|
+
| Threat | Mitigation |
|
|
1173
|
+
|--------|-----------|
|
|
1174
|
+
| Query depth attack | Set max depth (e.g., 7) |
|
|
1175
|
+
| Query complexity | Calculate cost per field, set max |
|
|
1176
|
+
| Batching abuse | Limit batch size |
|
|
1177
|
+
| Introspection leak | Disable in production |
|
|
1178
|
+
| Field-level auth | Check permissions per resolver |
|
|
1179
|
+
|
|
1180
|
+
```typescript
|
|
1181
|
+
// Query depth + complexity limits
|
|
1182
|
+
const server = new ApolloServer({
|
|
1183
|
+
validationRules: [
|
|
1184
|
+
depthLimit(7),
|
|
1185
|
+
costAnalysis({ maximumCost: 1000 }),
|
|
1186
|
+
],
|
|
1187
|
+
introspection: process.env.NODE_ENV !== 'production',
|
|
1188
|
+
});
|
|
1189
|
+
```
|
|
1190
|
+
|
|
1191
|
+
## Anti-Patterns
|
|
1192
|
+
|
|
1193
|
+
| ❌ Don't | ✅ Do |
|
|
1194
|
+
|---------|-------|
|
|
1195
|
+
| Expose database schema directly | Design schema for clients |
|
|
1196
|
+
| One mega-query resolver | Keep resolvers small + composable |
|
|
1197
|
+
| Skip DataLoader | Always use DataLoader for relations |
|
|
1198
|
+
| Allow unlimited query depth | Set max depth (7) + cost limits |
|
|
1199
|
+
|
|
1200
|
+
---
|
|
1201
|
+
|
|
1202
|
+
## 🔗 Related
|
|
1203
|
+
|
|
1204
|
+
| File | When to Read |
|
|
1205
|
+
|------|-------------|
|
|
1206
|
+
| [api-style.md](api-style.md) | REST vs GraphQL vs tRPC decision |
|
|
1207
|
+
| [security-testing.md](security-testing.md) | GraphQL security testing |
|
|
1208
|
+
| [SKILL.md](../SKILL.md) | Full decision framework |
|
|
1209
|
+
|
|
1210
|
+
---
|
|
1211
|
+
|
|
1212
|
+
### Rule: rate-limiting
|
|
1213
|
+
|
|
1214
|
+
---
|
|
1215
|
+
name: rate-limiting
|
|
1216
|
+
description: Rate limiting strategies — token bucket, sliding window, Redis implementation, recommended limits
|
|
1217
|
+
---
|
|
1218
|
+
|
|
1219
|
+
# Rate Limiting Principles
|
|
1220
|
+
|
|
1221
|
+
> Protect your API from abuse and overload.
|
|
1222
|
+
|
|
1223
|
+
## Why Rate Limit
|
|
1224
|
+
|
|
1225
|
+
```
|
|
1226
|
+
Protect against:
|
|
1227
|
+
├── Brute force attacks
|
|
1228
|
+
├── Resource exhaustion
|
|
1229
|
+
├── Cost overruns (if pay-per-use)
|
|
1230
|
+
└── Unfair usage
|
|
1231
|
+
```
|
|
1232
|
+
|
|
1233
|
+
## Strategy Selection
|
|
1234
|
+
|
|
1235
|
+
| Type | How | When |
|
|
1236
|
+
|------|-----|------|
|
|
1237
|
+
| **Token bucket** | Burst allowed, refills over time | Most APIs |
|
|
1238
|
+
| **Sliding window** | Smooth distribution | Strict limits |
|
|
1239
|
+
| **Fixed window** | Simple counters per window | Basic needs |
|
|
1240
|
+
|
|
1241
|
+
## Response Headers
|
|
1242
|
+
|
|
1243
|
+
```
|
|
1244
|
+
Include in headers:
|
|
1245
|
+
├── X-RateLimit-Limit (max requests)
|
|
1246
|
+
├── X-RateLimit-Remaining (requests left)
|
|
1247
|
+
├── X-RateLimit-Reset (when limit resets)
|
|
1248
|
+
└── Return 429 when exceeded
|
|
1249
|
+
```
|
|
1250
|
+
|
|
1251
|
+
## Redis Implementation Pattern
|
|
1252
|
+
|
|
1253
|
+
```typescript
|
|
1254
|
+
// Sliding window with Redis
|
|
1255
|
+
const key = `ratelimit:${userId}:${endpoint}`;
|
|
1256
|
+
const current = await redis.incr(key);
|
|
1257
|
+
if (current === 1) {
|
|
1258
|
+
await redis.expire(key, windowSeconds);
|
|
1259
|
+
}
|
|
1260
|
+
if (current > maxRequests) {
|
|
1261
|
+
throw new RateLimitError();
|
|
1262
|
+
}
|
|
1263
|
+
```
|
|
1264
|
+
|
|
1265
|
+
**Recommended Limits:**
|
|
1266
|
+
| Endpoint Type | Limit | Window |
|
|
1267
|
+
|---------------|-------|--------|
|
|
1268
|
+
| Public API | 100 | 1 min |
|
|
1269
|
+
| Authenticated | 1000 | 1 min |
|
|
1270
|
+
| Auth endpoints | 5 | 15 min |
|
|
1271
|
+
| File uploads | 10 | 1 hour |
|
|
1272
|
+
|
|
1273
|
+
---
|
|
1274
|
+
|
|
1275
|
+
## 🔗 Related
|
|
1276
|
+
|
|
1277
|
+
| File | When to Read |
|
|
1278
|
+
|------|-------------|
|
|
1279
|
+
| [security-testing.md](security-testing.md) | Rate limit bypass testing |
|
|
1280
|
+
| [auth.md](auth.md) | Auth endpoint limits |
|
|
1281
|
+
| [SKILL.md](../SKILL.md) | Full decision framework |
|
|
1282
|
+
|
|
1283
|
+
---
|
|
1284
|
+
|
|
1285
|
+
### Rule: response
|
|
1286
|
+
|
|
1287
|
+
---
|
|
1288
|
+
name: response
|
|
1289
|
+
description: API response envelope pattern, error format, pagination, TypeScript types
|
|
1290
|
+
---
|
|
1291
|
+
|
|
1292
|
+
# Response Format Principles
|
|
1293
|
+
|
|
1294
|
+
> One envelope pattern for ALL endpoints — consistency is key.
|
|
1295
|
+
|
|
1296
|
+
---
|
|
1297
|
+
|
|
1298
|
+
## Envelope Pattern (Recommended)
|
|
1299
|
+
|
|
1300
|
+
```typescript
|
|
1301
|
+
// Success response
|
|
1302
|
+
interface ApiResponse<T> {
|
|
1303
|
+
success: true;
|
|
1304
|
+
data: T;
|
|
1305
|
+
meta?: PaginationMeta;
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
// Error response
|
|
1309
|
+
interface ApiError {
|
|
1310
|
+
success: false;
|
|
1311
|
+
error: {
|
|
1312
|
+
code: string; // Machine-readable: "VALIDATION_ERROR"
|
|
1313
|
+
message: string; // Human-readable: "Email is invalid"
|
|
1314
|
+
details?: Record<string, string[]>; // Field-level errors
|
|
1315
|
+
requestId: string; // For support: "req_abc123"
|
|
1316
|
+
};
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
type ApiResult<T> = ApiResponse<T> | ApiError;
|
|
1320
|
+
```
|
|
1321
|
+
|
|
1322
|
+
### Usage Example
|
|
1323
|
+
|
|
1324
|
+
```typescript
|
|
1325
|
+
// Express middleware helper
|
|
1326
|
+
function ok<T>(res: Response, data: T, meta?: PaginationMeta) {
|
|
1327
|
+
res.json({ success: true, data, meta });
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1330
|
+
function fail(res: Response, status: number, code: string, message: string) {
|
|
1331
|
+
res.status(status).json({
|
|
1332
|
+
success: false,
|
|
1333
|
+
error: { code, message, requestId: res.locals.requestId },
|
|
1334
|
+
});
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
// In route handler
|
|
1338
|
+
app.get('/users/:id', async (req, res) => {
|
|
1339
|
+
const user = await db.user.findUnique({ where: { id: req.params.id } });
|
|
1340
|
+
if (!user) return fail(res, 404, 'NOT_FOUND', 'User not found');
|
|
1341
|
+
ok(res, user);
|
|
1342
|
+
});
|
|
1343
|
+
```
|
|
1344
|
+
|
|
1345
|
+
## Error Response Standards
|
|
1346
|
+
|
|
1347
|
+
```json
|
|
1348
|
+
{
|
|
1349
|
+
"success": false,
|
|
1350
|
+
"error": {
|
|
1351
|
+
"code": "VALIDATION_ERROR",
|
|
1352
|
+
"message": "Invalid input data",
|
|
1353
|
+
"details": {
|
|
1354
|
+
"email": ["Must be a valid email"],
|
|
1355
|
+
"age": ["Must be at least 18"]
|
|
1356
|
+
},
|
|
1357
|
+
"requestId": "req_abc123"
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
```
|
|
1361
|
+
|
|
1362
|
+
**Never expose:** stack traces, SQL queries, internal paths, dependency versions.
|
|
1363
|
+
|
|
1364
|
+
## Pagination
|
|
1365
|
+
|
|
1366
|
+
| Type | Best For | Trade-offs |
|
|
1367
|
+
|------|----------|------------|
|
|
1368
|
+
| **Offset** | Simple, jumpable pages | Slow on large datasets, skip drift |
|
|
1369
|
+
| **Cursor** | Large datasets, infinite scroll | Can't jump to page N |
|
|
1370
|
+
| **Keyset** | Performance critical, sorted data | Requires sortable unique key |
|
|
1371
|
+
|
|
1372
|
+
### Pagination Response
|
|
1373
|
+
|
|
1374
|
+
```typescript
|
|
1375
|
+
interface PaginationMeta {
|
|
1376
|
+
page: number;
|
|
1377
|
+
limit: number;
|
|
1378
|
+
total: number;
|
|
1379
|
+
totalPages: number;
|
|
1380
|
+
hasNext: boolean;
|
|
1381
|
+
hasPrev: boolean;
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
// Cursor-based alternative
|
|
1385
|
+
interface CursorMeta {
|
|
1386
|
+
cursor: string | null; // null = no more pages
|
|
1387
|
+
hasMore: boolean;
|
|
1388
|
+
limit: number;
|
|
1389
|
+
}
|
|
1390
|
+
```
|
|
1391
|
+
|
|
1392
|
+
### Selection Guide
|
|
1393
|
+
|
|
1394
|
+
1. Dataset < 10K rows → Offset pagination
|
|
1395
|
+
2. Dataset > 10K, infinite scroll → Cursor pagination
|
|
1396
|
+
3. Performance critical → Keyset pagination
|
|
1397
|
+
4. Data frequently changing → Cursor (avoids skip drift)
|
|
1398
|
+
|
|
1399
|
+
## Anti-Patterns
|
|
1400
|
+
|
|
1401
|
+
| ❌ Don't | ✅ Do |
|
|
1402
|
+
|---------|-------|
|
|
1403
|
+
| Different formats per endpoint | One envelope for all endpoints |
|
|
1404
|
+
| Expose stack traces in errors | Map to safe client-facing codes |
|
|
1405
|
+
| Return `200 OK` with error body | Use proper HTTP status codes |
|
|
1406
|
+
| No request ID in errors | Always include for debugging/support |
|
|
1407
|
+
|
|
1408
|
+
---
|
|
1409
|
+
|
|
1410
|
+
## 🔗 Related
|
|
1411
|
+
|
|
1412
|
+
| File | When to Read |
|
|
1413
|
+
|------|-------------|
|
|
1414
|
+
| [rest.md](rest.md) | HTTP methods + status codes |
|
|
1415
|
+
| [rate-limiting.md](rate-limiting.md) | 429 response format |
|
|
1416
|
+
| [SKILL.md](../SKILL.md) | Full decision framework |
|
|
1417
|
+
|
|
1418
|
+
---
|
|
1419
|
+
|
|
1420
|
+
### Rule: rest
|
|
1421
|
+
|
|
1422
|
+
---
|
|
1423
|
+
name: rest
|
|
1424
|
+
description: REST API design — resource naming, HTTP methods, status codes, filtering, sorting
|
|
1425
|
+
---
|
|
1426
|
+
|
|
1427
|
+
# REST Principles
|
|
1428
|
+
|
|
1429
|
+
> Resource-based API design — nouns not verbs.
|
|
1430
|
+
|
|
1431
|
+
---
|
|
1432
|
+
|
|
1433
|
+
## Resource Naming Rules
|
|
1434
|
+
|
|
1435
|
+
```
|
|
1436
|
+
Principles:
|
|
1437
|
+
├── Use NOUNS, not verbs (resources, not actions)
|
|
1438
|
+
├── Use PLURAL forms (/users not /user)
|
|
1439
|
+
├── Use lowercase with hyphens (/user-profiles)
|
|
1440
|
+
├── Nest for relationships (/users/123/posts)
|
|
1441
|
+
└── Keep shallow (max 3 levels deep)
|
|
1442
|
+
```
|
|
1443
|
+
|
|
1444
|
+
### Endpoint Examples
|
|
1445
|
+
|
|
1446
|
+
```
|
|
1447
|
+
✅ Good:
|
|
1448
|
+
GET /users → List users
|
|
1449
|
+
GET /users/123 → Get user 123
|
|
1450
|
+
POST /users → Create user
|
|
1451
|
+
PUT /users/123 → Replace user 123
|
|
1452
|
+
PATCH /users/123 → Partial update user 123
|
|
1453
|
+
DELETE /users/123 → Delete user 123
|
|
1454
|
+
GET /users/123/posts → User 123's posts
|
|
1455
|
+
|
|
1456
|
+
❌ Bad:
|
|
1457
|
+
GET /getUsers → Verb in URL
|
|
1458
|
+
POST /createUser → Verb in URL
|
|
1459
|
+
GET /user → Singular
|
|
1460
|
+
GET /users/123/posts/456/comments/789/likes → Too deep (>3 levels)
|
|
1461
|
+
```
|
|
1462
|
+
|
|
1463
|
+
## HTTP Method Selection
|
|
1464
|
+
|
|
1465
|
+
| Method | Purpose | Idempotent? | Body? |
|
|
1466
|
+
|--------|---------|-------------|-------|
|
|
1467
|
+
| **GET** | Read resource(s) | Yes | No |
|
|
1468
|
+
| **POST** | Create new resource | No | Yes |
|
|
1469
|
+
| **PUT** | Replace entire resource | Yes | Yes |
|
|
1470
|
+
| **PATCH** | Partial update | No | Yes |
|
|
1471
|
+
| **DELETE** | Remove resource | Yes | No |
|
|
1472
|
+
|
|
1473
|
+
## Status Code Selection
|
|
1474
|
+
|
|
1475
|
+
| Situation | Code | When |
|
|
1476
|
+
|-----------|------|------|
|
|
1477
|
+
| Success (read) | 200 | GET returning data |
|
|
1478
|
+
| Created | 201 | POST success, include Location header |
|
|
1479
|
+
| No content | 204 | DELETE success, PUT with no response body |
|
|
1480
|
+
| Bad request | 400 | Malformed JSON, missing required field |
|
|
1481
|
+
| Unauthorized | 401 | Missing or invalid auth token |
|
|
1482
|
+
| Forbidden | 403 | Valid auth, insufficient permissions |
|
|
1483
|
+
| Not found | 404 | Resource doesn't exist |
|
|
1484
|
+
| Conflict | 409 | Duplicate key, state conflict |
|
|
1485
|
+
| Validation error | 422 | Valid syntax, invalid semantics |
|
|
1486
|
+
| Rate limited | 429 | Too many requests, include Retry-After |
|
|
1487
|
+
| Server error | 500 | Unhandled exception |
|
|
1488
|
+
|
|
1489
|
+
## Filtering, Sorting & Search
|
|
1490
|
+
|
|
1491
|
+
```typescript
|
|
1492
|
+
// Filtering — use query params
|
|
1493
|
+
GET /users?role=admin&status=active
|
|
1494
|
+
|
|
1495
|
+
// Sorting — prefix with - for descending
|
|
1496
|
+
GET /users?sort=-created_at,name
|
|
1497
|
+
|
|
1498
|
+
// Search — use q parameter
|
|
1499
|
+
GET /users?q=john
|
|
1500
|
+
|
|
1501
|
+
// Fields projection (sparse fieldsets)
|
|
1502
|
+
GET /users?fields=id,name,email
|
|
1503
|
+
|
|
1504
|
+
// Combined
|
|
1505
|
+
GET /users?role=admin&sort=-created_at&fields=id,name&page=2&limit=20
|
|
1506
|
+
```
|
|
1507
|
+
|
|
1508
|
+
## Anti-Patterns
|
|
1509
|
+
|
|
1510
|
+
| ❌ Don't | ✅ Do |
|
|
1511
|
+
|---------|-------|
|
|
1512
|
+
| `/getUsers`, `/deleteUser/123` | `GET /users`, `DELETE /users/123` |
|
|
1513
|
+
| `/user` (singular) | `/users` (plural) |
|
|
1514
|
+
| Return 200 for errors | Use semantic HTTP status codes |
|
|
1515
|
+
| Nest beyond 3 levels | Use flat endpoints with filters |
|
|
1516
|
+
| Ignore idempotency | Design PUT/DELETE as idempotent |
|
|
1517
|
+
|
|
1518
|
+
---
|
|
1519
|
+
|
|
1520
|
+
## 🔗 Related
|
|
1521
|
+
|
|
1522
|
+
| File | When to Read |
|
|
1523
|
+
|------|-------------|
|
|
1524
|
+
| [response.md](response.md) | Response envelope + pagination |
|
|
1525
|
+
| [versioning.md](versioning.md) | API versioning strategy |
|
|
1526
|
+
| [api-style.md](api-style.md) | REST vs GraphQL vs tRPC decision |
|
|
1527
|
+
|
|
1528
|
+
---
|
|
1529
|
+
|
|
1530
|
+
### Rule: security-testing
|
|
1531
|
+
|
|
1532
|
+
---
|
|
1533
|
+
name: security-testing
|
|
1534
|
+
description: OWASP API Top 10, JWT testing, BOLA/IDOR, authorization and input validation testing
|
|
1535
|
+
---
|
|
1536
|
+
|
|
1537
|
+
# API Security Testing
|
|
1538
|
+
|
|
1539
|
+
> Principles for testing API security. OWASP API Top 10, authentication, authorization testing.
|
|
1540
|
+
|
|
1541
|
+
---
|
|
1542
|
+
|
|
1543
|
+
## OWASP API Security Top 10
|
|
1544
|
+
|
|
1545
|
+
| Vulnerability | Test Focus |
|
|
1546
|
+
|---------------|------------|
|
|
1547
|
+
| **API1: BOLA** | Access other users' resources |
|
|
1548
|
+
| **API2: Broken Auth** | JWT, session, credentials |
|
|
1549
|
+
| **API3: Property Auth** | Mass assignment, data exposure |
|
|
1550
|
+
| **API4: Resource Consumption** | Rate limiting, DoS |
|
|
1551
|
+
| **API5: Function Auth** | Admin endpoints, role bypass |
|
|
1552
|
+
| **API6: Business Flow** | Logic abuse, automation |
|
|
1553
|
+
| **API7: SSRF** | Internal network access |
|
|
1554
|
+
| **API8: Misconfiguration** | Debug endpoints, CORS |
|
|
1555
|
+
| **API9: Inventory** | Shadow APIs, old versions |
|
|
1556
|
+
| **API10: Unsafe Consumption** | Third-party API trust |
|
|
1557
|
+
|
|
1558
|
+
---
|
|
1559
|
+
|
|
1560
|
+
## Authentication Testing
|
|
1561
|
+
|
|
1562
|
+
### JWT Testing
|
|
1563
|
+
|
|
1564
|
+
| Check | What to Test |
|
|
1565
|
+
|-------|--------------|
|
|
1566
|
+
| Algorithm | None, algorithm confusion |
|
|
1567
|
+
| Secret | Weak secrets, brute force |
|
|
1568
|
+
| Claims | Expiration, issuer, audience |
|
|
1569
|
+
| Signature | Manipulation, key injection |
|
|
1570
|
+
|
|
1571
|
+
### Session Testing
|
|
1572
|
+
|
|
1573
|
+
| Check | What to Test |
|
|
1574
|
+
|-------|--------------|
|
|
1575
|
+
| Generation | Predictability |
|
|
1576
|
+
| Storage | Client-side security |
|
|
1577
|
+
| Expiration | Timeout enforcement |
|
|
1578
|
+
| Invalidation | Logout effectiveness |
|
|
1579
|
+
|
|
1580
|
+
---
|
|
1581
|
+
|
|
1582
|
+
## Authorization Testing
|
|
1583
|
+
|
|
1584
|
+
| Test Type | Approach |
|
|
1585
|
+
|-----------|----------|
|
|
1586
|
+
| **Horizontal** | Access peer users' data |
|
|
1587
|
+
| **Vertical** | Access higher privilege functions |
|
|
1588
|
+
| **Context** | Access outside allowed scope |
|
|
1589
|
+
|
|
1590
|
+
### BOLA/IDOR Testing
|
|
1591
|
+
|
|
1592
|
+
1. Identify resource IDs in requests
|
|
1593
|
+
2. Capture request with user A's session
|
|
1594
|
+
3. Replay with user B's session
|
|
1595
|
+
4. Check for unauthorized access
|
|
1596
|
+
|
|
1597
|
+
---
|
|
1598
|
+
|
|
1599
|
+
## Input Validation Testing
|
|
1600
|
+
|
|
1601
|
+
| Injection Type | Test Focus |
|
|
1602
|
+
|----------------|------------|
|
|
1603
|
+
| SQL | Query manipulation |
|
|
1604
|
+
| NoSQL | Document queries |
|
|
1605
|
+
| Command | System commands |
|
|
1606
|
+
| LDAP | Directory queries |
|
|
1607
|
+
|
|
1608
|
+
**Approach:** Test all parameters, try type coercion, test boundaries, check error messages.
|
|
1609
|
+
|
|
1610
|
+
---
|
|
1611
|
+
|
|
1612
|
+
## Rate Limiting Testing
|
|
1613
|
+
|
|
1614
|
+
| Aspect | Check |
|
|
1615
|
+
|--------|-------|
|
|
1616
|
+
| Existence | Is there any limit? |
|
|
1617
|
+
| Bypass | Headers, IP rotation |
|
|
1618
|
+
| Scope | Per-user, per-IP, global |
|
|
1619
|
+
|
|
1620
|
+
**Bypass techniques:** X-Forwarded-For, different HTTP methods, case variations, API versioning.
|
|
1621
|
+
|
|
1622
|
+
---
|
|
1623
|
+
|
|
1624
|
+
## GraphQL Security
|
|
1625
|
+
|
|
1626
|
+
| Test | Focus |
|
|
1627
|
+
|------|-------|
|
|
1628
|
+
| Introspection | Schema disclosure |
|
|
1629
|
+
| Batching | Query DoS |
|
|
1630
|
+
| Nesting | Depth-based DoS |
|
|
1631
|
+
| Authorization | Field-level access |
|
|
1632
|
+
|
|
1633
|
+
---
|
|
1634
|
+
|
|
1635
|
+
## Security Testing Checklist
|
|
1636
|
+
|
|
1637
|
+
**Authentication:**
|
|
1638
|
+
- [ ] Test for bypass
|
|
1639
|
+
- [ ] Check credential strength
|
|
1640
|
+
- [ ] Verify token security
|
|
1641
|
+
|
|
1642
|
+
**Authorization:**
|
|
1643
|
+
- [ ] Test BOLA/IDOR
|
|
1644
|
+
- [ ] Check privilege escalation
|
|
1645
|
+
- [ ] Verify function access
|
|
1646
|
+
|
|
1647
|
+
**Input:**
|
|
1648
|
+
- [ ] Test all parameters
|
|
1649
|
+
- [ ] Check for injection
|
|
1650
|
+
|
|
1651
|
+
**Config:**
|
|
1652
|
+
- [ ] Check CORS
|
|
1653
|
+
- [ ] Verify headers
|
|
1654
|
+
- [ ] Test error handling
|
|
1655
|
+
|
|
1656
|
+
---
|
|
1657
|
+
|
|
1658
|
+
> **Remember:** APIs are the backbone of modern apps. Test them like attackers will.
|
|
1659
|
+
|
|
1660
|
+
---
|
|
1661
|
+
|
|
1662
|
+
## 🔗 Related
|
|
1663
|
+
|
|
1664
|
+
| File | When to Read |
|
|
1665
|
+
|------|-------------|
|
|
1666
|
+
| [auth.md](auth.md) | Auth patterns to test |
|
|
1667
|
+
| [rate-limiting.md](rate-limiting.md) | Rate limit bypass testing |
|
|
1668
|
+
| [graphql.md](graphql.md) | GraphQL-specific security |
|
|
1669
|
+
| [SKILL.md](../SKILL.md) | Full decision framework |
|
|
1670
|
+
|
|
1671
|
+
---
|
|
1672
|
+
|
|
1673
|
+
### Rule: trpc
|
|
1674
|
+
|
|
1675
|
+
---
|
|
1676
|
+
name: trpc
|
|
1677
|
+
description: tRPC router patterns, Zod validation, React Query client for TypeScript monorepos
|
|
1678
|
+
---
|
|
1679
|
+
|
|
1680
|
+
# tRPC Principles
|
|
1681
|
+
|
|
1682
|
+
> End-to-end type safety for TypeScript monorepos — zero code generation.
|
|
1683
|
+
|
|
1684
|
+
---
|
|
1685
|
+
|
|
1686
|
+
## When to Use
|
|
1687
|
+
|
|
1688
|
+
```
|
|
1689
|
+
✅ Perfect fit:
|
|
1690
|
+
├── TypeScript on both ends
|
|
1691
|
+
├── Monorepo structure
|
|
1692
|
+
├── Internal tools / dashboards
|
|
1693
|
+
├── Rapid development
|
|
1694
|
+
└── Type safety is critical
|
|
1695
|
+
|
|
1696
|
+
❌ Poor fit:
|
|
1697
|
+
├── Non-TypeScript clients
|
|
1698
|
+
├── Public API (need OpenAPI docs)
|
|
1699
|
+
├── Need REST conventions (caching)
|
|
1700
|
+
└── Multiple language backends
|
|
1701
|
+
```
|
|
1702
|
+
|
|
1703
|
+
## Router Definition
|
|
1704
|
+
|
|
1705
|
+
```typescript
|
|
1706
|
+
// server/trpc.ts — Base setup
|
|
1707
|
+
import { initTRPC, TRPCError } from '@trpc/server';
|
|
1708
|
+
import { z } from 'zod';
|
|
1709
|
+
|
|
1710
|
+
const t = initTRPC.context<Context>().create();
|
|
1711
|
+
|
|
1712
|
+
export const router = t.router;
|
|
1713
|
+
export const publicProcedure = t.procedure;
|
|
1714
|
+
export const protectedProcedure = t.procedure.use(isAuthed);
|
|
1715
|
+
```
|
|
1716
|
+
|
|
1717
|
+
```typescript
|
|
1718
|
+
// server/routers/user.ts — Router with Zod validation
|
|
1719
|
+
export const userRouter = router({
|
|
1720
|
+
getById: publicProcedure
|
|
1721
|
+
.input(z.string().uuid())
|
|
1722
|
+
.query(async ({ input, ctx }) => {
|
|
1723
|
+
const user = await ctx.db.user.findUnique({ where: { id: input } });
|
|
1724
|
+
if (!user) throw new TRPCError({ code: 'NOT_FOUND' });
|
|
1725
|
+
return user;
|
|
1726
|
+
}),
|
|
1727
|
+
|
|
1728
|
+
create: protectedProcedure
|
|
1729
|
+
.input(z.object({
|
|
1730
|
+
name: z.string().min(1).max(100),
|
|
1731
|
+
email: z.string().email(),
|
|
1732
|
+
role: z.enum(['user', 'admin']).default('user'),
|
|
1733
|
+
}))
|
|
1734
|
+
.mutation(async ({ input, ctx }) => {
|
|
1735
|
+
return ctx.db.user.create({ data: input });
|
|
1736
|
+
}),
|
|
1737
|
+
|
|
1738
|
+
list: publicProcedure
|
|
1739
|
+
.input(z.object({
|
|
1740
|
+
page: z.number().int().min(1).default(1),
|
|
1741
|
+
limit: z.number().int().min(1).max(100).default(20),
|
|
1742
|
+
}))
|
|
1743
|
+
.query(async ({ input, ctx }) => {
|
|
1744
|
+
const { page, limit } = input;
|
|
1745
|
+
const [data, total] = await Promise.all([
|
|
1746
|
+
ctx.db.user.findMany({ skip: (page - 1) * limit, take: limit }),
|
|
1747
|
+
ctx.db.user.count(),
|
|
1748
|
+
]);
|
|
1749
|
+
return { data, total, totalPages: Math.ceil(total / limit) };
|
|
1750
|
+
}),
|
|
1751
|
+
});
|
|
1752
|
+
```
|
|
1753
|
+
|
|
1754
|
+
## Client Usage (React Query)
|
|
1755
|
+
|
|
1756
|
+
```typescript
|
|
1757
|
+
// Client — fully typed, zero codegen
|
|
1758
|
+
import { trpc } from '~/utils/trpc';
|
|
1759
|
+
|
|
1760
|
+
function UserProfile({ id }: { id: string }) {
|
|
1761
|
+
const { data: user } = trpc.user.getById.useQuery(id);
|
|
1762
|
+
const createUser = trpc.user.create.useMutation();
|
|
1763
|
+
|
|
1764
|
+
// Autocomplete works across the full stack
|
|
1765
|
+
return <div>{user?.name}</div>;
|
|
1766
|
+
}
|
|
1767
|
+
```
|
|
1768
|
+
|
|
1769
|
+
## Integration Patterns
|
|
1770
|
+
|
|
1771
|
+
| Setup | Framework | Notes |
|
|
1772
|
+
|-------|-----------|-------|
|
|
1773
|
+
| Next.js + tRPC | `@trpc/next` | App Router + RSC support |
|
|
1774
|
+
| Remix + tRPC | Custom adapter | Less common |
|
|
1775
|
+
| Monorepo | Shared `@repo/trpc` package | Most scalable |
|
|
1776
|
+
| Standalone | Express adapter | `@trpc/server/adapters/express` |
|
|
1777
|
+
|
|
1778
|
+
## Anti-Patterns
|
|
1779
|
+
|
|
1780
|
+
| ❌ Don't | ✅ Do |
|
|
1781
|
+
|---------|-------|
|
|
1782
|
+
| Use tRPC for public APIs | Use REST + OpenAPI for public |
|
|
1783
|
+
| Skip Zod validation | Always validate with `.input(z.object(...))` |
|
|
1784
|
+
| Put all routes in one file | Split into domain routers (`userRouter`, `postRouter`) |
|
|
1785
|
+
| Catch errors silently | Throw `TRPCError` with proper codes |
|
|
1786
|
+
|
|
1787
|
+
---
|
|
1788
|
+
|
|
1789
|
+
## 🔗 Related
|
|
1790
|
+
|
|
1791
|
+
| File | When to Read |
|
|
1792
|
+
|------|-------------|
|
|
1793
|
+
| [api-style.md](api-style.md) | REST vs GraphQL vs tRPC decision |
|
|
1794
|
+
| [auth.md](auth.md) | Auth middleware patterns |
|
|
1795
|
+
| [SKILL.md](../SKILL.md) | Full decision framework |
|
|
1796
|
+
|
|
1797
|
+
---
|
|
1798
|
+
|
|
1799
|
+
### Rule: versioning
|
|
1800
|
+
|
|
1801
|
+
---
|
|
1802
|
+
name: versioning
|
|
1803
|
+
description: API versioning strategies — URI, header, query; deprecation and sunset policies
|
|
1804
|
+
---
|
|
1805
|
+
|
|
1806
|
+
# Versioning Strategies
|
|
1807
|
+
|
|
1808
|
+
> Plan for API evolution from day one.
|
|
1809
|
+
|
|
1810
|
+
---
|
|
1811
|
+
|
|
1812
|
+
## Strategy Selection
|
|
1813
|
+
|
|
1814
|
+
| Strategy | Implementation | Best For | Trade-offs |
|
|
1815
|
+
|----------|---------------|----------|------------|
|
|
1816
|
+
| **URI** | `/v1/users` | Public APIs | Clear, easy caching; URL pollution |
|
|
1817
|
+
| **Header** | `Accept-Version: 1` | Internal APIs | Clean URLs; harder discovery |
|
|
1818
|
+
| **Query** | `?version=1` | Quick prototypes | Easy to add; messy, cache-unfriendly |
|
|
1819
|
+
| **None** | Evolve carefully | GraphQL, tRPC | Simplest; risky for REST public APIs |
|
|
1820
|
+
|
|
1821
|
+
## Decision Guide
|
|
1822
|
+
|
|
1823
|
+
```
|
|
1824
|
+
Is it a public REST API?
|
|
1825
|
+
├── Yes → URI versioning (/v1/users)
|
|
1826
|
+
│ Most discoverable, best tooling support
|
|
1827
|
+
│
|
|
1828
|
+
├── Internal REST only? → Header versioning
|
|
1829
|
+
│ Cleaner URLs, version-aware clients
|
|
1830
|
+
│
|
|
1831
|
+
├── GraphQL? → No versioning (evolve schema)
|
|
1832
|
+
│ Add fields, deprecate old ones
|
|
1833
|
+
│
|
|
1834
|
+
└── tRPC? → No versioning (types enforce compat)
|
|
1835
|
+
Breaking changes caught at compile time
|
|
1836
|
+
```
|
|
1837
|
+
|
|
1838
|
+
## URI Versioning Example
|
|
1839
|
+
|
|
1840
|
+
```typescript
|
|
1841
|
+
// Express — version in path
|
|
1842
|
+
import { Router } from 'express';
|
|
1843
|
+
|
|
1844
|
+
const v1 = Router();
|
|
1845
|
+
v1.get('/users', getUsersV1);
|
|
1846
|
+
v1.get('/users/:id', getUserByIdV1);
|
|
1847
|
+
|
|
1848
|
+
const v2 = Router();
|
|
1849
|
+
v2.get('/users', getUsersV2); // Changed response format
|
|
1850
|
+
v2.get('/users/:id', getUserByIdV2);
|
|
1851
|
+
|
|
1852
|
+
app.use('/api/v1', v1);
|
|
1853
|
+
app.use('/api/v2', v2);
|
|
1854
|
+
```
|
|
1855
|
+
|
|
1856
|
+
## Deprecation & Sunset
|
|
1857
|
+
|
|
1858
|
+
```typescript
|
|
1859
|
+
// Deprecation headers (RFC 8594)
|
|
1860
|
+
app.use('/api/v1', (req, res, next) => {
|
|
1861
|
+
res.set('Deprecation', 'true');
|
|
1862
|
+
res.set('Sunset', 'Sat, 01 Jun 2026 00:00:00 GMT');
|
|
1863
|
+
res.set('Link', '</api/v2>; rel="successor-version"');
|
|
1864
|
+
next();
|
|
1865
|
+
});
|
|
1866
|
+
```
|
|
1867
|
+
|
|
1868
|
+
**Sunset Policy:**
|
|
1869
|
+
1. Announce deprecation with `Deprecation: true` header
|
|
1870
|
+
2. Set `Sunset` date (minimum 6 months for public APIs)
|
|
1871
|
+
3. Include `Link` header pointing to successor
|
|
1872
|
+
4. Monitor usage — notify active consumers
|
|
1873
|
+
5. Remove after sunset date
|
|
1874
|
+
|
|
1875
|
+
## Anti-Patterns
|
|
1876
|
+
|
|
1877
|
+
| ❌ Don't | ✅ Do |
|
|
1878
|
+
|---------|-------|
|
|
1879
|
+
| Version after breaking changes | Define strategy before first endpoint |
|
|
1880
|
+
| Remove old version without notice | Sunset with 6+ months warning |
|
|
1881
|
+
| Mix versioning strategies | Pick one approach |
|
|
1882
|
+
| Version internal tRPC APIs | Let TypeScript catch breaking changes |
|
|
1883
|
+
|
|
1884
|
+
---
|
|
1885
|
+
|
|
1886
|
+
## 🔗 Related
|
|
1887
|
+
|
|
1888
|
+
| File | When to Read |
|
|
1889
|
+
|------|-------------|
|
|
1890
|
+
| [rest.md](rest.md) | REST endpoint design |
|
|
1891
|
+
| [documentation.md](documentation.md) | Documenting versions |
|
|
1892
|
+
| [api-style.md](api-style.md) | API style decision |
|
|
1893
|
+
|
|
1894
|
+
---
|
|
1895
|
+
|
|
1896
|
+
⚡ PikaKit v3.9.134
|