@litfamily/litopencode 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/.gitattributes +8 -0
- package/ATTRIBUTION.md +56 -0
- package/CHANGELOG.md +267 -0
- package/CODE_OF_CONDUCT.md +30 -0
- package/CONTRIBUTING.md +82 -0
- package/LICENSE +21 -0
- package/README-Ko-KR.md +252 -0
- package/README.md +252 -0
- package/SECURITY.md +36 -0
- package/SUPPORT.md +37 -0
- package/bin/litopencode +3 -0
- package/bin/litopencode.cjs +10 -0
- package/dist/activation-managed-prompts.d.ts +2 -0
- package/dist/activation-managed-prompts.js +51 -0
- package/dist/activation-primary-prompts.d.ts +2 -0
- package/dist/activation-primary-prompts.js +176 -0
- package/dist/activation-probe.d.ts +3 -0
- package/dist/activation-probe.js +19 -0
- package/dist/activation-prompt-utils.d.ts +6 -0
- package/dist/activation-prompt-utils.js +36 -0
- package/dist/activation-routing.d.ts +5 -0
- package/dist/activation-routing.js +340 -0
- package/dist/activation-workflow-prompts.d.ts +26 -0
- package/dist/activation-workflow-prompts.js +295 -0
- package/dist/activation.d.ts +24 -0
- package/dist/activation.js +152 -0
- package/dist/agents/defaults.d.ts +15 -0
- package/dist/agents/defaults.js +112 -0
- package/dist/agents/registry.d.ts +65 -0
- package/dist/agents/registry.js +319 -0
- package/dist/agents/specialists.d.ts +49 -0
- package/dist/agents/specialists.js +307 -0
- package/dist/agents/types.d.ts +55 -0
- package/dist/agents/types.js +4 -0
- package/dist/agents.d.ts +4 -0
- package/dist/agents.js +3 -0
- package/dist/benchmark.d.ts +94 -0
- package/dist/benchmark.js +172 -0
- package/dist/bounded-authority-hooks.d.ts +19 -0
- package/dist/bounded-authority-hooks.js +157 -0
- package/dist/bounded-authority.d.ts +184 -0
- package/dist/bounded-authority.js +825 -0
- package/dist/cache-metrics.d.ts +54 -0
- package/dist/cache-metrics.js +81 -0
- package/dist/cli/args.d.ts +5 -0
- package/dist/cli/args.js +415 -0
- package/dist/cli/auto-update.d.ts +117 -0
- package/dist/cli/auto-update.js +604 -0
- package/dist/cli/command-alias-ownership.d.ts +2 -0
- package/dist/cli/command-alias-ownership.js +14 -0
- package/dist/cli/command-aliases.d.ts +12 -0
- package/dist/cli/command-aliases.js +112 -0
- package/dist/cli/doctor.d.ts +2 -0
- package/dist/cli/doctor.js +175 -0
- package/dist/cli/host-capabilities.d.ts +12 -0
- package/dist/cli/host-capabilities.js +25 -0
- package/dist/cli/host-limits.d.ts +21 -0
- package/dist/cli/host-limits.js +83 -0
- package/dist/cli/install-config.d.ts +13 -0
- package/dist/cli/install-config.js +201 -0
- package/dist/cli/install-report.d.ts +2 -0
- package/dist/cli/install-report.js +180 -0
- package/dist/cli/install-tui.d.ts +12 -0
- package/dist/cli/install-tui.js +174 -0
- package/dist/cli/install.d.ts +2 -0
- package/dist/cli/install.js +264 -0
- package/dist/cli/json.d.ts +4 -0
- package/dist/cli/json.js +31 -0
- package/dist/cli/loop.d.ts +3 -0
- package/dist/cli/loop.js +135 -0
- package/dist/cli/lsp-capability.d.ts +17 -0
- package/dist/cli/lsp-capability.js +92 -0
- package/dist/cli/managed-skill-assets.d.ts +23 -0
- package/dist/cli/managed-skill-assets.js +117 -0
- package/dist/cli/model-catalog.d.ts +21 -0
- package/dist/cli/model-catalog.js +107 -0
- package/dist/cli/model-policy.d.ts +3 -0
- package/dist/cli/model-policy.js +143 -0
- package/dist/cli/model-routing.d.ts +5 -0
- package/dist/cli/model-routing.js +208 -0
- package/dist/cli/native-canonical-backup.d.ts +9 -0
- package/dist/cli/native-canonical-backup.js +96 -0
- package/dist/cli/native-canonical-cache.d.ts +9 -0
- package/dist/cli/native-canonical-cache.js +37 -0
- package/dist/cli/native-skill-install.d.ts +2 -0
- package/dist/cli/native-skill-install.js +128 -0
- package/dist/cli/native-skill-integrity.d.ts +25 -0
- package/dist/cli/native-skill-integrity.js +178 -0
- package/dist/cli/native-skill-tree.d.ts +12 -0
- package/dist/cli/native-skill-tree.js +104 -0
- package/dist/cli/native-skills.d.ts +22 -0
- package/dist/cli/native-skills.js +105 -0
- package/dist/cli/plugin-mutation.d.ts +4 -0
- package/dist/cli/plugin-mutation.js +89 -0
- package/dist/cli/scientific-visualization-dependencies.d.ts +18 -0
- package/dist/cli/scientific-visualization-dependencies.js +91 -0
- package/dist/cli/skill-loop.d.ts +3 -0
- package/dist/cli/skill-loop.js +649 -0
- package/dist/cli/types.d.ts +188 -0
- package/dist/cli/types.js +1 -0
- package/dist/cli/update-check.d.ts +2 -0
- package/dist/cli/update-check.js +15 -0
- package/dist/cli/update-notifier.d.ts +70 -0
- package/dist/cli/update-notifier.js +717 -0
- package/dist/cli/vendor-path-migration.d.ts +9 -0
- package/dist/cli/vendor-path-migration.js +96 -0
- package/dist/cli.d.ts +7 -0
- package/dist/cli.js +250 -0
- package/dist/commands.d.ts +331 -0
- package/dist/commands.js +600 -0
- package/dist/config-parser.d.ts +5 -0
- package/dist/config-parser.js +274 -0
- package/dist/config.d.ts +72 -0
- package/dist/config.js +157 -0
- package/dist/deliverable-hedge-guard.d.ts +26 -0
- package/dist/deliverable-hedge-guard.js +302 -0
- package/dist/durable-plan.d.ts +23 -0
- package/dist/durable-plan.js +349 -0
- package/dist/features.d.ts +828 -0
- package/dist/features.js +1109 -0
- package/dist/hooks.d.ts +17 -0
- package/dist/hooks.js +83 -0
- package/dist/ignition.d.ts +14 -0
- package/dist/ignition.js +33 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +30 -0
- package/dist/inert-data.d.ts +2 -0
- package/dist/inert-data.js +13 -0
- package/dist/knowledge.d.ts +98 -0
- package/dist/knowledge.js +961 -0
- package/dist/ledger.d.ts +181 -0
- package/dist/ledger.js +1179 -0
- package/dist/lit-fetch-classify.d.ts +8 -0
- package/dist/lit-fetch-classify.js +107 -0
- package/dist/lit-fetch-content.d.ts +2 -0
- package/dist/lit-fetch-content.js +43 -0
- package/dist/lit-fetch-http.d.ts +10 -0
- package/dist/lit-fetch-http.js +82 -0
- package/dist/lit-fetch-result.d.ts +2 -0
- package/dist/lit-fetch-result.js +65 -0
- package/dist/lit-fetch-ssrf.d.ts +9 -0
- package/dist/lit-fetch-ssrf.js +77 -0
- package/dist/lit-fetch-url.d.ts +3 -0
- package/dist/lit-fetch-url.js +28 -0
- package/dist/lit-fetch.d.ts +69 -0
- package/dist/lit-fetch.js +84 -0
- package/dist/lit-mark.d.ts +17 -0
- package/dist/lit-mark.js +129 -0
- package/dist/logger.d.ts +9 -0
- package/dist/logger.js +21 -0
- package/dist/model-route-policy.d.ts +25 -0
- package/dist/model-route-policy.js +129 -0
- package/dist/reader-facing-output.d.ts +3 -0
- package/dist/reader-facing-output.js +28 -0
- package/dist/rules/discovery.d.ts +36 -0
- package/dist/rules/discovery.js +270 -0
- package/dist/rules/engine.d.ts +43 -0
- package/dist/rules/engine.js +236 -0
- package/dist/rules/frontmatter.d.ts +16 -0
- package/dist/rules/frontmatter.js +179 -0
- package/dist/rules/glob.d.ts +12 -0
- package/dist/rules/glob.js +233 -0
- package/dist/rules/hooks.d.ts +25 -0
- package/dist/rules/hooks.js +75 -0
- package/dist/rules/output-style.d.ts +1 -0
- package/dist/rules/output-style.js +20 -0
- package/dist/scientific-visualization-banner.d.ts +1 -0
- package/dist/scientific-visualization-banner.js +2 -0
- package/dist/search-workflow-ideas.d.ts +67 -0
- package/dist/search-workflow-ideas.js +128 -0
- package/dist/secret-shapes.d.ts +9 -0
- package/dist/secret-shapes.js +63 -0
- package/dist/server.d.ts +6 -0
- package/dist/server.js +129 -0
- package/dist/session-lineage.d.ts +8 -0
- package/dist/session-lineage.js +12 -0
- package/dist/skill-loop/apply.d.ts +19 -0
- package/dist/skill-loop/apply.js +483 -0
- package/dist/skill-loop/config.d.ts +50 -0
- package/dist/skill-loop/config.js +215 -0
- package/dist/skill-loop/curator.d.ts +18 -0
- package/dist/skill-loop/curator.js +232 -0
- package/dist/skill-loop/ledger.d.ts +39 -0
- package/dist/skill-loop/ledger.js +344 -0
- package/dist/skill-loop/proposals.d.ts +48 -0
- package/dist/skill-loop/proposals.js +290 -0
- package/dist/skill-loop/storage.d.ts +72 -0
- package/dist/skill-loop/storage.js +817 -0
- package/dist/skill-loop/time.d.ts +2 -0
- package/dist/skill-loop/time.js +23 -0
- package/dist/skill-loop/transaction.d.ts +62 -0
- package/dist/skill-loop/transaction.js +836 -0
- package/dist/skill-loop/usage.d.ts +31 -0
- package/dist/skill-loop/usage.js +146 -0
- package/dist/skill-observer.d.ts +22 -0
- package/dist/skill-observer.js +1154 -0
- package/dist/skill-renames.d.ts +5 -0
- package/dist/skill-renames.js +8 -0
- package/dist/skills.d.ts +307 -0
- package/dist/skills.js +450 -0
- package/dist/stable-identity.d.ts +14 -0
- package/dist/stable-identity.js +15 -0
- package/dist/state.d.ts +25 -0
- package/dist/state.js +38 -0
- package/dist/strict-json.d.ts +2 -0
- package/dist/strict-json.js +94 -0
- package/dist/tool-guards.d.ts +34 -0
- package/dist/tool-guards.js +210 -0
- package/dist/tool-kit.d.ts +32 -0
- package/dist/tool-kit.js +75 -0
- package/dist/tools.d.ts +43 -0
- package/dist/tools.js +381 -0
- package/dist/uiux-visual-catalog.d.ts +50 -0
- package/dist/uiux-visual-catalog.js +103 -0
- package/dist/user-facing-markdown.d.ts +5 -0
- package/dist/user-facing-markdown.js +93 -0
- package/dist/workflow-families.d.ts +16 -0
- package/dist/workflow-families.js +95 -0
- package/docs/assets/cover.webp +0 -0
- package/docs/assets/litopencode-continuity-1600.webp +0 -0
- package/docs/assets/litopencode-ignition-1600.webp +0 -0
- package/docs/assets/readme/badge-license.svg +1 -0
- package/docs/assets/readme/badge-version.svg +1 -0
- package/docs/assets/readme/litopencode-clay-icon.png +0 -0
- package/docs/assets/readme/litopencode-wordmark.svg +5 -0
- package/docs/lit-mark.md +46 -0
- package/docs/migration.md +162 -0
- package/docs/privacy.md +82 -0
- package/docs/reference-Ko-KR.md +309 -0
- package/docs/reference.md +444 -0
- package/output-styles/asd-ste100-ko.md +41 -0
- package/output-styles/asd-ste100.md +40 -0
- package/output-styles/eli5-ko.md +13 -0
- package/output-styles/eli5.md +11 -0
- package/package.json +57 -0
- package/qa/fixtures/litfamily-harness-speed-v1.json +38 -0
- package/qa/harness-speed-contract.mjs +209 -0
- package/qa/harness-speed-v2-contract.mjs +213 -0
- package/qa/harness-speed-verdict.mjs +105 -0
- package/skills/agent-roster/SKILL.md +262 -0
- package/skills/autoconference/LICENSE +21 -0
- package/skills/autoconference/PROVENANCE.md +20 -0
- package/skills/autoconference/SKILL.md +125 -0
- package/skills/autoconference/assets/conference_template.md +76 -0
- package/skills/autoconference/assets/report_template.md +53 -0
- package/skills/autoconference/assets/synthesis_template.md +39 -0
- package/skills/autoconference/modes/analyze.md +255 -0
- package/skills/autoconference/modes/core.md +112 -0
- package/skills/autoconference/modes/debate.md +373 -0
- package/skills/autoconference/modes/plan.md +310 -0
- package/skills/autoconference/modes/resume.md +48 -0
- package/skills/autoconference/modes/ship.md +57 -0
- package/skills/autoconference/modes/survey.md +109 -0
- package/skills/autoconference/references/agent-prompts.md +134 -0
- package/skills/autoconference/references/conference-protocol.md +102 -0
- package/skills/autoconference/references/convergence-guide.md +167 -0
- package/skills/autoconference/references/core-principles.md +83 -0
- package/skills/autoconference/references/crash-recovery.md +104 -0
- package/skills/autoconference/references/results-logging.md +198 -0
- package/skills/autoconference/references/upstream-family-contract.md +130 -0
- package/skills/autoconference/references/visualization-guide.md +105 -0
- package/skills/autoconference/scripts/check_conference.sh +371 -0
- package/skills/autoconference/scripts/init_conference.py +625 -0
- package/skills/autoconference/scripts/style_presets.py +104 -0
- package/skills/autoresearch/LICENSE +21 -0
- package/skills/autoresearch/PROVENANCE.md +20 -0
- package/skills/autoresearch/SKILL.md +131 -0
- package/skills/autoresearch/assets/report_template.md +50 -0
- package/skills/autoresearch/assets/research_template.md +38 -0
- package/skills/autoresearch/assets/results_template.tsv +1 -0
- package/skills/autoresearch/modes/core.md +216 -0
- package/skills/autoresearch/modes/debug.md +235 -0
- package/skills/autoresearch/modes/fix.md +173 -0
- package/skills/autoresearch/modes/learn.md +91 -0
- package/skills/autoresearch/modes/plan.md +291 -0
- package/skills/autoresearch/modes/predict.md +266 -0
- package/skills/autoresearch/modes/reason.md +170 -0
- package/skills/autoresearch/modes/scenario.md +164 -0
- package/skills/autoresearch/modes/security.md +282 -0
- package/skills/autoresearch/modes/ship.md +49 -0
- package/skills/autoresearch/references/core-principles.md +80 -0
- package/skills/autoresearch/references/evaluator-contract.md +126 -0
- package/skills/autoresearch/references/investigation-techniques.md +205 -0
- package/skills/autoresearch/references/owasp-checklist.md +161 -0
- package/skills/autoresearch/references/persona-templates.md +232 -0
- package/skills/autoresearch/references/results-logging.md +96 -0
- package/skills/autoresearch/references/scenario-dimensions.md +178 -0
- package/skills/autoresearch/references/stride-model.md +196 -0
- package/skills/autoresearch/references/stuck-detection.md +107 -0
- package/skills/autoresearch/references/type-checklists.md +163 -0
- package/skills/autoresearch/references/upstream-family-contract.md +125 -0
- package/skills/autoresearch/references/visualization-guide.md +95 -0
- package/skills/autoresearch/scripts/check_progress.sh +272 -0
- package/skills/autoresearch/scripts/init_research.py +330 -0
- package/skills/autoresearch/scripts/run_with_deadline.py +164 -0
- package/skills/autoresearch/scripts/style_presets.py +104 -0
- package/skills/browser-drive/SKILL.md +133 -0
- package/skills/browser-drive/references/snapshot-act-loop.md +37 -0
- package/skills/browser-drive/scripts/capability-probe.mjs +262 -0
- package/skills/comment-checker/SKILL.md +171 -0
- package/skills/debugging/SKILL.md +202 -0
- package/skills/debugging/references/README.md +15 -0
- package/skills/debugging/references/escalation.md +43 -0
- package/skills/debugging/references/runtimes/README.md +17 -0
- package/skills/debugging/references/runtimes/bundled-js-binary.md +44 -0
- package/skills/debugging/references/runtimes/go.md +37 -0
- package/skills/debugging/references/runtimes/native-binary.md +44 -0
- package/skills/debugging/references/runtimes/node.md +43 -0
- package/skills/debugging/references/runtimes/python.md +41 -0
- package/skills/debugging/references/runtimes/rust.md +37 -0
- package/skills/debugging/references/tools.md +72 -0
- package/skills/deep-interview/SKILL.md +201 -0
- package/skills/doctor-installer/SKILL.md +252 -0
- package/skills/durable-litgoal/SKILL.md +248 -0
- package/skills/frontend-ui-ux/SKILL.md +70 -0
- package/skills/frontend-ui-ux/data/LICENSE +21 -0
- package/skills/frontend-ui-ux/data/PROVENANCE.json +1088 -0
- package/skills/frontend-ui-ux/data/THIRD-PARTY-NOTICE.txt +14 -0
- package/skills/frontend-ui-ux/data/design-intelligence.json +1 -0
- package/skills/frontend-ui-ux/references/_canonical-corpus/ATTRIBUTION.md +217 -0
- package/skills/frontend-ui-ux/references/_canonical-corpus/LICENSE +21 -0
- package/skills/frontend-ui-ux/references/_canonical-corpus/LICENSE-Apache-2.0.txt +201 -0
- package/skills/frontend-ui-ux/references/_canonical-corpus/manifest.json +867 -0
- package/skills/frontend-ui-ux/references/adaptive-layout.md +85 -0
- package/skills/frontend-ui-ux/references/brand-and-imagery.md +79 -0
- package/skills/frontend-ui-ux/references/complete-contract.md +282 -0
- package/skills/frontend-ui-ux/references/composition.md +87 -0
- package/skills/frontend-ui-ux/references/creative-directions.md +83 -0
- package/skills/frontend-ui-ux/references/design/README.md +248 -0
- package/skills/frontend-ui-ux/references/design/_INDEX.md +191 -0
- package/skills/frontend-ui-ux/references/design/airbnb.md +393 -0
- package/skills/frontend-ui-ux/references/design/airtable.md +92 -0
- package/skills/frontend-ui-ux/references/design/apple.md +250 -0
- package/skills/frontend-ui-ux/references/design/aside.md +209 -0
- package/skills/frontend-ui-ux/references/design/binance.md +348 -0
- package/skills/frontend-ui-ux/references/design/bmw.md +183 -0
- package/skills/frontend-ui-ux/references/design/brutalist-skill.md +92 -0
- package/skills/frontend-ui-ux/references/design/bugatti.md +271 -0
- package/skills/frontend-ui-ux/references/design/cal.md +262 -0
- package/skills/frontend-ui-ux/references/design/claude.md +315 -0
- package/skills/frontend-ui-ux/references/design/clay.md +307 -0
- package/skills/frontend-ui-ux/references/design/clickhouse.md +284 -0
- package/skills/frontend-ui-ux/references/design/clone-from-url.md +65 -0
- package/skills/frontend-ui-ux/references/design/cohere.md +269 -0
- package/skills/frontend-ui-ux/references/design/coinbase.md +132 -0
- package/skills/frontend-ui-ux/references/design/composio.md +310 -0
- package/skills/frontend-ui-ux/references/design/cursor.md +312 -0
- package/skills/frontend-ui-ux/references/design/design-system-architecture.md +244 -0
- package/skills/frontend-ui-ux/references/design/elevenlabs.md +268 -0
- package/skills/frontend-ui-ux/references/design/expo.md +284 -0
- package/skills/frontend-ui-ux/references/design/ferrari.md +317 -0
- package/skills/frontend-ui-ux/references/design/figma.md +223 -0
- package/skills/frontend-ui-ux/references/design/framer.md +249 -0
- package/skills/frontend-ui-ux/references/design/gpt-tasteskill.md +74 -0
- package/skills/frontend-ui-ux/references/design/hashicorp.md +281 -0
- package/skills/frontend-ui-ux/references/design/ibm.md +335 -0
- package/skills/frontend-ui-ux/references/design/image-to-code-skill.md +1228 -0
- package/skills/frontend-ui-ux/references/design/imagegen-brandkit.md +798 -0
- package/skills/frontend-ui-ux/references/design/imagegen-frontend-mobile.md +1465 -0
- package/skills/frontend-ui-ux/references/design/imagegen-frontend-web.md +987 -0
- package/skills/frontend-ui-ux/references/design/intercom.md +149 -0
- package/skills/frontend-ui-ux/references/design/kraken.md +128 -0
- package/skills/frontend-ui-ux/references/design/lamborghini.md +291 -0
- package/skills/frontend-ui-ux/references/design/layout-skill.md +107 -0
- package/skills/frontend-ui-ux/references/design/lazyweb.md +77 -0
- package/skills/frontend-ui-ux/references/design/linear.app.md +370 -0
- package/skills/frontend-ui-ux/references/design/lovable.md +301 -0
- package/skills/frontend-ui-ux/references/design/mastercard.md +368 -0
- package/skills/frontend-ui-ux/references/design/meta.md +369 -0
- package/skills/frontend-ui-ux/references/design/minimalist-skill.md +85 -0
- package/skills/frontend-ui-ux/references/design/minimax.md +260 -0
- package/skills/frontend-ui-ux/references/design/mintlify.md +329 -0
- package/skills/frontend-ui-ux/references/design/miro.md +111 -0
- package/skills/frontend-ui-ux/references/design/mistral.ai.md +264 -0
- package/skills/frontend-ui-ux/references/design/mongodb.md +269 -0
- package/skills/frontend-ui-ux/references/design/nike.md +366 -0
- package/skills/frontend-ui-ux/references/design/notion.md +312 -0
- package/skills/frontend-ui-ux/references/design/nvidia.md +296 -0
- package/skills/frontend-ui-ux/references/design/ollama.md +270 -0
- package/skills/frontend-ui-ux/references/design/opencode.ai.md +284 -0
- package/skills/frontend-ui-ux/references/design/output-skill.md +49 -0
- package/skills/frontend-ui-ux/references/design/pinterest.md +233 -0
- package/skills/frontend-ui-ux/references/design/playstation.md +367 -0
- package/skills/frontend-ui-ux/references/design/posthog.md +259 -0
- package/skills/frontend-ui-ux/references/design/raycast.md +271 -0
- package/skills/frontend-ui-ux/references/design/react-dev-tooling-skill.md +230 -0
- package/skills/frontend-ui-ux/references/design/redesign-skill.md +178 -0
- package/skills/frontend-ui-ux/references/design/renault.md +314 -0
- package/skills/frontend-ui-ux/references/design/replicate.md +264 -0
- package/skills/frontend-ui-ux/references/design/resend.md +306 -0
- package/skills/frontend-ui-ux/references/design/revolut.md +188 -0
- package/skills/frontend-ui-ux/references/design/runwayml.md +247 -0
- package/skills/frontend-ui-ux/references/design/sanity.md +360 -0
- package/skills/frontend-ui-ux/references/design/sentry.md +265 -0
- package/skills/frontend-ui-ux/references/design/shopify.md +353 -0
- package/skills/frontend-ui-ux/references/design/soft-skill.md +98 -0
- package/skills/frontend-ui-ux/references/design/spacex.md +197 -0
- package/skills/frontend-ui-ux/references/design/spotify.md +249 -0
- package/skills/frontend-ui-ux/references/design/starbucks.md +583 -0
- package/skills/frontend-ui-ux/references/design/stitch-design-example.md +121 -0
- package/skills/frontend-ui-ux/references/design/stitch-skill.md +184 -0
- package/skills/frontend-ui-ux/references/design/stripe.md +325 -0
- package/skills/frontend-ui-ux/references/design/supabase.md +258 -0
- package/skills/frontend-ui-ux/references/design/superhuman.md +255 -0
- package/skills/frontend-ui-ux/references/design/taste-skill.md +1206 -0
- package/skills/frontend-ui-ux/references/design/tesla.md +289 -0
- package/skills/frontend-ui-ux/references/design/theverge.md +342 -0
- package/skills/frontend-ui-ux/references/design/together.ai.md +266 -0
- package/skills/frontend-ui-ux/references/design/uber.md +298 -0
- package/skills/frontend-ui-ux/references/design/vercel.md +313 -0
- package/skills/frontend-ui-ux/references/design/vodafone.md +426 -0
- package/skills/frontend-ui-ux/references/design/voltagent.md +326 -0
- package/skills/frontend-ui-ux/references/design/warp.md +256 -0
- package/skills/frontend-ui-ux/references/design/webflow.md +95 -0
- package/skills/frontend-ui-ux/references/design/wired.md +281 -0
- package/skills/frontend-ui-ux/references/design/wise.md +176 -0
- package/skills/frontend-ui-ux/references/design/x.ai.md +260 -0
- package/skills/frontend-ui-ux/references/design/zapier.md +331 -0
- package/skills/frontend-ui-ux/references/designpowers/EVIDENCE.md +97 -0
- package/skills/frontend-ui-ux/references/designpowers/README.md +48 -0
- package/skills/frontend-ui-ux/references/designpowers/UPSTREAM.md +80 -0
- package/skills/frontend-ui-ux/references/designpowers/lane-a-direction.md +64 -0
- package/skills/frontend-ui-ux/references/designpowers/lane-b-execution.md +65 -0
- package/skills/frontend-ui-ux/references/designpowers/lane-c-review.md +65 -0
- package/skills/frontend-ui-ux/references/designpowers/lane-d-memory.md +83 -0
- package/skills/frontend-ui-ux/references/designpowers/orchestration.md +80 -0
- package/skills/frontend-ui-ux/references/designpowers/routing.md +79 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/LICENSE +21 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/agents/accessibility-reviewer.md +83 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/agents/content-writer.md +132 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/agents/design-builder.md +109 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/agents/design-critic.md +89 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/agents/design-lead.md +113 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/agents/design-scout.md +78 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/agents/design-strategist.md +121 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/agents/heuristic-evaluator.md +268 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/agents/inspiration-scout.md +107 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/agents/motion-designer.md +120 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/skills/accessible-content/reference.md +101 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/skills/adaptive-interfaces/reference.md +109 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/skills/cognitive-accessibility/reference.md +107 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/skills/design-debate/reference.md +199 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/skills/design-debt-tracker/reference.md +174 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/skills/design-handoff/reference.md +125 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/skills/design-md/reference.md +106 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/skills/design-retrospective/reference.md +266 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/skills/design-review/reference.md +123 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/skills/design-system-alignment/reference.md +120 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/skills/designpowers-critique/reference.md +164 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/skills/heuristic-evaluation/reference.md +85 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/skills/inclusive-personas/reference.md +98 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/skills/inspiration-scouting/reference.md +165 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/skills/interaction-design/reference.md +122 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/skills/motion-choreography/reference.md +81 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/skills/research-planning/reference.md +96 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/skills/responsive-patterns/reference.md +77 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/skills/synthetic-user-testing/reference.md +192 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/skills/taste-feedback/reference.md +165 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/skills/taste-report/reference.md +78 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/skills/token-architecture/reference.md +75 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/skills/ui-composition/reference.md +117 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/skills/usability-testing/reference.md +78 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/skills/verification-before-shipping/reference.md +125 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/skills/voice-and-tone/reference.md +79 -0
- package/skills/frontend-ui-ux/references/designpowers/vendor/skills/writing-design-plans/reference.md +119 -0
- package/skills/frontend-ui-ux/references/evidence-review.md +103 -0
- package/skills/frontend-ui-ux/references/implementation-platforms.md +94 -0
- package/skills/frontend-ui-ux/references/inclusive-interface.md +85 -0
- package/skills/frontend-ui-ux/references/interaction-motion.md +93 -0
- package/skills/frontend-ui-ux/references/operating-lanes.md +80 -0
- package/skills/frontend-ui-ux/references/perfection/README.md +160 -0
- package/skills/frontend-ui-ux/references/perfection/react-perf-tooling.md +127 -0
- package/skills/frontend-ui-ux/references/performance-delivery.md +77 -0
- package/skills/frontend-ui-ux/references/product-direction.md +84 -0
- package/skills/frontend-ui-ux/references/redesign-playbook.md +88 -0
- package/skills/frontend-ui-ux/references/system-foundations.md +86 -0
- package/skills/frontend-ui-ux/references/taste-direction.md +55 -0
- package/skills/frontend-ui-ux/references/ui-ux-db/README.md +659 -0
- package/skills/frontend-ui-ux/references/ui-ux-db/data/charts.csv +26 -0
- package/skills/frontend-ui-ux/references/ui-ux-db/data/colors.csv +162 -0
- package/skills/frontend-ui-ux/references/ui-ux-db/data/icons.csv +106 -0
- package/skills/frontend-ui-ux/references/ui-ux-db/data/landing.csv +35 -0
- package/skills/frontend-ui-ux/references/ui-ux-db/data/products.csv +162 -0
- package/skills/frontend-ui-ux/references/ui-ux-db/data/react-performance.csv +45 -0
- package/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/astro.csv +54 -0
- package/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/flutter.csv +53 -0
- package/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/html-tailwind.csv +56 -0
- package/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/jetpack-compose.csv +53 -0
- package/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/nextjs.csv +53 -0
- package/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/nuxt-ui.csv +51 -0
- package/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/nuxtjs.csv +59 -0
- package/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/react-native.csv +52 -0
- package/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/react.csv +54 -0
- package/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/shadcn.csv +61 -0
- package/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/svelte.csv +54 -0
- package/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/swiftui.csv +51 -0
- package/skills/frontend-ui-ux/references/ui-ux-db/data/stacks/vue.csv +50 -0
- package/skills/frontend-ui-ux/references/ui-ux-db/data/styles.csv +85 -0
- package/skills/frontend-ui-ux/references/ui-ux-db/data/typography.csv +74 -0
- package/skills/frontend-ui-ux/references/ui-ux-db/data/ui-reasoning.csv +162 -0
- package/skills/frontend-ui-ux/references/ui-ux-db/data/ux-guidelines.csv +100 -0
- package/skills/frontend-ui-ux/references/ui-ux-db/data/web-interface.csv +31 -0
- package/skills/frontend-ui-ux/references/ui-ux-db/scripts/core.py +262 -0
- package/skills/frontend-ui-ux/references/ui-ux-db/scripts/design_system.py +1148 -0
- package/skills/frontend-ui-ux/references/ui-ux-db/scripts/search.py +114 -0
- package/skills/frontend-ui-ux/references/visual-language.md +84 -0
- package/skills/frontend-ui-ux/references/visual-reconstruction.md +87 -0
- package/skills/frontend-ui-ux/schemas/design-contract-v1alpha1.json +570 -0
- package/skills/frontend-ui-ux/schemas/design-contract-v1beta1.json +32 -0
- package/skills/frontend-ui-ux/schemas/design-contract-v1beta2.json +34 -0
- package/skills/frontend-ui-ux/scripts/bounded-json.mjs +45 -0
- package/skills/frontend-ui-ux/scripts/canonical-json.mjs +26 -0
- package/skills/frontend-ui-ux/scripts/contract-error.mjs +15 -0
- package/skills/frontend-ui-ux/scripts/csv.mjs +64 -0
- package/skills/frontend-ui-ux/scripts/dataset.mjs +65 -0
- package/skills/frontend-ui-ux/scripts/design-contract.mjs +609 -0
- package/skills/frontend-ui-ux/scripts/import-design-intelligence.mjs +193 -0
- package/skills/frontend-ui-ux/scripts/retrieval.mjs +92 -0
- package/skills/frontend-ui-ux/scripts/stable-file-read.mjs +237 -0
- package/skills/frontend-ui-ux/scripts/stdin-json.mjs +16 -0
- package/skills/frontend-ui-ux/scripts/strict-json.mjs +102 -0
- package/skills/frontend-ui-ux/scripts/uiux.mjs +86 -0
- package/skills/frontend-ui-ux/scripts/verify-canonical-corpus.mjs +266 -0
- package/skills/lit-burnoff/SKILL.md +227 -0
- package/skills/lit-burnoff-file/SKILL.md +175 -0
- package/skills/lit-code/SKILL.md +266 -0
- package/skills/lit-code/references/README.md +18 -0
- package/skills/lit-code/references/go/README.md +12 -0
- package/skills/lit-code/references/go/concurrency.md +42 -0
- package/skills/lit-code/references/go/error-handling.md +47 -0
- package/skills/lit-code/references/go/testing.md +55 -0
- package/skills/lit-code/references/go/tooling.md +35 -0
- package/skills/lit-code/references/go/type-patterns.md +50 -0
- package/skills/lit-code/references/python/README.md +12 -0
- package/skills/lit-code/references/python/async.md +50 -0
- package/skills/lit-code/references/python/error-handling.md +44 -0
- package/skills/lit-code/references/python/testing.md +50 -0
- package/skills/lit-code/references/python/tooling.md +38 -0
- package/skills/lit-code/references/python/type-patterns.md +46 -0
- package/skills/lit-code/references/rust/README.md +12 -0
- package/skills/lit-code/references/rust/concurrency.md +45 -0
- package/skills/lit-code/references/rust/error-handling.md +43 -0
- package/skills/lit-code/references/rust/tooling.md +36 -0
- package/skills/lit-code/references/rust/type-patterns.md +46 -0
- package/skills/lit-code/references/rust/unsafe.md +47 -0
- package/skills/lit-code/references/typescript/README.md +11 -0
- package/skills/lit-code/references/typescript/error-handling.md +56 -0
- package/skills/lit-code/references/typescript/testing.md +42 -0
- package/skills/lit-code/references/typescript/tsconfig-strict.md +40 -0
- package/skills/lit-code/references/typescript/type-patterns.md +60 -0
- package/skills/lit-commit/SKILL.md +222 -0
- package/skills/lit-comprehend/SKILL.md +278 -0
- package/skills/lit-comprehend/assets/explainer-scaffold.html +104 -0
- package/skills/lit-comprehend/references/artifact-template.md +114 -0
- package/skills/lit-comprehend/references/micro-worlds.md +115 -0
- package/skills/lit-comprehend/scripts/verify-explainer.ts +339 -0
- package/skills/lit-crucible/SKILL.md +212 -0
- package/skills/lit-fetch/SKILL.md +242 -0
- package/skills/lit-handoff/SKILL.md +199 -0
- package/skills/lit-init/SKILL.md +214 -0
- package/skills/lit-korean/SKILL.md +231 -0
- package/skills/lit-plan/SKILL.md +351 -0
- package/skills/lit-plan/scripts/scaffold-plan.mjs +275 -0
- package/skills/lit-recap/SKILL.md +233 -0
- package/skills/lit-scientific-visualization/SKILL.md +175 -0
- package/skills/litresearch/SKILL.md +436 -0
- package/skills/litwork/SKILL.md +227 -0
- package/skills/lsp/SKILL.md +186 -0
- package/skills/lsp-setup/SKILL.md +187 -0
- package/skills/lsp-setup/references/README.md +40 -0
- package/skills/lsp-setup/references/bash.md +31 -0
- package/skills/lsp-setup/references/c-cpp.md +43 -0
- package/skills/lsp-setup/references/csharp.md +29 -0
- package/skills/lsp-setup/references/dart.md +25 -0
- package/skills/lsp-setup/references/elixir.md +30 -0
- package/skills/lsp-setup/references/go.md +33 -0
- package/skills/lsp-setup/references/haskell.md +27 -0
- package/skills/lsp-setup/references/java.md +28 -0
- package/skills/lsp-setup/references/julia.md +28 -0
- package/skills/lsp-setup/references/kotlin.md +25 -0
- package/skills/lsp-setup/references/lua.md +26 -0
- package/skills/lsp-setup/references/php.md +30 -0
- package/skills/lsp-setup/references/python.md +33 -0
- package/skills/lsp-setup/references/ruby.md +34 -0
- package/skills/lsp-setup/references/rust.md +34 -0
- package/skills/lsp-setup/references/swift.md +26 -0
- package/skills/lsp-setup/references/terraform.md +26 -0
- package/skills/lsp-setup/references/typescript.md +35 -0
- package/skills/lsp-setup/references/yaml.md +27 -0
- package/skills/lsp-setup/references/zig.md +28 -0
- package/skills/managed-skill-manifest.json +1386 -0
- package/skills/native-goal-verdict/SKILL.md +216 -0
- package/skills/refactor/SKILL.md +221 -0
- package/skills/reference-benchmark-claims/SKILL.md +204 -0
- package/skills/release-guardrails/SKILL.md +245 -0
- package/skills/review-work/SKILL.md +301 -0
- package/skills/rules/SKILL.md +196 -0
- package/skills/search-workflow-ideas/SKILL.md +223 -0
- package/skills/skill-observer/SKILL.md +148 -0
- package/skills/skill-observer/references/review-contract.md +95 -0
- package/skills/skill-rename-aliases.json +10 -0
- package/skills/start-work/SKILL.md +334 -0
- package/skills/structural-search/SKILL.md +234 -0
- package/skills/tool-guards/SKILL.md +223 -0
- package/skills/visual-qa/SKILL.md +61 -0
- package/skills/visual-qa/references/capture-playbook.md +105 -0
- package/skills/visual-qa/references/complete-contract.md +411 -0
- package/skills/visual-qa/schemas/evidence-manifest-v1alpha1.json +201 -0
- package/skills/visual-qa/schemas/evidence-manifest-v1beta1.json +141 -0
- package/skills/visual-qa/schemas/review-receipt-v1alpha1.json +113 -0
- package/skills/visual-qa/scripts/artifact.mjs +123 -0
- package/skills/visual-qa/scripts/bounded-json.mjs +47 -0
- package/skills/visual-qa/scripts/canonical-json.mjs +28 -0
- package/skills/visual-qa/scripts/capabilities.mjs +66 -0
- package/skills/visual-qa/scripts/contract-text.mjs +15 -0
- package/skills/visual-qa/scripts/design-contract.mjs +611 -0
- package/skills/visual-qa/scripts/evidence-evaluate.mjs +521 -0
- package/skills/visual-qa/scripts/evidence.mjs +271 -0
- package/skills/visual-qa/scripts/png-decode.mjs +146 -0
- package/skills/visual-qa/scripts/png.mjs +154 -0
- package/skills/visual-qa/scripts/review.mjs +188 -0
- package/skills/visual-qa/scripts/stdin-json.mjs +16 -0
- package/skills/visual-qa/scripts/strict-json.mjs +102 -0
- package/skills/visual-qa/scripts/tui.mjs +149 -0
- package/skills/visual-qa/scripts/visual-qa.mjs +90 -0
- package/skills/wikify/LICENSE +21 -0
- package/skills/wikify/PROVENANCE.md +18 -0
- package/skills/wikify/SKILL.md +176 -0
- package/skills/wikify/assets/home-template.md +44 -0
- package/skills/wikify/assets/maintenance-report-template.md +46 -0
- package/skills/wikify/assets/paper-source-note-template.md +137 -0
- package/skills/wikify/assets/source-note-template.md +45 -0
- package/skills/wikify/assets/wiki-rules-template.md +117 -0
- package/skills/wikify/modes/ingest.md +57 -0
- package/skills/wikify/modes/init.md +44 -0
- package/skills/wikify/modes/lint.md +60 -0
- package/skills/wikify/modes/query.md +38 -0
- package/skills/wikify/modes/save.md +45 -0
- package/skills/wikify/references-upstream-contract.md +758 -0
- package/skills/workflow-loop/SKILL.md +387 -0
- package/tools/check-pack-payload.mjs +410 -0
- package/tools/check-payload-substance.mjs +738 -0
- package/tools/check-version-lockstep.mjs +238 -0
- package/tools/gen-canonical-frontend-manifest.mjs +66 -0
- package/tools/gen-managed-skill-manifest.mjs +135 -0
- package/tools/harness-speed-local.mjs +261 -0
- package/tools/payload-reference-exemptions.json +49 -0
- package/tools/payload-substance-allowlist.json +46 -0
- package/tools/payload-substance-parity.json +571 -0
- package/tools/qa-real-surface-fixtures.mjs +428 -0
- package/tools/qa-real-surface-harness.mjs +173 -0
- package/tools/run-behavior-replacement-probes.mjs +296 -0
- package/tools/run-build.mjs +101 -0
- package/tools/run-harness-speed-local.mjs +52 -0
- package/tools/run-harness-speed-v2.mjs +36 -0
- package/tools/run-installed-resource-tamper-probe.mjs +62 -0
- package/tools/run-negative-gate-matrix.mjs +516 -0
- package/tools/run-rules-glob-differential.mjs +232 -0
- package/tools/run-typecheck.mjs +25 -0
- package/tools/run-uiux-visual-qa-scenarios.mjs +234 -0
- package/tools/run-wikify-surface-probe.mjs +170 -0
- package/tools/scan-legacy-tokens.mjs +431 -0
- package/tools/version-manifests.json +60 -0
- package/tsconfig.build.json +12 -0
- package/tsconfig.json +13 -0
- package/vendor/NOTICE.md +21 -0
- package/vendor/handoff/SKILL.md +199 -0
- package/vendor/handoff/evals/evals.json +154 -0
- package/vendor/handoff/examples/HANDOFF-example-generic-auth-refactor.md +97 -0
- package/vendor/handoff/templates/HANDOFF.md +121 -0
- package/vendor/licenses/022_handoff-MIT.txt +21 -0
- package/vendor/licenses/045_scientific-visualization-MIT.txt +21 -0
- package/vendor/provenance/022_handoff.md +19 -0
- package/vendor/provenance/045_scientific-visualization.md +36 -0
- package/vendor/scientific-visualization/SKILL.md +283 -0
- package/vendor/scientific-visualization/assets/color_palettes.py +197 -0
- package/vendor/scientific-visualization/assets/nature.mplstyle +75 -0
- package/vendor/scientific-visualization/assets/presentation.mplstyle +74 -0
- package/vendor/scientific-visualization/assets/publication.mplstyle +78 -0
- package/vendor/scientific-visualization/evals/evals.json +158 -0
- package/vendor/scientific-visualization/references/color_palettes.md +380 -0
- package/vendor/scientific-visualization/references/journal_requirements.md +359 -0
- package/vendor/scientific-visualization/references/matplotlib_examples.md +608 -0
- package/vendor/scientific-visualization/references/mdanalysis_martini_visualization.md +85 -0
- package/vendor/scientific-visualization/references/publication_guidelines.md +217 -0
- package/vendor/scientific-visualization/references/seaborn_for_publications.md +293 -0
- package/vendor/scientific-visualization/scripts/figure_export.py +238 -0
- package/vendor/scientific-visualization/scripts/style_presets.py +467 -0
- package/vendor/scientific-visualization/tests/test_figure_export.py +51 -0
- package/vendor/scientific-visualization/tests/test_style_presets.py +114 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Go — tooling
|
|
2
|
+
|
|
3
|
+
## Linting
|
|
4
|
+
|
|
5
|
+
`golangci-lint` with a small strict set beats a large permissive one. A useful baseline beyond the
|
|
6
|
+
defaults:
|
|
7
|
+
|
|
8
|
+
```yaml
|
|
9
|
+
linters:
|
|
10
|
+
enable:
|
|
11
|
+
- errcheck # unchecked errors
|
|
12
|
+
- govet
|
|
13
|
+
- staticcheck
|
|
14
|
+
- errorlint # %v where %w belongs; comparison instead of errors.Is
|
|
15
|
+
- bodyclose # unclosed HTTP response bodies
|
|
16
|
+
- rowserrcheck
|
|
17
|
+
- contextcheck # dropped or wrong context
|
|
18
|
+
- nilerr # returning nil after checking err != nil
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`errorlint` and `nilerr` catch real defects rather than style; enable them before anything cosmetic.
|
|
22
|
+
|
|
23
|
+
## Modules
|
|
24
|
+
|
|
25
|
+
- Commit `go.sum`. It is the integrity record, not a lockfile artifact.
|
|
26
|
+
- `go mod tidy` before every commit that changed imports; a stale `go.mod` fails other people's
|
|
27
|
+
builds and not yours.
|
|
28
|
+
- Pin the toolchain in `go.mod` (`go 1.23.0`) so behavior differences between contributors are
|
|
29
|
+
visible rather than mysterious.
|
|
30
|
+
|
|
31
|
+
## Formatting
|
|
32
|
+
|
|
33
|
+
`gofmt` is not negotiable and needs no discussion. `gofumpt` adds a stricter superset — adopt it per
|
|
34
|
+
project, not per file, and never mix the two in one repository.
|
|
35
|
+
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Go — modelling with types
|
|
2
|
+
|
|
3
|
+
Go's type system is deliberately small. The productive stance is to use it for the two things it does
|
|
4
|
+
well — distinguishing values that must not be confused, and making zero values usable — and to accept
|
|
5
|
+
that the rest is enforced by tests and review.
|
|
6
|
+
|
|
7
|
+
## Named types for units and identifiers
|
|
8
|
+
|
|
9
|
+
```go
|
|
10
|
+
type UserID string
|
|
11
|
+
type Cents int64
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
The cost is a conversion at the boundary; the benefit is that passing an `OrderID` where a `UserID`
|
|
15
|
+
belongs stops compiling. Do this wherever two values of the same underlying type mean different
|
|
16
|
+
things. It is the highest-value type-level guard the language offers.
|
|
17
|
+
|
|
18
|
+
## Make the zero value useful
|
|
19
|
+
|
|
20
|
+
A struct whose zero value works needs no constructor and cannot be half-initialised:
|
|
21
|
+
|
|
22
|
+
```go
|
|
23
|
+
type Buffer struct { buf []byte } // ready to use
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
When the zero value cannot be valid, do not export the struct — export a constructor returning an
|
|
27
|
+
interface or an opaque type, so an uninitialised instance is unconstructable rather than a runtime
|
|
28
|
+
surprise.
|
|
29
|
+
|
|
30
|
+
## Accept interfaces, return structs
|
|
31
|
+
|
|
32
|
+
Define the interface where it is *consumed*, listing only the methods that caller needs. A one- or
|
|
33
|
+
two-method interface declared next to its use is composable; a large interface declared next to its
|
|
34
|
+
implementation is a maintenance liability and forces fake-heavy tests.
|
|
35
|
+
|
|
36
|
+
```go
|
|
37
|
+
type userStore interface { ByID(context.Context, UserID) (User, error) }
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Avoid
|
|
41
|
+
|
|
42
|
+
- **`interface{}` / `any` in a domain signature.** It moves an error from compile time to run time
|
|
43
|
+
and erases the documentation the signature was carrying.
|
|
44
|
+
- **Generics for a single concrete type.** Write the concrete version. Generalise on the second real
|
|
45
|
+
caller, not in anticipation of one.
|
|
46
|
+
- **Embedding to fake inheritance.** Embedding promotes methods, including ones you did not intend to
|
|
47
|
+
expose, and the promoted set changes when the embedded type changes.
|
|
48
|
+
- **Pointer receivers chosen at random.** Pick one form per type. Mixing them makes the method set
|
|
49
|
+
differ between `T` and `*T`, which produces interface-satisfaction errors that read as nonsense.
|
|
50
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
|
|
3
|
+
| File | Covers |
|
|
4
|
+
|---|---|
|
|
5
|
+
| [type-patterns.md](type-patterns.md) | Annotations that carry weight, and where they stop helping |
|
|
6
|
+
| [error-handling.md](error-handling.md) | Exception design and the boundary rule |
|
|
7
|
+
| [async.md](async.md) | Structured concurrency, cancellation, and blocking the loop |
|
|
8
|
+
| [testing.md](testing.md) | pytest structure, fixtures, and what to parametrise |
|
|
9
|
+
| [tooling.md](tooling.md) | Strict project configuration |
|
|
10
|
+
|
|
11
|
+
Defaults for new code. An existing codebase's conventions win.
|
|
12
|
+
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Python — async
|
|
2
|
+
|
|
3
|
+
## Structured concurrency by default
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
async with asyncio.TaskGroup() as tg: # 3.11+
|
|
7
|
+
tg.create_task(fetch(a))
|
|
8
|
+
tg.create_task(fetch(b))
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
The group waits for every child and cancels the rest when one fails. A bare `create_task` whose
|
|
12
|
+
handle is discarded is a leak: it can be garbage-collected mid-flight, and its exception surfaces as
|
|
13
|
+
a warning rather than an error. `anyio` provides the same guarantee across asyncio and trio.
|
|
14
|
+
|
|
15
|
+
## Never block the loop
|
|
16
|
+
|
|
17
|
+
A synchronous call inside a coroutine stops every other task. The commonest offenders are `requests`,
|
|
18
|
+
`time.sleep`, file reads, and CPU-bound work.
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
await asyncio.to_thread(blocking_call, arg) # I/O-bound
|
|
22
|
+
await loop.run_in_executor(process_pool, cpu_bound) # CPU-bound
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
A "slow async service" is usually one blocking call away from being fast.
|
|
26
|
+
|
|
27
|
+
## Cancellation is an exception
|
|
28
|
+
|
|
29
|
+
`asyncio.CancelledError` propagates through your code. Two consequences:
|
|
30
|
+
|
|
31
|
+
- `except Exception` does not catch it in 3.8+ — that is deliberate, do not "fix" it.
|
|
32
|
+
- Cleanup in `finally` runs during cancellation, and an `await` there can be cancelled too. Use
|
|
33
|
+
`asyncio.shield` only when the cleanup genuinely must complete.
|
|
34
|
+
|
|
35
|
+
## Timeouts at every external boundary
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
async with asyncio.timeout(5): # 3.11+
|
|
39
|
+
result = await client.get(url)
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
No network call should be able to hang forever. A missing timeout is not visible in testing and is
|
|
43
|
+
the usual cause of a production stall.
|
|
44
|
+
|
|
45
|
+
## Avoid
|
|
46
|
+
|
|
47
|
+
- **Mixing sync and async versions of the same client** in one code path.
|
|
48
|
+
- **`asyncio.run` called more than once** in a process, or called from inside a running loop.
|
|
49
|
+
- **Sharing a connection pool across event loops.**
|
|
50
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Python — exceptions
|
|
2
|
+
|
|
3
|
+
## Define a base exception per package
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
class StorageError(Exception): ...
|
|
7
|
+
class RecordNotFound(StorageError): ...
|
|
8
|
+
class RecordConflict(StorageError): ...
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
One base lets a caller opt into "anything from this subsystem" without catching `Exception`. The
|
|
12
|
+
subclasses let it react to the specific case. Carry structured data as attributes rather than
|
|
13
|
+
formatting it into the message — callers should not parse strings.
|
|
14
|
+
|
|
15
|
+
## Chain, do not swallow
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
try:
|
|
19
|
+
payload = json.loads(raw)
|
|
20
|
+
except json.JSONDecodeError as exc:
|
|
21
|
+
raise ConfigInvalid(f"config at {path} is not valid JSON") from exc
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
`raise ... from exc` keeps the original traceback. `raise ...` alone inside an `except` block also
|
|
25
|
+
chains implicitly, but stating it is clearer. Never `except: pass` — if a failure is genuinely
|
|
26
|
+
ignorable, catch the specific type and say why in a comment.
|
|
27
|
+
|
|
28
|
+
## Catch narrowly, near the cause
|
|
29
|
+
|
|
30
|
+
`except Exception` at a low level is the single biggest reason a Python traceback points somewhere
|
|
31
|
+
unrelated to the fault. Catch the exception you can actually handle, at the place where you can
|
|
32
|
+
handle it, and let everything else travel.
|
|
33
|
+
|
|
34
|
+
## The boundary rule
|
|
35
|
+
|
|
36
|
+
Libraries raise. Applications decide. Only the top-level entry point — `main`, a request handler, a
|
|
37
|
+
task runner — converts an exception into an exit code, an HTTP status, or a log line. Logging and
|
|
38
|
+
re-raising at every layer produces the same fault reported five times.
|
|
39
|
+
|
|
40
|
+
## Cleanup
|
|
41
|
+
|
|
42
|
+
`with` for anything with a lifetime; `contextlib.contextmanager` to write one in a few lines;
|
|
43
|
+
`try/finally` only when neither fits. `ExitStack` when the number of resources is dynamic.
|
|
44
|
+
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Python — testing
|
|
2
|
+
|
|
3
|
+
## Structure
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
@pytest.mark.parametrize(
|
|
7
|
+
("raw", "expected"),
|
|
8
|
+
[("", None), ("a", 1)],
|
|
9
|
+
ids=["empty", "single"],
|
|
10
|
+
)
|
|
11
|
+
def test_parse(raw, expected):
|
|
12
|
+
assert parse(raw) == expected
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
`ids` gives each case a readable failure name. Parametrise over inputs; do not parametrise over
|
|
16
|
+
behavior — two genuinely different behaviors are two tests, and squeezing them into one parametrised
|
|
17
|
+
case with an `if` inside is how a test stops being readable.
|
|
18
|
+
|
|
19
|
+
## Fixtures
|
|
20
|
+
|
|
21
|
+
Prefer function scope. A `session`-scoped fixture holding mutable state creates order dependence,
|
|
22
|
+
which appears as a test that passes alone and fails in the suite. `tmp_path` and `monkeypatch` cover
|
|
23
|
+
most needs without custom teardown.
|
|
24
|
+
|
|
25
|
+
## Assert on behavior
|
|
26
|
+
|
|
27
|
+
Check the return value, the raised exception type, or the observable side effect. Reaching into
|
|
28
|
+
private attributes couples the test to the implementation and guarantees churn.
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
with pytest.raises(RecordNotFound):
|
|
32
|
+
store.get("missing")
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Assert the exception *type*, not its message.
|
|
36
|
+
|
|
37
|
+
## Mock at the boundary only
|
|
38
|
+
|
|
39
|
+
Patch the external service, not your own function. `unittest.mock.patch` targets where a name is
|
|
40
|
+
looked up, not where it is defined — patching `mypkg.module.requests` rather than `requests` is the
|
|
41
|
+
correction for the commonest "the mock did nothing" symptom.
|
|
42
|
+
|
|
43
|
+
## Run
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pytest -x -q # stop at first failure
|
|
47
|
+
pytest --lf # rerun last failures
|
|
48
|
+
pytest -p no:randomly # rule out ordering when a failure looks flaky
|
|
49
|
+
```
|
|
50
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Python — project configuration
|
|
2
|
+
|
|
3
|
+
Everything in `pyproject.toml`, so contributors, CI, and the editor read one source.
|
|
4
|
+
|
|
5
|
+
## Type checking
|
|
6
|
+
|
|
7
|
+
```toml
|
|
8
|
+
[tool.basedpyright]
|
|
9
|
+
typeCheckingMode = "strict"
|
|
10
|
+
venvPath = "."
|
|
11
|
+
venv = ".venv"
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
`venvPath`/`venv` matter more than the strictness setting: without them the checker resolves the
|
|
15
|
+
wrong interpreter and reports import errors for packages that are installed.
|
|
16
|
+
|
|
17
|
+
Adopting strict mode on an existing codebase works file by file. A repo-wide flip that produces
|
|
18
|
+
hundreds of errors gets suppressed wholesale, which is worse than not enabling it.
|
|
19
|
+
|
|
20
|
+
## Lint and format
|
|
21
|
+
|
|
22
|
+
```toml
|
|
23
|
+
[tool.ruff]
|
|
24
|
+
line-length = 100
|
|
25
|
+
|
|
26
|
+
[tool.ruff.lint]
|
|
27
|
+
select = ["E", "F", "I", "UP", "B", "SIM", "RUF", "ASYNC"]
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
`B` (bugbear) and `ASYNC` catch real defects — mutable defaults, blocking calls in async code. `I`
|
|
31
|
+
replaces isort. `ruff format` replaces black; do not run both.
|
|
32
|
+
|
|
33
|
+
## Dependencies
|
|
34
|
+
|
|
35
|
+
Pin with a lockfile (`uv.lock`, `poetry.lock`) and commit it. Declare ranges in `pyproject.toml`,
|
|
36
|
+
resolve exact versions in the lock. Separate dev dependencies from runtime ones so the deployed
|
|
37
|
+
image does not carry the test suite.
|
|
38
|
+
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Python — types that carry weight
|
|
2
|
+
|
|
3
|
+
Annotations are checked by a separate tool, never at run time. That makes some patterns genuinely
|
|
4
|
+
valuable and others decorative.
|
|
5
|
+
|
|
6
|
+
## Worth doing
|
|
7
|
+
|
|
8
|
+
**Annotate every public signature.** Parameters and return type. Internal helpers can stay bare when
|
|
9
|
+
the types are obvious from two lines of context; a module boundary should not.
|
|
10
|
+
|
|
11
|
+
**`NewType` for identifiers.** Free at run time, and it stops the argument-order mistake that unit
|
|
12
|
+
tests rarely catch:
|
|
13
|
+
|
|
14
|
+
```python
|
|
15
|
+
from typing import NewType
|
|
16
|
+
UserId = NewType("UserId", str)
|
|
17
|
+
OrderId = NewType("OrderId", str)
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
**Narrow the container types.** `Sequence[str]` in a parameter accepts more callers than `list[str]`
|
|
21
|
+
and promises less; `list[str]` in a return type promises more than `Iterable[str]` and lets the
|
|
22
|
+
caller index. Pick per direction, not per habit.
|
|
23
|
+
|
|
24
|
+
**Model absent and invalid separately.** `str | None` says "may be missing". A `Result`-style union
|
|
25
|
+
or a raised exception says "may be wrong". Collapsing the two into `None` is how a validation failure
|
|
26
|
+
becomes a `NoneType` error three frames away.
|
|
27
|
+
|
|
28
|
+
**`Literal` and `Enum` for closed sets.** `Literal["read", "write"]` costs nothing and turns a typo
|
|
29
|
+
into a type error.
|
|
30
|
+
|
|
31
|
+
## Where it stops helping
|
|
32
|
+
|
|
33
|
+
- **`Any` anywhere in a domain signature** disables checking for everything downstream of it, silently.
|
|
34
|
+
- **`cast()` as a way to quiet the checker.** It asserts something the checker could not verify. Each
|
|
35
|
+
use should be justified in a comment or replaced with a runtime check.
|
|
36
|
+
- **Deep generic gymnastics.** If the annotation is harder to read than the function, the function is
|
|
37
|
+
probably doing two things.
|
|
38
|
+
- **`# type: ignore` without a code.** Use `# type: ignore[arg-type]` so the suppression stops
|
|
39
|
+
applying when the reason changes.
|
|
40
|
+
|
|
41
|
+
## Dataclasses
|
|
42
|
+
|
|
43
|
+
`@dataclass(frozen=True, slots=True)` for value objects: immutability prevents a whole class of
|
|
44
|
+
aliasing bug, and `slots` removes the per-instance dict. Use `field(default_factory=list)` — a bare
|
|
45
|
+
mutable default is shared across every instance, which is the oldest trap in the language.
|
|
46
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Rust
|
|
2
|
+
|
|
3
|
+
| File | Covers |
|
|
4
|
+
|---|---|
|
|
5
|
+
| [type-patterns.md](type-patterns.md) | Making invalid states unrepresentable |
|
|
6
|
+
| [error-handling.md](error-handling.md) | `thiserror` in libraries, `anyhow` in binaries |
|
|
7
|
+
| [concurrency.md](concurrency.md) | Send/Sync, async, and what the compiler does not check |
|
|
8
|
+
| [unsafe.md](unsafe.md) | The discipline, and the tools that actually verify it |
|
|
9
|
+
| [tooling.md](tooling.md) | Strict lints and test tooling |
|
|
10
|
+
|
|
11
|
+
Defaults for new code. An existing codebase's conventions win.
|
|
12
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Rust — concurrency
|
|
2
|
+
|
|
3
|
+
The compiler proves the absence of data races. It does not prove the absence of deadlocks, lost
|
|
4
|
+
wakeups, or logic that is simply wrong under interleaving.
|
|
5
|
+
|
|
6
|
+
## Send and Sync
|
|
7
|
+
|
|
8
|
+
`Send` means it can move to another thread; `Sync` means `&T` can be shared. Both are inferred. When
|
|
9
|
+
a type is not `Send`, the error names the offending field — usually an `Rc` or a raw pointer, and the
|
|
10
|
+
fix is usually `Arc`, not `unsafe impl Send`.
|
|
11
|
+
|
|
12
|
+
**Never write `unsafe impl Send`/`Sync` to make an error go away.** That assertion is the one the
|
|
13
|
+
compiler was making for you.
|
|
14
|
+
|
|
15
|
+
## Shared state
|
|
16
|
+
|
|
17
|
+
```rust
|
|
18
|
+
let counter = Arc::new(Mutex::new(0));
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`Arc<Mutex<T>>` is the default and is usually right. `RwLock` only when reads genuinely dominate —
|
|
22
|
+
its bookkeeping costs more than a `Mutex` under contention. `parking_lot` is faster and has no
|
|
23
|
+
poisoning, at the cost of a dependency.
|
|
24
|
+
|
|
25
|
+
A `MutexGuard` held across an `.await` blocks the executor thread. Use `tokio::sync::Mutex` in async
|
|
26
|
+
code, or restructure so the lock is released before awaiting — the second is almost always better.
|
|
27
|
+
|
|
28
|
+
## Async
|
|
29
|
+
|
|
30
|
+
```rust
|
|
31
|
+
let (a, b) = tokio::try_join!(fetch(x), fetch(y))?;
|
|
32
|
+
tokio::select! { res = work() => ..., _ = shutdown.recv() => ... }
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Spawned tasks need a `JoinHandle` that someone awaits, or they are fire-and-forget. `select!` drops
|
|
36
|
+
the losing futures at the branch point — a future cancelled mid-operation may leave state
|
|
37
|
+
half-written, so make each branch cancellation-safe or use `tokio::spawn` instead.
|
|
38
|
+
|
|
39
|
+
Never call blocking code in an async task: `spawn_blocking` for I/O, `rayon` for CPU work.
|
|
40
|
+
|
|
41
|
+
## Verify
|
|
42
|
+
|
|
43
|
+
`cargo test -- --test-threads=1` to expose order dependence, and `loom` for lock-free code — it
|
|
44
|
+
exhaustively explores interleavings that testing will never hit.
|
|
45
|
+
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Rust — errors
|
|
2
|
+
|
|
3
|
+
## Libraries: typed errors
|
|
4
|
+
|
|
5
|
+
```rust
|
|
6
|
+
#[derive(Debug, thiserror::Error)]
|
|
7
|
+
pub enum StoreError {
|
|
8
|
+
#[error("record {0} not found")]
|
|
9
|
+
NotFound(UserId),
|
|
10
|
+
#[error("database unavailable")]
|
|
11
|
+
Unavailable(#[from] sqlx::Error),
|
|
12
|
+
}
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
A caller can match on the variant and react. `#[from]` gives `?` conversion without boilerplate.
|
|
16
|
+
Never expose `anyhow::Error` from a library API — it erases exactly the information the caller needs.
|
|
17
|
+
|
|
18
|
+
## Binaries: contextual errors
|
|
19
|
+
|
|
20
|
+
```rust
|
|
21
|
+
use anyhow::{Context, Result};
|
|
22
|
+
|
|
23
|
+
let config = fs::read_to_string(&path)
|
|
24
|
+
.with_context(|| format!("read config at {}", path.display()))?;
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
At the top level nobody matches on the error; they read it. `with_context` builds the chain that
|
|
28
|
+
makes the message useful, and the closure form avoids formatting on the success path.
|
|
29
|
+
|
|
30
|
+
## `unwrap` and `expect`
|
|
31
|
+
|
|
32
|
+
`unwrap()` in production code is a panic with no explanation. When a value genuinely cannot be
|
|
33
|
+
absent, `expect("...")` documents why — and the message should state the invariant, not the symptom:
|
|
34
|
+
`expect("config was validated at startup")`, not `expect("should exist")`.
|
|
35
|
+
|
|
36
|
+
In tests, `unwrap()` is fine.
|
|
37
|
+
|
|
38
|
+
## Panics are for broken invariants
|
|
39
|
+
|
|
40
|
+
A panic says "this program is wrong". Anything the caller could reasonably encounter — bad input, a
|
|
41
|
+
missing file, a network failure — is a `Result`. Panicking across an FFI boundary is undefined
|
|
42
|
+
behavior; catch it with `catch_unwind` there.
|
|
43
|
+
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Rust — tooling
|
|
2
|
+
|
|
3
|
+
## Lints
|
|
4
|
+
|
|
5
|
+
```toml
|
|
6
|
+
# Cargo.toml
|
|
7
|
+
[lints.rust]
|
|
8
|
+
unsafe_code = "deny" # remove per-crate where unsafe is genuinely needed
|
|
9
|
+
missing_debug_implementations = "warn"
|
|
10
|
+
|
|
11
|
+
[lints.clippy]
|
|
12
|
+
pedantic = { level = "warn", priority = -1 }
|
|
13
|
+
unwrap_used = "warn"
|
|
14
|
+
expect_used = "allow"
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Declaring lints in `Cargo.toml` beats `#![deny(...)]` in `lib.rs`: it applies to the whole crate, is
|
|
18
|
+
visible where dependencies are, and does not need editing in a source file.
|
|
19
|
+
|
|
20
|
+
`clippy::pedantic` as a warning is productive. As `deny` it fights you over style during unrelated
|
|
21
|
+
work.
|
|
22
|
+
|
|
23
|
+
## Tests
|
|
24
|
+
|
|
25
|
+
- `insta` for snapshot tests — `cargo insta review` makes accepting a change deliberate.
|
|
26
|
+
- `proptest` where the input space is large and the invariant is simple. One property often replaces
|
|
27
|
+
a dozen examples and finds the case nobody thought of.
|
|
28
|
+
- `criterion` for benchmarks. Do not infer performance from a `#[test]` with a timer.
|
|
29
|
+
|
|
30
|
+
## Build hygiene
|
|
31
|
+
|
|
32
|
+
- Commit `Cargo.lock` for binaries; for libraries it is advisory.
|
|
33
|
+
- `cargo deny check` for licence and advisory auditing in anything shipped.
|
|
34
|
+
- Pin the toolchain in `rust-toolchain.toml` so a nightly-only feature does not silently become a
|
|
35
|
+
requirement for every contributor.
|
|
36
|
+
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Rust — making invalid states unrepresentable
|
|
2
|
+
|
|
3
|
+
Rust's type system is strong enough that most invariants can be structural rather than checked. That
|
|
4
|
+
is where the language pays for its difficulty; use it.
|
|
5
|
+
|
|
6
|
+
## Newtypes at every boundary
|
|
7
|
+
|
|
8
|
+
```rust
|
|
9
|
+
pub struct UserId(String);
|
|
10
|
+
pub struct Email(String);
|
|
11
|
+
|
|
12
|
+
impl Email {
|
|
13
|
+
pub fn parse(raw: &str) -> Result<Self, InvalidEmail> { ... }
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Validate once, in the constructor, and the rest of the program can stop re-checking. A function
|
|
18
|
+
taking `Email` cannot receive an unvalidated string, so the check cannot be forgotten.
|
|
19
|
+
|
|
20
|
+
## Enums instead of flag combinations
|
|
21
|
+
|
|
22
|
+
```rust
|
|
23
|
+
enum Connection {
|
|
24
|
+
Disconnected,
|
|
25
|
+
Connecting { started: Instant },
|
|
26
|
+
Ready { session: SessionId },
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Three booleans allow eight states, of which perhaps three are legal. An enum allows exactly the legal
|
|
31
|
+
ones, and the compiler enumerates them at every `match`.
|
|
32
|
+
|
|
33
|
+
## Typestate for ordering rules
|
|
34
|
+
|
|
35
|
+
When operations must happen in an order, encode the order in types: `Builder<Unvalidated>` →
|
|
36
|
+
`Builder<Validated>` → `build()`. A misordered call fails to compile instead of failing at run time.
|
|
37
|
+
Use this where the ordering is genuinely load-bearing; it costs readability, so it is not a default.
|
|
38
|
+
|
|
39
|
+
## Borrow rather than clone — but not religiously
|
|
40
|
+
|
|
41
|
+
Take `&str` and `&[T]` in parameters. Return owned values. Reach for `Cow<'_, str>` only when
|
|
42
|
+
profiling shows the clone matters. A `.clone()` that makes a lifetime problem disappear in
|
|
43
|
+
non-hot-path code is a reasonable trade, and fighting the borrow checker for a nanosecond is not.
|
|
44
|
+
|
|
45
|
+
`Rc`/`Arc` in a data model usually signals that ownership was never decided. Decide it.
|
|
46
|
+
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Rust — `unsafe`
|
|
2
|
+
|
|
3
|
+
`unsafe` does not disable the borrow checker. It permits five specific operations: dereferencing a
|
|
4
|
+
raw pointer, calling an `unsafe` function, implementing an `unsafe` trait, mutating a `static mut`,
|
|
5
|
+
and accessing a union field. Everything else is checked as usual.
|
|
6
|
+
|
|
7
|
+
## The discipline
|
|
8
|
+
|
|
9
|
+
**Every `unsafe` block gets a `// SAFETY:` comment** stating the invariant that makes it sound, in
|
|
10
|
+
terms a reviewer can check:
|
|
11
|
+
|
|
12
|
+
```rust
|
|
13
|
+
// SAFETY: `idx < self.len` was checked above, and `self.ptr` is valid for
|
|
14
|
+
// `self.len` initialised elements for the lifetime of `&self`.
|
|
15
|
+
unsafe { &*self.ptr.add(idx) }
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
A block without one is not reviewable, and "it works" is not the invariant.
|
|
19
|
+
|
|
20
|
+
**Keep the block minimal.** Wrap the single operation, not the surrounding logic. A large `unsafe`
|
|
21
|
+
block hides which line carries the risk.
|
|
22
|
+
|
|
23
|
+
**Encapsulate behind a safe API.** The module exposing `unsafe` internals owns the proof. If a caller
|
|
24
|
+
can break the invariant through the safe interface, the interface is wrong — that is a soundness bug,
|
|
25
|
+
and it is a defect even when no current caller triggers it.
|
|
26
|
+
|
|
27
|
+
## The undefined behavior that actually bites
|
|
28
|
+
|
|
29
|
+
- **Aliasing `&mut`.** Two mutable references to the same location, even briefly, even unused.
|
|
30
|
+
- **Reading uninitialised memory.** Use `MaybeUninit`; a zeroed `bool` or reference is UB.
|
|
31
|
+
- **Invalid values.** A `bool` that is not 0 or 1, a `char` outside the Unicode range, a null
|
|
32
|
+
reference — constructing one is UB immediately, before it is read.
|
|
33
|
+
- **Pointer provenance.** A pointer derived from one allocation cannot address another, even at a
|
|
34
|
+
numerically correct address.
|
|
35
|
+
- **Unwinding across FFI.** Wrap in `catch_unwind`.
|
|
36
|
+
|
|
37
|
+
## Verify, do not assert
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
cargo +nightly miri test
|
|
41
|
+
RUSTFLAGS="-Zsanitizer=address" cargo +nightly test --target <host-triple>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Miri catches aliasing and provenance violations that run correctly in debug and corrupt memory in
|
|
45
|
+
release. For anything with `unsafe`, run it before believing the tests. A clean release run proves
|
|
46
|
+
very little on its own.
|
|
47
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# TypeScript
|
|
2
|
+
|
|
3
|
+
| File | Covers |
|
|
4
|
+
|---|---|
|
|
5
|
+
| [type-patterns.md](type-patterns.md) | Types that prevent defects rather than describe code |
|
|
6
|
+
| [error-handling.md](error-handling.md) | Typed failure at the boundary |
|
|
7
|
+
| [tsconfig-strict.md](tsconfig-strict.md) | The settings that change what compiles |
|
|
8
|
+
| [testing.md](testing.md) | Structure and the mocking boundary |
|
|
9
|
+
|
|
10
|
+
Defaults for new code. An existing codebase's conventions win.
|
|
11
|
+
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# TypeScript — failure at the boundary
|
|
2
|
+
|
|
3
|
+
`throw` accepts any value, and a caught value is `unknown`. Both facts shape how errors should be
|
|
4
|
+
handled.
|
|
5
|
+
|
|
6
|
+
## Narrow what you catch
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
try {
|
|
10
|
+
await run();
|
|
11
|
+
} catch (err: unknown) {
|
|
12
|
+
if (err instanceof ApiError) { ...; return; }
|
|
13
|
+
throw err;
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
`catch (err)` gives `unknown` under `useUnknownInCatchVariables` (included in `strict`). Treat that
|
|
18
|
+
as a feature: it forces the narrowing that `err.message` would otherwise skip.
|
|
19
|
+
|
|
20
|
+
## Typed errors carry data
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
export class ApiError extends Error {
|
|
24
|
+
constructor(readonly status: number, readonly code: string, message: string) {
|
|
25
|
+
super(message);
|
|
26
|
+
this.name = "ApiError";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Setting `name` explicitly matters — subclass names are lost through some transpilation targets, and a
|
|
32
|
+
caller matching on it silently stops matching.
|
|
33
|
+
|
|
34
|
+
Use `cause` to chain: `new ConfigError("load failed", { cause: err })`.
|
|
35
|
+
|
|
36
|
+
## Result types where failure is expected
|
|
37
|
+
|
|
38
|
+
For an operation whose failure is ordinary — validation, parsing, a lookup that may miss — returning
|
|
39
|
+
a discriminated union puts the failure in the signature rather than out of band:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
type Result<T, E> = { ok: true; value: T } | { ok: false; error: E };
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Use exceptions for the unexpected. Using them for control flow makes every call site a potential
|
|
46
|
+
non-local exit, which is what makes async cleanup hard to reason about.
|
|
47
|
+
|
|
48
|
+
## Async
|
|
49
|
+
|
|
50
|
+
Every `Promise` needs an owner. A floating promise swallows its rejection and, in Node, can terminate
|
|
51
|
+
the process. Enable `@typescript-eslint/no-floating-promises` — it is the single highest-value lint
|
|
52
|
+
rule in this language. Use `void promise` to mark a deliberate fire-and-forget.
|
|
53
|
+
|
|
54
|
+
`Promise.allSettled` when partial failure is acceptable; `Promise.all` when it is not. Choosing
|
|
55
|
+
`all` by default turns one slow failure into a total one.
|
|
56
|
+
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# TypeScript — testing
|
|
2
|
+
|
|
3
|
+
## Structure
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
describe("parseConfig", () => {
|
|
7
|
+
it.each([
|
|
8
|
+
["empty input", "", null],
|
|
9
|
+
["valid port", '{"port":8080}', 8080],
|
|
10
|
+
])("%s", (_name, raw, expected) => {
|
|
11
|
+
expect(parseConfig(raw)?.port ?? null).toBe(expected);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Name the case, not the index. A failure that reads `parseConfig > case 3` costs a lookup every time.
|
|
17
|
+
|
|
18
|
+
## Assert on behavior
|
|
19
|
+
|
|
20
|
+
Check the returned value, the thrown error type, or the observable effect. Testing that a private
|
|
21
|
+
method was called couples the test to the implementation and produces churn on every refactor.
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
await expect(store.get("missing")).rejects.toThrow(RecordNotFound);
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Assert the error type, not the message.
|
|
28
|
+
|
|
29
|
+
## Mock at the boundary
|
|
30
|
+
|
|
31
|
+
Mock the HTTP client, the clock, the filesystem — the things you do not own. Mocking your own modules
|
|
32
|
+
means the test verifies the mock. For HTTP specifically, an interceptor such as `msw` or `nock`
|
|
33
|
+
exercises the real client code path, which a stubbed module does not.
|
|
34
|
+
|
|
35
|
+
Fake timers for anything time-dependent; a test with a real `setTimeout` is a slow test and
|
|
36
|
+
eventually a flaky one.
|
|
37
|
+
|
|
38
|
+
## Types are not tests
|
|
39
|
+
|
|
40
|
+
A passing type check proves the shapes line up, not that the logic is right. Conversely, a test that
|
|
41
|
+
only asserts a type (`expectTypeOf`) belongs in a type-level test file, separate from behavior tests.
|
|
42
|
+
|