@litfamily/litgrok 1.0.0
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/.grok/agents/litgrok-executor.md +33 -0
- package/.grok/agents/litgrok-korean-prose-editor.md +32 -0
- package/.grok/agents/litgrok-korean-style-analyzer.md +30 -0
- package/.grok/agents/litgrok-librarian-researcher.md +31 -0
- package/.grok/agents/litgrok-meaning-preservation-auditor.md +30 -0
- package/.grok/agents/litgrok-native-flow-reviewer.md +30 -0
- package/.grok/agents/litgrok-planner.md +31 -0
- package/.grok/agents/litgrok-polish-orchestrator.md +30 -0
- package/.grok/agents/litgrok-qa-runner.md +33 -0
- package/.grok/agents/litgrok-quality-reviewer.md +33 -0
- package/.grok/agents/litgrok-verifier.md +32 -0
- package/.grok/hooks/deliverable-hedge-guard.json +16 -0
- package/.grok/hooks/deliverable-hedge-guard.mjs +148 -0
- package/.grok/hooks/lit-mark.mjs +142 -0
- package/.grok/hooks/plan-gate.mjs +81 -0
- package/.grok/hooks/post-compact.json +15 -0
- package/.grok/hooks/post-compact.mjs +6 -0
- package/.grok/hooks/post-tool-use-failure.json +15 -0
- package/.grok/hooks/post-tool-use-failure.mjs +6 -0
- package/.grok/hooks/post-tool-use.json +16 -0
- package/.grok/hooks/post-tool-use.mjs +7 -0
- package/.grok/hooks/pre-compact.json +15 -0
- package/.grok/hooks/pre-compact.mjs +6 -0
- package/.grok/hooks/record-passive-event.mjs +198 -0
- package/.grok/hooks/session-start.json +15 -0
- package/.grok/hooks/session-start.mjs +37 -0
- package/.grok/hooks/stop-failure.json +15 -0
- package/.grok/hooks/stop-failure.mjs +6 -0
- package/.grok/hooks/stop.json +15 -0
- package/.grok/hooks/stop.mjs +36 -0
- package/.grok/hooks/subagent-start.json +15 -0
- package/.grok/hooks/subagent-start.mjs +6 -0
- package/.grok/hooks/subagent-stop.json +15 -0
- package/.grok/hooks/subagent-stop.mjs +6 -0
- package/.grok/hooks/user-prompt-submit.json +15 -0
- package/.grok/hooks/user-prompt-submit.mjs +7 -0
- package/.grok/rules/00-litgrok.md +152 -0
- package/.grok/skills/autoconference/LICENSE +21 -0
- package/.grok/skills/autoconference/PROVENANCE.md +23 -0
- package/.grok/skills/autoconference/SKILL.md +140 -0
- package/.grok/skills/autoconference/assets/conference_template.md +76 -0
- package/.grok/skills/autoconference/assets/report_template.md +56 -0
- package/.grok/skills/autoconference/assets/synthesis_template.md +40 -0
- package/.grok/skills/autoconference/references/_canonical-corpus/manifest.json +138 -0
- package/.grok/skills/autoconference/references/agent-prompts.md +30 -0
- package/.grok/skills/autoconference/references/conference-protocol.md +21 -0
- package/.grok/skills/autoconference/references/core-principles.md +13 -0
- package/.grok/skills/autoconference/references/family-contract.md +26 -0
- package/.grok/skills/autoconference/references/modes/analyze.md +11 -0
- package/.grok/skills/autoconference/references/modes/core/convergence-guide.md +41 -0
- package/.grok/skills/autoconference/references/modes/core/crash-recovery.md +11 -0
- package/.grok/skills/autoconference/references/modes/core.md +26 -0
- package/.grok/skills/autoconference/references/modes/debate.md +11 -0
- package/.grok/skills/autoconference/references/modes/plan.md +12 -0
- package/.grok/skills/autoconference/references/modes/resume.md +11 -0
- package/.grok/skills/autoconference/references/modes/ship.md +11 -0
- package/.grok/skills/autoconference/references/modes/survey.md +11 -0
- package/.grok/skills/autoconference/references/results-logging.md +12 -0
- package/.grok/skills/autoconference/references/visualization-guide.md +10 -0
- package/.grok/skills/autoconference/scripts/init_conference.py +646 -0
- package/.grok/skills/autoconference/scripts/verify-canonical-corpus.mjs +177 -0
- package/.grok/skills/autoconference/templates/code-performance.md +59 -0
- package/.grok/skills/autoconference/templates/debate-mode.md +50 -0
- package/.grok/skills/autoconference/templates/prompt-optimization.md +58 -0
- package/.grok/skills/autoconference/templates/quick-conference.md +48 -0
- package/.grok/skills/autoconference/templates/research-synthesis.md +56 -0
- package/.grok/skills/autoconference/templates/survey-mode.md +63 -0
- package/.grok/skills/autoresearch/LICENSE +21 -0
- package/.grok/skills/autoresearch/PROVENANCE.md +22 -0
- package/.grok/skills/autoresearch/SKILL.md +149 -0
- package/.grok/skills/autoresearch/assets/report_template.md +52 -0
- package/.grok/skills/autoresearch/assets/research_template.md +38 -0
- package/.grok/skills/autoresearch/assets/results_template.tsv +2 -0
- package/.grok/skills/autoresearch/references/_canonical-corpus/manifest.json +148 -0
- package/.grok/skills/autoresearch/references/core-principles.md +16 -0
- package/.grok/skills/autoresearch/references/family-contract.md +36 -0
- package/.grok/skills/autoresearch/references/modes/core/evaluator-contract.md +12 -0
- package/.grok/skills/autoresearch/references/modes/core/stuck-detection.md +11 -0
- package/.grok/skills/autoresearch/references/modes/core.md +21 -0
- package/.grok/skills/autoresearch/references/modes/debug/investigation-techniques.md +11 -0
- package/.grok/skills/autoresearch/references/modes/debug.md +11 -0
- package/.grok/skills/autoresearch/references/modes/fix.md +11 -0
- package/.grok/skills/autoresearch/references/modes/learn.md +11 -0
- package/.grok/skills/autoresearch/references/modes/plan.md +14 -0
- package/.grok/skills/autoresearch/references/modes/predict/persona-templates.md +11 -0
- package/.grok/skills/autoresearch/references/modes/predict.md +11 -0
- package/.grok/skills/autoresearch/references/modes/reason.md +11 -0
- package/.grok/skills/autoresearch/references/modes/scenario/dimensions.md +11 -0
- package/.grok/skills/autoresearch/references/modes/scenario.md +11 -0
- package/.grok/skills/autoresearch/references/modes/security/owasp-checklist.md +11 -0
- package/.grok/skills/autoresearch/references/modes/security/stride-model.md +11 -0
- package/.grok/skills/autoresearch/references/modes/security.md +12 -0
- package/.grok/skills/autoresearch/references/modes/ship/type-checklists.md +12 -0
- package/.grok/skills/autoresearch/references/modes/ship.md +11 -0
- package/.grok/skills/autoresearch/references/results-logging.md +12 -0
- package/.grok/skills/autoresearch/references/visualization-guide.md +24 -0
- package/.grok/skills/autoresearch/scripts/init_research.py +391 -0
- package/.grok/skills/autoresearch/scripts/style_presets.py +123 -0
- package/.grok/skills/autoresearch/scripts/verify-canonical-corpus.mjs +179 -0
- package/.grok/skills/browser-drive/SKILL.md +194 -0
- package/.grok/skills/browser-drive/references/snapshot-act-loop.md +61 -0
- package/.grok/skills/comment-checker/SKILL.md +194 -0
- package/.grok/skills/debugging/SKILL.md +82 -0
- package/.grok/skills/debugging/references/methodology/00-setup.md +108 -0
- package/.grok/skills/debugging/references/methodology/02-investigate.md +126 -0
- package/.grok/skills/debugging/references/methodology/04-oracle-triple.md +106 -0
- package/.grok/skills/debugging/references/methodology/05-escalate.md +69 -0
- package/.grok/skills/debugging/references/methodology/06-fix.md +116 -0
- package/.grok/skills/debugging/references/methodology/08-qa.md +94 -0
- package/.grok/skills/debugging/references/methodology/09-cleanup.md +164 -0
- package/.grok/skills/debugging/references/methodology/partial-runtime-evidence.md +228 -0
- package/.grok/skills/debugging/references/post-tool-use-failure-taxonomy.md +55 -0
- package/.grok/skills/debugging/references/reproduction-recipes.md +182 -0
- package/.grok/skills/debugging/references/runtimes/bundled-js-binary.md +415 -0
- package/.grok/skills/debugging/references/runtimes/go.md +252 -0
- package/.grok/skills/debugging/references/runtimes/native-binary.md +484 -0
- package/.grok/skills/debugging/references/runtimes/node.md +260 -0
- package/.grok/skills/debugging/references/runtimes/python.md +248 -0
- package/.grok/skills/debugging/references/runtimes/rust.md +234 -0
- package/.grok/skills/debugging/references/tools/ghidra.md +212 -0
- package/.grok/skills/debugging/references/tools/playwright-cli.md +194 -0
- package/.grok/skills/debugging/references/tools/pwndbg.md +263 -0
- package/.grok/skills/debugging/references/tools/pwntools.md +265 -0
- package/.grok/skills/deep-interview/SKILL.md +216 -0
- package/.grok/skills/frontend-ui-ux/LICENSE +21 -0
- package/.grok/skills/frontend-ui-ux/PROVENANCE.json +38 -0
- package/.grok/skills/frontend-ui-ux/SKILL.md +58 -0
- package/.grok/skills/frontend-ui-ux/SOURCE-MANIFEST.json +1060 -0
- package/.grok/skills/frontend-ui-ux/THIRD-PARTY-NOTICE.txt +14 -0
- package/.grok/skills/frontend-ui-ux/data/design-intelligence.json +1 -0
- package/.grok/skills/frontend-ui-ux/references/_canonical-corpus/legal/frontend-ATTRIBUTION.md +217 -0
- package/.grok/skills/frontend-ui-ux/references/_canonical-corpus/legal/frontend-LICENSE-Apache-2.0.txt +201 -0
- package/.grok/skills/frontend-ui-ux/references/_canonical-corpus/legal/root-LICENSE +21 -0
- package/.grok/skills/frontend-ui-ux/references/_canonical-corpus/manifest.json +873 -0
- package/.grok/skills/frontend-ui-ux/references/adaptive-layout.md +92 -0
- package/.grok/skills/frontend-ui-ux/references/brand-and-imagery.md +93 -0
- package/.grok/skills/frontend-ui-ux/references/complete-contract.md +557 -0
- package/.grok/skills/frontend-ui-ux/references/composition.md +85 -0
- package/.grok/skills/frontend-ui-ux/references/creative-directions.md +80 -0
- package/.grok/skills/frontend-ui-ux/references/design/README.md +248 -0
- package/.grok/skills/frontend-ui-ux/references/design/_INDEX.md +191 -0
- package/.grok/skills/frontend-ui-ux/references/design/airbnb.md +393 -0
- package/.grok/skills/frontend-ui-ux/references/design/airtable.md +92 -0
- package/.grok/skills/frontend-ui-ux/references/design/apple.md +250 -0
- package/.grok/skills/frontend-ui-ux/references/design/aside.md +209 -0
- package/.grok/skills/frontend-ui-ux/references/design/binance.md +348 -0
- package/.grok/skills/frontend-ui-ux/references/design/bmw.md +183 -0
- package/.grok/skills/frontend-ui-ux/references/design/brutalist-skill.md +92 -0
- package/.grok/skills/frontend-ui-ux/references/design/bugatti.md +271 -0
- package/.grok/skills/frontend-ui-ux/references/design/cal.md +262 -0
- package/.grok/skills/frontend-ui-ux/references/design/claude.md +315 -0
- package/.grok/skills/frontend-ui-ux/references/design/clay.md +307 -0
- package/.grok/skills/frontend-ui-ux/references/design/clickhouse.md +284 -0
- package/.grok/skills/frontend-ui-ux/references/design/clone-from-url.md +65 -0
- package/.grok/skills/frontend-ui-ux/references/design/cohere.md +269 -0
- package/.grok/skills/frontend-ui-ux/references/design/coinbase.md +132 -0
- package/.grok/skills/frontend-ui-ux/references/design/composio.md +310 -0
- package/.grok/skills/frontend-ui-ux/references/design/cursor.md +312 -0
- package/.grok/skills/frontend-ui-ux/references/design/design-system-architecture.md +244 -0
- package/.grok/skills/frontend-ui-ux/references/design/elevenlabs.md +268 -0
- package/.grok/skills/frontend-ui-ux/references/design/expo.md +284 -0
- package/.grok/skills/frontend-ui-ux/references/design/ferrari.md +317 -0
- package/.grok/skills/frontend-ui-ux/references/design/figma.md +223 -0
- package/.grok/skills/frontend-ui-ux/references/design/framer.md +249 -0
- package/.grok/skills/frontend-ui-ux/references/design/gpt-tasteskill.md +74 -0
- package/.grok/skills/frontend-ui-ux/references/design/hashicorp.md +281 -0
- package/.grok/skills/frontend-ui-ux/references/design/ibm.md +335 -0
- package/.grok/skills/frontend-ui-ux/references/design/image-to-code-skill.md +1228 -0
- package/.grok/skills/frontend-ui-ux/references/design/imagegen-brandkit.md +798 -0
- package/.grok/skills/frontend-ui-ux/references/design/imagegen-frontend-mobile.md +1465 -0
- package/.grok/skills/frontend-ui-ux/references/design/imagegen-frontend-web.md +987 -0
- package/.grok/skills/frontend-ui-ux/references/design/intercom.md +149 -0
- package/.grok/skills/frontend-ui-ux/references/design/kraken.md +128 -0
- package/.grok/skills/frontend-ui-ux/references/design/lamborghini.md +291 -0
- package/.grok/skills/frontend-ui-ux/references/design/layout-skill.md +107 -0
- package/.grok/skills/frontend-ui-ux/references/design/lazyweb.md +77 -0
- package/.grok/skills/frontend-ui-ux/references/design/linear.app.md +370 -0
- package/.grok/skills/frontend-ui-ux/references/design/lovable.md +301 -0
- package/.grok/skills/frontend-ui-ux/references/design/mastercard.md +368 -0
- package/.grok/skills/frontend-ui-ux/references/design/meta.md +369 -0
- package/.grok/skills/frontend-ui-ux/references/design/minimalist-skill.md +85 -0
- package/.grok/skills/frontend-ui-ux/references/design/minimax.md +260 -0
- package/.grok/skills/frontend-ui-ux/references/design/mintlify.md +329 -0
- package/.grok/skills/frontend-ui-ux/references/design/miro.md +111 -0
- package/.grok/skills/frontend-ui-ux/references/design/mistral.ai.md +264 -0
- package/.grok/skills/frontend-ui-ux/references/design/mongodb.md +269 -0
- package/.grok/skills/frontend-ui-ux/references/design/nike.md +366 -0
- package/.grok/skills/frontend-ui-ux/references/design/notion.md +312 -0
- package/.grok/skills/frontend-ui-ux/references/design/nvidia.md +296 -0
- package/.grok/skills/frontend-ui-ux/references/design/ollama.md +270 -0
- package/.grok/skills/frontend-ui-ux/references/design/opencode.ai.md +284 -0
- package/.grok/skills/frontend-ui-ux/references/design/output-skill.md +49 -0
- package/.grok/skills/frontend-ui-ux/references/design/pinterest.md +233 -0
- package/.grok/skills/frontend-ui-ux/references/design/playstation.md +367 -0
- package/.grok/skills/frontend-ui-ux/references/design/posthog.md +259 -0
- package/.grok/skills/frontend-ui-ux/references/design/raycast.md +271 -0
- package/.grok/skills/frontend-ui-ux/references/design/react-dev-tooling-skill.md +230 -0
- package/.grok/skills/frontend-ui-ux/references/design/redesign-skill.md +178 -0
- package/.grok/skills/frontend-ui-ux/references/design/renault.md +314 -0
- package/.grok/skills/frontend-ui-ux/references/design/replicate.md +264 -0
- package/.grok/skills/frontend-ui-ux/references/design/resend.md +306 -0
- package/.grok/skills/frontend-ui-ux/references/design/revolut.md +188 -0
- package/.grok/skills/frontend-ui-ux/references/design/runwayml.md +247 -0
- package/.grok/skills/frontend-ui-ux/references/design/sanity.md +360 -0
- package/.grok/skills/frontend-ui-ux/references/design/sentry.md +265 -0
- package/.grok/skills/frontend-ui-ux/references/design/shopify.md +353 -0
- package/.grok/skills/frontend-ui-ux/references/design/soft-skill.md +98 -0
- package/.grok/skills/frontend-ui-ux/references/design/spacex.md +197 -0
- package/.grok/skills/frontend-ui-ux/references/design/spotify.md +249 -0
- package/.grok/skills/frontend-ui-ux/references/design/starbucks.md +583 -0
- package/.grok/skills/frontend-ui-ux/references/design/stitch-design-example.md +121 -0
- package/.grok/skills/frontend-ui-ux/references/design/stitch-skill.md +184 -0
- package/.grok/skills/frontend-ui-ux/references/design/stripe.md +325 -0
- package/.grok/skills/frontend-ui-ux/references/design/supabase.md +258 -0
- package/.grok/skills/frontend-ui-ux/references/design/superhuman.md +255 -0
- package/.grok/skills/frontend-ui-ux/references/design/taste-skill.md +1206 -0
- package/.grok/skills/frontend-ui-ux/references/design/tesla.md +289 -0
- package/.grok/skills/frontend-ui-ux/references/design/theverge.md +342 -0
- package/.grok/skills/frontend-ui-ux/references/design/together.ai.md +266 -0
- package/.grok/skills/frontend-ui-ux/references/design/uber.md +298 -0
- package/.grok/skills/frontend-ui-ux/references/design/vercel.md +313 -0
- package/.grok/skills/frontend-ui-ux/references/design/vodafone.md +426 -0
- package/.grok/skills/frontend-ui-ux/references/design/voltagent.md +326 -0
- package/.grok/skills/frontend-ui-ux/references/design/warp.md +256 -0
- package/.grok/skills/frontend-ui-ux/references/design/webflow.md +95 -0
- package/.grok/skills/frontend-ui-ux/references/design/wired.md +281 -0
- package/.grok/skills/frontend-ui-ux/references/design/wise.md +176 -0
- package/.grok/skills/frontend-ui-ux/references/design/x.ai.md +260 -0
- package/.grok/skills/frontend-ui-ux/references/design/zapier.md +331 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/EVIDENCE.md +97 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/README.md +48 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/UPSTREAM.md +80 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/lane-a-direction.md +64 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/lane-b-execution.md +65 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/lane-c-review.md +65 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/lane-d-memory.md +83 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/orchestration.md +80 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/routing.md +79 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/LICENSE +21 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/agents/accessibility-reviewer.md +83 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/agents/content-writer.md +132 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/agents/design-builder.md +109 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/agents/design-critic.md +89 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/agents/design-lead.md +113 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/agents/design-scout.md +78 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/agents/design-strategist.md +121 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/agents/heuristic-evaluator.md +268 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/agents/inspiration-scout.md +107 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/agents/motion-designer.md +120 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/accessible-content/reference.md +101 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/adaptive-interfaces/reference.md +109 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/cognitive-accessibility/reference.md +107 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/design-debate/reference.md +199 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/design-debt-tracker/reference.md +174 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/design-handoff/reference.md +125 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/design-md/reference.md +106 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/design-retrospective/reference.md +266 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/design-review/reference.md +123 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/design-system-alignment/reference.md +120 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/designpowers-critique/reference.md +164 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/heuristic-evaluation/reference.md +85 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/inclusive-personas/reference.md +98 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/inspiration-scouting/reference.md +165 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/interaction-design/reference.md +122 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/motion-choreography/reference.md +81 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/research-planning/reference.md +96 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/responsive-patterns/reference.md +77 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/synthetic-user-testing/reference.md +192 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/taste-feedback/reference.md +165 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/taste-report/reference.md +78 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/token-architecture/reference.md +75 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/ui-composition/reference.md +117 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/usability-testing/reference.md +78 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/verification-before-shipping/reference.md +125 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/voice-and-tone/reference.md +79 -0
- package/.grok/skills/frontend-ui-ux/references/designpowers/vendor/skills/writing-design-plans/reference.md +119 -0
- package/.grok/skills/frontend-ui-ux/references/evidence-review.md +126 -0
- package/.grok/skills/frontend-ui-ux/references/implementation-platforms.md +109 -0
- package/.grok/skills/frontend-ui-ux/references/inclusive-interface.md +92 -0
- package/.grok/skills/frontend-ui-ux/references/interaction-motion.md +101 -0
- package/.grok/skills/frontend-ui-ux/references/operating-lanes.md +92 -0
- package/.grok/skills/frontend-ui-ux/references/perfection/README.md +160 -0
- package/.grok/skills/frontend-ui-ux/references/perfection/react-perf-tooling.md +127 -0
- package/.grok/skills/frontend-ui-ux/references/performance-delivery.md +93 -0
- package/.grok/skills/frontend-ui-ux/references/product-direction.md +84 -0
- package/.grok/skills/frontend-ui-ux/references/redesign-playbook.md +97 -0
- package/.grok/skills/frontend-ui-ux/references/system-foundations.md +84 -0
- package/.grok/skills/frontend-ui-ux/references/taste-direction.md +86 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/README.md +659 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/charts.csv +26 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/colors.csv +162 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/icons.csv +106 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/landing.csv +35 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/products.csv +162 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/react-performance.csv +45 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/astro.csv +54 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/flutter.csv +53 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/html-tailwind.csv +56 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/jetpack-compose.csv +53 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/nextjs.csv +53 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/nuxt-ui.csv +51 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/nuxtjs.csv +59 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/react-native.csv +52 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/react.csv +54 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/shadcn.csv +61 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/svelte.csv +54 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/swiftui.csv +51 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/vue.csv +50 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/styles.csv +85 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/typography.csv +74 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/ui-reasoning.csv +162 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/ux-guidelines.csv +100 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/data/web-interface.csv +31 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/scripts/core.py +262 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/scripts/design_system.py +1148 -0
- package/.grok/skills/frontend-ui-ux/references/ui-ux-db/scripts/search.py +114 -0
- package/.grok/skills/frontend-ui-ux/references/visual-language.md +84 -0
- package/.grok/skills/frontend-ui-ux/references/visual-reconstruction.md +97 -0
- package/.grok/skills/frontend-ui-ux/schemas/design-contract-v1alpha1.schema.json +306 -0
- package/.grok/skills/frontend-ui-ux/schemas/design-contract-v1beta1.schema.json +291 -0
- package/.grok/skills/frontend-ui-ux/schemas/design-contract-v1beta2.schema.json +311 -0
- package/.grok/skills/frontend-ui-ux/scripts/design-contract-format.mjs +286 -0
- package/.grok/skills/frontend-ui-ux/scripts/design-contract-inventory-rules.mjs +354 -0
- package/.grok/skills/frontend-ui-ux/scripts/design-contract-rules.mjs +361 -0
- package/.grok/skills/frontend-ui-ux/scripts/design-contract-surface-rules.mjs +313 -0
- package/.grok/skills/frontend-ui-ux/scripts/design-data.mjs +68 -0
- package/.grok/skills/frontend-ui-ux/scripts/errors.mjs +12 -0
- package/.grok/skills/frontend-ui-ux/scripts/import-design-intelligence.mjs +124 -0
- package/.grok/skills/frontend-ui-ux/scripts/json-boundary.mjs +63 -0
- package/.grok/skills/frontend-ui-ux/scripts/query-design-intelligence.mjs +106 -0
- package/.grok/skills/frontend-ui-ux/scripts/search.mjs +43 -0
- package/.grok/skills/frontend-ui-ux/scripts/source-replay.mjs +153 -0
- package/.grok/skills/frontend-ui-ux/scripts/strict-json.mjs +143 -0
- package/.grok/skills/frontend-ui-ux/scripts/validate-design-contract.mjs +52 -0
- package/.grok/skills/frontend-ui-ux/scripts/verify-canonical-corpus.mjs +214 -0
- package/.grok/skills/lit-burnoff/SKILL.md +175 -0
- package/.grok/skills/lit-burnoff-file/SKILL.md +67 -0
- package/.grok/skills/lit-code/SKILL.md +531 -0
- package/.grok/skills/lit-code/references/go/README.md +90 -0
- package/.grok/skills/lit-code/references/go/backend-stack.md +641 -0
- package/.grok/skills/lit-code/references/go/bootstrap.md +328 -0
- package/.grok/skills/lit-code/references/go/bubbletea-v2.md +360 -0
- package/.grok/skills/lit-code/references/go/cobra-stack.md +468 -0
- package/.grok/skills/lit-code/references/go/concurrency.md +362 -0
- package/.grok/skills/lit-code/references/go/data-modeling.md +329 -0
- package/.grok/skills/lit-code/references/go/error-handling.md +359 -0
- package/.grok/skills/lit-code/references/go/golangci-strict.md +236 -0
- package/.grok/skills/lit-code/references/go/grpc-connect.md +375 -0
- package/.grok/skills/lit-code/references/go/libraries.md +337 -0
- package/.grok/skills/lit-code/references/go/one-liners.md +202 -0
- package/.grok/skills/lit-code/references/go/sqlc-pgx.md +471 -0
- package/.grok/skills/lit-code/references/go/testing.md +467 -0
- package/.grok/skills/lit-code/references/go/type-patterns.md +298 -0
- package/.grok/skills/lit-code/references/permission-sandbox-matrix.md +70 -0
- package/.grok/skills/lit-code/references/python/README.md +314 -0
- package/.grok/skills/lit-code/references/python/async-anyio.md +442 -0
- package/.grok/skills/lit-code/references/python/data-modeling.md +233 -0
- package/.grok/skills/lit-code/references/python/data-processing.md +133 -0
- package/.grok/skills/lit-code/references/python/error-handling.md +218 -0
- package/.grok/skills/lit-code/references/python/fastapi-stack.md +316 -0
- package/.grok/skills/lit-code/references/python/httpx2-optimization.md +360 -0
- package/.grok/skills/lit-code/references/python/libraries.md +307 -0
- package/.grok/skills/lit-code/references/python/one-liners.md +268 -0
- package/.grok/skills/lit-code/references/python/orjson-stack.md +378 -0
- package/.grok/skills/lit-code/references/python/pydantic-ai.md +285 -0
- package/.grok/skills/lit-code/references/python/pyproject-strict.md +232 -0
- package/.grok/skills/lit-code/references/python/textual-tui.md +201 -0
- package/.grok/skills/lit-code/references/python/type-patterns.md +176 -0
- package/.grok/skills/lit-code/references/rust/README.md +317 -0
- package/.grok/skills/lit-code/references/rust/async-tokio.md +299 -0
- package/.grok/skills/lit-code/references/rust/axum-stack.md +467 -0
- package/.grok/skills/lit-code/references/rust/cargo-strict.md +317 -0
- package/.grok/skills/lit-code/references/rust/clap-stack.md +409 -0
- package/.grok/skills/lit-code/references/rust/concurrency.md +375 -0
- package/.grok/skills/lit-code/references/rust/libraries.md +439 -0
- package/.grok/skills/lit-code/references/rust/one-liners.md +291 -0
- package/.grok/skills/lit-code/references/rust/proptest-insta.md +429 -0
- package/.grok/skills/lit-code/references/rust/type-state.md +354 -0
- package/.grok/skills/lit-code/references/rust/unsafe-discipline.md +250 -0
- package/.grok/skills/lit-code/references/rust/zero-cost-safety.md +527 -0
- package/.grok/skills/lit-code/references/rust-ub/README.md +289 -0
- package/.grok/skills/lit-code/references/rust-ub/miri-sanitizers-loom.md +411 -0
- package/.grok/skills/lit-code/references/rust-ub/ub-taxonomy.md +269 -0
- package/.grok/skills/lit-code/references/tool-boundaries.md +66 -0
- package/.grok/skills/lit-code/references/typescript/README.md +195 -0
- package/.grok/skills/lit-code/references/typescript/backend-hono.md +672 -0
- package/.grok/skills/lit-code/references/typescript/bootstrap.md +199 -0
- package/.grok/skills/lit-code/references/typescript/data-modeling.md +202 -0
- package/.grok/skills/lit-code/references/typescript/error-handling.md +169 -0
- package/.grok/skills/lit-code/references/typescript/tsconfig-strict.md +152 -0
- package/.grok/skills/lit-code/references/typescript/type-patterns.md +196 -0
- package/.grok/skills/lit-code/references/worked-cases.md +190 -0
- package/.grok/skills/lit-commit/SKILL.md +218 -0
- package/.grok/skills/lit-comprehend/SKILL.md +63 -0
- package/.grok/skills/lit-comprehend/references/artifact-format.md +58 -0
- package/.grok/skills/lit-comprehend/references/artifact-template.md +219 -0
- package/.grok/skills/lit-comprehend/references/honesty-ledger-contract.md +51 -0
- package/.grok/skills/lit-comprehend/references/micro-worlds.md +195 -0
- package/.grok/skills/lit-comprehend/references/worked-explainer.md +51 -0
- package/.grok/skills/lit-crucible/SKILL.md +231 -0
- package/.grok/skills/lit-handoff/SKILL.md +159 -0
- package/.grok/skills/lit-handoff/evals/evals.json +154 -0
- package/.grok/skills/lit-handoff/examples/HANDOFF-example-generic-auth-refactor.md +97 -0
- package/.grok/skills/lit-handoff/references/_canonical-corpus/manifest.json +17 -0
- package/.grok/skills/lit-handoff/references/source-pointer.md +31 -0
- package/.grok/skills/lit-handoff/scripts/verify-canonical-corpus.mjs +137 -0
- package/.grok/skills/lit-handoff/templates/HANDOFF.md +121 -0
- package/.grok/skills/lit-init/SKILL.md +244 -0
- package/.grok/skills/lit-korean/SKILL.md +176 -0
- package/.grok/skills/lit-plan/SKILL.md +71 -0
- package/.grok/skills/lit-plan/references/plan-schema.md +87 -0
- package/.grok/skills/lit-plan/references/start-work-handoff-contract.md +59 -0
- package/.grok/skills/lit-plan/scripts/scaffold-plan.mjs +259 -0
- package/.grok/skills/lit-plan/scripts/validate-plan.mjs +89 -0
- package/.grok/skills/lit-recap/SKILL.md +57 -0
- package/.grok/skills/lit-scientific-visualization/SKILL.md +213 -0
- package/.grok/skills/lit-scientific-visualization/scripts/verify-canonical-corpus.mjs +181 -0
- package/.grok/skills/lit-team/SKILL.md +73 -0
- package/.grok/skills/lit-team/references/explore-packet.md +70 -0
- package/.grok/skills/lit-team/references/general-purpose-packet.md +75 -0
- package/.grok/skills/lit-team/references/plan-packet.md +73 -0
- package/.grok/skills/litgoal/SKILL.md +98 -0
- package/.grok/skills/litgrok/SKILL.md +77 -0
- package/.grok/skills/litresearch/SKILL.md +60 -0
- package/.grok/skills/litresearch/references/mcp-tool-use-patterns.md +83 -0
- package/.grok/skills/litresearch/references/source-verdict-taxonomy.md +40 -0
- package/.grok/skills/litwork/SKILL.md +109 -0
- package/.grok/skills/lsp/SKILL.md +56 -0
- package/.grok/skills/lsp/references/built-in-lsp-contract.md +71 -0
- package/.grok/skills/lsp-setup/SKILL.md +82 -0
- package/.grok/skills/lsp-setup/references/bash/README.md +54 -0
- package/.grok/skills/lsp-setup/references/c-cpp/README.md +58 -0
- package/.grok/skills/lsp-setup/references/csharp/README.md +64 -0
- package/.grok/skills/lsp-setup/references/dart/README.md +48 -0
- package/.grok/skills/lsp-setup/references/elixir/README.md +51 -0
- package/.grok/skills/lsp-setup/references/go/README.md +53 -0
- package/.grok/skills/lsp-setup/references/haskell/README.md +57 -0
- package/.grok/skills/lsp-setup/references/java/README.md +55 -0
- package/.grok/skills/lsp-setup/references/julia/README.md +56 -0
- package/.grok/skills/lsp-setup/references/kotlin/README.md +58 -0
- package/.grok/skills/lsp-setup/references/lua/README.md +48 -0
- package/.grok/skills/lsp-setup/references/php/README.md +49 -0
- package/.grok/skills/lsp-setup/references/python/README.md +60 -0
- package/.grok/skills/lsp-setup/references/ruby/README.md +53 -0
- package/.grok/skills/lsp-setup/references/rust/README.md +55 -0
- package/.grok/skills/lsp-setup/references/swift/README.md +52 -0
- package/.grok/skills/lsp-setup/references/terraform/README.md +50 -0
- package/.grok/skills/lsp-setup/references/typescript/README.md +63 -0
- package/.grok/skills/lsp-setup/references/yaml/README.md +47 -0
- package/.grok/skills/lsp-setup/references/zig/README.md +49 -0
- package/.grok/skills/lsp-setup/scripts/detect-lsp.mjs +40 -0
- package/.grok/skills/lsp-setup/scripts/lsp-server-table.mjs +309 -0
- package/.grok/skills/lsp-setup/scripts/verify-lsp.mjs +54 -0
- package/.grok/skills/refactor/SKILL.md +210 -0
- package/.grok/skills/review-work/SKILL.md +515 -0
- package/.grok/skills/review-work/references/behavior-lane-contract.md +48 -0
- package/.grok/skills/review-work/references/documentation-lane-contract.md +49 -0
- package/.grok/skills/review-work/references/integration-lane-contract.md +51 -0
- package/.grok/skills/review-work/references/regression-lane-contract.md +48 -0
- package/.grok/skills/review-work/references/safety-lane-contract.md +48 -0
- package/.grok/skills/review-work/references/test-lane-contract.md +48 -0
- package/.grok/skills/review-work/scripts/check-lanes.mjs +63 -0
- package/.grok/skills/rules/SKILL.md +51 -0
- package/.grok/skills/rules/references/loading-order-contract.md +66 -0
- package/.grok/skills/rules/scripts/resolve-guidance.mjs +180 -0
- package/.grok/skills/skill-observer/SKILL.md +78 -0
- package/.grok/skills/skill-observer/references/review-contract.md +77 -0
- package/.grok/skills/skill-observer/scripts/curator.mjs +121 -0
- package/.grok/skills/skill-observer/scripts/review.mjs +347 -0
- package/.grok/skills/skill-observer/scripts/skill-loop.mjs +2087 -0
- package/.grok/skills/skill-observer/scripts/validate-skills.mjs +83 -0
- package/.grok/skills/start-work/SKILL.md +396 -0
- package/.grok/skills/structural-search/SKILL.md +195 -0
- package/.grok/skills/visual-qa/SKILL.md +50 -0
- package/.grok/skills/visual-qa/references/capture-playbook.md +47 -0
- package/.grok/skills/visual-qa/references/complete-contract.md +721 -0
- package/.grok/skills/visual-qa/references/verdict-taxonomy.md +34 -0
- package/.grok/skills/visual-qa/scripts/verify-evidence-manifest.mjs +91 -0
- package/.grok/skills/wikify/SKILL.md +65 -0
- package/.grok/skills/wikify/references/page-format.md +81 -0
- package/.grok/skills/wikify/references/provenance-contract.md +52 -0
- package/.grok/vendor/NOTICE.md +16 -0
- package/.grok/vendor/licenses/045_scientific-visualization-MIT.txt +21 -0
- package/.grok/vendor/provenance/045_scientific-visualization.md +37 -0
- package/.grok/vendor/scientific-visualization/assets/color_palettes.py +197 -0
- package/.grok/vendor/scientific-visualization/assets/nature.mplstyle +75 -0
- package/.grok/vendor/scientific-visualization/assets/presentation.mplstyle +74 -0
- package/.grok/vendor/scientific-visualization/assets/publication.mplstyle +78 -0
- package/.grok/vendor/scientific-visualization/evals/evals.json +158 -0
- package/.grok/vendor/scientific-visualization/references/_canonical-corpus/manifest.json +38 -0
- package/.grok/vendor/scientific-visualization/references/color_palettes.md +380 -0
- package/.grok/vendor/scientific-visualization/references/journal_requirements.md +359 -0
- package/.grok/vendor/scientific-visualization/references/matplotlib_examples.md +608 -0
- package/.grok/vendor/scientific-visualization/references/mdanalysis_martini_visualization.md +85 -0
- package/.grok/vendor/scientific-visualization/references/publication_guidelines.md +217 -0
- package/.grok/vendor/scientific-visualization/references/seaborn_for_publications.md +293 -0
- package/.grok/vendor/scientific-visualization/scripts/figure_export.py +238 -0
- package/.grok/vendor/scientific-visualization/scripts/style_presets.py +467 -0
- package/.grok/vendor/scientific-visualization/tests/test_figure_export.py +51 -0
- package/.grok/vendor/scientific-visualization/tests/test_style_presets.py +114 -0
- package/CHANGELOG.md +131 -0
- package/CODE_OF_CONDUCT.md +9 -0
- package/CONTRIBUTING.md +22 -0
- package/LICENSE +21 -0
- package/README.md +228 -0
- package/README_ko-KR.md +228 -0
- package/SECURITY.md +11 -0
- package/SUPPORT.md +9 -0
- package/bin/litgrok.mjs +860 -0
- package/docs/assets/cover.webp +0 -0
- package/docs/assets/litgrok-clay-icon.png +0 -0
- package/docs/assets/litgrok-continuity-1600.webp +0 -0
- package/docs/assets/litgrok-ignition-1600.webp +0 -0
- package/docs/assets/litgrok-wordmark.svg +5 -0
- package/docs/assets/readme/README.md +31 -0
- package/docs/assets/readme/badge-license.svg +1 -0
- package/docs/assets/readme/badge-version.svg +1 -0
- package/docs/privacy.md +13 -0
- package/docs/reference.md +271 -0
- package/docs/reference_ko-KR.md +267 -0
- package/package.json +50 -0
- package/plugin.json +27 -0
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
# Rust Undefined Behavior Taxonomy
|
|
2
|
+
|
|
3
|
+
Every category of UB the Rust compiler, Miri, and the language specification recognize. The agent must know the full surface to hunt systematically. Each entry names the UB class, its root cause, canonical trigger, Miri detection status, and the canonical fix.
|
|
4
|
+
|
|
5
|
+
## 1. Aliasing Violations (Stacked Borrows / Tree Borrows)
|
|
6
|
+
|
|
7
|
+
**Root cause:** Two pointers access the same memory in ways that violate Rust's borrowing model — even through raw pointers inside `unsafe`.
|
|
8
|
+
|
|
9
|
+
**Canonical triggers:**
|
|
10
|
+
- Creating a `&mut T` while another `&T` or `&mut T` to the same location exists.
|
|
11
|
+
- Dereferencing a raw pointer derived from a reference after that reference was invalidated (e.g., `&mut` was retaken).
|
|
12
|
+
- Calling `slice::from_raw_parts_mut` on overlapping regions.
|
|
13
|
+
- Interior mutability through `UnsafeCell` without going through the `UnsafeCell` API.
|
|
14
|
+
- Casting `&T` to `*mut T` and writing through it (even via FFI).
|
|
15
|
+
|
|
16
|
+
**Miri detection:** YES — Stacked Borrows is the default model. Tree Borrows (`-Zmiri-tree-borrows`) is the newer, more permissive model. Run both:
|
|
17
|
+
```bash
|
|
18
|
+
cargo +nightly miri test # Stacked Borrows (stricter)
|
|
19
|
+
MIRIFLAGS="-Zmiri-tree-borrows" cargo +nightly miri test # Tree Borrows (relaxed)
|
|
20
|
+
```
|
|
21
|
+
If code passes Tree Borrows but fails Stacked Borrows, it is *likely* sound but *possibly* relying on unspecified behavior. Fix it anyway — Stacked Borrows is the conservative bet.
|
|
22
|
+
|
|
23
|
+
**Fix pattern:** Use `UnsafeCell` for all interior mutability. Never cast `&T` to `*mut T`. Derive mutable pointers from `*mut T` obtained via `UnsafeCell::get()` or `addr_of_mut!()`.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 2. Data Races
|
|
28
|
+
|
|
29
|
+
**Root cause:** Two threads access the same non-atomic memory location, at least one is a write, and there is no happens-before ordering between them.
|
|
30
|
+
|
|
31
|
+
**Canonical triggers:**
|
|
32
|
+
- `unsafe impl Send for T` on a type containing `*mut U` without synchronization.
|
|
33
|
+
- `unsafe impl Sync for T` on a type containing `Cell<T>` or `UnsafeCell<T>` without a lock.
|
|
34
|
+
- Using `std::ptr::write` from multiple threads to the same allocation.
|
|
35
|
+
- Shared `&T` where `T` has interior mutability but no atomic/lock guard.
|
|
36
|
+
|
|
37
|
+
**Miri detection:** YES — Miri's data-race detector is on by default. It detects races on non-atomic accesses. For **preemptive scheduling** stress, use:
|
|
38
|
+
```bash
|
|
39
|
+
MIRIFLAGS="-Zmiri-preemption-rate=0.1" cargo +nightly miri test
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**Complementary tools:** `loom` for exhaustive interleaving exploration on lock-free algorithms. ThreadSanitizer (TSAN) for integration tests Miri cannot run (I/O, FFI).
|
|
43
|
+
|
|
44
|
+
**Fix pattern:** Wrap in `Mutex`/`RwLock`/`AtomicXxx`. Never `unsafe impl Sync` unless you can name the synchronization primitive guarding every mutable field.
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## 3. Use After Free / Dangling Pointers
|
|
49
|
+
|
|
50
|
+
**Root cause:** A pointer or reference outlives the allocation it points to.
|
|
51
|
+
|
|
52
|
+
**Canonical triggers:**
|
|
53
|
+
- Returning a reference to a local variable (compiler catches most, but raw pointers escape).
|
|
54
|
+
- `Box::into_raw` → manual `Box::from_raw` with wrong lifetime.
|
|
55
|
+
- `Vec` reallocation invalidating raw pointers obtained from `as_ptr()` / `as_mut_ptr()`.
|
|
56
|
+
- `Pin<Box<T>>` unpinned and moved after self-referential pointers were set up.
|
|
57
|
+
|
|
58
|
+
**Miri detection:** YES — allocation tracking catches use-after-free on the exact operation.
|
|
59
|
+
|
|
60
|
+
**Fix pattern:** Borrow checker for references. For raw pointers: tie pointer validity to an explicit lifetime via a `PhantomData<&'a T>` in the wrapper, or use arena allocation (`bumpalo`) so all pointers share one lifetime.
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## 4. Uninitialized Memory
|
|
65
|
+
|
|
66
|
+
**Root cause:** Reading a value from memory that was never written to.
|
|
67
|
+
|
|
68
|
+
**Canonical triggers:**
|
|
69
|
+
- `MaybeUninit::assume_init()` before all bytes are written.
|
|
70
|
+
- `mem::uninitialized()` (deprecated, still compiles).
|
|
71
|
+
- `alloc::alloc(layout)` returns uninitialized memory — reading it before writing is UB.
|
|
72
|
+
- Padding bytes in structs read via `transmute` or raw pointer casts.
|
|
73
|
+
- `read_unaligned` on uninitialized memory.
|
|
74
|
+
|
|
75
|
+
**Miri detection:** YES — tracks initialization state per byte. Catches partial-init structs, padding reads, and premature `assume_init`.
|
|
76
|
+
|
|
77
|
+
**Fix pattern:** Use `MaybeUninit::zeroed()` when zero-init is acceptable. Write every field before calling `assume_init()`. Use `MaybeUninit::write()` instead of raw pointer writes. Never `transmute` structs with padding unless you zeroed the padding.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## 5. Invalid Values (Type Invariant Violations)
|
|
82
|
+
|
|
83
|
+
**Root cause:** Producing a value that violates the type's validity invariant.
|
|
84
|
+
|
|
85
|
+
**Canonical triggers:**
|
|
86
|
+
- `bool` not 0 or 1.
|
|
87
|
+
- `char` outside Unicode scalar range.
|
|
88
|
+
- Enum discriminant not matching any variant.
|
|
89
|
+
- `NonZeroU32` containing 0.
|
|
90
|
+
- `&T` or `&mut T` that is null or dangling.
|
|
91
|
+
- `str` containing non-UTF-8 bytes.
|
|
92
|
+
- `fn` pointer that is null.
|
|
93
|
+
|
|
94
|
+
**Miri detection:** YES — validity checks are on by default. Extra strictness:
|
|
95
|
+
```bash
|
|
96
|
+
MIRIFLAGS="-Zmiri-strict-provenance" cargo +nightly miri test
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**Fix pattern:** Validate before transmuting. Use `TryFrom` at boundaries. Never `transmute` to enum types — use a checked conversion function.
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## 6. Misaligned Pointer Access
|
|
104
|
+
|
|
105
|
+
**Root cause:** Dereferencing a pointer that is not aligned to the type's required alignment.
|
|
106
|
+
|
|
107
|
+
**Canonical triggers:**
|
|
108
|
+
- Casting `*const u8` to `*const u64` and dereferencing (alignment goes from 1 to 8).
|
|
109
|
+
- `#[repr(packed)]` struct field references (the compiler warns, but raw pointers bypass the warning).
|
|
110
|
+
- Network buffer parsing where offsets are arbitrary.
|
|
111
|
+
|
|
112
|
+
**Miri detection:** YES — immediate trap on misaligned read/write.
|
|
113
|
+
|
|
114
|
+
**Fix pattern:** Use `read_unaligned` / `write_unaligned` for packed data. Use `bytemuck` or `zerocopy` for safe reinterpretation with alignment checks.
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## 7. Violating `Pin` Invariants
|
|
119
|
+
|
|
120
|
+
**Root cause:** Moving a value that was pinned and relied on its address stability (self-referential types, intrusive linked lists).
|
|
121
|
+
|
|
122
|
+
**Canonical triggers:**
|
|
123
|
+
- `mem::swap` on a `Pin<&mut T>` after `unsafe` deref.
|
|
124
|
+
- Implementing `Unpin` for a type that contains self-referential pointers.
|
|
125
|
+
- Manually calling `Pin::new_unchecked` on a movable allocation.
|
|
126
|
+
|
|
127
|
+
**Miri detection:** PARTIAL — Miri detects the resulting aliasing/use-after-free if the self-referential pointer is actually used. It does not detect "Pin contract violated but pointer was never dereferenced."
|
|
128
|
+
|
|
129
|
+
**Fix pattern:** Never `impl Unpin` for self-referential types. Use `pin_project` or `pin_project_lite` for safe pin projections. Review every `Pin::new_unchecked` call.
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## 8. FFI Boundary UB
|
|
134
|
+
|
|
135
|
+
**Root cause:** Mismatch between Rust's ABI expectations and the foreign code's actual behavior.
|
|
136
|
+
|
|
137
|
+
**Canonical triggers:**
|
|
138
|
+
- C function returning uninitialized memory into a Rust `&T`.
|
|
139
|
+
- Wrong `#[repr(C)]` layout (padding differs between platforms).
|
|
140
|
+
- Passing a Rust `enum` to C without `#[repr(C)]` or `#[repr(i32)]`.
|
|
141
|
+
- Null pointer passed where C expects non-null (and Rust wraps it in `&T`).
|
|
142
|
+
- C code writing to Rust-owned memory through a pointer Rust considers immutable.
|
|
143
|
+
- Forgetting to mark FFI functions as `unsafe extern "C"`.
|
|
144
|
+
- longjmp/setjmp across Rust frames (unwinding UB).
|
|
145
|
+
|
|
146
|
+
**Miri detection:** LIMITED — Miri cannot execute foreign code. It detects UB in the Rust-side handling of FFI return values.
|
|
147
|
+
|
|
148
|
+
**Complementary tools:** AddressSanitizer (ASAN), MemorySanitizer (MSAN) for detecting actual FFI-side corruption. Valgrind as a last resort.
|
|
149
|
+
|
|
150
|
+
**Fix pattern:** Validate every FFI return at the boundary. Use `Option<NonNull<T>>` for nullable pointers. Use `CStr`/`CString` for strings. Add `cbindgen` to CI to verify layout agreement. Wrap every FFI call in a safe Rust function that checks preconditions.
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## 9. Incorrect `Send` / `Sync` Implementations
|
|
155
|
+
|
|
156
|
+
**Root cause:** Manually implementing `Send` or `Sync` for a type that does not actually uphold the required invariant.
|
|
157
|
+
|
|
158
|
+
**Canonical triggers:**
|
|
159
|
+
- `unsafe impl Send for Wrapper(*mut T)` when `T` is not `Send`.
|
|
160
|
+
- `unsafe impl Sync for Wrapper(UnsafeCell<T>)` without a lock, atomic, or other synchronization.
|
|
161
|
+
- Types containing `Rc<T>` with a manual `Send` impl (Rc is explicitly !Send).
|
|
162
|
+
|
|
163
|
+
**Miri detection:** YES for the *resulting* data race if exercised. Miri's data-race detector will fire when two threads access the same location unsynchronized.
|
|
164
|
+
|
|
165
|
+
**Fix pattern:** Never manually implement `Send`/`Sync` unless you can write a SAFETY proof naming the synchronization mechanism. Use `PhantomData<*const ()>` to opt-out of auto-`Send`/`Sync` when in doubt.
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## 10. Out-of-Bounds Memory Access
|
|
170
|
+
|
|
171
|
+
**Root cause:** Pointer arithmetic or indexing that escapes the allocation.
|
|
172
|
+
|
|
173
|
+
**Canonical triggers:**
|
|
174
|
+
- `ptr.offset(n)` where `n` exceeds the allocation size.
|
|
175
|
+
- `slice::from_raw_parts(ptr, len)` where `len` is too large.
|
|
176
|
+
- Off-by-one in manual buffer management.
|
|
177
|
+
- Integer overflow in size calculations leading to undersized allocation.
|
|
178
|
+
|
|
179
|
+
**Miri detection:** YES — allocation-precise bounds checking.
|
|
180
|
+
|
|
181
|
+
**Fix pattern:** Use checked arithmetic (`checked_add`, `checked_mul`) for size calculations. Use `slice::from_raw_parts` only with validated lengths. Prefer safe indexing (`get()`, iterators) over raw pointer arithmetic.
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## 11. Provenance Violations
|
|
186
|
+
|
|
187
|
+
**Root cause:** Using a pointer whose provenance does not grant access to the target memory, even if the address is numerically correct.
|
|
188
|
+
|
|
189
|
+
**Canonical triggers:**
|
|
190
|
+
- Casting an integer to a pointer and dereferencing it (`addr as *const T`).
|
|
191
|
+
- Roundtripping a pointer through `usize` and back (`ptr as usize as *const T`) — the provenance is lost.
|
|
192
|
+
- Using `ptr::from_exposed_addr` without a corresponding `ptr.expose_provenance()`.
|
|
193
|
+
|
|
194
|
+
**Miri detection:** YES with strict provenance:
|
|
195
|
+
```bash
|
|
196
|
+
MIRIFLAGS="-Zmiri-strict-provenance" cargo +nightly miri test
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
**Fix pattern:** Use `ptr::with_exposed_provenance` / `ptr.expose_provenance()` for legitimate int-to-ptr roundtrips. Avoid `as usize as *const T` entirely. Use `sptr` crate for provenance-safe pointer manipulation on stable.
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## 12. Double Free / Invalid Free
|
|
204
|
+
|
|
205
|
+
**Root cause:** Freeing the same allocation twice, or freeing memory not obtained from the allocator.
|
|
206
|
+
|
|
207
|
+
**Canonical triggers:**
|
|
208
|
+
- `Box::from_raw` called twice on the same pointer.
|
|
209
|
+
- Manual `dealloc` on a pointer already freed.
|
|
210
|
+
- `ManuallyDrop` dropped explicitly then the outer type also drops it.
|
|
211
|
+
|
|
212
|
+
**Miri detection:** YES — immediate trap.
|
|
213
|
+
|
|
214
|
+
**Fix pattern:** Enforce single ownership via RAII. Use `ManuallyDrop` with extreme care — document who is responsible for the drop. Never clone a raw pointer and `Box::from_raw` both copies.
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## 13. Library / Unsafe Contract Violations
|
|
219
|
+
|
|
220
|
+
**Root cause:** Violating the documented safety invariant of a safe or unsafe API, where the library author relied on the invariant for soundness.
|
|
221
|
+
|
|
222
|
+
**Canonical triggers:**
|
|
223
|
+
- `Vec::set_len(n)` where the first `n` elements are not initialized.
|
|
224
|
+
- `String::from_utf8_unchecked` on non-UTF-8 bytes.
|
|
225
|
+
- `HashMap` key mutated after insertion (violates hash invariant — not UB per se, but unsound and Miri may detect downstream effects).
|
|
226
|
+
- `BTreeMap` key with broken `Ord` impl (the standard library assumes a total order).
|
|
227
|
+
|
|
228
|
+
**Miri detection:** DEPENDS — Miri catches the downstream UB (e.g., reading uninitialized bytes from a `Vec` with inflated len). It does not catch "you violated the documented contract" if no memory-level UB results.
|
|
229
|
+
|
|
230
|
+
**Fix pattern:** Read the `# Safety` section of every `unsafe fn` you call. Document the invariant in your SAFETY comment. When in doubt, use the safe API and pay the cost.
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
## 14. Unwinding Across `extern "C"` Boundaries
|
|
235
|
+
|
|
236
|
+
**Root cause:** A Rust panic unwinding through a frame that uses the C calling convention.
|
|
237
|
+
|
|
238
|
+
**Canonical triggers:**
|
|
239
|
+
- `panic!()` inside a `#[no_mangle] extern "C" fn` callback passed to C code.
|
|
240
|
+
- `unwrap()` inside FFI callbacks.
|
|
241
|
+
|
|
242
|
+
**Miri detection:** PARTIAL — Miri does not model foreign unwinding, but it can detect the immediate UB if the panic reaches the FFI boundary.
|
|
243
|
+
|
|
244
|
+
**Fix pattern:** Use `std::panic::catch_unwind` at every FFI entry point. Mark FFI callbacks as `extern "C-unwind"` when panic propagation is intentional (nightly). Prefer returning `Result`-like error codes from FFI callbacks.
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## Summary Table
|
|
249
|
+
|
|
250
|
+
| # | Category | Miri Detects? | Complementary Tool |
|
|
251
|
+
|---|----------|--------------|-------------------|
|
|
252
|
+
| 1 | Aliasing (Stacked/Tree Borrows) | YES | — |
|
|
253
|
+
| 2 | Data races | YES | loom, TSAN |
|
|
254
|
+
| 3 | Use-after-free / dangling | YES | ASAN |
|
|
255
|
+
| 4 | Uninitialized memory | YES | MSAN |
|
|
256
|
+
| 5 | Invalid values | YES | — |
|
|
257
|
+
| 6 | Misaligned access | YES | UBSAN |
|
|
258
|
+
| 7 | Pin invariant violation | PARTIAL | manual review |
|
|
259
|
+
| 8 | FFI boundary UB | LIMITED | ASAN, MSAN, Valgrind |
|
|
260
|
+
| 9 | Incorrect Send/Sync | YES (via race) | loom |
|
|
261
|
+
| 10 | Out-of-bounds access | YES | ASAN |
|
|
262
|
+
| 11 | Provenance violations | YES (strict mode) | — |
|
|
263
|
+
| 12 | Double free | YES | ASAN |
|
|
264
|
+
| 13 | Library contract violations | PARTIAL | proptest, fuzzing |
|
|
265
|
+
| 14 | Unwinding across FFI | PARTIAL | — |
|
|
266
|
+
|
|
267
|
+
## Miri Coverage Assessment
|
|
268
|
+
|
|
269
|
+
Miri catches categories 1-6, 9-12 with high confidence. Categories 7, 8, 13, 14 require supplementary tools or manual audit. **Miri is the single highest-leverage tool** — it should run on every PR that touches `unsafe`, and ideally on the full test suite regularly.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Tool-by-tool implementation boundaries
|
|
2
|
+
|
|
3
|
+
Load this reference when a programming task crosses more than one tool class, when the same operation could be attempted through several tools, or when a safe verification path is unclear. This is a decision table, not a catalog of every host tool.
|
|
4
|
+
|
|
5
|
+
## Boundary table
|
|
6
|
+
|
|
7
|
+
| Tool or action | Primary effect | Permission filter | Sandbox concern | Safe programming use | Stop condition |
|
|
8
|
+
| --- | --- | --- | --- | --- | --- |
|
|
9
|
+
| read a file | observes bytes | `Read` / `read` | source path must be readable | inspect guidance, source, tests, and generated ownership | path is outside authorized scope or contains protected secrets |
|
|
10
|
+
| list or search | discovers paths/text | `Grep` / `grep` or read-like rules | traversal remains within readable roots | locate symbols, callers, manifests, and guards | query would scan a prohibited sibling or private root |
|
|
11
|
+
| edit existing file | mutates bytes | `Edit` / `edit` | destination must be writable | targeted patch to an owned file after reading it | target is foreign, generated without its generator, or outside scope |
|
|
12
|
+
| write new file | creates bytes | write/edit feature and rules | parent directory must be writable | add a required source, test, or reference with a known owner | destination schema is undocumented or conflicts with existing state |
|
|
13
|
+
| shell command | launches process | `Bash` / `bash` | child filesystem and network limits apply | run documented tests, syntax checks, and read-only status commands | destructive or external effect lacks explicit authority |
|
|
14
|
+
| package test | executes repository scripts | usually shell rules | may write caches or evidence | run from the documented product root and report counts | command is known to mutate protected artifacts without isolation |
|
|
15
|
+
| formatter | rewrites source | shell plus write reach | all formatted paths must be writable | run only on named files when formatting is required | repository-wide format would touch unrelated dirty files |
|
|
16
|
+
| generator | rewrites derived files | shell plus write reach | output roots must be writable | run the owning generator after source changes | generator scope is unknown or includes protected mirrors |
|
|
17
|
+
| package dry run | resolves shipped payload | shell; may read package files | temp/cache paths must be writable | inspect structured JSON listing without publishing | lifecycle scripts have unreviewed external effects |
|
|
18
|
+
| network fetch | reaches remote service | `WebFetch`, `WebSearch`, or tool-specific rule | child-network setting may not cover in-process tools | retrieve a named primary source when current facts require it | credentials, purchase, upload, or private data transfer is implied |
|
|
19
|
+
| MCP tool | invokes configured server | `MCPTool` / `mcp` | server process and transport have separate reach | use only a configured, documented server and namespaced tool | server identity, arguments, or external effect is unclear |
|
|
20
|
+
| background task | persists command beyond turn | shell rules | same child limits continue | bounded long test or monitor with explicit receipt | completion cannot be observed or cancellation would corrupt state |
|
|
21
|
+
| worktree operation | creates isolated checkout | shell and filesystem writes | parent and checkout paths must be writable | isolate a baseline or parallel change when authorized | dirty state would be lost or target branch/ref is ambiguous |
|
|
22
|
+
| version-control commit | records repository state | shell rules | `.git` must be writable | only with explicit commit authority and explicit staging | broad staging, generated attribution, or unexpected paths appear |
|
|
23
|
+
| push, publish, deploy | mutates external state | shell/network rules | credentials and remote reach required | only under explicit release authorization | authorization is absent, version is unresolved, or destination differs |
|
|
24
|
+
|
|
25
|
+
Permission filters name host matching categories. They do not promise that a particular tool is enabled or that its input schema has a certain shape. Inspect the live tool surface before constructing a call.
|
|
26
|
+
|
|
27
|
+
## Tool substitution rule
|
|
28
|
+
|
|
29
|
+
Do not substitute a different tool merely because the intended one is denied. Editing through shell redirection is still an edit. Calling a network-capable server instead of a blocked child process is still a network action. Writing a generated file manually is still mutation of a derived artifact. Authorization follows the effect, not the tool label.
|
|
30
|
+
|
|
31
|
+
A substitute is acceptable only when it stays within the same authorized effect, its permission and sandbox boundaries are independently satisfied, it preserves validation and cleanup, the evidence still exercises the user-facing path, and it does not bypass a denial or hard stop.
|
|
32
|
+
|
|
33
|
+
## Read and search boundary
|
|
34
|
+
|
|
35
|
+
Read the narrowest sources that establish ownership and behavior. A repository search can reveal generated copies, registrations, and tests; it can also cross scope if rooted too high. Resolve the product root before searching. Keep secrets, ignored credentials, and unrelated trees outside the query. Treat matches as pointers, then read the owning context.
|
|
36
|
+
|
|
37
|
+
Search output is not execution evidence. A symbol existing in source does not prove registration, packaging, or runtime reachability. Follow it to the surface the user touches.
|
|
38
|
+
|
|
39
|
+
## Edit and write boundary
|
|
40
|
+
|
|
41
|
+
Before mutation, inspect status, read the exact file and nearest test, decide whether it is source or generated output, resolve conflict policy, add a focused failing test when behavior changes, and prefer a patch that leaves unrelated lines intact.
|
|
42
|
+
|
|
43
|
+
After mutation, inspect the diff. A parser check does not prove behavior. A focused test does not prove package inclusion. Select the next verification layer based on the changed surface.
|
|
44
|
+
|
|
45
|
+
## Shell boundary
|
|
46
|
+
|
|
47
|
+
Shell commands can read, write, spawn children, access the network, and change external state. Classify the command before running it. Avoid combining commands whose exit states matter. Quote paths safely. Keep untrusted text out of interpolation. Use explicit working directories. Treat timeouts as timeouts, and inspect background tasks instead of declaring them failed or complete by elapsed time alone.
|
|
48
|
+
|
|
49
|
+
Commands that delete, reset, clean, stash, commit, push, publish, deploy, grant trust, or rewrite host configuration require their own authorization. A broad task such as “fix tests” does not imply them.
|
|
50
|
+
|
|
51
|
+
## Verification boundary
|
|
52
|
+
|
|
53
|
+
| Change type | First evidence | Adjacent evidence | User-surface evidence |
|
|
54
|
+
| --- | --- | --- | --- |
|
|
55
|
+
| parser or pure function | focused unit test | module test file | caller integration |
|
|
56
|
+
| CLI behavior | argument/exit test | package test | temp-directory invocation |
|
|
57
|
+
| installer payload | synthetic conflict test | pack listing | real temp install and file inventory |
|
|
58
|
+
| hook command | stdin driver | config-schema test | documented event-shaped invocation |
|
|
59
|
+
| documentation contract | structural test | full docs suite | packed path and reachability link |
|
|
60
|
+
| generated manifest | generator RED/GREEN | hash or consistency check | packed/install listing |
|
|
61
|
+
|
|
62
|
+
Use the table to select evidence, not to demand every layer for every edit. State which load-bearing layer was omitted and why.
|
|
63
|
+
|
|
64
|
+
## External-state boundary
|
|
65
|
+
|
|
66
|
+
Authentication, host configuration, repository history, remote branches, registries, deployment targets, messages, and purchases are external state. Preparation can be in scope while mutation is not. A task may authorize a version edit without authorizing publication, or authorize a commit without authorizing push. Preserve those distinctions in tool choice and receipts.
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
|
|
2
|
+
# TypeScript Programmer
|
|
3
|
+
|
|
4
|
+
Modern TypeScript. Type-strict, stack-first, async-correct.
|
|
5
|
+
|
|
6
|
+
## Philosophy
|
|
7
|
+
|
|
8
|
+
The compiler is your proof system. Make illegal states unrepresentable. Parse at boundaries. Every function has a contract; the type system enforces it.
|
|
9
|
+
|
|
10
|
+
## Hard rules
|
|
11
|
+
|
|
12
|
+
These are deliberate project choices. Violations are always wrong, not "style preferences".
|
|
13
|
+
|
|
14
|
+
### Tooling
|
|
15
|
+
|
|
16
|
+
| Category | Use | Never |
|
|
17
|
+
|---|---|---|
|
|
18
|
+
| Runtime | Bun (native TS, single binary) | ts-node, tsx |
|
|
19
|
+
| Package manager | `pnpm` | npm, yarn (unless workspace requires it) |
|
|
20
|
+
| Linter + formatter | Biome | ESLint, Prettier |
|
|
21
|
+
| Type checker | `tsc --noEmit` with strict config | skip type checking |
|
|
22
|
+
| Web framework | Hono | Express |
|
|
23
|
+
| Validation | Zod | joi, yup, class-validator |
|
|
24
|
+
| Testing | `bun test` or vitest | jest |
|
|
25
|
+
| ORM | Drizzle | TypeORM, Prisma (unless already in project) |
|
|
26
|
+
|
|
27
|
+
### The iron list
|
|
28
|
+
|
|
29
|
+
1. **Readonly by default** — all `type`/`interface` properties are `readonly`. Arrays are `readonly T[]`. Mutable only when mutation is the documented purpose.
|
|
30
|
+
2. **Branded types for distinct IDs** — `type UserId = Brand<string, "UserId">`. Never pass raw `string` where a branded type exists.
|
|
31
|
+
3. **Exhaustive switch** — every `switch` on a discriminated union ends with `default: assertNever(x)`. No fall-through.
|
|
32
|
+
4. **No any** — `any` is banned in annotations, returns, and parameters. Use `unknown` and narrow.
|
|
33
|
+
5. **No type assertions** — `as any`, `as unknown` banned. `as const` and `satisfies` are fine.
|
|
34
|
+
6. **No non-null assertion** — `x!` is banned. Use narrowing or optional chaining (`x?.y`).
|
|
35
|
+
7. **No @ts-ignore / @ts-expect-error** — fix the type.
|
|
36
|
+
8. **No enum** — use `as const` objects + literal union types.
|
|
37
|
+
9. **Zod at boundaries** — external input (API, user, file) → Zod schema. Internal → plain types.
|
|
38
|
+
10. **Typed errors** — Error subclasses with typed fields. No `throw new Error("bare string")` for domain errors. Use Result for expected failures within 1-2 call levels; throw for propagation across many layers.
|
|
39
|
+
11. **as const for constants** — module-level constant objects and arrays use `as const`.
|
|
40
|
+
12. **import type** — type-only imports use `import type`. Enforced by `verbatimModuleSyntax`.
|
|
41
|
+
13. **Named exports only** — no `export default`. Exception: framework requirement (Next.js pages, etc.).
|
|
42
|
+
14. **No empty catch, no catch-and-swallow** — every `catch` block must either (a) narrow the error with `instanceof` and handle each case, or (b) re-throw. Empty catch blocks and `catch (e) { console.error(e) }` without narrowing or re-throw are banned — they hide bugs. At top-level boundaries (CLI entry, HTTP handler), opt out with `// no-excuse-ok: catch`.
|
|
43
|
+
|
|
44
|
+
### Data modeling — which construct, when
|
|
45
|
+
|
|
46
|
+
| Situation | Use |
|
|
47
|
+
|---|---|
|
|
48
|
+
| User input, API request/response | Zod schema + `z.infer` |
|
|
49
|
+
| Internal value object | `type` with `readonly` properties |
|
|
50
|
+
| Function with multiple outcomes | Discriminated union (`kind` field) |
|
|
51
|
+
| Contract for implementations | `interface` |
|
|
52
|
+
| Fixed constants | `as const` + literal union |
|
|
53
|
+
| Distinct primitive (UserId vs OrderId) | Branded type |
|
|
54
|
+
| Key-value map | `Record<K, V>` or index signature |
|
|
55
|
+
|
|
56
|
+
**The one rule**: data crosses trust boundary → Zod. Everything else → plain `type` with `readonly`.
|
|
57
|
+
|
|
58
|
+
Load `data-modeling.md` for the full decision flowchart and comparison.
|
|
59
|
+
|
|
60
|
+
### When readonly does not apply
|
|
61
|
+
|
|
62
|
+
- **Framework state** (React `useState`, signals) — managed by framework.
|
|
63
|
+
- **Builder / accumulator** — object exists to be mutated (buffer, cache). Document why.
|
|
64
|
+
- **ORM mutations** — Drizzle insert/update objects.
|
|
65
|
+
|
|
66
|
+
### Why empty/unhandled catch is banned
|
|
67
|
+
|
|
68
|
+
In TypeScript, every `catch` receives `unknown`. The language gives you no type safety in catch blocks — you must earn it with `instanceof`. A bare `catch (e) { console.error(e) }` swallows `TypeError`, `RangeError`, and your domain errors identically. When a new error type appears, nothing warns you.
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
// BANNED — empty catch
|
|
72
|
+
try { await fetchData() } catch {}
|
|
73
|
+
try { await fetchData() } catch (e) { /* will fix later */ }
|
|
74
|
+
|
|
75
|
+
// BANNED — catch-and-swallow (no narrowing, no rethrow)
|
|
76
|
+
try {
|
|
77
|
+
const data = await api.get("/users")
|
|
78
|
+
} catch (e) {
|
|
79
|
+
console.error("failed", e)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// GOOD — narrow with instanceof
|
|
83
|
+
try {
|
|
84
|
+
const data = await api.get("/users")
|
|
85
|
+
} catch (e) {
|
|
86
|
+
if (e instanceof HttpError) {
|
|
87
|
+
logger.warn(`API ${e.status}: ${e.message}`)
|
|
88
|
+
return fallback
|
|
89
|
+
}
|
|
90
|
+
throw e // unknown errors propagate
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// GOOD — top-level boundary (only place catch-all is acceptable)
|
|
94
|
+
async function main(): Promise<void> { // no-excuse-ok: catch
|
|
95
|
+
try {
|
|
96
|
+
await run()
|
|
97
|
+
} catch (e) {
|
|
98
|
+
console.error("unhandled:", e)
|
|
99
|
+
process.exit(1)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Libraries
|
|
105
|
+
|
|
106
|
+
| Domain | Library | Why |
|
|
107
|
+
|---|---|---|
|
|
108
|
+
| HTTP framework | Hono | Lightweight, multi-runtime, middleware, OpenAPI |
|
|
109
|
+
| Validation | Zod | Runtime validation + type inference |
|
|
110
|
+
| ORM | Drizzle | Type-safe SQL, no codegen |
|
|
111
|
+
| HTTP client | `ky` | Thin fetch wrapper (5KB); auto-throw on non-2xx, retry, timeout, hooks, prefixUrl. Browser + Node + Bun + Deno |
|
|
112
|
+
| HTTP client (perf) | `undici` (direct API) | Node backend에서 connection pooling, HTTP/2, pipelining 필요 시 |
|
|
113
|
+
|
|
114
|
+
> **HTTP client 규칙** — 프로덕션 코드에서 bare `fetch()`는 사용 금지. retry·timeout·에러 핸들링이 전무하여 장애 시 silent failure를 유발한다. **`ky`** 를 기본으로 설치하고, Node backend에서 대량 요청·커넥션 풀·HTTP/2 파이프라이닝이 필요하면 **`undici`** direct API를 쓴다. ~~`axios`~~ 는 supply-chain compromise(2026-03) 이후 사용 금지. `node-fetch`는 Node 18+ 내장 fetch로 대체되어 불필요.
|
|
115
|
+
| Testing | `bun test` / vitest | Fast, ESM-native |
|
|
116
|
+
| Logging | `pino` | Structured JSON, fast |
|
|
117
|
+
| CLI | `@clack/prompts` + `commander` | Interactive + parsing |
|
|
118
|
+
|
|
119
|
+
## tsconfig — the one true config
|
|
120
|
+
|
|
121
|
+
Scaffold a new project with all strict defaults pre-configured:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
bun run ../../scripts/typescript/new-project.ts my-api
|
|
125
|
+
bun run ../../scripts/typescript/new-project.ts my-api --path ./projects
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Creates: `package.json` (Hono + Zod + Biome), `tsconfig.json` (ultra-strict), `biome.json`, `src/index.ts`, `.gitignore`. Works on macOS, Linux, Windows.
|
|
129
|
+
|
|
130
|
+
For manual setup: `bunx tsc --init`, then load `tsconfig-strict.md` for the full strict config.
|
|
131
|
+
|
|
132
|
+
Key flags beyond `"strict": true`:
|
|
133
|
+
|
|
134
|
+
| Flag | What it catches |
|
|
135
|
+
|---|---|
|
|
136
|
+
| `noUncheckedIndexedAccess` | `arr[0]` is `T \| undefined`, forces check |
|
|
137
|
+
| `exactOptionalPropertyTypes` | `{ x?: string }` ≠ `{ x: string \| undefined }` |
|
|
138
|
+
| `verbatimModuleSyntax` | Forces `import type` for type-only imports |
|
|
139
|
+
| `noFallthroughCasesInSwitch` | Forgotten `break` / `return` |
|
|
140
|
+
| `noPropertyAccessFromIndexSignature` | `.key` on index sig → bracket notation |
|
|
141
|
+
|
|
142
|
+
## Reference loading
|
|
143
|
+
|
|
144
|
+
Load on demand — not all at once.
|
|
145
|
+
|
|
146
|
+
| Need | Load |
|
|
147
|
+
|---|---|
|
|
148
|
+
| Strict tsconfig + Biome config | `tsconfig-strict.md` |
|
|
149
|
+
| Type patterns (branded, as const, satisfies, narrowing, assertNever) | `type-patterns.md` |
|
|
150
|
+
| Data modeling (type vs interface vs Zod, readonly, parse-don't-validate) | `data-modeling.md` |
|
|
151
|
+
| Error handling (Result, typed errors, union vs throw) | `error-handling.md` |
|
|
152
|
+
| Bootstrapping a new project (Bun, pnpm, Hono, Vite) | `bootstrap.md` |
|
|
153
|
+
| Hono backend stack (hono-openapi, Scalar, Swagger) | `backend-hono.md` |
|
|
154
|
+
|
|
155
|
+
## No-excuse audit
|
|
156
|
+
|
|
157
|
+
Violations caught by `../../scripts/typescript/check-no-excuse-rules.ts`. Run after every edit session.
|
|
158
|
+
|
|
159
|
+
| Rule ID | Catches | Opt-out |
|
|
160
|
+
|---|---|---|
|
|
161
|
+
| `no-any-assertion` | `as any` | None — redesign types |
|
|
162
|
+
| `no-unknown-assertion` | `as unknown` | None — redesign types |
|
|
163
|
+
| `no-ts-ignore` | `@ts-ignore` | None — fix the type |
|
|
164
|
+
| `no-ts-expect-error` | `@ts-expect-error` | None — fix the type |
|
|
165
|
+
| `no-enum` | `enum` declarations | None — use `as const` |
|
|
166
|
+
| `no-non-null-assertion` | `x!` postfix | None — narrow or `?.` |
|
|
167
|
+
| `no-throw-literal` | `throw "string"` / `throw 123` | None — throw Error subclass |
|
|
168
|
+
| `no-mutable-export` | `export let` / `export var` | None — use `export const` |
|
|
169
|
+
| `no-any-annotation` | `: any` in parameter/return/variable types | `// no-excuse-ok: any` |
|
|
170
|
+
| `no-explicit-any-return` | `(): any` or `(): Promise<any>` return types | `// no-excuse-ok: any` |
|
|
171
|
+
| `empty-catch` | `catch { }` or `catch (e) { }` with empty body | `// no-excuse-ok: catch` |
|
|
172
|
+
| `catch-without-narrowing` | `catch (e)` used without `instanceof` or re-throw | `// no-excuse-ok: catch` |
|
|
173
|
+
|
|
174
|
+
Biome enforces additional rules (noExplicitAny, noNonNullAssertion, noDefaultExport, useImportType). The script catches what Biome cannot.
|
|
175
|
+
|
|
176
|
+
## In tests
|
|
177
|
+
|
|
178
|
+
Tests are strict too, with these exceptions (configure in `biome.jsonc` overrides):
|
|
179
|
+
|
|
180
|
+
| In tests you may | Why |
|
|
181
|
+
|---|---|
|
|
182
|
+
| Use `expect()` assertions | That's how testing works |
|
|
183
|
+
| Use magic numbers | Test data |
|
|
184
|
+
| Access private members via bracket notation | Testing internals |
|
|
185
|
+
| Skip readonly on test fixtures | Mutable setup/teardown |
|
|
186
|
+
|
|
187
|
+
Tests still follow the iron list — branded types, typed errors, exhaustive switch.
|
|
188
|
+
|
|
189
|
+
## Existing codebases
|
|
190
|
+
|
|
191
|
+
When editing an existing file that doesn't follow these rules: **write new code in strict style, don't refactor existing code in the same change.**
|
|
192
|
+
|
|
193
|
+
## Activation
|
|
194
|
+
|
|
195
|
+
This skill activates whenever you are writing or modifying any `.ts` or `.tsx` file. Even one-off scripts get the strict treatment.
|