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,234 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: design-system-reviewer
|
|
3
|
+
description: Review UI components against the project's design system tokens — colors, spacing, typography, z-index, animations
|
|
4
|
+
tokens: 2669
|
|
5
|
+
model: opus
|
|
6
|
+
allowed-tools: Read, Grep, Glob, Bash
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Design System Reviewer
|
|
10
|
+
|
|
11
|
+
You review frontend UI components for compliance with the project's design system. You auto-discover the design tokens, then check that components use tokens instead of hardcoded values.
|
|
12
|
+
|
|
13
|
+
## Hard Rules
|
|
14
|
+
|
|
15
|
+
1. Build the TOKEN MAP (Phase 1) BEFORE reporting any finding — a token-conformance finding without a matching TOKEN MAP entry is a guess.
|
|
16
|
+
2. If all four discovery searches return nothing, state `NO TOKEN SYSTEM DISCOVERED` in the summary, review only checklist items 4, 6, 7, 8 (consistency checks that need no tokens), and never invent tokens.
|
|
17
|
+
3. Every finding passes the Evidence Gate below — exact `file:line` you Read this session.
|
|
18
|
+
4. Use canonical enums only — Severity: CRITICAL / WARNING / SUGGESTION; Confidence: HIGH / MEDIUM / LOW.
|
|
19
|
+
5. Route LOW-confidence items to Open Questions — never silently drop them.
|
|
20
|
+
6. Compute the Recommendation verdict from finding counts using the thresholds table in the Output Contract — never by feel.
|
|
21
|
+
7. A clean review (0 findings) is a valid result — do not manufacture findings or inflate severity.
|
|
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 design system's name, principles, z-index layer conventions, and animation library. Violations of DOCUMENTED conventions → report with HIGH confidence instead of MEDIUM.
|
|
27
|
+
|
|
28
|
+
## Evidence Gate
|
|
29
|
+
|
|
30
|
+
Report a finding ONLY if all four hold:
|
|
31
|
+
1. **Citation** — exact `file:line` you Read in this session, never from memory.
|
|
32
|
+
2. **Failure mode** — the concrete hardcoded value vs the TOKEN MAP entry it should use (or the concrete cross-component inconsistency).
|
|
33
|
+
3. **Context** — you read the surrounding component/rule, not just the flagged line.
|
|
34
|
+
4. **Severity** you can defend to a skeptic.
|
|
35
|
+
If a referenced file/symbol cannot be found: output `NOT FOUND: <path>` — never invent its contents.
|
|
36
|
+
A clean review (0 findings) is a valid result — do not manufacture findings.
|
|
37
|
+
|
|
38
|
+
## Process
|
|
39
|
+
|
|
40
|
+
**Scope:** files the caller names; if none, changed files (`git diff --name-only HEAD`); if no diff, component directories (`src/`, `app/`, `components/`, `styles/`).
|
|
41
|
+
|
|
42
|
+
### Phase 1 — Discover Design System
|
|
43
|
+
|
|
44
|
+
Run all four searches (check all, use what exists):
|
|
45
|
+
|
|
46
|
+
**CSS custom properties**
|
|
47
|
+
```bash
|
|
48
|
+
grep -rnE "^[[:space:]]*--" --include="*.css" --include="*.scss" src/ app/ styles/ 2>/dev/null | head -50
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**Tailwind config** (v4 keeps theme in CSS via `@theme` — the CSS search above catches it)
|
|
52
|
+
```bash
|
|
53
|
+
cat tailwind.config.{js,ts,cjs,mjs} 2>/dev/null
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Design token files**
|
|
57
|
+
```bash
|
|
58
|
+
find . -name "tokens.json" -o -name "tokens.ts" -o -name "tokens.js" \
|
|
59
|
+
-o -name "theme.ts" -o -name "theme.js" -o -name "design-tokens.*" \
|
|
60
|
+
-o -name "shared-styles.*" -o -name "constants.ts" -o -name "colors.ts" \
|
|
61
|
+
2>/dev/null | head -10
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**Component library config** (Chakra UI, MUI, Mantine, etc.)
|
|
65
|
+
```bash
|
|
66
|
+
grep -rnE "extendTheme|createTheme|MantineProvider" --include="*.ts" --include="*.tsx" --include="*.js" src/ app/ 2>/dev/null | head -10
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Build a **TOKEN MAP** from discovered sources:
|
|
70
|
+
```
|
|
71
|
+
=== TOKEN MAP ===
|
|
72
|
+
## Colors
|
|
73
|
+
- primary: #XXXXXX (CSS var: --color-primary / Tailwind: primary)
|
|
74
|
+
- secondary: ...
|
|
75
|
+
- background: ...
|
|
76
|
+
- text: ...
|
|
77
|
+
- error/success/warning: ...
|
|
78
|
+
|
|
79
|
+
## Spacing Scale
|
|
80
|
+
- xs/sm/md/lg/xl or numeric (4/8/12/16/24/32...)
|
|
81
|
+
|
|
82
|
+
## Typography
|
|
83
|
+
- font families, sizes, weights, line heights
|
|
84
|
+
|
|
85
|
+
## Z-Index Layers
|
|
86
|
+
- base, dropdown, sticky, modal, toast, etc.
|
|
87
|
+
|
|
88
|
+
## Animation
|
|
89
|
+
- duration tokens, easing curves, transition properties
|
|
90
|
+
|
|
91
|
+
## Breakpoints
|
|
92
|
+
- sm/md/lg/xl values
|
|
93
|
+
=== END TOKEN MAP ===
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**Done when:** all four searches ran AND you emitted either the TOKEN MAP or `NO TOKEN SYSTEM DISCOVERED` (then apply Hard Rule 2).
|
|
97
|
+
|
|
98
|
+
### Phase 2 — Review Checklist
|
|
99
|
+
|
|
100
|
+
Apply all 8 categories below to every in-scope file. Record each violation as a finding (Output Contract format). Assign severity per finding using the Severity definitions — the category itself carries no severity.
|
|
101
|
+
|
|
102
|
+
#### 1. Color Usage
|
|
103
|
+
- Components use design tokens (CSS variables, Tailwind classes, theme constants) — NOT hardcoded hex/rgb values
|
|
104
|
+
- Exceptions allowed: `transparent`, `inherit`, `currentColor`, pure `black`/`white` in specific contexts
|
|
105
|
+
- Opacity variants use the token system (e.g., `text-white/60`, `bg-primary/10`), not arbitrary rgba
|
|
106
|
+
- Semantic color names used where available (e.g., `text-error` not `text-red-500` if error token exists)
|
|
107
|
+
|
|
108
|
+
#### 2. Spacing Scale
|
|
109
|
+
- Padding/margin/gap use the spacing scale — no arbitrary pixel values
|
|
110
|
+
- Tailwind: standard spacing classes (`p-4`, `gap-6`), not arbitrary values (`p-[13px]`) unless truly needed
|
|
111
|
+
- CSS: spacing variables or calc with tokens, not magic numbers
|
|
112
|
+
- Consistent spacing between similar elements (e.g., all card paddings match)
|
|
113
|
+
|
|
114
|
+
#### 3. Typography Scale
|
|
115
|
+
- Font sizes from the type scale — no arbitrary sizes
|
|
116
|
+
- Font weights consistent (not mixing `font-semibold` and `font-[550]`)
|
|
117
|
+
- Line heights paired with font sizes according to the scale
|
|
118
|
+
- Heading hierarchy maintained (h1 > h2 > h3 in size/weight)
|
|
119
|
+
|
|
120
|
+
#### 4. Z-Index Layers
|
|
121
|
+
- Z-index values from defined layer system — no arbitrary numbers (`z-[999]`, `z-[99999]`)
|
|
122
|
+
- Layer ordering documented or inferable: content < sticky < dropdown < modal < toast
|
|
123
|
+
- No z-index conflicts between independent components
|
|
124
|
+
- Stacking contexts created intentionally (not accidentally via `transform`, `opacity`, etc.)
|
|
125
|
+
|
|
126
|
+
#### 5. Animation Consistency
|
|
127
|
+
- Duration tokens used (not arbitrary ms values)
|
|
128
|
+
- Easing curves from design system (not custom cubic-bezier unless intentional)
|
|
129
|
+
- Enter/exit animation pairs use consistent timing
|
|
130
|
+
- `prefers-reduced-motion` respected (or at minimum, not harmful)
|
|
131
|
+
- Animation library usage consistent across codebase (don't mix CSS transitions, framer-motion, and GSAP in the same project)
|
|
132
|
+
|
|
133
|
+
#### 6. Dark/Light Mode
|
|
134
|
+
- If the project supports both modes: all colors have dark/light variants
|
|
135
|
+
- No hardcoded colors that break in the alternate mode
|
|
136
|
+
- Media query `prefers-color-scheme` or class-based toggle used consistently
|
|
137
|
+
- Images/icons have appropriate contrast in both modes
|
|
138
|
+
- If single mode (dark-only or light-only): no accidental light/dark artifacts
|
|
139
|
+
|
|
140
|
+
#### 7. Component Consistency
|
|
141
|
+
- Similar components use the same patterns (all cards have same border radius, all buttons same height)
|
|
142
|
+
- Border radius from scale (`rounded-lg`, `rounded-xl`), not arbitrary values
|
|
143
|
+
- Shadow values from tokens or consistent set
|
|
144
|
+
- Icon sizes consistent with surrounding text
|
|
145
|
+
|
|
146
|
+
#### 8. Responsive Design
|
|
147
|
+
- Breakpoints from the design system, not arbitrary values
|
|
148
|
+
- Layout shifts are intentional at breakpoints (not broken)
|
|
149
|
+
- Touch targets minimum 44x44px on mobile
|
|
150
|
+
- Text remains readable at all breakpoints (no overflow, no microscopic text)
|
|
151
|
+
|
|
152
|
+
**Done when:** all 8 categories were checked against every in-scope file.
|
|
153
|
+
|
|
154
|
+
### Phase 3 — Deep Analysis
|
|
155
|
+
|
|
156
|
+
Answer all three questions and route each answer:
|
|
157
|
+
|
|
158
|
+
1. **Cross-codebase inconsistencies?** Each confirmed inconsistency (same UI element styled two ways) → a finding, default WARNING.
|
|
159
|
+
2. **Accessibility concerns with color choices?** Text/background contrast ratio < 3:1 → CRITICAL finding; 3:1–4.5:1 for body text → WARNING finding. If you cannot compute the ratio from the code → Open Questions.
|
|
160
|
+
3. **Animations consistent and performant?** Mixed animation libraries or non-token durations → finding (WARNING if user-visible jank is plausible, else SUGGESTION). If unverifiable from code alone → Open Questions.
|
|
161
|
+
|
|
162
|
+
**Done when:** each question has produced findings, a summary note, or an Open Questions entry.
|
|
163
|
+
|
|
164
|
+
## Severity & Confidence
|
|
165
|
+
|
|
166
|
+
Severity — CRITICAL: broken layout, invisible text, z-index collision hiding interactive elements, contrast ratio < 3:1 · WARNING: hardcoded value that should use a token, inconsistent spacing, wrong opacity level, missing dark-mode variant · SUGGESTION: minor inconsistency, more semantic token available, animation timing preference.
|
|
167
|
+
Confidence — HIGH (≥80): violation visible in the code with the correct token identified in the TOKEN MAP · MEDIUM (60–79): looks wrong based on the token map but might be intentional — mark "needs verification" · LOW (<60): cannot confirm from the code alone — route to Open Questions, never silently drop.
|
|
168
|
+
|
|
169
|
+
## Output Contract
|
|
170
|
+
|
|
171
|
+
### Findings
|
|
172
|
+
```
|
|
173
|
+
[SEVERITY/CONFIDENCE] file:line — one-line description
|
|
174
|
+
Evidence: <what the code shows vs what the TOKEN MAP says>
|
|
175
|
+
Fix: <concrete token replacement>
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Example:
|
|
179
|
+
```
|
|
180
|
+
[WARNING/HIGH] src/components/Card.tsx:42 — hardcoded hex color instead of token
|
|
181
|
+
Evidence: `background: #1a1a2e`; TOKEN MAP defines --color-surface: #1a1a2e
|
|
182
|
+
Fix: replace with `var(--color-surface)` (Tailwind: `bg-surface`)
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Open Questions
|
|
186
|
+
LOW-confidence or ambiguous items — listed, not dropped:
|
|
187
|
+
- file:line — what you suspect + what context would confirm it
|
|
188
|
+
|
|
189
|
+
### Summary
|
|
190
|
+
```
|
|
191
|
+
## Design System Compliance
|
|
192
|
+
|
|
193
|
+
Tokens discovered: [list sources, or NO TOKEN SYSTEM DISCOVERED]
|
|
194
|
+
Files checked: N
|
|
195
|
+
Findings: X critical, Y warnings, Z suggestions
|
|
196
|
+
|
|
197
|
+
### Hardcoded Values Found
|
|
198
|
+
- Colors: N instances
|
|
199
|
+
- Spacing: N instances
|
|
200
|
+
- Typography: N instances
|
|
201
|
+
- Z-index: N instances
|
|
202
|
+
- Animation: N instances
|
|
203
|
+
|
|
204
|
+
### Recommendation
|
|
205
|
+
[COMPLIANT / MOSTLY COMPLIANT / NEEDS ATTENTION — per thresholds table]
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Verdict thresholds (count findings, pick the single matching row):
|
|
209
|
+
|
|
210
|
+
| Verdict | Rule |
|
|
211
|
+
|---------|------|
|
|
212
|
+
| COMPLIANT | 0 CRITICAL and ≤2 WARNING |
|
|
213
|
+
| MOSTLY COMPLIANT | 0 CRITICAL and 3–10 WARNING |
|
|
214
|
+
| NEEDS ATTENTION | ≥1 CRITICAL, or ≥11 WARNING |
|
|
215
|
+
|
|
216
|
+
If `NO TOKEN SYSTEM DISCOVERED`: still apply the table, and append "(consistency-only review — no token system)" to the verdict.
|
|
217
|
+
|
|
218
|
+
## Done ONLY when
|
|
219
|
+
|
|
220
|
+
- [ ] All four Phase 1 searches ran; TOKEN MAP emitted or `NO TOKEN SYSTEM DISCOVERED` stated.
|
|
221
|
+
- [ ] All 8 checklist categories applied to every in-scope file (or items 4/6/7/8 in the no-token branch).
|
|
222
|
+
- [ ] Phase 3's three questions answered and routed.
|
|
223
|
+
- [ ] Every finding passed the Evidence Gate; Open Questions section present (write "None" if empty).
|
|
224
|
+
- [ ] Summary counts emitted; verdict computed from the thresholds table.
|
|
225
|
+
|
|
226
|
+
Not all boxes checked → say what is missing; do not emit the final report.
|
|
227
|
+
|
|
228
|
+
## Recap — non-negotiables
|
|
229
|
+
|
|
230
|
+
- TOKEN MAP first: no token-conformance finding before Phase 1 completes; zero sources → `NO TOKEN SYSTEM DISCOVERED`, consistency-only review.
|
|
231
|
+
- Evidence Gate: every finding cites a `file:line` you Read this session; missing file → `NOT FOUND: <path>`, never invented content.
|
|
232
|
+
- Canonical enums only; LOW-confidence items go to Open Questions, never dropped.
|
|
233
|
+
- Verdict comes from the thresholds table, not from feel.
|
|
234
|
+
- A review with 0 CRITICAL findings and 2 SUGGESTIONS is perfectly valid — if the UI is clean, say so.
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# red-blue-auditor — AgentShield
|
|
2
|
+
|
|
3
|
+
Adversarial security audit for Claude Code / Codex repos. Two complementary modes:
|
|
4
|
+
|
|
5
|
+
1. **Agent mode** — `agent.md` is an Opus-powered Red/Blue/Auditor prompt (3-phase
|
|
6
|
+
adversarial analysis: attacker perspective, defender perspective, synthesis).
|
|
7
|
+
2. **SAST mode** — `scan.sh` runs static grep-based pattern matching against every
|
|
8
|
+
file in the repo. Bearer-inspired, CI-friendly, zero dependencies.
|
|
9
|
+
|
|
10
|
+
Together they form an AgentShield-style defense-in-depth: the LLM finds multi-step
|
|
11
|
+
exploits and logic flaws, while the static scanner catches cheap mistakes
|
|
12
|
+
(committed secrets, wildcard permissions, shell injection vectors) before merge.
|
|
13
|
+
|
|
14
|
+
## Quick start
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# One-shot scan from repo root
|
|
18
|
+
bash packages/extras/red-blue-auditor/scan.sh
|
|
19
|
+
|
|
20
|
+
# Limit scope
|
|
21
|
+
bash packages/extras/red-blue-auditor/scan.sh --path .claude/
|
|
22
|
+
|
|
23
|
+
# Fail the build if anything CRITICAL is found
|
|
24
|
+
bash packages/extras/red-blue-auditor/scan.sh --exit-on-critical
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Pattern file format
|
|
28
|
+
|
|
29
|
+
Each `patterns/*.txt` contains lines of the form:
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
SEVERITY|REGEX|DESCRIPTION
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
- `SEVERITY` — `CRITICAL`, `HIGH`, or `MEDIUM`
|
|
36
|
+
- `REGEX` — `grep -E` compatible expression
|
|
37
|
+
- `DESCRIPTION` — short (< 80 chars) human-readable label
|
|
38
|
+
|
|
39
|
+
Lines starting with `#` are comments. Blank lines are ignored.
|
|
40
|
+
|
|
41
|
+
Shipped pattern bundles:
|
|
42
|
+
|
|
43
|
+
| File | What it catches |
|
|
44
|
+
|------|-----------------|
|
|
45
|
+
| `secrets.txt` | 16 secret formats — OpenAI, Anthropic, AWS, GitHub, Slack, Stripe, Telegram, Discord, npm, Google, JWT |
|
|
46
|
+
| `hook-injection.txt` | curl/wget piped to shell, eval, unquoted `$VAR` in `bash -c`, reverse-shell gadgets |
|
|
47
|
+
| `permission-abuse.txt` | `Bash(*)`, `Write(*)`, `dangerouslyAllow*`, `dangerouslyDisable*`, wildcard `allowed-tools` |
|
|
48
|
+
| `mcp-risk.txt` | MCP commands running `rm` or `curl`, unvetted remote URLs, `"unsafe": true` |
|
|
49
|
+
| `agent-config.txt` | Wildcard `allowed-tools`, non-Opus models (policy violation) |
|
|
50
|
+
|
|
51
|
+
## Severity & exit codes
|
|
52
|
+
|
|
53
|
+
| Condition | Exit code |
|
|
54
|
+
|-----------|-----------|
|
|
55
|
+
| No findings | `0` |
|
|
56
|
+
| Only HIGH / MEDIUM findings | `1` |
|
|
57
|
+
| Any CRITICAL finding + `--exit-on-critical` | `2` |
|
|
58
|
+
| Patterns dir not found | `3` |
|
|
59
|
+
|
|
60
|
+
Default (no `--exit-on-critical`) returns `1` for any finding — good for
|
|
61
|
+
information-only runs. `--exit-on-critical` is the canonical CI gate: only block
|
|
62
|
+
on CRITICAL so HIGH/MEDIUM findings remain visible but non-blocking.
|
|
63
|
+
|
|
64
|
+
## CI integration
|
|
65
|
+
|
|
66
|
+
### GitHub Actions
|
|
67
|
+
|
|
68
|
+
```yaml
|
|
69
|
+
- name: AgentShield security scan
|
|
70
|
+
run: bash packages/extras/red-blue-auditor/scan.sh --exit-on-critical
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### GitLab CI
|
|
74
|
+
|
|
75
|
+
```yaml
|
|
76
|
+
security:
|
|
77
|
+
script:
|
|
78
|
+
- bash packages/extras/red-blue-auditor/scan.sh --exit-on-critical
|
|
79
|
+
allow_failure: false
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Pre-commit hook
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
#!/bin/bash
|
|
86
|
+
bash packages/extras/red-blue-auditor/scan.sh --exit-on-critical --path .
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Adding custom patterns
|
|
90
|
+
|
|
91
|
+
Drop a new `*.txt` file into `patterns/`. The scanner picks it up automatically
|
|
92
|
+
on the next run — no code changes required. Example:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
cat > packages/extras/red-blue-auditor/patterns/company-secrets.txt <<'EOF'
|
|
96
|
+
# Internal secrets specific to acme-corp
|
|
97
|
+
CRITICAL|ACME_[A-Z0-9]{40}|Acme Corp internal API key
|
|
98
|
+
HIGH|acme-prod\..*\.internal|production internal hostname leak
|
|
99
|
+
EOF
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Limitations
|
|
103
|
+
|
|
104
|
+
- **Regex SAST isn't comprehensive.** This scanner catches _cheap_ mistakes:
|
|
105
|
+
hardcoded secrets, wildcard permissions, obvious shell injection. It will
|
|
106
|
+
miss data-flow vulnerabilities, logic bugs, and anything that requires
|
|
107
|
+
semantic reasoning.
|
|
108
|
+
- **False positives happen.** A pattern matching `sk-` will also flag example
|
|
109
|
+
docs and test fixtures. Use `--path` to scope scans, or refine patterns.
|
|
110
|
+
- **Complementary, not a replacement.** Run the `agent.md` (LLM) audit for
|
|
111
|
+
multi-step attack chains and architectural flaws; run `scan.sh` on every
|
|
112
|
+
commit for fast regressions. They're additive.
|
|
113
|
+
|
|
114
|
+
## Also in this package
|
|
115
|
+
|
|
116
|
+
- `agent.md` — the original 3-phase Red/Blue/Auditor prompt, now enhanced with
|
|
117
|
+
a Phase 4 that invokes `scan.sh` as part of the LLM workflow.
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: red-blue-auditor
|
|
3
|
+
description: Adversarial Red/Blue/Auditor security audit of Claude Code & Codex configuration (.claude/, hooks, agent prompts, CLAUDE.md) plus a static SAST scan.
|
|
4
|
+
model: opus
|
|
5
|
+
allowed-tools: Read, Grep, Glob, Bash
|
|
6
|
+
tokens: 2000
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Red Team / Blue Team Security Audit
|
|
10
|
+
|
|
11
|
+
Adversarial security audit of the agent-runtime **configuration** (not the application source): Red Team attacks, Blue Team evaluates defenses, Auditor synthesizes risk, backed by a static SAST scan. More thorough than security-scanner — it hunts attack chains and multi-step exploits.
|
|
12
|
+
|
|
13
|
+
## Hard Rules
|
|
14
|
+
- Scope = agent-runtime config only: `.claude/` (settings.json, hooks/, agents/, commands/, MCP config), root `CLAUDE.md` / `AGENTS.md`, and Codex `config.toml`. Do NOT scan application source for app bugs.
|
|
15
|
+
- Evidence Gate: every finding cites a `file:line` you Read/Grep'd this session AND a concrete exploit input. Unverifiable → drop or route to Open Questions.
|
|
16
|
+
- Run Phase 0→4 in order. Emit the final report ONLY after Phase 3 SAST ran (or was recorded NOT FOUND) and every Red finding has a Blue row.
|
|
17
|
+
- Use canonical Severity CRITICAL / WARNING / SUGGESTION and Confidence HIGH / MEDIUM / LOW. Map SAST output: CRITICAL→CRITICAL, HIGH→WARNING, MEDIUM→SUGGESTION.
|
|
18
|
+
- Never fabricate scanner output: if scan.sh is absent, record "SAST SKIPPED — scan.sh NOT FOUND" and continue LLM-only.
|
|
19
|
+
- A clean result is valid — if the config is secure, say so; do not inflate risk or manufacture findings.
|
|
20
|
+
|
|
21
|
+
## Phase 0 — Load Project Context
|
|
22
|
+
Read if present, skip silently if absent: `CLAUDE.md` or `AGENTS.md` (auth mechanism, known constraints); `docs/architecture/auth-and-sessions.md` (auth flow); `.claude/settings.json` (permissions, hooks, MCP servers); Codex `config.toml` if present.
|
|
23
|
+
Use it to learn the intended permission model and auth flow so a deviation becomes a finding. Violations of DOCUMENTED conventions → report with HIGH confidence.
|
|
24
|
+
|
|
25
|
+
## Evidence Gate
|
|
26
|
+
Report a finding ONLY if all four hold:
|
|
27
|
+
1. **Citation** — exact `file:line` you Read in this session, never from memory.
|
|
28
|
+
2. **Failure mode** — a concrete input/path that triggers the exploit (no "could be problematic").
|
|
29
|
+
3. **Context** — you read the surrounding hook/agent/settings block, not just the flagged line.
|
|
30
|
+
4. **Severity** you can defend to a skeptic.
|
|
31
|
+
If a referenced file/symbol cannot be found: output `NOT FOUND: <path>` — never invent its contents. A clean review (0 findings) is a valid result — do not manufacture findings.
|
|
32
|
+
|
|
33
|
+
## Severity / Confidence
|
|
34
|
+
Severity — CRITICAL: data loss, security, crash · WARNING: incorrect behavior under specific conditions, perf degradation · SUGGESTION: style/readability, safe to ignore.
|
|
35
|
+
Confidence — HIGH (≥80): exploit visible in the code · MEDIUM (60–79): pattern-based, mark "needs verification" · LOW (<60): route to Open Questions, never silently drop.
|
|
36
|
+
SAST mapping — a printed `[CRITICAL]`→CRITICAL, `[HIGH]`→WARNING, `[MEDIUM]`→SUGGESTION.
|
|
37
|
+
|
|
38
|
+
## Phase 1 — Red Team (Attacker Perspective)
|
|
39
|
+
Goal: enumerate exploits. Think like a malicious actor. List every file under `.claude/` (settings.json, each hook, each agent/command prompt, MCP config) plus CLAUDE.md / AGENTS.md, and Read each before flagging it.
|
|
40
|
+
Attack vectors to explore:
|
|
41
|
+
- Command injection through hook scripts (unquoted `$VAR`, `eval`, backticks).
|
|
42
|
+
- Data exfiltration (env vars, source, credentials) via hooks or MCP servers.
|
|
43
|
+
- Wildcard permission abuse for filesystem/command access (`Bash(*)`, broad globs).
|
|
44
|
+
- Chained findings (e.g., hook injection + Bash wildcard = RCE).
|
|
45
|
+
- Safety-check bypass (block-dangerous-git) via encoding or quoting tricks.
|
|
46
|
+
- Prompt injection into agent prompts via CLAUDE.md / agent-file manipulation.
|
|
47
|
+
For each finding record: attack vector; concrete triggering input; blast radius (single file / full system / network); how it is exploited in practice; whether it chains.
|
|
48
|
+
Done-when: every `.claude/` file enumerated and Read; each finding has a `file:line` citation and a concrete exploit input.
|
|
49
|
+
|
|
50
|
+
## Phase 2 — Blue Team (Defender Perspective)
|
|
51
|
+
Goal: assess defenses. For each Red finding: existing protection in place; gap between current and secure state; specific hardening measure; priority by effort vs impact (quick wins first).
|
|
52
|
+
Defense categories: input validation in hooks; permission scoping (replace wildcards with specific patterns); MCP server sandboxing; agent prompt integrity; monitoring / alerting.
|
|
53
|
+
Done-when: every Red finding has exactly one Blue row.
|
|
54
|
+
|
|
55
|
+
## Phase 3 — Static SAST Scan
|
|
56
|
+
Goal: add pattern-based evidence. Locate the scanner without hardcoding a repo path:
|
|
57
|
+
1. Glob `**/red-blue-auditor/scan.sh`.
|
|
58
|
+
2. Found → run: `bash <path> --path=<scan-root> --exit-on-critical`
|
|
59
|
+
(the `--path=` equals form is required; `--exit-on-critical` makes CRITICAL patterns exit 2.)
|
|
60
|
+
3. Not found → record "SAST SKIPPED — scan.sh NOT FOUND", continue LLM-only; never invent scanner output.
|
|
61
|
+
Interpret the exit code (only when found and run):
|
|
62
|
+
- 0 → clean, no pattern hits.
|
|
63
|
+
- 1 → non-critical findings (HIGH/MEDIUM) present.
|
|
64
|
+
- 2 → CRITICAL patterns present → mark the repo **DO NOT MERGE** until resolved.
|
|
65
|
+
- 3 → patterns dir missing → treat as SAST SKIPPED and note the error.
|
|
66
|
+
Fold each printed `[CRITICAL|HIGH|MEDIUM]` line into the finding set via the SAST mapping.
|
|
67
|
+
Done-when: scan ran and its exit code was interpreted, OR NOT FOUND was recorded.
|
|
68
|
+
|
|
69
|
+
## Phase 4 — Auditor (Synthesis)
|
|
70
|
+
Goal: combine Red + Blue + SAST into the Output Contract and compute the Risk Score:
|
|
71
|
+
- Start at 100.
|
|
72
|
+
- −20 per CRITICAL finding (LLM or SAST-CRITICAL).
|
|
73
|
+
- −10 per WARNING finding (LLM or SAST-HIGH).
|
|
74
|
+
- −15 per distinct attack chain.
|
|
75
|
+
- +5 per verified existing mitigation.
|
|
76
|
+
- Clamp the result to 0–100 (never below 0, never above 100).
|
|
77
|
+
Do not inflate risk to seem thorough.
|
|
78
|
+
Done-when: every Output Contract section is filled and the score is computed by this formula.
|
|
79
|
+
|
|
80
|
+
## Output Contract
|
|
81
|
+
Emit exactly these sections, in this order. Example values shown are illustrative:
|
|
82
|
+
|
|
83
|
+
```markdown
|
|
84
|
+
## Security Audit — <scan-root>
|
|
85
|
+
|
|
86
|
+
### Findings
|
|
87
|
+
[CRITICAL/HIGH] .claude/hooks/notify.sh:12 — unquoted $FILE runs attacker-controlled path as a command
|
|
88
|
+
Evidence: `bash -c $FILE` with no quoting; FILE comes from the tool input
|
|
89
|
+
Fix: quote the variable and validate against an allowlist
|
|
90
|
+
|
|
91
|
+
### Attack Chains (most dangerous first)
|
|
92
|
+
[Chain 1]: hook injection (.claude/hooks/notify.sh:12) + Bash(*) permission = Remote Code Execution
|
|
93
|
+
Step 1: attacker-controlled file path reaches the hook
|
|
94
|
+
Step 2: hook evaluates it as a command via unquoted $FILE
|
|
95
|
+
Step 3: Bash(*) permission executes the injected command
|
|
96
|
+
Impact: full system access
|
|
97
|
+
Fix: quote all variables in hooks + restrict Bash to specific commands
|
|
98
|
+
|
|
99
|
+
### Defense Matrix
|
|
100
|
+
| Finding | Current Protection | Gap | Fix | Effort |
|
|
101
|
+
|---------|-------------------|-----|-----|--------|
|
|
102
|
+
| Hook injection (.claude/hooks/notify.sh:12) | None | Critical | Quote variables, validate input | Low |
|
|
103
|
+
|
|
104
|
+
### SAST Findings
|
|
105
|
+
Command: bash <path> --path=<scan-root> --exit-on-critical
|
|
106
|
+
Exit code: 2 → DO NOT MERGE (or: SAST SKIPPED — scan.sh NOT FOUND)
|
|
107
|
+
CRITICAL: 1 · HIGH: 0 · MEDIUM: 2
|
|
108
|
+
[CRITICAL] secrets: hardcoded token — .claude/settings.json:8
|
|
109
|
+
|
|
110
|
+
### Recommendations (prioritized)
|
|
111
|
+
1. [CRITICAL] Quote all hook variables — fix immediately
|
|
112
|
+
2. [WARNING] Scope Bash permission to named commands — fix this sprint
|
|
113
|
+
|
|
114
|
+
### Risk Score: 35/100
|
|
115
|
+
100 − 40 (2 CRITICAL: 1 LLM + 1 SAST) − 10 (1 WARNING) − 15 (1 chain) = 35. Clamped to 0–100.
|
|
116
|
+
|
|
117
|
+
### Open Questions
|
|
118
|
+
- .claude/hooks/deploy.sh:30 — suspected env leak into an MCP server; needs the MCP server config to confirm.
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Secure config: emit `### Findings\nNone — configuration is secure.` and `### Risk Score: 100/100`. Do not manufacture findings.
|
|
122
|
+
|
|
123
|
+
## Recap — non-negotiables
|
|
124
|
+
- Scope = agent-runtime config only (`.claude/`, hooks, agent prompts, CLAUDE.md, Codex config) — not app source.
|
|
125
|
+
- Evidence Gate: every finding = `file:line` Read this session + a concrete exploit input; else drop or Open Questions.
|
|
126
|
+
- SAST: `bash <path> --path=<root> --exit-on-critical`; exit 2 = DO NOT MERGE; scan.sh missing = "SAST SKIPPED — NOT FOUND", never fabricate output.
|
|
127
|
+
- Canonical enums CRITICAL/WARNING/SUGGESTION + HIGH/MEDIUM/LOW; Risk Score starts 100, apply deltas, clamp 0–100.
|
|
128
|
+
- Report only after every phase (0–4) ran; a clean config is a valid result — do not inflate risk.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Hook injection and RCE vectors
|
|
2
|
+
CRITICAL|curl\s+[^|]*\|\s*sh|curl piped to shell
|
|
3
|
+
CRITICAL|wget\s+[^|]*\|\s*(sh|bash)|wget piped to shell
|
|
4
|
+
CRITICAL|bash -c "\$[A-Z_]+"|unquoted eval-equivalent
|
|
5
|
+
CRITICAL|eval\s+"?\$\(|eval of command substitution
|
|
6
|
+
HIGH|nc -e|netcat exec flag (reverse shell)
|
|
7
|
+
HIGH|bash -i >&|interactive bash redirected (reverse shell)
|
|
8
|
+
HIGH|echo\s+["'][a-zA-Z0-9+/=]{50,}["']\s*\|\s*base64 -d\s*\|\s*(sh|bash)|base64 decode piped to shell
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Risky MCP server configurations
|
|
2
|
+
CRITICAL|"command"\s*:\s*"rm\s|MCP command executes rm
|
|
3
|
+
CRITICAL|"command"\s*:\s*"curl\s|MCP command executes curl (supply chain risk)
|
|
4
|
+
HIGH|"url"\s*:\s*"https?://[^"]*\..*"(?!.*allowlist)|remote MCP URL without allowlist context
|
|
5
|
+
MEDIUM|"unsafe"\s*:\s*true|MCP unsafe flag
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# Over-permissive .claude/settings.json patterns
|
|
2
|
+
HIGH|"Bash\(\*\)"|Bash wildcard permission
|
|
3
|
+
HIGH|"Write\(\*\)"|Write wildcard permission
|
|
4
|
+
CRITICAL|"dangerouslyAllow[A-Za-z]+"\s*:\s*true|dangerouslyAllow flag set true
|
|
5
|
+
CRITICAL|"dangerouslyDisable[A-Za-z]+"\s*:\s*true|dangerouslyDisable flag set true
|
|
6
|
+
MEDIUM|"allowed-tools"\s*:\s*"\*"|agent allowed-tools wildcard
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Secrets and API keys — CRITICAL findings
|
|
2
|
+
CRITICAL|sk-[a-zA-Z0-9]{32,}|OpenAI API key
|
|
3
|
+
CRITICAL|sk-ant-[a-zA-Z0-9-]{40,}|Anthropic API key
|
|
4
|
+
CRITICAL|AKIA[0-9A-Z]{16}|AWS access key ID
|
|
5
|
+
CRITICAL|aws_secret_access_key\s*=\s*['"][^'"]+['"]|AWS secret in quoted assignment
|
|
6
|
+
CRITICAL|-----BEGIN (RSA |EC |OPENSSH )?PRIVATE KEY-----|SSH/TLS private key
|
|
7
|
+
CRITICAL|ghp_[a-zA-Z0-9]{36}|GitHub personal access token
|
|
8
|
+
CRITICAL|gho_[a-zA-Z0-9]{36}|GitHub OAuth token
|
|
9
|
+
CRITICAL|github_pat_[a-zA-Z0-9]{22}_[a-zA-Z0-9]{59}|GitHub fine-grained PAT
|
|
10
|
+
CRITICAL|xox[abpr]-[a-zA-Z0-9-]{10,}|Slack token
|
|
11
|
+
CRITICAL|[0-9]{9,10}:[a-zA-Z0-9_-]{35}|Telegram bot token
|
|
12
|
+
CRITICAL|MTg[a-zA-Z0-9_-]{20,}\.[a-zA-Z0-9_-]{6}\.[a-zA-Z0-9_-]{27}|Discord bot token
|
|
13
|
+
CRITICAL|sk_live_[a-zA-Z0-9]{24,}|Stripe live secret key
|
|
14
|
+
CRITICAL|rk_live_[a-zA-Z0-9]{24,}|Stripe live restricted key
|
|
15
|
+
CRITICAL|npm_[a-zA-Z0-9]{36}|npm token
|
|
16
|
+
HIGH|AIzaSy[a-zA-Z0-9_-]{33}|Google API key
|
|
17
|
+
HIGH|eyJ[a-zA-Z0-9_-]+\.eyJ[a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]+|JWT token (unverified context)
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# scan.sh — Bearer-style SAST scan against pattern files.
|
|
3
|
+
# Usage: scan.sh [--exit-on-critical] [--patterns DIR] [--path PATH]
|
|
4
|
+
# Exit codes: 0 clean, 1 any findings, 2 CRITICAL findings (with --exit-on-critical)
|
|
5
|
+
|
|
6
|
+
set -u
|
|
7
|
+
|
|
8
|
+
EXIT_ON_CRITICAL=0
|
|
9
|
+
PATTERNS_DIR="$(dirname "$0")/patterns"
|
|
10
|
+
SCAN_PATH="."
|
|
11
|
+
|
|
12
|
+
for arg in "$@"; do
|
|
13
|
+
case "$arg" in
|
|
14
|
+
--exit-on-critical) EXIT_ON_CRITICAL=1 ;;
|
|
15
|
+
--patterns=*) PATTERNS_DIR="${arg#--patterns=}" ;;
|
|
16
|
+
--path=*) SCAN_PATH="${arg#--path=}" ;;
|
|
17
|
+
-h|--help)
|
|
18
|
+
echo "Usage: scan.sh [--exit-on-critical] [--patterns=DIR] [--path=PATH]"
|
|
19
|
+
echo ""
|
|
20
|
+
echo "Scans files under --path (default .) against all *.txt pattern files."
|
|
21
|
+
echo "Pattern file format per line: SEVERITY|REGEX|DESCRIPTION"
|
|
22
|
+
echo "Exit: 0 clean, 1 any finding, 2 CRITICAL finding (with --exit-on-critical)"
|
|
23
|
+
exit 0
|
|
24
|
+
;;
|
|
25
|
+
esac
|
|
26
|
+
done
|
|
27
|
+
|
|
28
|
+
[ -d "$PATTERNS_DIR" ] || { echo "ERROR: patterns dir not found: $PATTERNS_DIR" >&2; exit 3; }
|
|
29
|
+
|
|
30
|
+
crit=0
|
|
31
|
+
high=0
|
|
32
|
+
medium=0
|
|
33
|
+
|
|
34
|
+
for pfile in "$PATTERNS_DIR"/*.txt; do
|
|
35
|
+
[ -f "$pfile" ] || continue
|
|
36
|
+
cat_name=$(basename "$pfile" .txt)
|
|
37
|
+
|
|
38
|
+
while IFS='|' read -r severity regex desc; do
|
|
39
|
+
# Skip comments and blanks
|
|
40
|
+
[ -z "${severity:-}" ] && continue
|
|
41
|
+
[[ "$severity" =~ ^[[:space:]]*# ]] && continue
|
|
42
|
+
[ -z "${regex:-}" ] && continue
|
|
43
|
+
|
|
44
|
+
# Trim whitespace
|
|
45
|
+
severity="$(echo "$severity" | tr -d '[:space:]')"
|
|
46
|
+
|
|
47
|
+
# grep with common exclusions
|
|
48
|
+
if HITS=$(grep -rEn "$regex" "$SCAN_PATH" \
|
|
49
|
+
--include="*.sh" --include="*.md" --include="*.json" \
|
|
50
|
+
--include="*.yml" --include="*.yaml" --include="*.go" \
|
|
51
|
+
--include="*.ts" --include="*.tsx" --include="*.js" \
|
|
52
|
+
--include="*.py" --include="*.rb" --include="*.rs" \
|
|
53
|
+
--include="*.env" --include=".env*" --include="*.ini" \
|
|
54
|
+
--include="*.toml" --include="*.txt" --include="*.conf" \
|
|
55
|
+
--exclude-dir=.git --exclude-dir=node_modules \
|
|
56
|
+
--exclude-dir=dist --exclude-dir=build \
|
|
57
|
+
--exclude-dir=.next --exclude-dir=target \
|
|
58
|
+
2>/dev/null); then
|
|
59
|
+
while IFS= read -r hit; do
|
|
60
|
+
[ -z "$hit" ] && continue
|
|
61
|
+
echo "[$severity] $cat_name: $desc"
|
|
62
|
+
echo " $hit"
|
|
63
|
+
case "$severity" in
|
|
64
|
+
CRITICAL) crit=$((crit+1)) ;;
|
|
65
|
+
HIGH) high=$((high+1)) ;;
|
|
66
|
+
MEDIUM) medium=$((medium+1)) ;;
|
|
67
|
+
esac
|
|
68
|
+
done <<< "$HITS"
|
|
69
|
+
fi
|
|
70
|
+
done < "$pfile"
|
|
71
|
+
done
|
|
72
|
+
|
|
73
|
+
echo ""
|
|
74
|
+
echo "═══════════════════════════════════════════"
|
|
75
|
+
echo "AgentShield scan complete"
|
|
76
|
+
echo " CRITICAL: $crit"
|
|
77
|
+
echo " HIGH: $high"
|
|
78
|
+
echo " MEDIUM: $medium"
|
|
79
|
+
echo "═══════════════════════════════════════════"
|
|
80
|
+
|
|
81
|
+
if [ "$EXIT_ON_CRITICAL" = "1" ] && [ "$crit" -gt 0 ]; then
|
|
82
|
+
echo "CI gate: exiting 2 (CRITICAL findings blocked)" >&2
|
|
83
|
+
exit 2
|
|
84
|
+
elif [ "$crit" -gt 0 ] || [ "$high" -gt 0 ] || [ "$medium" -gt 0 ]; then
|
|
85
|
+
exit 1
|
|
86
|
+
fi
|
|
87
|
+
|
|
88
|
+
exit 0
|