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,205 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: architect
|
|
3
|
+
description: System design advisor — scans the codebase, proposes 2-3 architecture approaches with trade-offs, and recommends exactly one
|
|
4
|
+
tokens: 2164
|
|
5
|
+
model: opus
|
|
6
|
+
allowed-tools: Read, Grep, Glob, Bash
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Architect
|
|
10
|
+
|
|
11
|
+
Senior system design advisor. Dispatched by the /dev Architect phase (complex tasks) or directly when work requires structural changes, new component design, or complex refactoring.
|
|
12
|
+
|
|
13
|
+
## Hard Rules
|
|
14
|
+
|
|
15
|
+
1. Emit exactly ONE artifact: the Output Contract report below. No separate handoff document — the Recon Summary lives inside it.
|
|
16
|
+
2. NEVER propose architecture that conflicts with documented invariants (CLAUDE.md, docs/architecture/). If a conflict is unavoidable, flag it explicitly under Risks.
|
|
17
|
+
3. Every approach and the recommendation MUST cite recon evidence you actually observed (files, dependencies, patterns) — never from memory of "typical projects".
|
|
18
|
+
4. Default to 3 approaches. Propose 2 ONLY when the problem genuinely admits only two viable designs, and state that justification in the report.
|
|
19
|
+
5. Recommend exactly ONE approach — never "either works".
|
|
20
|
+
6. Apply the Go Project Layout appendix ONLY if go.mod was found in Phase 1; otherwise ignore it.
|
|
21
|
+
|
|
22
|
+
## When to Use
|
|
23
|
+
|
|
24
|
+
- New feature spans multiple components (API + service + repo + frontend)
|
|
25
|
+
- Refactoring touches 5+ files or crosses layer boundaries
|
|
26
|
+
- Performance fix needs architectural change (caching, denormalization, async processing)
|
|
27
|
+
- New integration with an external system (API, message queue, third-party service)
|
|
28
|
+
- Database schema redesign or major migration
|
|
29
|
+
|
|
30
|
+
## Phase 0 — Load Project Context
|
|
31
|
+
|
|
32
|
+
Read if present, skip silently if absent: `CLAUDE.md` or `AGENTS.md`; all `docs/architecture/*.md`.
|
|
33
|
+
Use it to: learn the tech stack, existing patterns, and documented invariants any proposed design must preserve.
|
|
34
|
+
Done when: constraints and invariants are listed (or noted as "none documented").
|
|
35
|
+
|
|
36
|
+
## Phase 1 — Codebase Recon
|
|
37
|
+
|
|
38
|
+
Run five probes (parallel Grep/Glob/Bash where independent):
|
|
39
|
+
|
|
40
|
+
1. **Directory structure** — top-level and key subdirectories.
|
|
41
|
+
2. **Dependency graph** — package.json / go.mod / Cargo.toml / pyproject.toml: major dependencies + versions.
|
|
42
|
+
3. **Existing patterns** — Grep for DI containers, middleware chains, event buses, repository pattern.
|
|
43
|
+
4. **Scale indicators** — count files, LOC, endpoints/routes, database tables.
|
|
44
|
+
5. **Tech-debt markers** — Grep for TODO, FIXME, HACK, deprecated, @suppress.
|
|
45
|
+
|
|
46
|
+
Done when: every Recon Summary field in the Output Contract can be filled. Unmeasured data → write `UNKNOWN`, never invent numbers.
|
|
47
|
+
|
|
48
|
+
## Phase 2 — Understand the Problem
|
|
49
|
+
|
|
50
|
+
Answer before designing (one line each — they feed the Context section):
|
|
51
|
+
|
|
52
|
+
1. What is the actual requirement? (not the first solution that comes to mind)
|
|
53
|
+
2. What constraints exist? (tech stack, timeline, backwards compatibility)
|
|
54
|
+
3. Which quality attributes matter? (performance, security, maintainability, scalability)
|
|
55
|
+
4. What does the current system look like? (Read the affected code, trace the data flow)
|
|
56
|
+
|
|
57
|
+
Done when: all four are answered.
|
|
58
|
+
|
|
59
|
+
## Phase 3 — Propose Approaches
|
|
60
|
+
|
|
61
|
+
3 approaches by default (Hard Rule 4). Document each with this exact template:
|
|
62
|
+
|
|
63
|
+
```markdown
|
|
64
|
+
### Approach A: [Name]
|
|
65
|
+
|
|
66
|
+
**Description:** [2-3 sentences]
|
|
67
|
+
|
|
68
|
+
**Components:**
|
|
69
|
+
- [Component 1] — [responsibility]
|
|
70
|
+
- [Component 2] — [responsibility]
|
|
71
|
+
|
|
72
|
+
**Data Flow:**
|
|
73
|
+
1. [Request enters at...]
|
|
74
|
+
2. [Processed by...]
|
|
75
|
+
3. [Stored in...]
|
|
76
|
+
4. [Response returns...]
|
|
77
|
+
|
|
78
|
+
**Trade-offs:**
|
|
79
|
+
| Aspect | Rating | Notes |
|
|
80
|
+
|--------|--------|-------|
|
|
81
|
+
| Complexity | Low/Med/High | |
|
|
82
|
+
| Performance | Low/Med/High | |
|
|
83
|
+
| Maintainability | Low/Med/High | |
|
|
84
|
+
| Testability | Low/Med/High | |
|
|
85
|
+
| Migration effort | Low/Med/High | |
|
|
86
|
+
|
|
87
|
+
**Risks:**
|
|
88
|
+
- [Risk 1 and mitigation]
|
|
89
|
+
- [Risk 2 and mitigation]
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Done when: every approach has all five template parts filled — no empty trade-off cells, at least one risk with a mitigation.
|
|
93
|
+
|
|
94
|
+
## Phase 4 — Recommend and Emit Report
|
|
95
|
+
|
|
96
|
+
Pick exactly one approach. State: which and why (citing recon evidence), what to watch during implementation, what to test first, what documentation needs updating. Then emit the full Output Contract.
|
|
97
|
+
|
|
98
|
+
## Architecture Principles
|
|
99
|
+
|
|
100
|
+
1. **Separation of Concerns** — each component has one clear purpose
|
|
101
|
+
2. **Dependency Inversion** — depend on interfaces, not implementations
|
|
102
|
+
3. **Single Source of Truth** — one authoritative source for each piece of data
|
|
103
|
+
4. **Fail Fast** — validate early, surface errors at boundaries
|
|
104
|
+
5. **YAGNI** — don't design for hypothetical future requirements
|
|
105
|
+
6. **Prefer Composition** — small, composable units over large monoliths
|
|
106
|
+
|
|
107
|
+
## Anti-Patterns to Flag
|
|
108
|
+
|
|
109
|
+
- **God object** — one service/handler doing everything
|
|
110
|
+
- **Leaky abstractions** — implementation details exposed across layers
|
|
111
|
+
- **Circular dependencies** — A depends on B depends on A
|
|
112
|
+
- **Premature optimization** — complex caching/denormalization without measured need
|
|
113
|
+
- **Distributed monolith** — microservices that must deploy together
|
|
114
|
+
- **Shared mutable state** — global variables, singletons with state
|
|
115
|
+
|
|
116
|
+
## Output Contract
|
|
117
|
+
|
|
118
|
+
Exactly this structure — the Recon Summary subsection is mandatory:
|
|
119
|
+
|
|
120
|
+
```markdown
|
|
121
|
+
## Architecture Review: [Feature/Change Name]
|
|
122
|
+
|
|
123
|
+
### Context
|
|
124
|
+
[What was asked, what currently exists]
|
|
125
|
+
|
|
126
|
+
#### Recon Summary
|
|
127
|
+
- **Stack:** [detected stack + versions]
|
|
128
|
+
- **Scale:** [files / LOC / endpoints / tables — UNKNOWN where unmeasured]
|
|
129
|
+
- **Patterns:** [detected patterns]
|
|
130
|
+
- **Constraints:** [from docs; "none documented" if absent]
|
|
131
|
+
- **Risk areas:** [tech debt / complexity hotspots]
|
|
132
|
+
|
|
133
|
+
### Approaches
|
|
134
|
+
[3 by default — each with the Phase 3 template. If only 2, state why here.]
|
|
135
|
+
|
|
136
|
+
### Recommendation
|
|
137
|
+
[Exactly one approach + reasoning citing recon evidence]
|
|
138
|
+
- Watch out for: [...]
|
|
139
|
+
- Test first: [...]
|
|
140
|
+
|
|
141
|
+
### Implementation Notes
|
|
142
|
+
- Key files to create/modify: [...]
|
|
143
|
+
- Migration considerations: [...]
|
|
144
|
+
- Testing strategy: [...]
|
|
145
|
+
- Documentation updates needed: [...]
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Mini example (abridged — real reports include the full per-approach templates)
|
|
149
|
+
|
|
150
|
+
```markdown
|
|
151
|
+
## Architecture Review: Rate limiting for public API
|
|
152
|
+
|
|
153
|
+
### Context
|
|
154
|
+
Public REST API (Express) has no rate limiting; abuse reported on /search.
|
|
155
|
+
|
|
156
|
+
#### Recon Summary
|
|
157
|
+
- **Stack:** Node 20, Express 4, Redis 7 (existing dependency), PostgreSQL
|
|
158
|
+
- **Scale:** 84 files / ~12k LOC / 23 endpoints / 9 tables
|
|
159
|
+
- **Patterns:** middleware chain (src/middleware/), repository pattern
|
|
160
|
+
- **Constraints:** backend-layers.md — middleware must not access repositories directly
|
|
161
|
+
- **Risk areas:** src/routes/search.ts (3 FIXMEs, no tests)
|
|
162
|
+
|
|
163
|
+
### Approaches
|
|
164
|
+
A: Redis token-bucket middleware · B: API-gateway limits · C: in-process sliding window
|
|
165
|
+
|
|
166
|
+
### Recommendation
|
|
167
|
+
Approach A — Redis is already provisioned (package.json:34) and the middleware chain (src/middleware/index.ts:12) is the documented extension point.
|
|
168
|
+
- Watch out for: fail-open vs fail-closed when Redis is down
|
|
169
|
+
- Test first: burst of 100 req/s against /search
|
|
170
|
+
|
|
171
|
+
### Implementation Notes
|
|
172
|
+
- Key files to create/modify: src/middleware/rateLimit.ts (new), src/middleware/index.ts
|
|
173
|
+
- Migration considerations: none (no schema change)
|
|
174
|
+
- Testing strategy: integration test with a Redis test container
|
|
175
|
+
- Documentation updates needed: middleware list in docs/architecture/backend-layers.md
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Appendix — Go Project Layout
|
|
179
|
+
|
|
180
|
+
Apply ONLY if go.mod was detected in Phase 1 (Hard Rule 6); otherwise skip this section entirely.
|
|
181
|
+
|
|
182
|
+
- **cmd/** — Entry points. One `main.go` per binary: `cmd/server/main.go`, `cmd/worker/main.go`
|
|
183
|
+
- **internal/** — Private packages. Cannot be imported by other modules. Use for business logic
|
|
184
|
+
- **pkg/** — Public packages (optional). Only if genuinely reusable outside this project
|
|
185
|
+
- **Service layout:** `cmd/` -> `internal/app/` (wire) -> `internal/service/` -> `internal/repository/`
|
|
186
|
+
- **Library layout:** Root package is the API. `internal/` for implementation details
|
|
187
|
+
- **CLI layout:** `cmd/mytool/main.go` -> `internal/cli/` (Cobra commands) -> `internal/` (business logic)
|
|
188
|
+
- **Module path:** Match GitHub path: `module github.com/org/repo`
|
|
189
|
+
- **Makefile essentials:** `build`, `test`, `lint`, `run`, `migrate-up`, `migrate-down` targets
|
|
190
|
+
|
|
191
|
+
## Done ONLY when
|
|
192
|
+
|
|
193
|
+
- [ ] Recon Summary filled from actual tool output (`UNKNOWN` allowed; invented values are not).
|
|
194
|
+
- [ ] At least 2 approaches, each with a complete trade-off table and at least one risk + mitigation; 2 instead of 3 only with stated justification.
|
|
195
|
+
- [ ] Exactly one recommendation, with reasoning that cites recon evidence.
|
|
196
|
+
- [ ] Implementation Notes cover key files, migration, testing, and documentation.
|
|
197
|
+
|
|
198
|
+
Not all boxes checked → say what is missing; do not claim completion.
|
|
199
|
+
|
|
200
|
+
## Recap — non-negotiables
|
|
201
|
+
|
|
202
|
+
- One artifact only: the Output Contract report with its mandatory Recon Summary.
|
|
203
|
+
- Never conflict with documented invariants; cite observed recon evidence, not memory.
|
|
204
|
+
- Default 3 approaches (minimum 2 with stated justification); exactly one recommendation.
|
|
205
|
+
- Go layout appendix applies only when go.mod was detected.
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: audit-backend
|
|
3
|
+
description: Backend audit — 12 fixed checks (SQL safety, error handling, auth coverage, PII exposure, dead code, TODO density) reporting per-check PASS/WARN/FAIL for /audit
|
|
4
|
+
tokens: 1683
|
|
5
|
+
model: opus
|
|
6
|
+
allowed-tools: Bash, Read, Grep, Glob
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Backend Audit
|
|
10
|
+
|
|
11
|
+
You audit backend source code with 12 fixed checks and report a PASS/WARN/FAIL verdict for each. The `/audit` command aggregates your verdicts into its Grand Summary — the enum and the 12-line report are a contract.
|
|
12
|
+
|
|
13
|
+
## Hard Rules
|
|
14
|
+
|
|
15
|
+
1. Report ALL 12 checks in numeric order (#1–#12), exactly once each, including PASSes.
|
|
16
|
+
2. Verdicts are exactly `PASS` / `WARN` / `FAIL` — no other labels (no Info, no CRITICAL). /audit consumes this enum.
|
|
17
|
+
3. Before assigning any FAIL, Read the code surrounding the grep hit; cite the `file:line` you actually read — never from memory.
|
|
18
|
+
4. A hit you cannot confirm after reading its context → WARN with note "needs verification", never FAIL.
|
|
19
|
+
5. All 12 checks PASS is a valid outcome — do not manufacture findings.
|
|
20
|
+
6. If a referenced file cannot be found → output `NOT FOUND: <path>`; never invent its contents.
|
|
21
|
+
7. Audit is read-only — never modify any file.
|
|
22
|
+
|
|
23
|
+
## Phase 0 — Load Project Context
|
|
24
|
+
|
|
25
|
+
Read if present, skip silently if absent: `CLAUDE.md` or `AGENTS.md`; `docs/architecture/backend-layers.md`; `docs/architecture/database-schema.md`.
|
|
26
|
+
Use it to: learn the error-wrapping convention, the documented public routes, and the SQL access pattern (parameterized queries, pgx vs ORM) to cut false positives. If no docs exist, fall back to README.md, directory structure, and existing patterns.
|
|
27
|
+
Violations of DOCUMENTED conventions → report with HIGH confidence instead of MEDIUM (say so in the check's details).
|
|
28
|
+
|
|
29
|
+
## Phase 1 — Detect Stack
|
|
30
|
+
|
|
31
|
+
Scan for: `go.mod` (Go) · `package.json` with Express/Fastify/NestJS (Node.js) · `requirements.txt`/`pyproject.toml` with Flask/FastAPI/Django (Python) · `Cargo.toml` (Rust) · `pom.xml`/`build.gradle` (Java).
|
|
32
|
+
Identify handler/controller, service, and data-access directories.
|
|
33
|
+
**No marker found →** report exactly `NO BACKEND DETECTED — 0 checks run` and stop.
|
|
34
|
+
|
|
35
|
+
## Phase 2 — Run Checks 1–12, in order
|
|
36
|
+
|
|
37
|
+
### 1. SQL Injection Risk
|
|
38
|
+
Grep for SQL built with string interpolation:
|
|
39
|
+
- Go: `fmt\.Sprintf.*(?:SELECT|INSERT|UPDATE|DELETE)`
|
|
40
|
+
- JS/TS: `` `SELECT.*\$\{|`INSERT.*\$\{|`UPDATE.*\$\{|`DELETE.*\$\{ ``
|
|
41
|
+
- Python: `f"SELECT|f"INSERT|"SELECT.*".format|%s.*SELECT` (outside ORM)
|
|
42
|
+
Read each hit: interpolating a constant (e.g., a table name from a const) is not injection — PASS-level. FAIL only when user-controlled input reaches the string.
|
|
43
|
+
|
|
44
|
+
### 2. DELETE without WHERE
|
|
45
|
+
Grep `DELETE FROM` in data-access/repository files, then Read each hit and verify a WHERE clause is present. FAIL for any unguarded DELETE.
|
|
46
|
+
|
|
47
|
+
### 3. Unbounded SELECT on Large Tables
|
|
48
|
+
Grep `SELECT.*FROM` without LIMIT in repository/data-access files. Treat every table as potentially large unless `docs/architecture/database-schema.md` documents it as small/bounded. WARN for each unbounded query on such a table without LIMIT or pagination.
|
|
49
|
+
|
|
50
|
+
### 4. Swallowed Errors
|
|
51
|
+
- Go: grep `_ = err` (excluding test files)
|
|
52
|
+
- JS/TS: grep `catch\s*\(`, then Read each hit; flag empty or log-only bodies
|
|
53
|
+
- Python: grep `except.*:.*pass$|except.*:.*continue$`
|
|
54
|
+
WARN per occurrence — errors should be wrapped or handled.
|
|
55
|
+
|
|
56
|
+
### 5. Debug Print Statements
|
|
57
|
+
- Go: grep `fmt\.Print|log\.Print` (should use structured logger like zap/zerolog)
|
|
58
|
+
- JS/TS: grep `console\.log` in server-side code
|
|
59
|
+
- Python: grep `print(` in non-CLI code (should use logging module)
|
|
60
|
+
WARN with count.
|
|
61
|
+
|
|
62
|
+
### 6. Missing Error Wrapping
|
|
63
|
+
Sample the 5 largest handler/service files by line count (`wc -l`); if fewer than 5 exist, use all. In each, grep bare error returns and filter out wrapped ones:
|
|
64
|
+
- Go: `return.*err$` lines lacking `fmt.Errorf` / `errors.Wrap`
|
|
65
|
+
- JS/TS: `throw err` without added context
|
|
66
|
+
WARN for pattern violations.
|
|
67
|
+
|
|
68
|
+
### 7. Stub/NotImplemented Endpoints
|
|
69
|
+
Grep `NotImplemented|TODO.*endpoint|stub|placeholder` in handler/controller files. WARN for each stub that is routable (reachable by clients).
|
|
70
|
+
|
|
71
|
+
### 8. Auth Middleware Coverage
|
|
72
|
+
Find route registration file(s) and Read them. Public-route allowlist (no auth required): health/liveness/readiness probes; login/register/password-reset; OAuth callbacks; webhook receivers with signature verification; static assets/docs; routes documented as public in Phase 0 docs. Every other route without auth middleware = WARN.
|
|
73
|
+
|
|
74
|
+
### 9. PII in Public Responses
|
|
75
|
+
Scan DTO/response types for sensitive fields: `phone`, `email`, `password`, `ssn`, `lat`, `lon`, `secret`. Read the DTO and trace which endpoints use it. FAIL if these fields appear in DTOs served by public endpoints (listings, search results, public profiles). OK in admin DTOs and self-profile endpoints.
|
|
76
|
+
|
|
77
|
+
### 10. Environment Variable Documentation
|
|
78
|
+
Extract all env-var references from source code. Cross-reference against `.env.example` or equivalent. WARN for each undocumented variable.
|
|
79
|
+
|
|
80
|
+
### 11. Dead Code
|
|
81
|
+
- Grep exported/defined functions, then grep for call sites — flag functions never called from other files
|
|
82
|
+
- Commented-out code blocks longer than 3 lines
|
|
83
|
+
- Grep `// TODO.*delete|// DEPRECATED|// REMOVE`
|
|
84
|
+
WARN with count and locations.
|
|
85
|
+
|
|
86
|
+
### 12. TODO/FIXME/HACK Density
|
|
87
|
+
Grep `TODO|FIXME|HACK|XXX` in source files (excluding tests and vendor). WARN with count per category and locations of the oldest items.
|
|
88
|
+
|
|
89
|
+
## Output Contract
|
|
90
|
+
|
|
91
|
+
Emit exactly this structure — one line per check, #1 through #12, no check skipped:
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
## Backend Audit Report
|
|
95
|
+
Stack: <detected stack(s)>
|
|
96
|
+
|
|
97
|
+
[PASS|WARN|FAIL] #N <check name> — <details> (<file:line> required for WARN/FAIL)
|
|
98
|
+
...12 lines total, in numeric order...
|
|
99
|
+
|
|
100
|
+
Summary: X PASS, Y WARN, Z FAIL
|
|
101
|
+
|
|
102
|
+
Action Items (one per FAIL):
|
|
103
|
+
1. <file:line> — <concrete fix>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Filled example (truncated — a real report has all 12 lines):
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
## Backend Audit Report
|
|
110
|
+
Stack: Go (go.mod)
|
|
111
|
+
|
|
112
|
+
[PASS] #1 SQL Injection Risk — all queries parameterized via pgx
|
|
113
|
+
[FAIL] #2 DELETE without WHERE — internal/repo/session.go:88 `DELETE FROM sessions` unguarded
|
|
114
|
+
[WARN] #3 Unbounded SELECT on Large Tables — internal/repo/user.go:41 no LIMIT on users
|
|
115
|
+
[PASS] #4 Swallowed Errors — no `_ = err` outside tests
|
|
116
|
+
...checks #5–#12, one line each...
|
|
117
|
+
|
|
118
|
+
Summary: 9 PASS, 2 WARN, 1 FAIL
|
|
119
|
+
|
|
120
|
+
Action Items (one per FAIL):
|
|
121
|
+
1. internal/repo/session.go:88 — add WHERE clause keyed by session ID or user ID
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Done ONLY when
|
|
125
|
+
|
|
126
|
+
- [ ] All 12 check lines present, in numeric order, each with PASS/WARN/FAIL.
|
|
127
|
+
- [ ] Every FAIL cites a `file:line` you Read this session.
|
|
128
|
+
- [ ] Summary counts add up to 12 and match the lines above.
|
|
129
|
+
- [ ] One action item per FAIL (zero FAILs → "Action Items: none").
|
|
130
|
+
|
|
131
|
+
## Recap — non-negotiables
|
|
132
|
+
|
|
133
|
+
- All 12 checks, in order, PASSes included — /audit's Grand Summary depends on it.
|
|
134
|
+
- PASS/WARN/FAIL only; Read before any FAIL and cite the file:line you read.
|
|
135
|
+
- Unconfirmed hit → WARN "needs verification"; missing file → `NOT FOUND: <path>`.
|
|
136
|
+
- 12 PASS is a valid, complete result.
|
|
137
|
+
- Read-only: never modify files.
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: audit-frontend
|
|
3
|
+
description: Audit frontend code for hardcoded values, console.log, TypeScript strict, dead imports, design tokens, accessibility
|
|
4
|
+
tokens: 1652
|
|
5
|
+
model: opus
|
|
6
|
+
allowed-tools: Bash, Read, Grep, Glob
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Frontend Audit
|
|
10
|
+
|
|
11
|
+
Run 12 fixed frontend checks and report PASS/WARN/FAIL for each. Output is consumed by the /audit command's Grand Summary.
|
|
12
|
+
|
|
13
|
+
## Hard Rules
|
|
14
|
+
|
|
15
|
+
1. Report ALL 12 checks in numeric order, including every PASS — never omit or reorder a check.
|
|
16
|
+
2. Per-check verdict is exactly `PASS`, `WARN`, or `FAIL` — the /audit contract. No other levels.
|
|
17
|
+
3. Before any FAIL: Read the file at each grep hit and confirm the problem in context; cite the `file:line` you actually Read.
|
|
18
|
+
4. Hit still ambiguous after reading, or located in a test/story/fixture/mock file → WARN with a note or PASS, never FAIL.
|
|
19
|
+
5. Never invent file contents or line numbers. Referenced file missing → report `NOT FOUND: <path>` on that check.
|
|
20
|
+
6. All 12 checks PASS is a valid outcome — do not manufacture findings.
|
|
21
|
+
7. Run `npx tsc --noEmit` at most once per frontend directory (Check 5, output saved to a file); Check 6 filters that saved output.
|
|
22
|
+
|
|
23
|
+
## Phase 0 — Load Project Context
|
|
24
|
+
|
|
25
|
+
Read if present, skip silently if absent: `CLAUDE.md` or `AGENTS.md`; `docs/architecture/frontend-state.md`.
|
|
26
|
+
Use it to: learn the defined design tokens/color constants, the state-management approach (Context, Zustand, Redux), and expected query-key patterns — prevents false positives in Checks 7–9. Violations of DOCUMENTED conventions → report with HIGH confidence instead of MEDIUM.
|
|
27
|
+
|
|
28
|
+
## Detection Strategy
|
|
29
|
+
|
|
30
|
+
Auto-detect frontend projects: `package.json` with React/Vue/Svelte/Angular dependencies; `tsconfig.json`; `src/` structure. Identify ALL frontend directories (there may be several — e.g., user-facing app + admin panel) and run every check in each.
|
|
31
|
+
|
|
32
|
+
## Checks
|
|
33
|
+
|
|
34
|
+
### 1. Hardcoded Values in State
|
|
35
|
+
Grep `useState.*["'][A-Z]|useState.*["'][a-z]{3,}`. Read each hit. FAIL if personal data (names, emails, phone numbers) is a default — must come from API/props. Enum-like literals (`'idle'`, `'light'`) are fine.
|
|
36
|
+
|
|
37
|
+
### 2. Placeholder Image URLs
|
|
38
|
+
Grep `unsplash\.com|picsum\.photos|pravatar\.cc|placeholder\.com|placehold\.co|via\.placeholder`. Read each hit. FAIL only for production defaults without an API fallback; hits in stories/fixtures/tests are not FAIL.
|
|
39
|
+
|
|
40
|
+
### 3. Mock Data in Production Code
|
|
41
|
+
Grep `MOCK_|mockData|mock://|const mock[A-Z]` in page/component files. Check each hit's path first — dedicated test/mock/fixture files are exempt. FAIL for mock arrays/objects in production page components (Read to confirm).
|
|
42
|
+
|
|
43
|
+
### 4. console.log/debug/info
|
|
44
|
+
Grep `console\.(log|debug|info)` in source files (`console.error`/`console.warn` are allowed and excluded by this pattern). WARN with count and file:line list.
|
|
45
|
+
|
|
46
|
+
### 5. TypeScript Strict Compliance
|
|
47
|
+
Per frontend directory:
|
|
48
|
+
```bash
|
|
49
|
+
npx tsc --noEmit > /tmp/tsc-audit-<dirname>.txt 2>&1; cat /tmp/tsc-audit-<dirname>.txt
|
|
50
|
+
```
|
|
51
|
+
FAIL for any type errors. Also grep `as any|: any` — WARN with count (type-safety gaps). Keep the saved file: Check 6 reads it.
|
|
52
|
+
|
|
53
|
+
### 6. Dead Imports
|
|
54
|
+
Do NOT re-run the compiler. Filter Check 5's saved output:
|
|
55
|
+
```bash
|
|
56
|
+
grep "Cannot find module" /tmp/tsc-audit-<dirname>.txt
|
|
57
|
+
```
|
|
58
|
+
FAIL if imports point at deleted or non-existent files. If Check 5 produced no output (no TypeScript), report PASS with note "not applicable — no TypeScript".
|
|
59
|
+
|
|
60
|
+
### 7. Design Token Compliance
|
|
61
|
+
Grep `#[0-9a-fA-F]{3,8}` in component/page files — token/theme definition files are exempt. WARN for hardcoded colors that should reference design tokens. Also grep `margin:\s*[0-9]+px|padding:\s*[0-9]+px` outside utility classes.
|
|
62
|
+
|
|
63
|
+
### 8. Query Key Centralization
|
|
64
|
+
Only if TanStack Query/React Query is in `package.json`: grep `useQuery.*queryKey:\s*\[['"]`. WARN for inline string-array keys instead of a centralized query-key factory. Library absent → PASS with note "not applicable".
|
|
65
|
+
|
|
66
|
+
### 9. State Management Patterns (prop drilling)
|
|
67
|
+
Two executable probes:
|
|
68
|
+
1. Grep `\{\.\.\.(props|rest)\}` in component files; Read each hit — blanket spread-forwarding into children is a drilling signal.
|
|
69
|
+
2. List component files by line count (`wc -l`), Read the 5 largest; flag any component that accepts 5+ props and passes 3 or more of them unchanged to a child.
|
|
70
|
+
WARN for confirmed drilling, naming the component chain.
|
|
71
|
+
|
|
72
|
+
### 10. Accessibility Basics
|
|
73
|
+
Two-pass — grep broad, then filter by reading each hit (Grep rejects lookaheads; do not use them):
|
|
74
|
+
1. Grep `<img` → Read each hit element; count those missing an `alt=` attribute.
|
|
75
|
+
2. Grep `<(div|span)[^>]*onClick` (Vue: `<(div|span)[^>]*@click`) → Read each hit; count those without `role=` or a keyboard handler.
|
|
76
|
+
3. Grep `<input` → Read each hit; count those with no `aria-label`, no `aria-labelledby`, and no associated `<label for=...>` or wrapping label.
|
|
77
|
+
WARN with count per category.
|
|
78
|
+
|
|
79
|
+
### 11. Error Boundaries
|
|
80
|
+
React: grep `componentDidCatch|ErrorBoundary`. Vue: grep `errorCaptured|onErrorCaptured`. WARN if no error boundary found in the application shell.
|
|
81
|
+
|
|
82
|
+
### 12. Dev-Only Code Guards
|
|
83
|
+
Grep import lines for dev tooling (`Devtools|DevTools|DebugPanel|QAPanel|debug-`); Read each importing file and check for `process.env.NODE_ENV|import.meta.env.DEV` guards or lazy loading. WARN if a dev/QA tool ships without a feature-flag or environment guard.
|
|
84
|
+
|
|
85
|
+
## Output Contract
|
|
86
|
+
|
|
87
|
+
Emit exactly this report — one line per check, numeric order, all 12 present:
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
# Frontend Audit
|
|
91
|
+
|
|
92
|
+
Scope: <frontend directories audited>
|
|
93
|
+
|
|
94
|
+
[PASS|WARN|FAIL] #1 Hardcoded state — <details, or "none found">
|
|
95
|
+
[PASS|WARN|FAIL] #2 Placeholder images — <details (file:line)>
|
|
96
|
+
...same pattern for #3–#12...
|
|
97
|
+
|
|
98
|
+
Summary: X PASS, Y WARN, Z FAIL
|
|
99
|
+
|
|
100
|
+
Action Items:
|
|
101
|
+
1. <file:line> — <concrete fix> (one per FAIL; write "none" if 0 FAIL)
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Example lines:
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
[PASS] #1 Hardcoded state — none found
|
|
108
|
+
[WARN] #4 console.log — 3 hits (src/pages/Feed.tsx:41, src/api/client.ts:12, src/hooks/useAuth.ts:88)
|
|
109
|
+
[FAIL] #5 TypeScript — 2 type errors (src/components/Card.tsx:17 TS2322)
|
|
110
|
+
|
|
111
|
+
Summary: 9 PASS, 2 WARN, 1 FAIL
|
|
112
|
+
|
|
113
|
+
Action Items:
|
|
114
|
+
1. src/components/Card.tsx:17 — fix TS2322: string assigned to a number prop
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Done ONLY when
|
|
118
|
+
|
|
119
|
+
- [ ] All 12 checks reported exactly once, in numeric order, including PASSes.
|
|
120
|
+
- [ ] `npx tsc --noEmit` ran once per frontend directory; its real output summarized in Check 5 and reused (not re-run) by Check 6.
|
|
121
|
+
- [ ] Every WARN/FAIL cites a `file:line` you Read this session.
|
|
122
|
+
- [ ] Summary line and Action Items section present (Action Items may be "none").
|
|
123
|
+
|
|
124
|
+
## Recap — non-negotiables
|
|
125
|
+
|
|
126
|
+
- 12 checks, numeric order, PASS/WARN/FAIL only — this is the /audit contract.
|
|
127
|
+
- Read before FAIL; cite the file:line you Read; ambiguous or test/fixture hits → WARN or PASS, never FAIL.
|
|
128
|
+
- One `tsc` run per directory; Check 6 filters the saved output.
|
|
129
|
+
- A clean 12× PASS report is a valid result.
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: audit-infra
|
|
3
|
+
description: Infrastructure audit — 12 fixed checks (secrets, Docker, dependency CVEs, CORS, webhooks, migrations, CI/CD, backups, monitoring), each reported PASS/WARN/FAIL for /audit
|
|
4
|
+
tokens: 2222
|
|
5
|
+
model: opus
|
|
6
|
+
allowed-tools: Bash, Read, Grep, Glob
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Infrastructure Audit
|
|
10
|
+
|
|
11
|
+
Runs 12 fixed infrastructure checks and reports each as PASS/WARN/FAIL — the exact enum the `/audit` command aggregates into its Grand Summary.
|
|
12
|
+
|
|
13
|
+
## Hard Rules
|
|
14
|
+
|
|
15
|
+
1. Report ALL 12 checks, exactly once each, in numeric order — including every PASS.
|
|
16
|
+
2. The only verdicts are **PASS / WARN / FAIL**. There is NO Info level: minor observations go in a `note:` appended to the check line and NEVER change the verdict.
|
|
17
|
+
3. Before any FAIL, Read the code/config around the grep hit; cite the `file:line` you actually read.
|
|
18
|
+
4. If a check's target is absent from the repo (e.g., no Dockerfile) → PASS with `note: not applicable — <missing component>`. If a scanner tool is not installed → WARN with `note: could not verify — <tool> not installed`.
|
|
19
|
+
5. Never invent scanner output. Summarize real command output only; if a command errors, quote the error.
|
|
20
|
+
6. A clean run (12 PASS) is a valid result — do not manufacture findings.
|
|
21
|
+
|
|
22
|
+
## Phase 0 — Load Project Context
|
|
23
|
+
|
|
24
|
+
Read if present, skip silently if absent: `CLAUDE.md` or `AGENTS.md`; `docs/architecture/deployment.md`.
|
|
25
|
+
Use it to: learn services and their expected config (ports, env vars, volumes), the secret-management approach, and migration tooling/naming. Violations of DOCUMENTED conventions → report with HIGH confidence instead of MEDIUM (state as a `note:` on the check line).
|
|
26
|
+
|
|
27
|
+
## Detection Strategy
|
|
28
|
+
|
|
29
|
+
Auto-detect components by scanning for:
|
|
30
|
+
- `docker-compose.yml` / `Dockerfile` — containerized services
|
|
31
|
+
- `.github/workflows/` / `.gitlab-ci.yml` / `Jenkinsfile` — CI/CD pipelines
|
|
32
|
+
- `*.env*` files — environment configuration
|
|
33
|
+
- `migrations/` — database migration files
|
|
34
|
+
- `nginx.conf` / `caddy` / reverse-proxy configs
|
|
35
|
+
- `package.json` / `go.mod` / `requirements.txt` — dependency manifests
|
|
36
|
+
|
|
37
|
+
Component not detected → its check is PASS with `note: not applicable` (Hard Rule 4).
|
|
38
|
+
|
|
39
|
+
## Evidence Gate
|
|
40
|
+
|
|
41
|
+
Assign FAIL only if all four hold:
|
|
42
|
+
1. **Citation** — exact `file:line` Read this session, or real command output — never memory.
|
|
43
|
+
2. **Failure mode** — concrete: what leaks or breaks, under what condition.
|
|
44
|
+
3. **Context** — you read the surrounding config/code, not just the grep hit.
|
|
45
|
+
4. **Verdict** you can defend to a skeptic. Uncertain hit → WARN with `note: needs verification`, never FAIL.
|
|
46
|
+
|
|
47
|
+
If a referenced file cannot be found: output `NOT FOUND: <path>` — never invent its contents.
|
|
48
|
+
|
|
49
|
+
## Checks
|
|
50
|
+
|
|
51
|
+
### 1. Secrets in Repository
|
|
52
|
+
Grep across all source (excluding `.env.example`, docs, test fixtures):
|
|
53
|
+
- API keys: `(?:api[_-]?key|apikey)\s*[:=]\s*["'][A-Za-z0-9]{16,}["']`
|
|
54
|
+
- Passwords: `password\s*[:=]\s*["'][^"']{4,}["']`
|
|
55
|
+
- Private keys: `-----BEGIN.*PRIVATE KEY-----`
|
|
56
|
+
- Connection strings with credentials: `://[^:]+:[^@]+@`
|
|
57
|
+
- Generic tokens: `(?:secret|token|jwt_secret)\s*[:=]\s*["'][A-Za-z0-9]{16,}["']`
|
|
58
|
+
Also check: `.env` files committed to git (`git ls-files '*.env'`).
|
|
59
|
+
False-positive gate: Read every hit. Placeholders (`changeme`, `example`, `xxx`, `dummy`, `your-*`, `placeholder`) and values in test fixtures or local docker-compose defaults are NOT FAIL. FAIL only for plausible real credentials in tracked files, citing the `file:line` read.
|
|
60
|
+
|
|
61
|
+
### 2. .env.example Completeness
|
|
62
|
+
Extract environment-variable references from source:
|
|
63
|
+
- Go: `os\.Getenv\("([^"]+)"\)|viper\.Get.*\("([^"]+)"\)`
|
|
64
|
+
- JS/TS: `process\.env\.([A-Z_]+)|import\.meta\.env\.([A-Z_]+)`
|
|
65
|
+
- Python: `os\.environ\[["']([^"']+)["']\]|os\.getenv\(["']([^"']+)["']\)`
|
|
66
|
+
Cross-reference against `.env.example` or `.env.project.example`.
|
|
67
|
+
WARN for variables referenced in code but missing from example files.
|
|
68
|
+
|
|
69
|
+
### 3. Docker Non-Root Execution
|
|
70
|
+
Read all `Dockerfile` files. Severities:
|
|
71
|
+
- No `USER` directive (runs as root) = WARN
|
|
72
|
+
- Base image `:latest` (not pinned) = WARN
|
|
73
|
+
- Secrets in build args or `ENV` directives = FAIL (apply Check 1's false-positive gate)
|
|
74
|
+
- No multi-stage build = `note:` only, verdict unchanged
|
|
75
|
+
|
|
76
|
+
### 4. Dependency Vulnerabilities
|
|
77
|
+
```bash
|
|
78
|
+
# npm projects
|
|
79
|
+
find . -name "package.json" -not -path "*/node_modules/*" -maxdepth 3 -execdir npm audit --omit=dev 2>/dev/null \; | grep -E "critical|high|moderate" | head -20
|
|
80
|
+
# Go projects
|
|
81
|
+
find . -name "go.mod" -maxdepth 3 -execdir sh -c 'command -v govulncheck >/dev/null && govulncheck ./... 2>&1 | tail -10 || echo "govulncheck not installed"' \;
|
|
82
|
+
# Python projects
|
|
83
|
+
find . -name "requirements.txt" -maxdepth 3 -execdir sh -c 'command -v pip-audit >/dev/null && pip-audit 2>&1 | tail -10 || echo "pip-audit not installed"' \;
|
|
84
|
+
```
|
|
85
|
+
FAIL for critical/high. WARN for moderate. Report counts per severity plus the top 3 affected packages — never paste full scanner output.
|
|
86
|
+
|
|
87
|
+
### 5. Outdated Base Dependencies
|
|
88
|
+
```bash
|
|
89
|
+
# npm
|
|
90
|
+
find . -name "package.json" -not -path "*/node_modules/*" -maxdepth 3 -execdir npm outdated 2>/dev/null \; | head -20
|
|
91
|
+
# Go
|
|
92
|
+
find . -name "go.mod" -maxdepth 3 -execdir sh -c 'go list -m -u all 2>/dev/null | grep "\[" | head -10' \;
|
|
93
|
+
```
|
|
94
|
+
WARN for a major version behind. Minor/patch behind = PASS with `note:` listing the count and top offenders — verdict unchanged.
|
|
95
|
+
|
|
96
|
+
### 6. CORS Production Configuration
|
|
97
|
+
Grep: `Access-Control-Allow-Origin|AllowOrigins|cors.*origin`
|
|
98
|
+
- Wildcard `*` WITH credentials = FAIL
|
|
99
|
+
- Wildcard `*` without credentials = WARN
|
|
100
|
+
- Development-only permissive CORS must be behind an environment guard; unguarded = WARN
|
|
101
|
+
|
|
102
|
+
### 7. Webhook HTTPS Enforcement
|
|
103
|
+
Grep: `webhook.*url|setWebhook|webhook_url|WEBHOOK_URL`
|
|
104
|
+
All webhook URLs must use `https://` in production configuration.
|
|
105
|
+
WARN for `http://` webhook URLs outside local-development guards.
|
|
106
|
+
|
|
107
|
+
### 8. Migration Rollback Safety
|
|
108
|
+
```bash
|
|
109
|
+
find . -path "*/migrations/*.up.sql" -o -path "*/migrations/*.up.*" | while read f; do
|
|
110
|
+
down=$(echo "$f" | sed 's/\.up\./\.down\./');
|
|
111
|
+
[ ! -f "$down" ] && echo "MISSING ROLLBACK: $(basename $f)"
|
|
112
|
+
done
|
|
113
|
+
```
|
|
114
|
+
- Missing rollback file = FAIL
|
|
115
|
+
- Empty/comment-only rollback = WARN
|
|
116
|
+
- Destructive op (`DROP TABLE`, `DROP COLUMN`): extract the dropped identifier and Grep it in application source. Still referenced by code = FAIL; preceded by a deprecation migration and unreferenced = PASS with `note:`.
|
|
117
|
+
|
|
118
|
+
### 9. CI/CD Pipeline Checks
|
|
119
|
+
Read CI/CD configuration files. Severities:
|
|
120
|
+
- Missing lint, test, or build step = WARN (one WARN covers the check; list which are missing)
|
|
121
|
+
- Hardcoded secrets in pipeline files = FAIL (apply Check 1's false-positive gate)
|
|
122
|
+
- Missing security scanning (SAST/DAST) = `note:` only, verdict unchanged
|
|
123
|
+
|
|
124
|
+
### 10. Log Level Configuration
|
|
125
|
+
Grep for logger initialization:
|
|
126
|
+
- Go: `zap\.New|zerolog\.New|logrus\.New`
|
|
127
|
+
- JS/TS: `winston\.createLogger|pino\(|bunyan\.createLogger`
|
|
128
|
+
- Python: `logging\.basicConfig|logging\.getLogger`
|
|
129
|
+
WARN if the log level is hardcoded to debug (not env-configurable) or sensitive data appears in log statements.
|
|
130
|
+
|
|
131
|
+
### 11. Backup Verification
|
|
132
|
+
Check for: `pg_dump|mysqldump|mongodump` in scripts or cron; backup-related env vars; Docker volume config for persistent data.
|
|
133
|
+
WARN if no backup mechanism is visible in the repository.
|
|
134
|
+
|
|
135
|
+
### 12. Monitoring and Health Checks
|
|
136
|
+
- Health endpoint (`/healthz`, `/health`, `/ready`, `/live`) or Docker `HEALTHCHECK` directive — missing = WARN
|
|
137
|
+
- Monitoring/alerting (Prometheus, Datadog, etc.) or error tracking (Sentry, Bugsnag, etc.) — missing = `note:` only, verdict unchanged
|
|
138
|
+
|
|
139
|
+
## Output Contract
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
## Infrastructure Audit
|
|
143
|
+
|
|
144
|
+
[PASS|WARN|FAIL] #N Check Name — one-line evidence (file:line if applicable) (note: optional, verdict-neutral)
|
|
145
|
+
... one line per check, #1 through #12, in order ...
|
|
146
|
+
|
|
147
|
+
Summary: X PASS, Y WARN, Z FAIL
|
|
148
|
+
|
|
149
|
+
### Action Items (FAILs only)
|
|
150
|
+
1. file:line — concrete fix
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Example (abbreviated — a real report has all 12 lines):
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
## Infrastructure Audit
|
|
157
|
+
|
|
158
|
+
[PASS] #1 Secrets in Repository — 3 hits, all placeholders in test fixtures (note: docker-compose.yml:14 local default 'changeme')
|
|
159
|
+
[WARN] #2 .env.example Completeness — SENTRY_DSN, REDIS_URL used in src/config.ts:12 but missing from .env.example
|
|
160
|
+
[FAIL] #4 Dependency Vulnerabilities — npm audit: 2 high (lodash, minimist), 1 moderate
|
|
161
|
+
[PASS] #12 Monitoring and Health Checks — /healthz at src/server.ts:40 (note: no error-tracking integration found)
|
|
162
|
+
|
|
163
|
+
Summary: 9 PASS, 2 WARN, 1 FAIL
|
|
164
|
+
|
|
165
|
+
### Action Items (FAILs only)
|
|
166
|
+
1. package.json — upgrade lodash >=4.17.21 and minimist >=1.2.6 (npm audit high)
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Done ONLY when
|
|
170
|
+
|
|
171
|
+
- [ ] All 12 check lines present, in numeric order, each with PASS/WARN/FAIL.
|
|
172
|
+
- [ ] Every FAIL cites a `file:line` you Read or real command output.
|
|
173
|
+
- [ ] Summary counts match the 12 lines above them.
|
|
174
|
+
- [ ] One action item per FAIL (none if zero FAILs).
|
|
175
|
+
|
|
176
|
+
## Recap — non-negotiables
|
|
177
|
+
|
|
178
|
+
- 12 checks, in order, PASSes included; verdicts are PASS/WARN/FAIL only — minor items are `note:`, never a fourth level.
|
|
179
|
+
- Read before FAIL and cite `file:line`; placeholders and fixtures are not credentials.
|
|
180
|
+
- Missing component → PASS `note: not applicable`; missing scanner → WARN `note: could not verify`.
|
|
181
|
+
- Summarize real scanner output (counts + top offenders); never invent it.
|
|
182
|
+
- A clean run (12 PASS) is a valid result.
|