claude-code-superkit 0.0.0-stage → 1.5.3
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/LICENSE +21 -0
- package/README.md +374 -2
- package/bin/cli.js +153 -0
- package/bin/inject-tokens.js +224 -0
- package/bin/measure-tokens.js +17 -0
- package/bin/superkit-counts-verify.sh +30 -0
- package/lib/codex.js +246 -0
- package/lib/docs-scaffold.js +147 -0
- package/lib/installer.js +499 -0
- package/lib/prompts.js +51 -0
- package/lib/settings-builder.js +51 -0
- package/lib/superpowers.js +99 -0
- package/lib/utils.js +117 -0
- package/lib/validator.js +84 -0
- package/package.json +49 -4
- package/packages/codex/AGENTS.md +396 -0
- package/packages/codex/INSTALL.md +342 -0
- package/packages/codex/config.toml +22 -0
- package/packages/codex/hooks/superkit.mjs +203 -0
- package/packages/codex/hooks.json +30 -0
- package/packages/codex/legacy-baseline.json +88 -0
- package/packages/codex/native-skills.txt +65 -0
- package/packages/codex/rules/default.rules +565 -0
- package/packages/codex/skills/ai-slop-cleaner/SKILL.md +44 -0
- package/packages/codex/skills/api-contract-sync/SKILL.md +96 -0
- package/packages/codex/skills/architect/SKILL.md +49 -0
- package/packages/codex/skills/audit-backend/SKILL.md +80 -0
- package/packages/codex/skills/audit-frontend/SKILL.md +82 -0
- package/packages/codex/skills/audit-infra/SKILL.md +87 -0
- package/packages/codex/skills/audit-orchestrator/SKILL.md +114 -0
- package/packages/codex/skills/behavioral-nudge-engine/SKILL.md +110 -0
- package/packages/codex/skills/benchmark/SKILL.md +49 -0
- package/packages/codex/skills/bot-reviewer/SKILL.md +94 -0
- package/packages/codex/skills/code-reviewer/SKILL.md +67 -0
- package/packages/codex/skills/codebase-onboarding-engineer/SKILL.md +46 -0
- package/packages/codex/skills/comment-rot-analyzer/SKILL.md +75 -0
- package/packages/codex/skills/commit-helper/SKILL.md +101 -0
- package/packages/codex/skills/critic/SKILL.md +56 -0
- package/packages/codex/skills/database-reviewer/SKILL.md +79 -0
- package/packages/codex/skills/debug-observer/SKILL.md +107 -0
- package/packages/codex/skills/dependency-checker/SKILL.md +69 -0
- package/packages/codex/skills/design-system-reviewer/SKILL.md +121 -0
- package/packages/codex/skills/dev-orchestrator/SKILL.md +304 -0
- package/packages/codex/skills/docs-reviewer/SKILL.md +86 -0
- package/packages/codex/skills/drizzle-orm-expert/SKILL.md +246 -0
- package/packages/codex/skills/e2e-test-generator/SKILL.md +95 -0
- package/packages/codex/skills/evaluator/SKILL.md +63 -0
- package/packages/codex/skills/frontend-perf-reviewer/SKILL.md +95 -0
- package/packages/codex/skills/frontend-ui-color-reviewer/SKILL.md +68 -0
- package/packages/codex/skills/frontend-ui-design-critic/SKILL.md +99 -0
- package/packages/codex/skills/frontend-ui-interaction-reviewer/SKILL.md +102 -0
- package/packages/codex/skills/frontend-ui-motion-reviewer/SKILL.md +85 -0
- package/packages/codex/skills/frontend-ui-reviewer/SKILL.md +81 -0
- package/packages/codex/skills/frontend-ui-typography-reviewer/SKILL.md +62 -0
- package/packages/codex/skills/gltf-debugging/SKILL.md +128 -0
- package/packages/codex/skills/go-benchmark/SKILL.md +217 -0
- package/packages/codex/skills/go-concurrency-reviewer/SKILL.md +113 -0
- package/packages/codex/skills/go-error-reviewer/SKILL.md +107 -0
- package/packages/codex/skills/go-grpc-patterns/SKILL.md +285 -0
- package/packages/codex/skills/go-modernizer/SKILL.md +111 -0
- package/packages/codex/skills/go-observability-reviewer/SKILL.md +121 -0
- package/packages/codex/skills/go-performance-reviewer/SKILL.md +112 -0
- package/packages/codex/skills/go-reviewer/SKILL.md +109 -0
- package/packages/codex/skills/go-samber-do/SKILL.md +158 -0
- package/packages/codex/skills/go-samber-lo/SKILL.md +178 -0
- package/packages/codex/skills/go-samber-oops/SKILL.md +174 -0
- package/packages/codex/skills/goal-verifier/SKILL.md +53 -0
- package/packages/codex/skills/health-checker/SKILL.md +109 -0
- package/packages/codex/skills/html-to-3d-texture/SKILL.md +153 -0
- package/packages/codex/skills/impeccable-craft/SKILL.md +101 -0
- package/packages/codex/skills/lint-runner/SKILL.md +85 -0
- package/packages/codex/skills/migrate/SKILL.md +60 -0
- package/packages/codex/skills/migration-reviewer/SKILL.md +88 -0
- package/packages/codex/skills/minimal-change-engineer/SKILL.md +44 -0
- package/packages/codex/skills/new-migration/SKILL.md +59 -0
- package/packages/codex/skills/nextjs-supabase-auth/SKILL.md +227 -0
- package/packages/codex/skills/output-enforcement/SKILL.md +71 -0
- package/packages/codex/skills/plan-checker/SKILL.md +53 -0
- package/packages/codex/skills/postgresql-optimization/SKILL.md +159 -0
- package/packages/codex/skills/pre-deploy-validator/SKILL.md +111 -0
- package/packages/codex/skills/presentation-reviewer/SKILL.md +88 -0
- package/packages/codex/skills/product-3d-lighting/SKILL.md +137 -0
- package/packages/codex/skills/project-architecture/SKILL.md +52 -0
- package/packages/codex/skills/py-reviewer/SKILL.md +100 -0
- package/packages/codex/skills/r3f-scene-reviewer/SKILL.md +88 -0
- package/packages/codex/skills/r3f-scroll-driven-3d/SKILL.md +162 -0
- package/packages/codex/skills/reality-checker/SKILL.md +61 -0
- package/packages/codex/skills/redis-patterns/SKILL.md +260 -0
- package/packages/codex/skills/review-orchestrator/SKILL.md +151 -0
- package/packages/codex/skills/rs-reviewer/SKILL.md +98 -0
- package/packages/codex/skills/ru-text/SKILL.md +132 -0
- package/packages/codex/skills/scaffold-endpoint/SKILL.md +44 -0
- package/packages/codex/skills/security-scanner/SKILL.md +94 -0
- package/packages/codex/skills/silent-failure-hunter/SKILL.md +176 -0
- package/packages/codex/skills/telegram-bot-builder/SKILL.md +120 -0
- package/packages/codex/skills/test-generator/SKILL.md +79 -0
- package/packages/codex/skills/test-runner/SKILL.md +101 -0
- package/packages/codex/skills/threejs-color-management/SKILL.md +97 -0
- package/packages/codex/skills/tree-generator/SKILL.md +63 -0
- package/packages/codex/skills/ts-reviewer/SKILL.md +90 -0
- package/packages/codex/skills/ui-design-reviewer/SKILL.md +89 -0
- package/packages/codex/skills/ui-reviewer/SKILL.md +103 -0
- package/packages/codex/skills/visual-reviewer/SKILL.md +85 -0
- package/packages/codex/skills/writing-agents/SKILL.md +165 -0
- package/packages/codex/skills/writing-commands/SKILL.md +173 -0
- package/packages/core/CLAUDE.md +118 -0
- package/packages/core/INTERNAL-FILES +16 -0
- package/packages/core/agents/ai-slop-cleaner.md +187 -0
- package/packages/core/agents/api-contract-sync.md +127 -0
- package/packages/core/agents/architect.md +205 -0
- package/packages/core/agents/audit-backend.md +137 -0
- package/packages/core/agents/audit-frontend.md +129 -0
- package/packages/core/agents/audit-infra.md +182 -0
- package/packages/core/agents/behavioral-nudge-engine.md +170 -0
- package/packages/core/agents/code-reviewer.md +195 -0
- package/packages/core/agents/codebase-onboarding-engineer.md +172 -0
- package/packages/core/agents/comment-rot-analyzer.md +115 -0
- package/packages/core/agents/critic.md +172 -0
- package/packages/core/agents/database-reviewer.md +201 -0
- package/packages/core/agents/debug-observer.md +261 -0
- package/packages/core/agents/dependency-checker.md +199 -0
- package/packages/core/agents/docs-reviewer.md +206 -0
- package/packages/core/agents/e2e-test-generator.md +261 -0
- package/packages/core/agents/evaluator.md +141 -0
- package/packages/core/agents/goal-verifier.md +130 -0
- package/packages/core/agents/health-checker.md +194 -0
- package/packages/core/agents/migration-reviewer.md +161 -0
- package/packages/core/agents/minimal-change-engineer.md +219 -0
- package/packages/core/agents/plan-checker.md +139 -0
- package/packages/core/agents/pre-deploy-validator.md +189 -0
- package/packages/core/agents/reality-checker.md +175 -0
- package/packages/core/agents/scaffold-endpoint.md +162 -0
- package/packages/core/agents/security-scanner.md +236 -0
- package/packages/core/agents/silent-failure-hunter.md +276 -0
- package/packages/core/agents/test-generator.md +146 -0
- package/packages/core/agents/tree-generator.md +141 -0
- package/packages/core/agents/ui-reviewer.md +172 -0
- package/packages/core/agents/visual-reviewer.md +211 -0
- package/packages/core/commands/audit.md +166 -0
- package/packages/core/commands/benchmark.md +130 -0
- package/packages/core/commands/commit.md +148 -0
- package/packages/core/commands/dev.md +302 -0
- package/packages/core/commands/docs-init.md +75 -0
- package/packages/core/commands/lint.md +137 -0
- package/packages/core/commands/migrate.md +146 -0
- package/packages/core/commands/new-migration.md +182 -0
- package/packages/core/commands/pair.md +209 -0
- package/packages/core/commands/review.md +195 -0
- package/packages/core/commands/security-scan.md +142 -0
- package/packages/core/commands/superkit-evolve.md +231 -0
- package/packages/core/commands/superkit-init.md +274 -0
- package/packages/core/commands/test.md +108 -0
- package/packages/core/commands/workflow.md +150 -0
- package/packages/core/docs/guide/01-getting-started.md +41 -0
- package/packages/core/docs-templates/README.md +33 -0
- package/packages/core/docs-templates/adr-template.md +62 -0
- package/packages/core/docs-templates/architecture/api-contracts.md +26 -0
- package/packages/core/docs-templates/architecture/api-reference.md +48 -0
- package/packages/core/docs-templates/architecture/auth-and-sessions.md +38 -0
- package/packages/core/docs-templates/architecture/backend-layers.md +42 -0
- package/packages/core/docs-templates/architecture/data-flow.md +26 -0
- package/packages/core/docs-templates/architecture/database-schema.md +51 -0
- package/packages/core/docs-templates/architecture/deployment.md +41 -0
- package/packages/core/docs-templates/architecture/frontend-state.md +46 -0
- package/packages/core/helpers/statusline.cjs +370 -0
- package/packages/core/hooks/CHAIN-SEMANTICS.md +84 -0
- package/packages/core/hooks/audit-settings-source.sh +98 -0
- package/packages/core/hooks/audit-trail.sh +120 -0
- package/packages/core/hooks/block-dangerous-git.sh +189 -0
- package/packages/core/hooks/bundle-import-check.sh +64 -0
- package/packages/core/hooks/compact-state-inject.sh +84 -0
- package/packages/core/hooks/config-protection.sh +68 -0
- package/packages/core/hooks/console-log-warning.sh +28 -0
- package/packages/core/hooks/context-monitor.sh +35 -0
- package/packages/core/hooks/dev-edit-counter.sh +59 -0
- package/packages/core/hooks/dev-marker-set.sh +55 -0
- package/packages/core/hooks/dev-required-on-commit.sh +426 -0
- package/packages/core/hooks/doc-check-on-commit.sh +396 -0
- package/packages/core/hooks/edit-streak-check.sh +63 -0
- package/packages/core/hooks/evolve-check.sh +78 -0
- package/packages/core/hooks/gateguard-pre-edit.sh +154 -0
- package/packages/core/hooks/gateguard-record-facts.sh +37 -0
- package/packages/core/hooks/intake-classifier.py +449 -0
- package/packages/core/hooks/lib/profile.sh +141 -0
- package/packages/core/hooks/loop-guard.sh +75 -0
- package/packages/core/hooks/migration-safety.sh +56 -0
- package/packages/core/hooks/plan-completion-gate.sh +61 -0
- package/packages/core/hooks/pre-compact-save.sh +89 -0
- package/packages/core/hooks/security-patterns.sh +119 -0
- package/packages/core/hooks/session-context-restore.sh +76 -0
- package/packages/core/hooks/subagent-stop-validate.sh +73 -0
- package/packages/core/hooks/superkit-counts-verify.sh +346 -0
- package/packages/core/hooks/superkit-update.sh +367 -0
- package/packages/core/hooks/tests/README.md +42 -0
- package/packages/core/hooks/tests/audit-trail-chain_test.sh +62 -0
- package/packages/core/hooks/tests/block-dangerous-git_test.sh +144 -0
- package/packages/core/hooks/tests/chain-semantics/h1.sh +11 -0
- package/packages/core/hooks/tests/chain-semantics/h2.sh +9 -0
- package/packages/core/hooks/tests/chain-semantics/h3.sh +11 -0
- package/packages/core/hooks/tests/chain-semantics/run-experiment.sh +65 -0
- package/packages/core/hooks/tests/chain-semantics/settings-experiment.json +15 -0
- package/packages/core/hooks/tests/counts-verify_test.sh +118 -0
- package/packages/core/hooks/tests/dev-required-on-commit_test.sh +207 -0
- package/packages/core/hooks/tests/dev-required-wip-on-main_test.sh +20 -0
- package/packages/core/hooks/tests/doc-check-on-commit_test.sh +122 -0
- package/packages/core/hooks/tests/edit-streak-check_test.sh +106 -0
- package/packages/core/hooks/tests/internal-manifest_test.sh +130 -0
- package/packages/core/hooks/tests/json-path_test.sh +108 -0
- package/packages/core/hooks/tests/mirror-invariants_test.sh +139 -0
- package/packages/core/hooks/tests/nudge-throttle_test.sh +95 -0
- package/packages/core/hooks/tests/profile-helper_test.sh +21 -0
- package/packages/core/hooks/tests/run-all.sh +47 -0
- package/packages/core/hooks/tests/session-key-helper_test.sh +17 -0
- package/packages/core/hooks/tests/superkit-update_test.sh +311 -0
- package/packages/core/hooks/tests/warn-visibility_test.sh +59 -0
- package/packages/core/hooks/user-intent-detect.sh +44 -0
- package/packages/core/hooks/verify-hooks.sh +69 -0
- package/packages/core/rules/auto-commands.md +124 -0
- package/packages/core/rules/coding-style.md +68 -0
- package/packages/core/rules/dev-workflow.md +77 -0
- package/packages/core/rules/documentation.md +106 -0
- package/packages/core/rules/frontend-aesthetics.md +53 -0
- package/packages/core/rules/git-workflow.md +14 -0
- package/packages/core/rules/security.md +29 -0
- package/packages/core/rules/superkit-integrity.md +114 -0
- package/packages/core/settings.json +229 -0
- package/packages/core/skills/drizzle-orm-expert/SKILL.md +260 -0
- package/packages/core/skills/nextjs-supabase-auth/SKILL.md +259 -0
- package/packages/core/skills/postgresql-optimization/SKILL.md +150 -0
- package/packages/core/skills/project-architecture/SKILL.md +31 -0
- package/packages/core/skills/project-scanner/SKILL.md +132 -0
- package/packages/core/skills/redis-patterns/SKILL.md +261 -0
- package/packages/core/skills/ru-text/SKILL.md +156 -0
- package/packages/core/skills/telegram-bot-builder/SKILL.md +145 -0
- package/packages/core/skills/writing-agents/SKILL.md +220 -0
- package/packages/core/skills/writing-commands/SKILL.md +176 -0
- package/packages/core/skills/writing-hooks/SKILL.md +335 -0
- package/packages/extras/bot-reviewer.md +279 -0
- package/packages/extras/design-system-reviewer.md +234 -0
- package/packages/extras/red-blue-auditor/README.md +117 -0
- package/packages/extras/red-blue-auditor/agent.md +128 -0
- package/packages/extras/red-blue-auditor/patterns/agent-config.txt +4 -0
- package/packages/extras/red-blue-auditor/patterns/hook-injection.txt +8 -0
- package/packages/extras/red-blue-auditor/patterns/mcp-risk.txt +5 -0
- package/packages/extras/red-blue-auditor/patterns/permission-abuse.txt +6 -0
- package/packages/extras/red-blue-auditor/patterns/secrets.txt +17 -0
- package/packages/extras/red-blue-auditor/scan.sh +88 -0
- package/packages/extras/skillsmp-search/SKILL.md +134 -0
- package/packages/frontend-3d/README.md +62 -0
- package/packages/frontend-3d/agents/frontend-perf-reviewer.md +164 -0
- package/packages/frontend-3d/agents/presentation-reviewer.md +146 -0
- package/packages/frontend-3d/agents/r3f-scene-reviewer.md +128 -0
- package/packages/frontend-3d/agents/ui-design-reviewer.md +169 -0
- package/packages/frontend-3d/commands/capture-screen.md +166 -0
- package/packages/frontend-3d/hooks/bundle-size-warn.sh +93 -0
- package/packages/frontend-3d/hooks/gsap-pattern-check.sh +74 -0
- package/packages/frontend-3d/hooks/r3f-color-check.sh +76 -0
- package/packages/frontend-3d/hooks/tailwind-version-guard.sh +98 -0
- package/packages/frontend-3d/rules/frontend-aesthetics-3d.md +81 -0
- package/packages/frontend-3d/rules/gsap-conventions.md +129 -0
- package/packages/frontend-3d/rules/threejs-conventions.md +116 -0
- package/packages/frontend-3d/skills/gltf-debugging/SKILL.md +145 -0
- package/packages/frontend-3d/skills/html-to-3d-texture/SKILL.md +183 -0
- package/packages/frontend-3d/skills/output-enforcement/SKILL.md +79 -0
- package/packages/frontend-3d/skills/product-3d-lighting/SKILL.md +166 -0
- package/packages/frontend-3d/skills/r3f-scroll-driven-3d/SKILL.md +209 -0
- package/packages/frontend-3d/skills/threejs-color-management/SKILL.md +111 -0
- package/packages/frontend-ui/NOTICE.md +99 -0
- package/packages/frontend-ui/README.md +59 -0
- package/packages/frontend-ui/agents/ui-color-reviewer.md +174 -0
- package/packages/frontend-ui/agents/ui-design-critic.md +198 -0
- package/packages/frontend-ui/agents/ui-interaction-reviewer.md +259 -0
- package/packages/frontend-ui/agents/ui-motion-reviewer.md +266 -0
- package/packages/frontend-ui/agents/ui-reviewer.md +251 -0
- package/packages/frontend-ui/agents/ui-typography-reviewer.md +222 -0
- package/packages/frontend-ui/hooks/tests/ui-animation-easing-check_test.sh +78 -0
- package/packages/frontend-ui/hooks/tests/ui-banned-fonts-check_test.sh +77 -0
- package/packages/frontend-ui/hooks/tests/ui-color-check_test.sh +75 -0
- package/packages/frontend-ui/hooks/ui-animation-easing-check.sh +86 -0
- package/packages/frontend-ui/hooks/ui-banned-fonts-check.sh +90 -0
- package/packages/frontend-ui/hooks/ui-color-check.sh +102 -0
- package/packages/frontend-ui/rules/color-and-contrast.md +230 -0
- package/packages/frontend-ui/rules/frontend-design-aesthetics.md +124 -0
- package/packages/frontend-ui/rules/interaction-polish.md +335 -0
- package/packages/frontend-ui/rules/motion-and-animation.md +283 -0
- package/packages/frontend-ui/rules/spatial-and-layout.md +212 -0
- package/packages/frontend-ui/rules/typography-guidelines.md +185 -0
- package/packages/frontend-ui/rules/ui-anti-patterns.md +309 -0
- package/packages/frontend-ui/settings.json +24 -0
- package/packages/frontend-ui/skills/impeccable-craft/SKILL.md +187 -0
- package/packages/gan/README.md +232 -0
- package/packages/gan/agents/gan-evaluator.md +214 -0
- package/packages/gan/agents/gan-generator.md +171 -0
- package/packages/gan/agents/gan-planner.md +206 -0
- package/packages/gan/rubrics/functionality.md +66 -0
- package/packages/gan/rubrics/ui-quality.md +77 -0
- package/packages/gan/skills/gan-evaluator/SKILL.md +91 -0
- package/packages/gan/skills/gan-generator/SKILL.md +72 -0
- package/packages/gan/skills/gan-planner/SKILL.md +93 -0
- package/packages/stack-agents/go/go-concurrency-reviewer.md +210 -0
- package/packages/stack-agents/go/go-error-reviewer.md +187 -0
- package/packages/stack-agents/go/go-modernizer.md +160 -0
- package/packages/stack-agents/go/go-observability-reviewer.md +185 -0
- package/packages/stack-agents/go/go-performance-reviewer.md +160 -0
- package/packages/stack-agents/go/go-reviewer.md +277 -0
- package/packages/stack-agents/go/references/benchmark-methodology.md +280 -0
- package/packages/stack-agents/go/references/channel-patterns.md +384 -0
- package/packages/stack-agents/go/references/cli-cobra-viper.md +190 -0
- package/packages/stack-agents/go/references/code-style.md +262 -0
- package/packages/stack-agents/go/references/context-propagation.md +317 -0
- package/packages/stack-agents/go/references/data-structures.md +315 -0
- package/packages/stack-agents/go/references/database-patterns.md +334 -0
- package/packages/stack-agents/go/references/design-patterns.md +411 -0
- package/packages/stack-agents/go/references/di-frameworks.md +146 -0
- package/packages/stack-agents/go/references/error-creation.md +251 -0
- package/packages/stack-agents/go/references/error-inspection.md +348 -0
- package/packages/stack-agents/go/references/error-wrapping.md +230 -0
- package/packages/stack-agents/go/references/gopls-driving.md +62 -0
- package/packages/stack-agents/go/references/goroutine-lifecycle.md +351 -0
- package/packages/stack-agents/go/references/graphql-patterns.md +221 -0
- package/packages/stack-agents/go/references/grpc-patterns.md +373 -0
- package/packages/stack-agents/go/references/modernize-guide.md +522 -0
- package/packages/stack-agents/go/references/module-management.md +191 -0
- package/packages/stack-agents/go/references/naming-conventions.md +176 -0
- package/packages/stack-agents/go/references/observability-pipeline.md +352 -0
- package/packages/stack-agents/go/references/performance-profiling.md +250 -0
- package/packages/stack-agents/go/references/refactoring-mechanics.md +127 -0
- package/packages/stack-agents/go/references/rest-openapi-patterns.md +160 -0
- package/packages/stack-agents/go/references/samber-do.md +201 -0
- package/packages/stack-agents/go/references/samber-libraries.md +363 -0
- package/packages/stack-agents/go/references/samber-lo.md +260 -0
- package/packages/stack-agents/go/references/samber-oops.md +200 -0
- package/packages/stack-agents/go/references/security-checklist.md +441 -0
- package/packages/stack-agents/go/references/standard-stdlib-now.md +181 -0
- package/packages/stack-agents/go/references/stay-updated.md +147 -0
- package/packages/stack-agents/go/references/structs-interfaces.md +312 -0
- package/packages/stack-agents/go/references/sync-primitives.md +395 -0
- package/packages/stack-agents/go/references/testing-patterns.md +483 -0
- package/packages/stack-agents/go/references/troubleshooting.md +98 -0
- package/packages/stack-agents/python/py-reviewer.md +194 -0
- package/packages/stack-agents/rust/rs-reviewer.md +188 -0
- package/packages/stack-agents/typescript/ts-reviewer.md +135 -0
- package/packages/stack-hooks/go/go-context-check-on-edit.sh +56 -0
- package/packages/stack-hooks/go/go-error-check-on-edit.sh +54 -0
- package/packages/stack-hooks/go/go-format-on-edit.sh +32 -0
- package/packages/stack-hooks/go/go-safety-check-on-edit.sh +54 -0
- package/packages/stack-hooks/go/go-vet-on-edit.sh +61 -0
- package/packages/stack-hooks/go/golangci-lint-on-edit.sh +54 -0
- package/packages/stack-hooks/python/ruff-on-edit.sh +67 -0
- package/packages/stack-hooks/rust/cargo-check-on-edit.sh +64 -0
- package/packages/stack-hooks/typescript/typecheck-on-edit.sh +76 -0
- package/packages/stack-rules/go/go-conventions.md +44 -0
- package/packages/stack-rules/go/go-safety.md +35 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": ["Bash", "Read", "Edit", "Write", "Glob", "Grep"],
|
|
4
|
+
"deny": [
|
|
5
|
+
"Bash(curl * | bash)",
|
|
6
|
+
"Bash(curl * | sh)",
|
|
7
|
+
"Bash(wget * | bash)",
|
|
8
|
+
"Bash(wget * | sh)",
|
|
9
|
+
"Bash(rm -rf /)",
|
|
10
|
+
"Bash(rm -rf /*)",
|
|
11
|
+
"Bash(mkfs *)",
|
|
12
|
+
"Bash(dd if=*)"
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
"hooks": {
|
|
16
|
+
"PreToolUse": [
|
|
17
|
+
{
|
|
18
|
+
"matcher": "Bash",
|
|
19
|
+
"hooks": [
|
|
20
|
+
{
|
|
21
|
+
"type": "command",
|
|
22
|
+
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/scripts/hooks/block-dangerous-git.sh"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"type": "command",
|
|
26
|
+
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/scripts/hooks/doc-check-on-commit.sh"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"type": "command",
|
|
30
|
+
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/scripts/hooks/dev-required-on-commit.sh"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"type": "command",
|
|
34
|
+
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/scripts/hooks/loop-guard.sh"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"type": "command",
|
|
38
|
+
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/scripts/hooks/gateguard-pre-edit.sh"
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"matcher": "Edit|Write|MultiEdit",
|
|
44
|
+
"hooks": [
|
|
45
|
+
{
|
|
46
|
+
"type": "command",
|
|
47
|
+
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/scripts/hooks/gateguard-pre-edit.sh"
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"matcher": "Skill",
|
|
53
|
+
"hooks": [
|
|
54
|
+
{
|
|
55
|
+
"type": "command",
|
|
56
|
+
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/scripts/hooks/dev-marker-set.sh"
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
"PostToolUse": [
|
|
62
|
+
{
|
|
63
|
+
"matcher": "Bash",
|
|
64
|
+
"hooks": [
|
|
65
|
+
{
|
|
66
|
+
"type": "command",
|
|
67
|
+
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/scripts/hooks/audit-trail.sh"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"type": "command",
|
|
71
|
+
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/scripts/hooks/edit-streak-check.sh"
|
|
72
|
+
}
|
|
73
|
+
]
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"matcher": "Skill",
|
|
77
|
+
"hooks": [
|
|
78
|
+
{
|
|
79
|
+
"type": "command",
|
|
80
|
+
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/scripts/hooks/plan-completion-gate.sh"
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"matcher": "Grep|Read|Glob",
|
|
86
|
+
"hooks": [
|
|
87
|
+
{
|
|
88
|
+
"type": "command",
|
|
89
|
+
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/scripts/hooks/gateguard-record-facts.sh"
|
|
90
|
+
}
|
|
91
|
+
]
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"matcher": "Edit|Write",
|
|
95
|
+
"hooks": [
|
|
96
|
+
{
|
|
97
|
+
"type": "command",
|
|
98
|
+
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/scripts/hooks/audit-trail.sh"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"type": "command",
|
|
102
|
+
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/scripts/hooks/dev-edit-counter.sh"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"type": "command",
|
|
106
|
+
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/scripts/hooks/edit-streak-check.sh"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"type": "command",
|
|
110
|
+
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/scripts/hooks/console-log-warning.sh"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"type": "command",
|
|
114
|
+
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/scripts/hooks/migration-safety.sh"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"type": "command",
|
|
118
|
+
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/scripts/hooks/bundle-import-check.sh"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"type": "command",
|
|
122
|
+
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/scripts/hooks/config-protection.sh"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"type": "command",
|
|
126
|
+
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/scripts/hooks/context-monitor.sh"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"type": "command",
|
|
130
|
+
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/scripts/hooks/security-patterns.sh"
|
|
131
|
+
}
|
|
132
|
+
]
|
|
133
|
+
}
|
|
134
|
+
],
|
|
135
|
+
"UserPromptSubmit": [
|
|
136
|
+
{
|
|
137
|
+
"matcher": "",
|
|
138
|
+
"hooks": [
|
|
139
|
+
{
|
|
140
|
+
"type": "command",
|
|
141
|
+
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/scripts/hooks/dev-marker-set.sh"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"type": "command",
|
|
145
|
+
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/scripts/hooks/user-intent-detect.sh"
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"type": "command",
|
|
149
|
+
"command": "python3 \"$CLAUDE_PROJECT_DIR\"/.claude/scripts/hooks/intake-classifier.py"
|
|
150
|
+
}
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
],
|
|
154
|
+
"PreCompact": [
|
|
155
|
+
{
|
|
156
|
+
"matcher": "",
|
|
157
|
+
"hooks": [
|
|
158
|
+
{
|
|
159
|
+
"type": "command",
|
|
160
|
+
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/scripts/hooks/pre-compact-save.sh"
|
|
161
|
+
}
|
|
162
|
+
]
|
|
163
|
+
}
|
|
164
|
+
],
|
|
165
|
+
"SessionStart": [
|
|
166
|
+
{
|
|
167
|
+
"matcher": "",
|
|
168
|
+
"hooks": [
|
|
169
|
+
{
|
|
170
|
+
"type": "command",
|
|
171
|
+
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/scripts/hooks/audit-settings-source.sh"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"type": "command",
|
|
175
|
+
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/scripts/hooks/session-context-restore.sh"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"type": "command",
|
|
179
|
+
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/scripts/hooks/evolve-check.sh"
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
"type": "command",
|
|
183
|
+
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/scripts/hooks/superkit-update.sh"
|
|
184
|
+
}
|
|
185
|
+
]
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
"matcher": "compact",
|
|
189
|
+
"hooks": [
|
|
190
|
+
{
|
|
191
|
+
"type": "command",
|
|
192
|
+
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/scripts/hooks/compact-state-inject.sh"
|
|
193
|
+
}
|
|
194
|
+
]
|
|
195
|
+
}
|
|
196
|
+
],
|
|
197
|
+
"SubagentStop": [
|
|
198
|
+
{
|
|
199
|
+
"matcher": "",
|
|
200
|
+
"hooks": [
|
|
201
|
+
{
|
|
202
|
+
"type": "command",
|
|
203
|
+
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/scripts/hooks/subagent-stop-validate.sh"
|
|
204
|
+
}
|
|
205
|
+
]
|
|
206
|
+
}
|
|
207
|
+
],
|
|
208
|
+
"Stop": [
|
|
209
|
+
{
|
|
210
|
+
"hooks": [
|
|
211
|
+
{
|
|
212
|
+
"type": "prompt",
|
|
213
|
+
"prompt": "Before finishing, verify: (1) All changed files pass stack-appropriate linters/compilers. (2) If logic/API/architecture changed — check that relevant docs were updated. Respond with {\"decision\": \"allow\"} if clean, or {\"decision\": \"block\", \"reason\": \"...\"} if issues.",
|
|
214
|
+
"model": "opus",
|
|
215
|
+
"timeout": 60,
|
|
216
|
+
"statusMessage": "Verifying session changes..."
|
|
217
|
+
}
|
|
218
|
+
]
|
|
219
|
+
}
|
|
220
|
+
]
|
|
221
|
+
},
|
|
222
|
+
"statusLine": "node \"$CLAUDE_PROJECT_DIR\"/.claude/scripts/statusline.cjs",
|
|
223
|
+
"enabledPlugins": {
|
|
224
|
+
"superpowers@claude-plugins-official": true,
|
|
225
|
+
"github@claude-plugins-official": true,
|
|
226
|
+
"context7@claude-plugins-official": true,
|
|
227
|
+
"code-review@claude-plugins-official": true
|
|
228
|
+
}
|
|
229
|
+
}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: drizzle-orm-expert
|
|
3
|
+
description: Expert in Drizzle ORM for TypeScript — schema design, relational queries, migrations, serverless DB integration. Use when building type-safe database layers with Drizzle, migrating from Prisma, or optimizing edge runtime DB access
|
|
4
|
+
tokens: 1960
|
|
5
|
+
user-invocable: false
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Drizzle ORM Expert
|
|
9
|
+
|
|
10
|
+
TypeScript-first ORM that compiles to raw SQL with zero runtime overhead. Ideal for edge runtimes and serverless. Two complementary APIs: SQL-like query builder and Prisma-style relational queries.
|
|
11
|
+
|
|
12
|
+
## Use this skill when
|
|
13
|
+
|
|
14
|
+
- Setting up Drizzle ORM in a new or existing project
|
|
15
|
+
- Designing database schemas with Drizzle's TypeScript-first approach
|
|
16
|
+
- Writing complex relational queries (joins, subqueries, aggregations)
|
|
17
|
+
- Setting up or troubleshooting Drizzle Kit migrations
|
|
18
|
+
- Integrating Drizzle with Next.js App Router, tRPC, or Hono
|
|
19
|
+
- Optimizing performance (prepared statements, batching, pooling)
|
|
20
|
+
- Migrating from Prisma, TypeORM, or Knex
|
|
21
|
+
|
|
22
|
+
## Do not use this skill when
|
|
23
|
+
|
|
24
|
+
- The DB layer uses Prisma, TypeORM, or raw SQL exclusively
|
|
25
|
+
- You need a database-agnostic ORM guide
|
|
26
|
+
- The task is about DB server configuration (use `postgresql-optimization`)
|
|
27
|
+
|
|
28
|
+
## Hard Rules
|
|
29
|
+
|
|
30
|
+
- NEVER run `drizzle-kit push` in production — it can drop columns and lose data. Use `generate` → review SQL → `migrate`.
|
|
31
|
+
- ALWAYS pass `{ schema }` to `drizzle()` — without it `db.query.*` is `undefined`.
|
|
32
|
+
- ALWAYS define and export `relations()` before using `db.query.*` with `with`.
|
|
33
|
+
- ALWAYS use connection pooling (pgBouncer, Neon serverless, or node-pg `Pool`).
|
|
34
|
+
- Use the query builder rather than raw SQL whenever it supports the operation.
|
|
35
|
+
- MySQL has no `.returning()` — read `insertId` from the result instead.
|
|
36
|
+
|
|
37
|
+
## Workflow
|
|
38
|
+
|
|
39
|
+
1. Identify the DB driver (PostgreSQL, SQLite, MySQL) and pick the adapter (see Adapters table).
|
|
40
|
+
2. Define schema in `db/schema.ts` (or domain-split `db/schema/users.ts`).
|
|
41
|
+
3. Define `relations()` separately and export them so `db.query.*` with `with` resolves.
|
|
42
|
+
4. Initialize the client with `{ schema }`.
|
|
43
|
+
5. Derive row types with `InferSelectModel` / `InferInsertModel` — never hand-write interfaces.
|
|
44
|
+
6. For production schema changes: `drizzle-kit generate` → review the SQL → `drizzle-kit migrate` (never `push`).
|
|
45
|
+
|
|
46
|
+
## Core Architecture
|
|
47
|
+
|
|
48
|
+
No runtime query-engine binary (unlike Prisma), so Drizzle runs on edge runtimes — Cloudflare Workers, Vercel Edge Functions, Deno Deploy. The two APIs:
|
|
49
|
+
|
|
50
|
+
- **SQL-like builder**: `db.select().from().where().join().orderBy()` — close to SQL semantics
|
|
51
|
+
- **Relational query API**: `db.query.users.findMany({ with: { posts: true } })` — Prisma-style nested fetching
|
|
52
|
+
|
|
53
|
+
## Schema Design
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
import { pgTable, uuid, text, boolean, timestamp, pgEnum, index, uniqueIndex } from 'drizzle-orm/pg-core';
|
|
57
|
+
|
|
58
|
+
export const roleEnum = pgEnum('role', ['admin', 'user', 'guest']);
|
|
59
|
+
|
|
60
|
+
export const users = pgTable('users', {
|
|
61
|
+
id: uuid('id').defaultRandom().primaryKey(),
|
|
62
|
+
email: text('email').notNull().unique(),
|
|
63
|
+
role: roleEnum('role').default('user').notNull(),
|
|
64
|
+
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
65
|
+
}, (table) => ({
|
|
66
|
+
emailIdx: uniqueIndex('users_email_idx').on(table.email),
|
|
67
|
+
createdIdx: index('users_created_idx').on(table.createdAt),
|
|
68
|
+
}));
|
|
69
|
+
|
|
70
|
+
export const posts = pgTable('posts', {
|
|
71
|
+
id: uuid('id').defaultRandom().primaryKey(),
|
|
72
|
+
userId: uuid('user_id').references(() => users.id, { onDelete: 'cascade' }).notNull(),
|
|
73
|
+
title: text('title').notNull(),
|
|
74
|
+
published: boolean('published').default(false).notNull(),
|
|
75
|
+
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
76
|
+
});
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Every column the query examples below read (`posts.published`, `posts.createdAt`) is defined here.
|
|
80
|
+
|
|
81
|
+
## Relations API
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
import { relations } from 'drizzle-orm';
|
|
85
|
+
|
|
86
|
+
export const usersRelations = relations(users, ({ many }) => ({
|
|
87
|
+
posts: many(posts),
|
|
88
|
+
}));
|
|
89
|
+
|
|
90
|
+
export const postsRelations = relations(posts, ({ one }) => ({
|
|
91
|
+
author: one(users, { fields: [posts.userId], references: [users.id] }),
|
|
92
|
+
}));
|
|
93
|
+
|
|
94
|
+
// Initialize client WITH schema so db.query.* works:
|
|
95
|
+
import { drizzle } from 'drizzle-orm/node-postgres';
|
|
96
|
+
import { Pool } from 'pg';
|
|
97
|
+
import * as schema from './schema';
|
|
98
|
+
|
|
99
|
+
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
|
|
100
|
+
export const db = drizzle(pool, { schema });
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Many-to-many requires an explicit junction table — Drizzle has no implicit join tables.
|
|
104
|
+
|
|
105
|
+
## Queries
|
|
106
|
+
|
|
107
|
+
### SQL-like builder
|
|
108
|
+
```typescript
|
|
109
|
+
import { eq, and, desc } from 'drizzle-orm';
|
|
110
|
+
|
|
111
|
+
const recent = await db
|
|
112
|
+
.select({ id: posts.id, title: posts.title, author: users.email })
|
|
113
|
+
.from(posts)
|
|
114
|
+
.innerJoin(users, eq(users.id, posts.userId))
|
|
115
|
+
.where(and(eq(users.role, 'user'), eq(posts.published, true)))
|
|
116
|
+
.orderBy(desc(posts.createdAt))
|
|
117
|
+
.limit(20);
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Relational
|
|
121
|
+
|
|
122
|
+
Prefer the callback form `(table, { eq }) => ...` — it avoids importing and shadowing the schema's table symbols:
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
const activeUsers = await db.query.users.findMany({
|
|
126
|
+
where: (user, { eq }) => eq(user.role, 'user'),
|
|
127
|
+
orderBy: (user, { desc }) => desc(user.createdAt),
|
|
128
|
+
with: {
|
|
129
|
+
posts: {
|
|
130
|
+
where: (post, { eq }) => eq(post.published, true),
|
|
131
|
+
limit: 5,
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
limit: 20,
|
|
135
|
+
});
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Mutations
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
// Insert + returning (Postgres only)
|
|
142
|
+
const [inserted] = await db.insert(users).values({ email: 'a@b.c' }).returning();
|
|
143
|
+
|
|
144
|
+
// Batch
|
|
145
|
+
await db.insert(users).values([{ email: 'x@x' }, { email: 'y@y' }]);
|
|
146
|
+
|
|
147
|
+
// Update
|
|
148
|
+
await db.update(users).set({ role: 'admin' }).where(eq(users.id, id));
|
|
149
|
+
|
|
150
|
+
// Delete
|
|
151
|
+
await db.delete(posts).where(eq(posts.userId, id));
|
|
152
|
+
|
|
153
|
+
// Upsert
|
|
154
|
+
await db.insert(users)
|
|
155
|
+
.values({ id, email })
|
|
156
|
+
.onConflictDoUpdate({ target: users.id, set: { email } });
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Transactions
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
import { sql } from 'drizzle-orm';
|
|
163
|
+
|
|
164
|
+
await db.transaction(async (tx) => {
|
|
165
|
+
const [author] = await tx.insert(users).values({ email: 'A@B.C' }).returning();
|
|
166
|
+
await tx.update(users)
|
|
167
|
+
.set({ email: sql`lower(${users.email})` }) // sql`` escape hatch, columns interpolate safely
|
|
168
|
+
.where(eq(users.id, author.id));
|
|
169
|
+
// any throw → rollback
|
|
170
|
+
});
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Drizzle Kit
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
drizzle-kit generate # write SQL migration files (review them)
|
|
177
|
+
drizzle-kit migrate # apply pending migrations — production
|
|
178
|
+
drizzle-kit push # sync schema directly — DEV ONLY, NEVER prod
|
|
179
|
+
drizzle-kit studio # GUI database browser
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
`drizzle.config.ts`:
|
|
183
|
+
```typescript
|
|
184
|
+
import type { Config } from 'drizzle-kit';
|
|
185
|
+
export default {
|
|
186
|
+
schema: './db/schema.ts',
|
|
187
|
+
out: './db/migrations',
|
|
188
|
+
dialect: 'postgresql',
|
|
189
|
+
dbCredentials: { url: process.env.DATABASE_URL! },
|
|
190
|
+
} satisfies Config;
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## Adapters
|
|
194
|
+
|
|
195
|
+
| DB | Adapter |
|
|
196
|
+
|---|---|
|
|
197
|
+
| Postgres (Neon) | `drizzle-orm/neon-http` |
|
|
198
|
+
| Postgres (node-pg) | `drizzle-orm/node-postgres` |
|
|
199
|
+
| Postgres (postgres.js) | `drizzle-orm/postgres-js` |
|
|
200
|
+
| SQLite (Turso) | `drizzle-orm/libsql` |
|
|
201
|
+
| SQLite (local) | `drizzle-orm/better-sqlite3` |
|
|
202
|
+
| MySQL (PlanetScale) | `drizzle-orm/planetscale-serverless` |
|
|
203
|
+
| MySQL (mysql2) | `drizzle-orm/mysql2` |
|
|
204
|
+
|
|
205
|
+
## Type Inference
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
import type { InferSelectModel, InferInsertModel } from 'drizzle-orm';
|
|
209
|
+
type User = InferSelectModel<typeof users>;
|
|
210
|
+
type NewUser = InferInsertModel<typeof users>;
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Never write manual TS interfaces for DB rows — schema is the source of truth.
|
|
214
|
+
|
|
215
|
+
## Performance
|
|
216
|
+
|
|
217
|
+
- **Prepared statements** for hot paths: `.prepare('getUser')` once, execute many times
|
|
218
|
+
- **Partial select**: choose only needed columns
|
|
219
|
+
- **Batch**: `db.batch([...])` for many independent queries in one round-trip (libsql / d1 only)
|
|
220
|
+
- **Indexes**: declare `index()` / `uniqueIndex()` inside the table builder
|
|
221
|
+
|
|
222
|
+
## Next.js Integration
|
|
223
|
+
|
|
224
|
+
```typescript
|
|
225
|
+
// app/dashboard/page.tsx — Server Component
|
|
226
|
+
import { db } from '@/db';
|
|
227
|
+
|
|
228
|
+
export default async function Dashboard() {
|
|
229
|
+
const allUsers = await db.query.users.findMany({ limit: 20 });
|
|
230
|
+
return <UsersList users={allUsers} />;
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
```typescript
|
|
235
|
+
// Server Action
|
|
236
|
+
'use server';
|
|
237
|
+
import { db } from '@/db';
|
|
238
|
+
import { users } from '@/db/schema';
|
|
239
|
+
export async function createUser(formData: FormData) {
|
|
240
|
+
await db.insert(users).values({ email: formData.get('email') as string });
|
|
241
|
+
}
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## Common Issues
|
|
245
|
+
|
|
246
|
+
| Symptom | Cause | Fix |
|
|
247
|
+
|---------|-------|-----|
|
|
248
|
+
| `db.query.users` is undefined | `{ schema }` not passed to `drizzle()` | Pass schema |
|
|
249
|
+
| Migration conflict | Out-of-sync DB state | `generate` new migration, review SQL, `migrate` |
|
|
250
|
+
| Type error on `relations` | Forgot to `export const usersRelations = relations(...)` | Add export |
|
|
251
|
+
| Slow query in Edge runtime | New connection per request | Use a serverless adapter (Neon, PlanetScale) or HTTP-based driver |
|
|
252
|
+
|
|
253
|
+
## Recap — non-negotiables
|
|
254
|
+
|
|
255
|
+
- Never `drizzle-kit push` in production; `generate` → review SQL → `migrate`.
|
|
256
|
+
- Pass `{ schema }` to `drizzle()` and export `relations()`, or `db.query.*` breaks.
|
|
257
|
+
- Always pool connections; prefer the query builder over raw SQL.
|
|
258
|
+
- MySQL has no `.returning()` — read `insertId` instead.
|
|
259
|
+
|
|
260
|
+
Adapted from VKirill/codex-starter-kit (Apache 2.0 community skill).
|