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,259 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: nextjs-supabase-auth
|
|
3
|
+
description: Expert integration of Supabase Auth with Next.js App Router — server/client boundary, middleware for session refresh, Server Components, Server Actions, RLS. Use when the task mentions Supabase auth, Next.js auth, login, signup, OAuth, protected routes, or auth middleware
|
|
4
|
+
tokens: 2155
|
|
5
|
+
user-invocable: false
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Next.js + Supabase Auth
|
|
9
|
+
|
|
10
|
+
Expert in integrating Supabase Auth with Next.js App Router: the server/client boundary, session refresh in middleware, Server Components, Client Components, and Server Actions.
|
|
11
|
+
|
|
12
|
+
## Use this skill when
|
|
13
|
+
|
|
14
|
+
- Wiring Supabase Auth into a Next.js App Router project (`@supabase/ssr`)
|
|
15
|
+
- Setting up login, signup, signout, OAuth, or magic-link / email-OTP flows
|
|
16
|
+
- Protecting routes or reading the authenticated user server-side
|
|
17
|
+
- Refreshing sessions in middleware
|
|
18
|
+
- Writing Row-Level Security (RLS) policies for authenticated tables
|
|
19
|
+
|
|
20
|
+
## Do not use this skill when
|
|
21
|
+
|
|
22
|
+
- The project uses the Pages Router or the deprecated `@supabase/auth-helpers-nextjs`
|
|
23
|
+
- Auth is handled by another provider (NextAuth/Auth.js, Clerk, Firebase)
|
|
24
|
+
- The task is Supabase database design with no auth surface
|
|
25
|
+
|
|
26
|
+
## Hard Rules
|
|
27
|
+
|
|
28
|
+
1. Use `@supabase/ssr` for App Router integration. NEVER use `@supabase/auth-helpers-nextjs` (deprecated).
|
|
29
|
+
2. Refresh the session in middleware on every request; the matcher MUST exclude static assets.
|
|
30
|
+
3. Read the user with `getUser()` in server code, NEVER `getSession()` — `getUser()` re-validates with the auth server; `getSession()` reads cookies only and is forgeable.
|
|
31
|
+
4. NEVER expose `SUPABASE_SERVICE_ROLE_KEY` to the client or any `NEXT_PUBLIC_*` var — it bypasses RLS.
|
|
32
|
+
5. Prefer Server Actions for auth operations (login, signup, signout).
|
|
33
|
+
6. Enable RLS on every table the anon key can reach — non-negotiable for production.
|
|
34
|
+
|
|
35
|
+
## Workflow
|
|
36
|
+
|
|
37
|
+
1. Create the browser and server clients (`lib/supabase/client.ts`, `lib/supabase/server.ts`) with the cookie handlers below. Done when both `createClient` helpers compile.
|
|
38
|
+
2. Wire `middleware.ts` to refresh the session and redirect unauthenticated users off protected paths. Done when the matcher excludes static assets.
|
|
39
|
+
3. Add the OAuth callback route (`app/auth/callback/route.ts`) if using OAuth or magic links. Done when it calls `exchangeCodeForSession`.
|
|
40
|
+
4. Build auth operations as Server Actions (login / signup / signout) with `revalidatePath` + `redirect`.
|
|
41
|
+
5. Read the user in Server Components with `getUser()`; redirect when it is null.
|
|
42
|
+
6. Enable RLS and add SELECT/INSERT policies on every table the anon key can reach.
|
|
43
|
+
|
|
44
|
+
## Stack
|
|
45
|
+
|
|
46
|
+
- `@supabase/ssr` — official SSR helper
|
|
47
|
+
- `@supabase/supabase-js` — base client (peer dependency)
|
|
48
|
+
- Next.js 14+ App Router
|
|
49
|
+
|
|
50
|
+
## Client Setup — Three Contexts
|
|
51
|
+
|
|
52
|
+
### Browser Client (`lib/supabase/client.ts`)
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
import { createBrowserClient } from '@supabase/ssr';
|
|
56
|
+
|
|
57
|
+
export function createClient() {
|
|
58
|
+
return createBrowserClient(
|
|
59
|
+
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
|
60
|
+
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Used in Client Components for realtime, file uploads, or direct client mutations.
|
|
66
|
+
|
|
67
|
+
### Server Client (`lib/supabase/server.ts`)
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
import { createServerClient } from '@supabase/ssr';
|
|
71
|
+
import { cookies } from 'next/headers';
|
|
72
|
+
|
|
73
|
+
export async function createClient() {
|
|
74
|
+
const cookieStore = await cookies();
|
|
75
|
+
return createServerClient(
|
|
76
|
+
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
|
77
|
+
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
|
78
|
+
{
|
|
79
|
+
cookies: {
|
|
80
|
+
getAll() { return cookieStore.getAll(); },
|
|
81
|
+
setAll(cookies) {
|
|
82
|
+
try {
|
|
83
|
+
cookies.forEach(({ name, value, options }) =>
|
|
84
|
+
cookieStore.set(name, value, options)
|
|
85
|
+
);
|
|
86
|
+
} catch { /* Server Component — middleware handles refresh */ }
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Used in Server Components, Server Actions, Route Handlers.
|
|
95
|
+
|
|
96
|
+
### Middleware Client (`middleware.ts`)
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
import { createServerClient } from '@supabase/ssr';
|
|
100
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
101
|
+
|
|
102
|
+
export async function middleware(request: NextRequest) {
|
|
103
|
+
let response = NextResponse.next({ request });
|
|
104
|
+
|
|
105
|
+
const supabase = createServerClient(
|
|
106
|
+
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
|
107
|
+
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
|
108
|
+
{
|
|
109
|
+
cookies: {
|
|
110
|
+
getAll() { return request.cookies.getAll(); },
|
|
111
|
+
setAll(cookies) {
|
|
112
|
+
cookies.forEach(({ name, value, options }) => {
|
|
113
|
+
request.cookies.set(name, value);
|
|
114
|
+
response.cookies.set(name, value, options);
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
const { data: { user } } = await supabase.auth.getUser();
|
|
122
|
+
|
|
123
|
+
// Protect specific routes
|
|
124
|
+
const isProtected = request.nextUrl.pathname.startsWith('/dashboard');
|
|
125
|
+
if (isProtected && !user) {
|
|
126
|
+
const url = request.nextUrl.clone();
|
|
127
|
+
url.pathname = '/login';
|
|
128
|
+
return NextResponse.redirect(url);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return response;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export const config = {
|
|
135
|
+
matcher: ['/((?!_next/static|_next/image|favicon.ico|.*\\.(?:svg|png|jpg)).*)'],
|
|
136
|
+
};
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## OAuth Callback Route
|
|
140
|
+
|
|
141
|
+
`app/auth/callback/route.ts` — required for OAuth flows (Google, GitHub, etc.):
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
import { createClient } from '@/lib/supabase/server';
|
|
145
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
146
|
+
|
|
147
|
+
export async function GET(request: NextRequest) {
|
|
148
|
+
const { searchParams, origin } = new URL(request.url);
|
|
149
|
+
const code = searchParams.get('code');
|
|
150
|
+
const next = searchParams.get('next') ?? '/dashboard';
|
|
151
|
+
|
|
152
|
+
if (code) {
|
|
153
|
+
const supabase = await createClient();
|
|
154
|
+
const { error } = await supabase.auth.exchangeCodeForSession(code);
|
|
155
|
+
if (!error) return NextResponse.redirect(`${origin}${next}`);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return NextResponse.redirect(`${origin}/auth/error`);
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Server Action — Login / Signup
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
'use server';
|
|
166
|
+
import { createClient } from '@/lib/supabase/server';
|
|
167
|
+
import { revalidatePath } from 'next/cache';
|
|
168
|
+
import { redirect } from 'next/navigation';
|
|
169
|
+
|
|
170
|
+
export async function login(formData: FormData) {
|
|
171
|
+
const supabase = await createClient();
|
|
172
|
+
const { error } = await supabase.auth.signInWithPassword({
|
|
173
|
+
email: formData.get('email') as string,
|
|
174
|
+
password: formData.get('password') as string,
|
|
175
|
+
});
|
|
176
|
+
if (error) return { error: error.message };
|
|
177
|
+
revalidatePath('/', 'layout');
|
|
178
|
+
redirect('/dashboard');
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Magic Link / Email OTP
|
|
183
|
+
|
|
184
|
+
```typescript
|
|
185
|
+
await supabase.auth.signInWithOtp({
|
|
186
|
+
email,
|
|
187
|
+
options: { emailRedirectTo: `${origin}/auth/callback?next=/dashboard` },
|
|
188
|
+
});
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Reading the User in a Server Component
|
|
192
|
+
|
|
193
|
+
```typescript
|
|
194
|
+
// app/dashboard/page.tsx
|
|
195
|
+
import { createClient } from '@/lib/supabase/server';
|
|
196
|
+
import { redirect } from 'next/navigation';
|
|
197
|
+
|
|
198
|
+
export default async function Dashboard() {
|
|
199
|
+
const supabase = await createClient();
|
|
200
|
+
const { data: { user } } = await supabase.auth.getUser();
|
|
201
|
+
if (!user) redirect('/login');
|
|
202
|
+
return <h1>Hi, {user.email}</h1>;
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Always `getUser()` here, never `getSession()` (Hard Rule 3).
|
|
207
|
+
|
|
208
|
+
## RLS (Row-Level Security)
|
|
209
|
+
|
|
210
|
+
Always enable RLS for tables touched by authenticated clients:
|
|
211
|
+
|
|
212
|
+
```sql
|
|
213
|
+
ALTER TABLE posts ENABLE ROW LEVEL SECURITY;
|
|
214
|
+
|
|
215
|
+
CREATE POLICY "Users can read their own posts"
|
|
216
|
+
ON posts FOR SELECT
|
|
217
|
+
USING (auth.uid() = user_id);
|
|
218
|
+
|
|
219
|
+
CREATE POLICY "Users can insert their own posts"
|
|
220
|
+
ON posts FOR INSERT
|
|
221
|
+
WITH CHECK (auth.uid() = user_id);
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Without RLS, the anon key gives full access to any table. RLS is a non-negotiable for production.
|
|
225
|
+
|
|
226
|
+
## Anti-Patterns to Avoid
|
|
227
|
+
|
|
228
|
+
### `getSession()` in server code
|
|
229
|
+
Forgeable — reads cookies without validation. Use `getUser()` (Hard Rule 3).
|
|
230
|
+
|
|
231
|
+
### Storing tokens manually
|
|
232
|
+
Don't `localStorage.setItem('token', ...)`. `@supabase/ssr` handles cookies for you.
|
|
233
|
+
|
|
234
|
+
### Hardcoding `service_role` key
|
|
235
|
+
`SUPABASE_SERVICE_ROLE_KEY` bypasses RLS and must NEVER be in client code or `NEXT_PUBLIC_*` env vars.
|
|
236
|
+
|
|
237
|
+
### Forgetting to revalidate after login
|
|
238
|
+
After a Server Action login, call `revalidatePath('/', 'layout')` so cached UI reflects the new user.
|
|
239
|
+
|
|
240
|
+
### Auth in client without listener
|
|
241
|
+
If you read user state on mount, also subscribe to `supabase.auth.onAuthStateChange` so sign-out in another tab updates UI.
|
|
242
|
+
|
|
243
|
+
## Common Production Issues
|
|
244
|
+
|
|
245
|
+
| Symptom | Fix |
|
|
246
|
+
|--------|-----|
|
|
247
|
+
| User logs in but Server Components see no session | Middleware not refreshing cookies — check matcher excludes static files |
|
|
248
|
+
| OAuth redirect loops | Mismatch between Supabase project's "Site URL" and your origin |
|
|
249
|
+
| RLS error "permission denied for table" | Policy missing or auth.uid() returning null |
|
|
250
|
+
| Cookies set in Server Component throw | Expected — let middleware handle it, wrap in try/catch |
|
|
251
|
+
|
|
252
|
+
## Recap — non-negotiables
|
|
253
|
+
|
|
254
|
+
- `@supabase/ssr` only; never the deprecated auth-helpers package.
|
|
255
|
+
- Middleware refreshes the session every request; matcher excludes static assets.
|
|
256
|
+
- Server code reads the user via `getUser()`, never `getSession()`.
|
|
257
|
+
- `SUPABASE_SERVICE_ROLE_KEY` never reaches the client; RLS is enabled on every anon-reachable table.
|
|
258
|
+
|
|
259
|
+
Adapted from vibeship-spawner-skills via VKirill/codex-starter-kit (Apache 2.0).
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: postgresql-optimization
|
|
3
|
+
description: PostgreSQL optimization — query tuning, indexing, EXPLAIN analysis, configuration, maintenance, and monitoring. Use when slow queries, missing indexes, vacuum lag, or performance bottlenecks are suspected
|
|
4
|
+
tokens: 1994
|
|
5
|
+
user-invocable: false
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# PostgreSQL Optimization
|
|
9
|
+
|
|
10
|
+
Diagnose and fix PostgreSQL performance: query tuning, indexing, EXPLAIN analysis, server configuration, maintenance, and monitoring. The core discipline is measure-before-and-after — one change per cycle, validated with `EXPLAIN ANALYZE`.
|
|
11
|
+
|
|
12
|
+
## Use this skill when
|
|
13
|
+
|
|
14
|
+
- Optimizing slow PostgreSQL queries
|
|
15
|
+
- Designing or reviewing indexing strategies
|
|
16
|
+
- Analyzing performance and identifying bottlenecks
|
|
17
|
+
- Tuning server configuration
|
|
18
|
+
- Managing production maintenance (VACUUM, ANALYZE, bloat)
|
|
19
|
+
- Setting up monitoring and alerting
|
|
20
|
+
|
|
21
|
+
## Do not use this skill when
|
|
22
|
+
|
|
23
|
+
- You need schema / data-model design — that is out of scope here; this skill tunes an existing schema. For Drizzle ORM schema and migration work, use the `drizzle-orm-expert` skill.
|
|
24
|
+
- The bottleneck is at the application layer, not the database.
|
|
25
|
+
- You need a database-agnostic optimization guide — this is PostgreSQL-specific.
|
|
26
|
+
|
|
27
|
+
## Hard Rules
|
|
28
|
+
|
|
29
|
+
- Measure with `EXPLAIN ANALYZE` BEFORE and AFTER every change — never tune from a guess.
|
|
30
|
+
- Change ONE layer at a time (index / query / config / maintenance), then re-measure.
|
|
31
|
+
- Use `CONCURRENTLY` for every `CREATE INDEX` and `REINDEX` on live tables — the plain form locks writes.
|
|
32
|
+
- NEVER disable autovacuum in production.
|
|
33
|
+
- NEVER run `VACUUM FULL` during business hours — it takes an ACCESS EXCLUSIVE lock on the whole table.
|
|
34
|
+
- Test config changes on staging first; treat each as a hypothesis to confirm with monitoring.
|
|
35
|
+
|
|
36
|
+
## Steps
|
|
37
|
+
|
|
38
|
+
Follow in order. Change one thing, re-measure, then move on.
|
|
39
|
+
|
|
40
|
+
1. **Identify** — Pin the specific slow query and its bottleneck category. Note the PostgreSQL version and key config (`shared_buffers`, `work_mem`, `effective_cache_size`, `autovacuum`); find the worst queries via `pg_stat_statements` or the slow-query log; check CPU / memory / disk I/O; classify the bottleneck as scan type, join strategy, I/O, locking, or vacuum lag. **Done when:** you have one target query and a suspected category.
|
|
41
|
+
2. **Measure the baseline** — Run `EXPLAIN (ANALYZE, BUFFERS)` on the target query before any change. Read the node types; compare estimated vs actual rows (large mismatch = stale statistics → run `ANALYZE`); locate the highest-cost node, highest actual-row node, or largest loop. Use the EXPLAIN Output Interpretation table below. **Done when:** you have a baseline plan and the specific expensive node.
|
|
42
|
+
3. **Apply one targeted fix** — Change exactly ONE layer, chosen from the bottleneck: missing index → Indexing Strategy; bad plan or query shape → Query Optimization; memory / checkpoint limits → Configuration Tuning; bloat or stale stats → Maintenance. Validate autovacuum is running before recommending a manual VACUUM; check for stale statistics before rewriting a query. **Done when:** exactly one change is applied.
|
|
43
|
+
4. **Verify** — Re-run `EXPLAIN ANALYZE`. Confirm the plan changed as intended and timing dropped. If it did not improve, revert the change and return to Step 2 with a different hypothesis. **Done when:** the second plan shows the expected improvement, or the change is reverted.
|
|
44
|
+
5. **Monitor** — Confirm the fix holds under real load using `pg_stat_statements`, `pg_stat_user_tables`, and `pg_stat_user_indexes` over time. Treat every config change as a hypothesis until monitoring confirms it. **Done when:** metrics are stable under production load.
|
|
45
|
+
|
|
46
|
+
## EXPLAIN Output Interpretation
|
|
47
|
+
|
|
48
|
+
```sql
|
|
49
|
+
EXPLAIN (ANALYZE, BUFFERS, FORMAT TEXT) SELECT ...;
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Node types to know: `Seq Scan`, `Index Scan`, `Index Only Scan`, `Hash Join`, `Nested Loop`, `Merge Join`. A `Seq Scan` on a small table is fine; on a large table it signals a missing or unused index.
|
|
53
|
+
|
|
54
|
+
| Output sign | Meaning |
|
|
55
|
+
|-------------|---------|
|
|
56
|
+
| Seq Scan on large table | Missing or unused index |
|
|
57
|
+
| Index Scan but slow | Index not selective; high row count returned |
|
|
58
|
+
| Nested Loop with large outer | Consider Hash Join (`enable_nestloop=off` for testing) |
|
|
59
|
+
| Hash Join with disk batches | `work_mem` too low |
|
|
60
|
+
| Sort with `external merge Disk` | `work_mem` too low for this sort |
|
|
61
|
+
| Estimated 1, actual 1M | Stale statistics → `ANALYZE table` |
|
|
62
|
+
| Estimated 1M, actual 1 | Histogram bucket too small → increase `ALTER TABLE ... ALTER COLUMN ... SET STATISTICS 1000` |
|
|
63
|
+
|
|
64
|
+
## Indexing Strategy
|
|
65
|
+
|
|
66
|
+
| Pattern | Index type |
|
|
67
|
+
|---------|-----------|
|
|
68
|
+
| Equality + range on 1 column | B-tree |
|
|
69
|
+
| Multi-column equality | Composite B-tree, most selective first |
|
|
70
|
+
| JSONB containment | GIN |
|
|
71
|
+
| Full-text search | GIN on `tsvector` |
|
|
72
|
+
| Range overlap, scheduling | GiST on range type |
|
|
73
|
+
| Hot subset (`WHERE status='active'`) | Partial index |
|
|
74
|
+
| Avoid heap reads for extra columns | Covering index with `INCLUDE` |
|
|
75
|
+
| Time-series, naturally ordered | BRIN |
|
|
76
|
+
|
|
77
|
+
Review `pg_stat_user_indexes` — unused indexes waste write performance and bloat.
|
|
78
|
+
|
|
79
|
+
```sql
|
|
80
|
+
-- Always CONCURRENTLY in production:
|
|
81
|
+
CREATE INDEX CONCURRENTLY idx_users_email_active
|
|
82
|
+
ON users (email) WHERE active = true;
|
|
83
|
+
|
|
84
|
+
-- Covering index for index-only scans:
|
|
85
|
+
CREATE INDEX CONCURRENTLY idx_orders_user_created
|
|
86
|
+
ON orders (user_id, created_at) INCLUDE (status, total);
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Query Optimization
|
|
90
|
+
|
|
91
|
+
- Rewrite subqueries as JOINs where the planner struggles
|
|
92
|
+
- Use CTEs (`WITH ...`) for readability; add `AS MATERIALIZED` when you need an optimization fence — PostgreSQL 12+ inlines plain CTEs
|
|
93
|
+
- Cursor-based pagination for large feeds (offset is O(n))
|
|
94
|
+
- Use `LIMIT` in subqueries to bound work
|
|
95
|
+
- Avoid functions on indexed columns in `WHERE` — prevents index use
|
|
96
|
+
- Avoid implicit type casts (`WHERE id = '123'` when id is integer)
|
|
97
|
+
|
|
98
|
+
## Configuration Tuning
|
|
99
|
+
|
|
100
|
+
| Setting | Default | Recommendation |
|
|
101
|
+
|---------|---------|----------------|
|
|
102
|
+
| `shared_buffers` | 128MB | 25% of RAM (dedicated DB server) |
|
|
103
|
+
| `work_mem` | 4MB | 16-64MB per connection; multiply by max_connections for peak |
|
|
104
|
+
| `effective_cache_size` | 4GB | 50-75% of RAM |
|
|
105
|
+
| `checkpoint_completion_target` | 0.9 | Keep 0.9 to spread checkpoint I/O |
|
|
106
|
+
| `max_wal_size` | 1GB | Increase if checkpoint frequency too high |
|
|
107
|
+
| `autovacuum_vacuum_scale_factor` | 0.2 | 0.01-0.05 for large tables |
|
|
108
|
+
|
|
109
|
+
## Maintenance
|
|
110
|
+
|
|
111
|
+
- Regular `VACUUM` reclaims dead tuples from updates/deletes
|
|
112
|
+
- `VACUUM ANALYZE` after large data changes updates planner stats
|
|
113
|
+
- Monitor bloat: `pg_stat_user_tables`, `pg_total_relation_size`, `pgstattuple`
|
|
114
|
+
- Check `pg_stat_user_tables.last_autovacuum`, `n_dead_tup`
|
|
115
|
+
- `REINDEX CONCURRENTLY` for bloated indexes (no table lock)
|
|
116
|
+
|
|
117
|
+
## Partitioning (very large tables)
|
|
118
|
+
|
|
119
|
+
- Declarative partitioning `PARTITION BY RANGE | LIST | HASH` splits a huge table so the planner prunes irrelevant partitions.
|
|
120
|
+
- Range-partition time-series data by date and pair each partition with a BRIN index; drop old partitions instead of `DELETE` to avoid bloat.
|
|
121
|
+
|
|
122
|
+
## Monitoring
|
|
123
|
+
|
|
124
|
+
| Tool | Purpose |
|
|
125
|
+
|------|---------|
|
|
126
|
+
| `pg_stat_statements` | Most time-consuming queries |
|
|
127
|
+
| `pg_stat_user_tables` | Table access patterns, dead tuples, vacuum timing |
|
|
128
|
+
| `pg_stat_user_indexes` | Index usage; identify unused indexes |
|
|
129
|
+
| `pg_locks` | Lock contention slowing queries |
|
|
130
|
+
| `pg_stat_activity` | Currently running queries, idle-in-transaction sessions |
|
|
131
|
+
| `postgres_exporter` + Grafana | Ongoing visibility |
|
|
132
|
+
|
|
133
|
+
## Common Anti-Patterns
|
|
134
|
+
|
|
135
|
+
- `WHERE LOWER(email) = ?` without expression index
|
|
136
|
+
- Implicit type cast: `WHERE id = '123'` when id is integer
|
|
137
|
+
- `SELECT *` on wide tables (prevents index-only scans)
|
|
138
|
+
- `OFFSET 1000000 LIMIT 10` — scans all preceding rows
|
|
139
|
+
- `IN (...)` with hundreds of values — consider `ANY(ARRAY[...])` or temp table
|
|
140
|
+
- Unnecessary `ORDER BY` in subqueries
|
|
141
|
+
- Correlated subqueries executing once per outer row
|
|
142
|
+
|
|
143
|
+
## Recap — non-negotiables
|
|
144
|
+
|
|
145
|
+
- Measure with `EXPLAIN ANALYZE` before and after; change one layer per cycle.
|
|
146
|
+
- Use `CONCURRENTLY` for every `CREATE INDEX` / `REINDEX` on live tables.
|
|
147
|
+
- Never disable autovacuum; never `VACUUM FULL` during business hours.
|
|
148
|
+
- Test config on staging first, then confirm with monitoring.
|
|
149
|
+
|
|
150
|
+
Adapted from VKirill/codex-starter-kit (personal skill, MIT).
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: project-architecture
|
|
3
|
+
description: Project architecture reference — modules, layers, data flow
|
|
4
|
+
tokens: 277
|
|
5
|
+
user-invocable: false
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# YOUR_PROJECT Architecture Reference
|
|
9
|
+
|
|
10
|
+
Auto-loaded template. Fill each section with real project details when you run `/superkit-init`, or by hand. While a section still reads `TODO`, this skill is unconfigured — agents must NEVER report a placeholder as a project fact.
|
|
11
|
+
|
|
12
|
+
Fill a count by running the example command and pasting the number. Keep example commands as plain inline code; do not prefix a command with a bang before its backtick (that would run it on load).
|
|
13
|
+
|
|
14
|
+
## Current Scale
|
|
15
|
+
- Services: TODO — count with `ls services/ | wc -l`
|
|
16
|
+
- Migrations: TODO — count with `ls migrations/*.up.sql | wc -l`
|
|
17
|
+
|
|
18
|
+
## System Overview
|
|
19
|
+
TODO: high-level component map / system diagram.
|
|
20
|
+
|
|
21
|
+
## Module Map
|
|
22
|
+
TODO: modules or services, and what each one owns.
|
|
23
|
+
|
|
24
|
+
## Data Flow
|
|
25
|
+
TODO: main request/response paths and background job flows.
|
|
26
|
+
|
|
27
|
+
## UI Components & Styling
|
|
28
|
+
TODO: component library and styling approach — design tokens, spacing scale, breakpoints, dark-mode support. Read by the visual-reviewer agent. Write "N/A — no frontend" if the project has no UI.
|
|
29
|
+
|
|
30
|
+
## Key Configuration
|
|
31
|
+
TODO: config files and what each one controls.
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: project-scanner
|
|
3
|
+
description: Project introspection — detect languages, frameworks, database, structure, scale, auth, CI/CD
|
|
4
|
+
tokens: 1509
|
|
5
|
+
user-invocable: false
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Project Scanner
|
|
9
|
+
|
|
10
|
+
Static reference for project introspection: file markers, import signals, and bash snippets that identify a repo's languages, frameworks, database, infrastructure, structure, components, and scale. Read the tables and apply them to the project in front of you — this file holds no per-project data.
|
|
11
|
+
|
|
12
|
+
## Use when
|
|
13
|
+
- You need to identify an unfamiliar project's stack, structure, or scale from its files alone.
|
|
14
|
+
- Building a project summary (languages, frameworks, DB, infra, components, auth, CI/CD) before deeper work.
|
|
15
|
+
|
|
16
|
+
## Do not use when
|
|
17
|
+
- The project is already described in `CLAUDE.md` / `AGENTS.md` — read that first; only re-detect what it omits.
|
|
18
|
+
- You already know the one fact you need from a file you have read (e.g. framework stated in `package.json`).
|
|
19
|
+
|
|
20
|
+
## Hard Rules
|
|
21
|
+
1. Detect from files actually present — read or grep the marker; never infer a stack from the project's name.
|
|
22
|
+
2. Report EVERY detected language, not just the first — polyglot repos are common.
|
|
23
|
+
3. Multiple structure matches → choose the most specific (see Tie-breaks) and name the signals that fired.
|
|
24
|
+
4. No marker matches a category → report `UNKNOWN` for it. Never guess a value.
|
|
25
|
+
|
|
26
|
+
## Scan procedure
|
|
27
|
+
1. Languages — match file markers (Languages table); read each hit's version source. Report all matches.
|
|
28
|
+
2. Frameworks — for each detected language, grep dependencies against the Frameworks table.
|
|
29
|
+
3. Database & infrastructure — check docker-compose, `.env`, and schema files (Database + Infrastructure tables).
|
|
30
|
+
4. Structure — classify the repo against the Structure Patterns table, applying Tie-breaks.
|
|
31
|
+
5. Components — scan top-level and second-level directories (Component Detection table).
|
|
32
|
+
6. Scale — run the Scale Estimation snippets for approximate counts.
|
|
33
|
+
|
|
34
|
+
Done when: every category above has a concrete value or `UNKNOWN`.
|
|
35
|
+
|
|
36
|
+
## Detection Patterns
|
|
37
|
+
|
|
38
|
+
### Languages
|
|
39
|
+
|
|
40
|
+
| File Marker | Language | Version Source |
|
|
41
|
+
|-------------|----------|---------------|
|
|
42
|
+
| `go.mod` | Go | First line: `go X.Y` |
|
|
43
|
+
| `package.json` + `tsconfig.json` | TypeScript | `package.json` → `typescript` version |
|
|
44
|
+
| `package.json` (no tsconfig) | JavaScript | `package.json` → `engines.node` |
|
|
45
|
+
| `pyproject.toml` | Python | `[project]` → `requires-python` |
|
|
46
|
+
| `requirements.txt` | Python | None (check `python --version`) |
|
|
47
|
+
| `Cargo.toml` | Rust | `[package]` → `edition` |
|
|
48
|
+
| `pom.xml` | Java | `<java.version>` |
|
|
49
|
+
| `build.gradle` / `build.gradle.kts` | Kotlin/Java | `sourceCompatibility` |
|
|
50
|
+
|
|
51
|
+
### Frameworks
|
|
52
|
+
|
|
53
|
+
| Language | Detection | Popular Frameworks |
|
|
54
|
+
|----------|-----------|-------------------|
|
|
55
|
+
| Go | `go.mod` requires | chi, gin, echo, fiber, gorilla/mux |
|
|
56
|
+
| TypeScript | `package.json` deps | react, vue, svelte, angular, next, nuxt, express, fastify, nestjs |
|
|
57
|
+
| Python | `pyproject.toml` / `requirements.txt` | fastapi, django, flask, starlette |
|
|
58
|
+
| Rust | `Cargo.toml` deps | actix-web, axum, rocket, warp |
|
|
59
|
+
|
|
60
|
+
### Database
|
|
61
|
+
|
|
62
|
+
| Signal | Database | Driver |
|
|
63
|
+
|--------|----------|--------|
|
|
64
|
+
| `postgres` in docker-compose | PostgreSQL | Read go.mod/package.json for driver |
|
|
65
|
+
| `mysql` in docker-compose | MySQL | Read go.mod/package.json for driver |
|
|
66
|
+
| `mongo` in docker-compose | MongoDB | Read go.mod/package.json for driver |
|
|
67
|
+
| `DATABASE_URL` in .env | Parse URL scheme | From URL |
|
|
68
|
+
| `schema.prisma` | From `datasource.provider` | Prisma |
|
|
69
|
+
|
|
70
|
+
### Infrastructure (cache, storage, auth, CI/CD)
|
|
71
|
+
|
|
72
|
+
| Category | Signal |
|
|
73
|
+
|----------|--------|
|
|
74
|
+
| Cache | `redis` in docker-compose; imports `go-redis`, `ioredis`, `redis-py` |
|
|
75
|
+
| Storage | `minio` / `s3` in docker-compose; imports `minio-go`, `@aws-sdk/client-s3` |
|
|
76
|
+
| Auth | grep for `jwt`, `session`, `oauth`, `passport`, `auth middleware` |
|
|
77
|
+
| CI/CD | `.github/workflows/`, `Dockerfile`, `docker-compose*.yml`, `.gitlab-ci.yml` |
|
|
78
|
+
|
|
79
|
+
### Structure Patterns
|
|
80
|
+
|
|
81
|
+
| Pattern | Classification |
|
|
82
|
+
|---------|---------------|
|
|
83
|
+
| Multiple `go.mod` or `package.json` (not in node_modules) | Monorepo |
|
|
84
|
+
| Single root `go.mod` + `cmd/` | Go standard layout |
|
|
85
|
+
| Single `package.json` + `src/` | Single app |
|
|
86
|
+
| `apps/` or `packages/` with workspace config | Monorepo (workspace) |
|
|
87
|
+
| `services/` with multiple subdirs each with own main | Microservices |
|
|
88
|
+
|
|
89
|
+
### Component Detection
|
|
90
|
+
|
|
91
|
+
Scan top-level and second-level directories:
|
|
92
|
+
|
|
93
|
+
| Directory Pattern | Component Type |
|
|
94
|
+
|-------------------|---------------|
|
|
95
|
+
| `backend/`, `server/`, `api/` | Backend |
|
|
96
|
+
| `frontend/`, `web/`, `client/`, `app/` | Frontend |
|
|
97
|
+
| `admin/`, `adminpanel/`, `dashboard/` | Admin UI |
|
|
98
|
+
| `bot*/`, `tgbot*/` | Bots |
|
|
99
|
+
| `worker*/`, `jobs/`, `queue/` | Background workers |
|
|
100
|
+
| `infra/`, `deploy/`, `terraform/` | Infrastructure |
|
|
101
|
+
| `mobile/`, `ios/`, `android/` | Mobile |
|
|
102
|
+
| `docs/` | Documentation |
|
|
103
|
+
|
|
104
|
+
### Tie-breaks (ambiguous detection)
|
|
105
|
+
|
|
106
|
+
- Several languages match → report all; there is no single "primary" language.
|
|
107
|
+
- Repo matches both Monorepo and Microservices → classify as Microservices only when `services/` holds ≥2 subdirs each with its own entrypoint (`main.go` / `package.json` / `main.py`); otherwise Monorepo.
|
|
108
|
+
- Several structure rows match → take the most specific (workspace or microservices over plain monorepo).
|
|
109
|
+
- No marker matches a category → `UNKNOWN`; do not infer a value from directory names alone.
|
|
110
|
+
|
|
111
|
+
### Scale Estimation
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
# Files by language
|
|
115
|
+
find . -name "*.go" | grep -v vendor | wc -l
|
|
116
|
+
find . \( -name "*.ts" -o -name "*.tsx" \) | grep -v node_modules | wc -l
|
|
117
|
+
|
|
118
|
+
# Migrations
|
|
119
|
+
find . -path "*/migrations/*" -name "*.up.sql" | wc -l
|
|
120
|
+
|
|
121
|
+
# API endpoints (approximate) — ERE, works with grep -E and ripgrep
|
|
122
|
+
grep -rE "router\.(Get|Post|Put|Delete|Patch)" --include="*.go" . | wc -l
|
|
123
|
+
grep -rE "app\.(get|post|put|delete|patch)" --include="*.ts" . | wc -l
|
|
124
|
+
|
|
125
|
+
# LOC estimate
|
|
126
|
+
find . \( -name "*.go" -o -name "*.ts" -o -name "*.py" \) | grep -v vendor | grep -v node_modules | xargs wc -l 2>/dev/null | tail -1
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Recap — non-negotiables
|
|
130
|
+
- Detect from real files; report every language; never infer a stack from the project name.
|
|
131
|
+
- Ambiguous structure → most specific match, and state which signals fired.
|
|
132
|
+
- No marker for a category → `UNKNOWN`, never a guess.
|