[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M72YC18XNZBZP0DKC4Y7Q71S":3,"skill-same:01M72YC18XNZBZP0DKC4Y7Q71S":54},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":27,"commitSha":28,"skillDirectory":29,"forksCount":14,"repositoryHtmlUrl":30,"repositoryHomepageUrl":6,"ownerHtmlUrl":31,"ownerBlogUrl":6,"ownerDescription":32,"updatedAt":33,"install":34,"resources":47},"01M72YC18XNZBZP0DKC4Y7Q71S","typescript-best-practices",null,"TypeScript best practices. Use when reading or editing any .ts or .tsx file.","h00mankind\u002Fworkflow","h00mankind","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F105175148?v=4","01M72XXA2JP2H3BBK5GP9AP4P6","h00man","01M72XXA3824K52XFYWJDBFJ06",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fh00mankind\u002Fworkflow\u002Fblob\u002Fmain\u002Fplugins\u002Fpstack\u002Fskills\u002Ftypescript-best-practices\u002FSKILL.md",[],[],"2026-11-10 22:39:42",false,"---\nname: typescript-best-practices\ndescription: TypeScript best practices. Use when reading or editing any .ts or .tsx file.\npaths: [\"**\u002F*.ts\", \"**\u002F*.tsx\"]\n---\n\n# TypeScript best practices\n\nOn Muse, read the [platform mapping](..\u002Fpoteto-mode\u002Freferences\u002Fmuse-tools.md), including its per-skill notes, before following this skill.\n\nApply the **type-system-discipline** principle skill first.\n\n| Rule | Summary |\n|------|---------|\n| Discriminated unions | Model variants with a `kind` literal discriminant so impossible states can't be represented. No optional-field bags. |\n| Branded types | Brand primitives with `& { readonly __brand: \"X\" }` so they can't be mixed up. Validate once at the boundary. A brand comes from a verifying type guard (`input is AgentId`), never from `as`. |\n| Constructive modeling | Build the shape so the illegal value can't be constructed. `[T, ...T[]]` for non-empty, `[T, T][]` for even length, `start` plus `duration` for a range. Not a runtime guard, not a wish for refinement types. |\n| Simplest total type | Keep `T[]` while every operation on it stays total. Strengthen to `NonEmpty\u003CT>` only where the loose type forces `!`, a cast, or a \"should never happen\" throw. |\n| `unknown` over `any` | External data is `unknown`. |\n| Schemas before guards | Before hand-writing a property-by-property type guard, use the repository's runtime schema library and infer the type from the schema, such as `z.infer`. |\n| No `as` casts | Every `as` is a runtime crash waiting. Cast only after validation. |\n| Narrowing hierarchy | Discriminant switch > `in` operator > `typeof`\u002F`instanceof` > user-defined type guard > `as`. |\n| Type guards | Must verify the claim. A lying guard is worse than `as` because the bug hides behind a name that says it's safe. Name them `isX` or `hasX`. |\n| Exhaustiveness | Inline `const _exhaustive: never = x;` in default arms so the compiler errors when a new variant is added. |\n| `satisfies` over `as` | Validates the value without widening literal types. |\n| Boundary validation | Parse where data crosses in, into a named domain type. `Record\u003Cstring, unknown>` (however spelled) stops at that parse. Trust types inside. See the **boundary-discipline** principle skill. |\n| Schema-derived types | Reach for `Pick`\u002F`Omit`\u002F`Parameters`\u002F`ReturnType`\u002F`Awaited`\u002F`typeof` before declaring a new interface. |\n| Object args | Pass objects, not positional, so argument order is self-documenting. Skip on hot paths (per-frame render, tokenizers, parsers). |\n| Real tests | Don't mock what you can run. Prefer the framework's real test primitives with leak\u002Fdisposable checks, and verify UI in a running build. Mock only what you can't run locally. |\n| Structured telemetry | Prefer structured logger diagnostics with enough context to debug from an id. No `console.log` in shipped code. |\n\nExamples: `references\u002Fpatterns.md`.\n","# TypeScript best practices\n\nOn Muse, read the [platform mapping](..\u002Fpoteto-mode\u002Freferences\u002Fmuse-tools.md), including its per-skill notes, before following this skill.\n\nApply the **type-system-discipline** principle skill first.\n\n| Rule | Summary |\n|------|---------|\n| Discriminated unions | Model variants with a `kind` literal discriminant so impossible states can't be represented. No optional-field bags. |\n| Branded types | Brand primitives with `& { readonly __brand: \"X\" }` so they can't be mixed up. Validate once at the boundary. A brand comes from a verifying type guard (`input is AgentId`), never from `as`. |\n| Constructive modeling | Build the shape so the illegal value can't be constructed. `[T, ...T[]]` for non-empty, `[T, T][]` for even length, `start` plus `duration` for a range. Not a runtime guard, not a wish for refinement types. |\n| Simplest total type | Keep `T[]` while every operation on it stays total. Strengthen to `NonEmpty\u003CT>` only where the loose type forces `!`, a cast, or a \"should never happen\" throw. |\n| `unknown` over `any` | External data is `unknown`. |\n| Schemas before guards | Before hand-writing a property-by-property type guard, use the repository's runtime schema library and infer the type from the schema, such as `z.infer`. |\n| No `as` casts | Every `as` is a runtime crash waiting. Cast only after validation. |\n| Narrowing hierarchy | Discriminant switch > `in` operator > `typeof`\u002F`instanceof` > user-defined type guard > `as`. |\n| Type guards | Must verify the claim. A lying guard is worse than `as` because the bug hides behind a name that says it's safe. Name them `isX` or `hasX`. |\n| Exhaustiveness | Inline `const _exhaustive: never = x;` in default arms so the compiler errors when a new variant is added. |\n| `satisfies` over `as` | Validates the value without widening literal types. |\n| Boundary validation | Parse where data crosses in, into a named domain type. `Record\u003Cstring, unknown>` (however spelled) stops at that parse. Trust types inside. See the **boundary-discipline** principle skill. |\n| Schema-derived types | Reach for `Pick`\u002F`Omit`\u002F`Parameters`\u002F`ReturnType`\u002F`Awaited`\u002F`typeof` before declaring a new interface. |\n| Object args | Pass objects, not positional, so argument order is self-documenting. Skip on hot paths (per-frame render, tokenizers, parsers). |\n| Real tests | Don't mock what you can run. Prefer the framework's real test primitives with leak\u002Fdisposable checks, and verify UI in a running build. Mock only what you can't run locally. |\n| Structured telemetry | Prefer structured logger diagnostics with enough context to debug from an id. No `console.log` in shipped code. |\n\nExamples: `references\u002Fpatterns.md`.\n",{"name":5,"paths":24,"description":7},[25,26],"**\u002F*.ts","**\u002F*.tsx","main","2b813251957e3e80c45cc5f55bf9c228d818d05b","plugins\u002Fpstack\u002Fskills\u002Ftypescript-best-practices","https:\u002F\u002Fgithub.com\u002Fh00mankind\u002Fworkflow","https:\u002F\u002Fgithub.com\u002Fh00mankind","an ordinary mortal h00man","2026-11-13 01:29:34",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add h00mankind\u002Fworkflow --skill typescript-best-practices",{"tool":40,"command":41},"bunx","bunx skills add h00mankind\u002Fworkflow --skill typescript-best-practices",{"tool":43,"command":44},"pnpm","pnpm dlx skills add h00mankind\u002Fworkflow --skill typescript-best-practices","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fh00mankind\u002Fworkflow\u002Fblob\u002Fmain\u002Fplugins\u002Fpstack\u002Fskills\u002Ftypescript-best-practices\u002FSKILL.md",true,[48],{"path":49,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":52,"sourceHtmlUrl":53},"references\u002Fpatterns.md","REFERENCE","参考文档",9287,"https:\u002F\u002Fgithub.com\u002Fh00mankind\u002Fworkflow\u002Fblob\u002Fmain\u002Fplugins\u002Fpstack\u002Fskills\u002Ftypescript-best-practices\u002Freferences\u002Fpatterns.md",[55,63,70,78,85,92],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":62},"01M78R7TT830V3BYFNDX1EHF0V","teach","Teach the user a subject, in explain mode (one plain account of code, a change, or a concept, in chat) or course mode (a learning workspace with a mission, lessons, and records over many sessions). Runs only when the user types \u002Fteach.","https:\u002F\u002Fgithub.com\u002Fh00mankind\u002Fworkflow\u002Fblob\u002Fmain\u002Fplugins\u002Fh00man\u002Fskills\u002Fteach\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":62},"01M78R7RSGFF5TFE0JBGY3WKEJ","council","Get a review or a second opinion on existing work from several strong models of different providers. Runs only when the user types \u002Fcouncil.","https:\u002F\u002Fgithub.com\u002Fh00mankind\u002Fworkflow\u002Fblob\u002Fmain\u002Fplugins\u002Fh00man\u002Fskills\u002Fcouncil\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":77},"01M74AAVCZZREXPZEE5HRN5WF5","variant","Builds multiple variants of a component you're working on and helps you iterate and pick one.","https:\u002F\u002Fgithub.com\u002Fh00mankind\u002Fworkflow\u002Fblob\u002Fmain\u002Fplugins\u002Fjakub\u002Fskills\u002Fvariant\u002FSKILL.md",[],[],"2026-11-11 15:11:14",{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":77},"01M74AAR3M07M86YX2CXPD79EX","teardown","Creates technical illustrations of physical objects and of how things work, such as display pixels or interface layers, with coherent views, fine linework and part fills.","https:\u002F\u002Fgithub.com\u002Fh00mankind\u002Fworkflow\u002Fblob\u002Fmain\u002Fplugins\u002Fjakub\u002Fskills\u002Fteardown\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":77},"01M74AAMKJ8MKP9M99K37A82ZM","state-machine","Renders every state of a component you choose on a throwaway page, with mock data and a switcher, so you can work on each state.","https:\u002F\u002Fgithub.com\u002Fh00mankind\u002Fworkflow\u002Fblob\u002Fmain\u002Fplugins\u002Fjakub\u002Fskills\u002Fstate-machine\u002FSKILL.md",[],[],{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":77},"01M74AAHF2A498F7F2E74696KF","interface-review","Reviews a branch, pull request or uncommitted change for the interface problems it introduced or regressed, across accessibility, layout, writing, typography, color and UI.","https:\u002F\u002Fgithub.com\u002Fh00mankind\u002Fworkflow\u002Fblob\u002Fmain\u002Fplugins\u002Fjakub\u002Fskills\u002Finterface-review\u002FSKILL.md",[],[]]