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,32 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# format-on-edit.sh — PostToolUse hook for Edit/Write
|
|
3
|
+
# Runs gofmt -w on edited Go files.
|
|
4
|
+
# Profile: standard, strict (skip on fast)
|
|
5
|
+
|
|
6
|
+
# Unified profile + disable check
|
|
7
|
+
SUPERKIT_PROFILE_LIB="$(dirname "$0")/lib/profile.sh"
|
|
8
|
+
[ -f "$SUPERKIT_PROFILE_LIB" ] || SUPERKIT_PROFILE_LIB="$(dirname "$0")/../lib/profile.sh"
|
|
9
|
+
# shellcheck source=/dev/null
|
|
10
|
+
[ -f "$SUPERKIT_PROFILE_LIB" ] && source "$SUPERKIT_PROFILE_LIB" && should_skip_hook "$(basename "$0" .sh)" && exit 0
|
|
11
|
+
|
|
12
|
+
PROFILE="${CLAUDE_HOOK_PROFILE:-standard}"
|
|
13
|
+
if [ "$PROFILE" = "fast" ]; then
|
|
14
|
+
exit 0
|
|
15
|
+
fi
|
|
16
|
+
|
|
17
|
+
INPUT=$(cat)
|
|
18
|
+
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty')
|
|
19
|
+
|
|
20
|
+
if [ -z "$FILE_PATH" ]; then
|
|
21
|
+
exit 0
|
|
22
|
+
fi
|
|
23
|
+
|
|
24
|
+
if [[ ! "$FILE_PATH" =~ \.go$ ]]; then
|
|
25
|
+
exit 0
|
|
26
|
+
fi
|
|
27
|
+
|
|
28
|
+
if [ -f "$FILE_PATH" ]; then
|
|
29
|
+
gofmt -w "$FILE_PATH" 2>/dev/null
|
|
30
|
+
fi
|
|
31
|
+
|
|
32
|
+
exit 0
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# go-safety-check-on-edit.sh — PostToolUse hook for Edit/Write
|
|
3
|
+
# Detects common Go safety traps: nil maps, defer in loops, append aliasing.
|
|
4
|
+
# Profile: standard, strict
|
|
5
|
+
|
|
6
|
+
# Unified profile + disable check
|
|
7
|
+
SUPERKIT_PROFILE_LIB="$(dirname "$0")/lib/profile.sh"
|
|
8
|
+
[ -f "$SUPERKIT_PROFILE_LIB" ] || SUPERKIT_PROFILE_LIB="$(dirname "$0")/../lib/profile.sh"
|
|
9
|
+
# shellcheck source=/dev/null
|
|
10
|
+
[ -f "$SUPERKIT_PROFILE_LIB" ] && source "$SUPERKIT_PROFILE_LIB" && should_skip_hook "$(basename "$0" .sh)" && exit 0
|
|
11
|
+
|
|
12
|
+
PROFILE="${CLAUDE_HOOK_PROFILE:-standard}"
|
|
13
|
+
if [ "$PROFILE" = "fast" ]; then
|
|
14
|
+
exit 0
|
|
15
|
+
fi
|
|
16
|
+
|
|
17
|
+
INPUT=$(cat)
|
|
18
|
+
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty')
|
|
19
|
+
|
|
20
|
+
if [ -z "$FILE_PATH" ]; then exit 0; fi
|
|
21
|
+
if [[ ! "$FILE_PATH" =~ \.go$ ]]; then exit 0; fi
|
|
22
|
+
if [ ! -f "$FILE_PATH" ]; then exit 0; fi
|
|
23
|
+
|
|
24
|
+
WARNINGS=""
|
|
25
|
+
|
|
26
|
+
# Check 1: Uninitialized map — var m map[...] without make()
|
|
27
|
+
while IFS= read -r line; do
|
|
28
|
+
LINENO_=$(echo "$line" | cut -d: -f1)
|
|
29
|
+
NEXT_LINES=$(sed -n "$((LINENO_+1)),$((LINENO_+3))p" "$FILE_PATH" 2>/dev/null)
|
|
30
|
+
if ! echo "$NEXT_LINES" | grep -q 'make(\|= map\['; then
|
|
31
|
+
WARNINGS="${WARNINGS}\n warning: go-safety: line ${LINENO_} — map declared without initialization (nil map panics on write)"
|
|
32
|
+
WARNINGS="${WARNINGS}\n Fix: use make(map[K]V) or literal map[K]V{}"
|
|
33
|
+
fi
|
|
34
|
+
done < <(grep -n 'var [a-zA-Z_]* map\[' "$FILE_PATH" 2>/dev/null)
|
|
35
|
+
|
|
36
|
+
# Check 2: defer inside for loop
|
|
37
|
+
while IFS= read -r line; do
|
|
38
|
+
LINENO_=$(echo "$line" | cut -d: -f1)
|
|
39
|
+
# Look backwards for enclosing 'for' within 20 lines
|
|
40
|
+
START=$((LINENO_ - 20))
|
|
41
|
+
if [ "$START" -lt 1 ]; then START=1; fi
|
|
42
|
+
CONTEXT=$(sed -n "${START},${LINENO_}p" "$FILE_PATH" 2>/dev/null)
|
|
43
|
+
if echo "$CONTEXT" | grep -q '^\s*for '; then
|
|
44
|
+
WARNINGS="${WARNINGS}\n warning: go-safety: line ${LINENO_} — defer inside for loop (accumulates until function exit)"
|
|
45
|
+
WARNINGS="${WARNINGS}\n Fix: wrap in closure or extract to separate function"
|
|
46
|
+
fi
|
|
47
|
+
done < <(grep -n '^\s*defer ' "$FILE_PATH" 2>/dev/null)
|
|
48
|
+
|
|
49
|
+
if [ -n "$WARNINGS" ]; then
|
|
50
|
+
echo -e "\nGo safety patterns detected:${WARNINGS}" >&2
|
|
51
|
+
echo "" >&2
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
exit 0
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# go-vet-on-edit.sh — PostToolUse hook for Edit/Write
|
|
3
|
+
# Runs go vet on the package containing the edited .go file.
|
|
4
|
+
# Finds the nearest go.mod to determine the module root.
|
|
5
|
+
# Profile: strict only
|
|
6
|
+
|
|
7
|
+
# Unified profile + disable check
|
|
8
|
+
SUPERKIT_PROFILE_LIB="$(dirname "$0")/lib/profile.sh"
|
|
9
|
+
[ -f "$SUPERKIT_PROFILE_LIB" ] || SUPERKIT_PROFILE_LIB="$(dirname "$0")/../lib/profile.sh"
|
|
10
|
+
# shellcheck source=/dev/null
|
|
11
|
+
[ -f "$SUPERKIT_PROFILE_LIB" ] && source "$SUPERKIT_PROFILE_LIB" && should_skip_hook "$(basename "$0" .sh)" && exit 0
|
|
12
|
+
|
|
13
|
+
PROFILE="${CLAUDE_HOOK_PROFILE:-standard}"
|
|
14
|
+
if [ "$PROFILE" != "strict" ]; then
|
|
15
|
+
exit 0
|
|
16
|
+
fi
|
|
17
|
+
|
|
18
|
+
INPUT=$(cat)
|
|
19
|
+
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty')
|
|
20
|
+
|
|
21
|
+
if [ -z "$FILE_PATH" ]; then
|
|
22
|
+
exit 0
|
|
23
|
+
fi
|
|
24
|
+
|
|
25
|
+
if [[ ! "$FILE_PATH" =~ \.go$ ]]; then
|
|
26
|
+
exit 0
|
|
27
|
+
fi
|
|
28
|
+
|
|
29
|
+
if [ ! -f "$FILE_PATH" ]; then
|
|
30
|
+
exit 0
|
|
31
|
+
fi
|
|
32
|
+
|
|
33
|
+
# Find nearest go.mod by walking up from the file's directory
|
|
34
|
+
DIR=$(dirname "$FILE_PATH")
|
|
35
|
+
MODULE_ROOT=""
|
|
36
|
+
SEARCH_DIR="$DIR"
|
|
37
|
+
while [ "$SEARCH_DIR" != "/" ] && [ "$SEARCH_DIR" != "." ]; do
|
|
38
|
+
if [ -f "$SEARCH_DIR/go.mod" ]; then
|
|
39
|
+
MODULE_ROOT="$SEARCH_DIR"
|
|
40
|
+
break
|
|
41
|
+
fi
|
|
42
|
+
SEARCH_DIR=$(dirname "$SEARCH_DIR")
|
|
43
|
+
done
|
|
44
|
+
|
|
45
|
+
if [ -z "$MODULE_ROOT" ]; then
|
|
46
|
+
exit 0
|
|
47
|
+
fi
|
|
48
|
+
|
|
49
|
+
cd "$MODULE_ROOT" 2>/dev/null || exit 0
|
|
50
|
+
|
|
51
|
+
# Compute relative package path from module root
|
|
52
|
+
REL_PKG="./${DIR#$MODULE_ROOT/}"
|
|
53
|
+
|
|
54
|
+
RESULT=$(go vet "$REL_PKG" 2>&1)
|
|
55
|
+
EXIT_CODE=$?
|
|
56
|
+
if [ $EXIT_CODE -ne 0 ]; then
|
|
57
|
+
echo "go vet issues:" >&2
|
|
58
|
+
echo "$RESULT" | head -15 >&2
|
|
59
|
+
fi
|
|
60
|
+
|
|
61
|
+
exit 0
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# golangci-lint-on-edit.sh — PostToolUse hook for Edit/Write
|
|
3
|
+
# Runs golangci-lint on the package containing the edited .go file.
|
|
4
|
+
# Profile: strict only (too slow for standard, ~2-5s)
|
|
5
|
+
|
|
6
|
+
# Unified profile + disable check
|
|
7
|
+
SUPERKIT_PROFILE_LIB="$(dirname "$0")/lib/profile.sh"
|
|
8
|
+
[ -f "$SUPERKIT_PROFILE_LIB" ] || SUPERKIT_PROFILE_LIB="$(dirname "$0")/../lib/profile.sh"
|
|
9
|
+
# shellcheck source=/dev/null
|
|
10
|
+
[ -f "$SUPERKIT_PROFILE_LIB" ] && source "$SUPERKIT_PROFILE_LIB" && should_skip_hook "$(basename "$0" .sh)" && exit 0
|
|
11
|
+
|
|
12
|
+
PROFILE="${CLAUDE_HOOK_PROFILE:-standard}"
|
|
13
|
+
if [ "$PROFILE" != "strict" ]; then
|
|
14
|
+
exit 0
|
|
15
|
+
fi
|
|
16
|
+
|
|
17
|
+
INPUT=$(cat)
|
|
18
|
+
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty')
|
|
19
|
+
|
|
20
|
+
if [ -z "$FILE_PATH" ]; then exit 0; fi
|
|
21
|
+
if [[ ! "$FILE_PATH" =~ \.go$ ]]; then exit 0; fi
|
|
22
|
+
if [ ! -f "$FILE_PATH" ]; then exit 0; fi
|
|
23
|
+
|
|
24
|
+
# Check golangci-lint is available
|
|
25
|
+
if ! command -v golangci-lint &>/dev/null; then
|
|
26
|
+
exit 0
|
|
27
|
+
fi
|
|
28
|
+
|
|
29
|
+
# Find nearest go.mod
|
|
30
|
+
DIR=$(dirname "$FILE_PATH")
|
|
31
|
+
MODULE_ROOT=""
|
|
32
|
+
SEARCH_DIR="$DIR"
|
|
33
|
+
while [ "$SEARCH_DIR" != "/" ] && [ "$SEARCH_DIR" != "." ]; do
|
|
34
|
+
if [ -f "$SEARCH_DIR/go.mod" ]; then
|
|
35
|
+
MODULE_ROOT="$SEARCH_DIR"
|
|
36
|
+
break
|
|
37
|
+
fi
|
|
38
|
+
SEARCH_DIR=$(dirname "$SEARCH_DIR")
|
|
39
|
+
done
|
|
40
|
+
|
|
41
|
+
if [ -z "$MODULE_ROOT" ]; then exit 0; fi
|
|
42
|
+
|
|
43
|
+
cd "$MODULE_ROOT" 2>/dev/null || exit 0
|
|
44
|
+
|
|
45
|
+
REL_PKG="./${DIR#$MODULE_ROOT/}"
|
|
46
|
+
|
|
47
|
+
RESULT=$(golangci-lint run --fast "$REL_PKG" 2>&1 | head -10)
|
|
48
|
+
if [ -n "$RESULT" ]; then
|
|
49
|
+
echo "golangci-lint issues:" >&2
|
|
50
|
+
echo "$RESULT" >&2
|
|
51
|
+
echo "" >&2
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
exit 0
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# ruff-on-edit.sh — PostToolUse hook for Edit/Write
|
|
3
|
+
# Runs ruff check --fix + ruff format on edited .py files.
|
|
4
|
+
# Profile: standard, strict (skip on fast)
|
|
5
|
+
|
|
6
|
+
# Unified profile + disable check
|
|
7
|
+
SUPERKIT_PROFILE_LIB="$(dirname "$0")/lib/profile.sh"
|
|
8
|
+
[ -f "$SUPERKIT_PROFILE_LIB" ] || SUPERKIT_PROFILE_LIB="$(dirname "$0")/../lib/profile.sh"
|
|
9
|
+
# shellcheck source=/dev/null
|
|
10
|
+
[ -f "$SUPERKIT_PROFILE_LIB" ] && source "$SUPERKIT_PROFILE_LIB" && should_skip_hook "$(basename "$0" .sh)" && exit 0
|
|
11
|
+
|
|
12
|
+
PROFILE="${CLAUDE_HOOK_PROFILE:-standard}"
|
|
13
|
+
if [ "$PROFILE" = "fast" ]; then
|
|
14
|
+
exit 0
|
|
15
|
+
fi
|
|
16
|
+
|
|
17
|
+
INPUT=$(cat)
|
|
18
|
+
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty')
|
|
19
|
+
|
|
20
|
+
if [ -z "$FILE_PATH" ]; then
|
|
21
|
+
exit 0
|
|
22
|
+
fi
|
|
23
|
+
|
|
24
|
+
if [[ ! "$FILE_PATH" =~ \.py$ ]]; then
|
|
25
|
+
exit 0
|
|
26
|
+
fi
|
|
27
|
+
|
|
28
|
+
if [ ! -f "$FILE_PATH" ]; then
|
|
29
|
+
exit 0
|
|
30
|
+
fi
|
|
31
|
+
|
|
32
|
+
# Check if ruff is available
|
|
33
|
+
if ! command -v ruff &>/dev/null; then
|
|
34
|
+
# Try via uvx or pipx as fallback
|
|
35
|
+
if command -v uvx &>/dev/null; then
|
|
36
|
+
RUFF="uvx ruff"
|
|
37
|
+
elif command -v pipx &>/dev/null; then
|
|
38
|
+
RUFF="pipx run ruff"
|
|
39
|
+
else
|
|
40
|
+
exit 0 # ruff not available, skip silently
|
|
41
|
+
fi
|
|
42
|
+
else
|
|
43
|
+
RUFF="ruff"
|
|
44
|
+
fi
|
|
45
|
+
|
|
46
|
+
# Run ruff check with auto-fix (safe fixes only)
|
|
47
|
+
$RUFF check --fix --select I "$FILE_PATH" 2>/dev/null
|
|
48
|
+
|
|
49
|
+
# Run ruff format
|
|
50
|
+
RESULT=$($RUFF format "$FILE_PATH" 2>&1)
|
|
51
|
+
EXIT_CODE=$?
|
|
52
|
+
|
|
53
|
+
if [ $EXIT_CODE -ne 0 ]; then
|
|
54
|
+
echo "ruff format issues:" >&2
|
|
55
|
+
echo "$RESULT" | head -10 >&2
|
|
56
|
+
fi
|
|
57
|
+
|
|
58
|
+
# Run ruff check (lint) and report remaining issues
|
|
59
|
+
LINT_RESULT=$($RUFF check "$FILE_PATH" 2>&1)
|
|
60
|
+
LINT_EXIT=$?
|
|
61
|
+
|
|
62
|
+
if [ $LINT_EXIT -ne 0 ]; then
|
|
63
|
+
echo "ruff lint issues:" >&2
|
|
64
|
+
echo "$LINT_RESULT" | head -15 >&2
|
|
65
|
+
fi
|
|
66
|
+
|
|
67
|
+
exit 0
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# cargo-check-on-edit.sh — PostToolUse hook for Edit/Write
|
|
3
|
+
# Runs cargo check in the nearest Cargo.toml directory after .rs file edits.
|
|
4
|
+
# Profile: standard, strict (skip on fast)
|
|
5
|
+
|
|
6
|
+
# Unified profile + disable check
|
|
7
|
+
SUPERKIT_PROFILE_LIB="$(dirname "$0")/lib/profile.sh"
|
|
8
|
+
[ -f "$SUPERKIT_PROFILE_LIB" ] || SUPERKIT_PROFILE_LIB="$(dirname "$0")/../lib/profile.sh"
|
|
9
|
+
# shellcheck source=/dev/null
|
|
10
|
+
[ -f "$SUPERKIT_PROFILE_LIB" ] && source "$SUPERKIT_PROFILE_LIB" && should_skip_hook "$(basename "$0" .sh)" && exit 0
|
|
11
|
+
|
|
12
|
+
PROFILE="${CLAUDE_HOOK_PROFILE:-standard}"
|
|
13
|
+
if [ "$PROFILE" = "fast" ]; then
|
|
14
|
+
exit 0
|
|
15
|
+
fi
|
|
16
|
+
|
|
17
|
+
INPUT=$(cat)
|
|
18
|
+
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty')
|
|
19
|
+
|
|
20
|
+
if [ -z "$FILE_PATH" ]; then
|
|
21
|
+
exit 0
|
|
22
|
+
fi
|
|
23
|
+
|
|
24
|
+
if [[ ! "$FILE_PATH" =~ \.rs$ ]]; then
|
|
25
|
+
exit 0
|
|
26
|
+
fi
|
|
27
|
+
|
|
28
|
+
if [ ! -f "$FILE_PATH" ]; then
|
|
29
|
+
exit 0
|
|
30
|
+
fi
|
|
31
|
+
|
|
32
|
+
# Find nearest Cargo.toml by walking up from the file's directory
|
|
33
|
+
DIR=$(dirname "$FILE_PATH")
|
|
34
|
+
CARGO_ROOT=""
|
|
35
|
+
SEARCH_DIR="$DIR"
|
|
36
|
+
while [ "$SEARCH_DIR" != "/" ] && [ "$SEARCH_DIR" != "." ]; do
|
|
37
|
+
if [ -f "$SEARCH_DIR/Cargo.toml" ]; then
|
|
38
|
+
CARGO_ROOT="$SEARCH_DIR"
|
|
39
|
+
break
|
|
40
|
+
fi
|
|
41
|
+
SEARCH_DIR=$(dirname "$SEARCH_DIR")
|
|
42
|
+
done
|
|
43
|
+
|
|
44
|
+
if [ -z "$CARGO_ROOT" ]; then
|
|
45
|
+
exit 0
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
cd "$CARGO_ROOT" 2>/dev/null || exit 0
|
|
49
|
+
|
|
50
|
+
# Run cargo check (faster than cargo build, catches type/borrow errors)
|
|
51
|
+
RESULT=$(cargo check --message-format=short 2>&1)
|
|
52
|
+
EXIT_CODE=$?
|
|
53
|
+
|
|
54
|
+
if [ $EXIT_CODE -ne 0 ]; then
|
|
55
|
+
echo "cargo check errors in $CARGO_ROOT:" >&2
|
|
56
|
+
# Show only error lines (not warnings) first, then warnings
|
|
57
|
+
echo "$RESULT" | grep "^error" | head -10 >&2
|
|
58
|
+
WARN_COUNT=$(echo "$RESULT" | grep -c "^warning")
|
|
59
|
+
if [ "$WARN_COUNT" -gt 0 ]; then
|
|
60
|
+
echo "($WARN_COUNT warnings)" >&2
|
|
61
|
+
fi
|
|
62
|
+
fi
|
|
63
|
+
|
|
64
|
+
exit 0
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# typecheck-on-edit.sh — PostToolUse hook for Edit/Write
|
|
3
|
+
# Runs tsc --noEmit after .ts/.tsx edits.
|
|
4
|
+
# Finds the nearest tsconfig.json to determine the TypeScript project root.
|
|
5
|
+
# Uses SHA256 hash cache to skip tsc if file unchanged since last successful check.
|
|
6
|
+
# Profile: standard, strict (skip on fast)
|
|
7
|
+
|
|
8
|
+
# Unified profile + disable check
|
|
9
|
+
SUPERKIT_PROFILE_LIB="$(dirname "$0")/lib/profile.sh"
|
|
10
|
+
[ -f "$SUPERKIT_PROFILE_LIB" ] || SUPERKIT_PROFILE_LIB="$(dirname "$0")/../lib/profile.sh"
|
|
11
|
+
# shellcheck source=/dev/null
|
|
12
|
+
[ -f "$SUPERKIT_PROFILE_LIB" ] && source "$SUPERKIT_PROFILE_LIB" && should_skip_hook "$(basename "$0" .sh)" && exit 0
|
|
13
|
+
|
|
14
|
+
PROFILE="${CLAUDE_HOOK_PROFILE:-standard}"
|
|
15
|
+
if [ "$PROFILE" = "fast" ]; then
|
|
16
|
+
exit 0
|
|
17
|
+
fi
|
|
18
|
+
|
|
19
|
+
INPUT=$(cat)
|
|
20
|
+
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty')
|
|
21
|
+
|
|
22
|
+
if [ -z "$FILE_PATH" ]; then
|
|
23
|
+
exit 0
|
|
24
|
+
fi
|
|
25
|
+
|
|
26
|
+
if [[ ! "$FILE_PATH" =~ \.(ts|tsx)$ ]]; then
|
|
27
|
+
exit 0
|
|
28
|
+
fi
|
|
29
|
+
|
|
30
|
+
if [ ! -f "$FILE_PATH" ]; then
|
|
31
|
+
exit 0
|
|
32
|
+
fi
|
|
33
|
+
|
|
34
|
+
# --- Hash cache: skip tsc if file unchanged since last successful check ---
|
|
35
|
+
CACHE_DIR="$HOME/.cache/claude-typecheck"
|
|
36
|
+
mkdir -p "$CACHE_DIR" 2>/dev/null
|
|
37
|
+
|
|
38
|
+
HASH=$(shasum -a 256 "$FILE_PATH" 2>/dev/null | cut -d' ' -f1)
|
|
39
|
+
CACHE_KEY="$CACHE_DIR/$(echo "$FILE_PATH" | tr '/' '_').hash"
|
|
40
|
+
if [ -n "$HASH" ] && [ -f "$CACHE_KEY" ] && [ "$(cat "$CACHE_KEY" 2>/dev/null)" = "$HASH" ]; then
|
|
41
|
+
exit 0 # Unchanged since last successful check — skip tsc
|
|
42
|
+
fi
|
|
43
|
+
|
|
44
|
+
# Find nearest tsconfig.json by walking up from the file's directory
|
|
45
|
+
DIR=$(dirname "$FILE_PATH")
|
|
46
|
+
TS_ROOT=""
|
|
47
|
+
SEARCH_DIR="$DIR"
|
|
48
|
+
while [ "$SEARCH_DIR" != "/" ] && [ "$SEARCH_DIR" != "." ]; do
|
|
49
|
+
if [ -f "$SEARCH_DIR/tsconfig.json" ]; then
|
|
50
|
+
TS_ROOT="$SEARCH_DIR"
|
|
51
|
+
break
|
|
52
|
+
fi
|
|
53
|
+
SEARCH_DIR=$(dirname "$SEARCH_DIR")
|
|
54
|
+
done
|
|
55
|
+
|
|
56
|
+
if [ -z "$TS_ROOT" ]; then
|
|
57
|
+
exit 0
|
|
58
|
+
fi
|
|
59
|
+
|
|
60
|
+
cd "$TS_ROOT" 2>/dev/null || exit 0
|
|
61
|
+
|
|
62
|
+
RESULT=$(npx tsc --noEmit 2>&1)
|
|
63
|
+
EXIT_CODE=$?
|
|
64
|
+
|
|
65
|
+
if [ $EXIT_CODE -ne 0 ]; then
|
|
66
|
+
echo "TypeScript errors in $TS_ROOT:" >&2
|
|
67
|
+
echo "$RESULT" | head -20 >&2
|
|
68
|
+
rm -f "$CACHE_KEY" 2>/dev/null
|
|
69
|
+
else
|
|
70
|
+
# Save hash on successful check
|
|
71
|
+
if [ -n "$HASH" ] && [ -n "$CACHE_KEY" ]; then
|
|
72
|
+
echo "$HASH" > "$CACHE_KEY" 2>/dev/null
|
|
73
|
+
fi
|
|
74
|
+
fi
|
|
75
|
+
|
|
76
|
+
exit 0
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
alwaysApply: false
|
|
3
|
+
applyWhenPaths:
|
|
4
|
+
- "**/*.go"
|
|
5
|
+
tokens: 409
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Go Conventions
|
|
9
|
+
|
|
10
|
+
## Naming
|
|
11
|
+
- MixedCaps for all names (not snake_case, not SCREAMING_CASE). Acronyms fully capitalized: `HTTPClient`, `userID`, `parseURL`
|
|
12
|
+
- Package names: lowercase, single word, no underscores. Never `util`, `common`, `base`, `helpers`
|
|
13
|
+
- Interfaces: verb or -er suffix (`Reader`, `Validator`, `Closer`). Max 3 methods. Declare at consumer side
|
|
14
|
+
- Error variables: `ErrNotFound`, `ErrValidation` (Err prefix + PascalCase)
|
|
15
|
+
- Avoid stuttering: `http.Client` not `http.HTTPClient`, `user.New()` not `user.NewUser()`
|
|
16
|
+
|
|
17
|
+
## Patterns
|
|
18
|
+
- Constructors: `NewX(deps) *X`, validate inside, return error if validation can fail
|
|
19
|
+
- >3 optional params: use functional options pattern (`func WithTimeout(d time.Duration) Option`)
|
|
20
|
+
- Enums: `iota` with `Unknown = 0` as zero value. Always include `String()` method
|
|
21
|
+
- Early returns (guard clauses), not deep nesting. Happy path at lowest indentation
|
|
22
|
+
- Accept interfaces, return structs. Keep interfaces small
|
|
23
|
+
|
|
24
|
+
## Error Handling
|
|
25
|
+
- Always wrap with caller context: `fmt.Errorf("Type.Method: %w", err)` — free-text parts lowercase, no trailing punctuation
|
|
26
|
+
|
|
27
|
+
```go
|
|
28
|
+
// BAD — logs AND returns, no context
|
|
29
|
+
log.Printf("save failed: %v", err)
|
|
30
|
+
return err
|
|
31
|
+
// GOOD — wrap with caller name, return only
|
|
32
|
+
return fmt.Errorf("UserRepo.Save: %w", err)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
- Log OR return, never both. Handlers log; services/repos return
|
|
36
|
+
- Sentinel errors (`var ErrNotFound = errors.New(...)`) for expected domain conditions
|
|
37
|
+
- `errors.Is()` / `errors.As()` for inspection, never `==` or type assertion
|
|
38
|
+
- Domain errors map to HTTP status in handlers only — services return domain errors
|
|
39
|
+
|
|
40
|
+
## Context
|
|
41
|
+
- `ctx context.Context` always first parameter, always named `ctx`
|
|
42
|
+
- Never store context in structs — pass explicitly
|
|
43
|
+
- `context.Background()` only in main, init, tests
|
|
44
|
+
- `defer cancel()` immediately after `context.WithCancel` / `WithTimeout` / `WithDeadline`
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
alwaysApply: false
|
|
3
|
+
applyWhenPaths:
|
|
4
|
+
- "**/*.go"
|
|
5
|
+
tokens: 512
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Go Safety Guardrails
|
|
9
|
+
|
|
10
|
+
Apply to every Go file you write or edit. In reviews, a violation of these is at least WARNING; panic, data-race, or leak paths are CRITICAL.
|
|
11
|
+
|
|
12
|
+
## Nil Traps
|
|
13
|
+
- Always `make()` maps before write — nil map panics: `m := make(map[K]V)`
|
|
14
|
+
- Typed nil pointer in interface is NOT nil — `var p *MyType; var i MyInterface = p; i != nil` is TRUE
|
|
15
|
+
- Check pointer receivers for nil in public methods of exported types
|
|
16
|
+
|
|
17
|
+
## Concurrency
|
|
18
|
+
- Every goroutine needs a shutdown mechanism: `ctx.Done()`, done channel, or explicit signal
|
|
19
|
+
- Only senders close channels — closing a closed channel panics
|
|
20
|
+
- Every `select` that can block, in code where a `ctx` is in scope, needs a `ctx.Done()` case. Exempt: non-blocking `select` with `default`, and code with no context available
|
|
21
|
+
- No `time.After` in loops — creates new timer (and leak) per iteration. Use `time.NewTimer` + `Reset()`
|
|
22
|
+
|
|
23
|
+
## Memory
|
|
24
|
+
- `append` may grow into a new array or reuse the old one — always assign the result back to the SAME slice: `s = append(s, x)`. Hazard: `b := append(a, x)` compiles but `b` can share `a`'s backing array, so a write through one mutates the other. Need an independent slice → `copy` explicitly
|
|
25
|
+
- `defer` in loops accumulates all defers until function exit — wrap body in closure or extract to function
|
|
26
|
+
- Sub-slice of large slice retains entire backing array in memory — copy if keeping small piece of large data
|
|
27
|
+
|
|
28
|
+
## Numeric
|
|
29
|
+
- `int64` -> `int32` truncates silently — use explicit conversion with bounds check
|
|
30
|
+
- Float `==` comparison unreliable — use epsilon: `math.Abs(a-b) < epsilon`
|
|
31
|
+
- Integer overflow wraps silently — check bounds before arithmetic on user input
|
|
32
|
+
|
|
33
|
+
## Linter Suppression
|
|
34
|
+
- `//nolint` directives MUST name the specific linter AND carry a justification comment (nolintlint style: `//nolint:gosec // reason`). A bare or unjustified `//nolint` is at least WARNING
|
|
35
|
+
- NEVER suppress a security linter (`gosec`, `bodyclose`, `sqlclosecheck`) without a documented strong reason — a suppressed security linter with no documented reason is CRITICAL
|