[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7BH3W0RQMVG1XRSSCMVP2TM":3,"skill-same:01M7BH3W0RQMVG1XRSSCMVP2TM":52},{"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":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":30,"updatedAt":31,"install":32,"resources":45},"01M7BH3W0RQMVG1XRSSCMVP2TM","typescript-best-practices",null,"TypeScript best practices. Use when reading or editing any .ts or .tsx file, or for \u002Ftypescript-best-practices.","lovrozagar\u002Fgrunt","lovrozagar","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F86857639?v=4","01M7B3T6X88HRBYP2A9ZEGQEMD","Lovro Zagar","01M7BGVF4JZBK92D0TSM09M44Q",2,"MIT","https:\u002F\u002Fgithub.com\u002Flovrozagar\u002Fgrunt\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Ftypescript-best-practices\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: typescript-best-practices\ndescription: >-\n  TypeScript best practices. Use when reading or editing any .ts or .tsx file,\n  or for \u002Ftypescript-best-practices.\n---\n# TypeScript best practices\n\nMake illegal states unrepresentable. Brand semantic primitives. Parse external data at boundaries. Exhaust variants. Derive types from the schema that owns the shape.\n\nValidate at the boundary (CLI, config, network, external APIs). Trust types inside. Keep business logic in pure functions.\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. |\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` next to this skill.\n","# TypeScript best practices\n\nMake illegal states unrepresentable. Brand semantic primitives. Parse external data at boundaries. Exhaust variants. Derive types from the schema that owns the shape.\n\nValidate at the boundary (CLI, config, network, external APIs). Trust types inside. Keep business logic in pure functions.\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. |\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` next to this skill.\n",{"name":5,"description":7},"main","91069c1955cc11def04b75dc2d3c4a99c9d5eb48",".claude\u002Fskills\u002Ftypescript-best-practices",0,"https:\u002F\u002Fgithub.com\u002Flovrozagar\u002Fgrunt","https:\u002F\u002Fgithub.com\u002Flovrozagar","TypeScript Jedi Master ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ @workerstack ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ OSS & SaaS","2026-11-04 09:19:39",{"source":8,"skillName":5,"commands":33,"prompt":43,"zipAvailable":44},[34,37,40],{"tool":35,"command":36},"npx","npx skills add lovrozagar\u002Fgrunt --skill typescript-best-practices",{"tool":38,"command":39},"bunx","bunx skills add lovrozagar\u002Fgrunt --skill typescript-best-practices",{"tool":41,"command":42},"pnpm","pnpm dlx skills add lovrozagar\u002Fgrunt --skill typescript-best-practices","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flovrozagar\u002Fgrunt\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Ftypescript-best-practices\u002FSKILL.md",true,[46],{"path":47,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":50,"sourceHtmlUrl":51},"references\u002Fpatterns.md","REFERENCE","参考文档",9157,"https:\u002F\u002Fgithub.com\u002Flovrozagar\u002Fgrunt\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Ftypescript-best-practices\u002Freferences\u002Fpatterns.md",[53,60,67,74,79,86],{"skillNo":54,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":19},"01M7BHARD0SQTQ83H73E779A8E","write-roadmap","Write an ordered program of plans under .tmp\u002Fgrunt\u002Froadmaps\u002F. Use for \u002Fwrite-roadmap. Stops for y, which locks and runs it.","https:\u002F\u002Fgithub.com\u002Flovrozagar\u002Fgrunt\u002Fblob\u002Fmain\u002F.rulesync\u002Fskills\u002Fwrite-roadmap\u002FSKILL.md",[],[],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":19},"01M7BHAQ7M9Y790C7DW0RAKAQM","write-plan","Write a local checklist under .tmp\u002Fgrunt\u002Fplans\u002F. Then \u002Fimplement-plan {n}.","https:\u002F\u002Fgithub.com\u002Flovrozagar\u002Fgrunt\u002Fblob\u002Fmain\u002F.rulesync\u002Fskills\u002Fwrite-plan\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":19},"01M7BHANM3QZF2QP8P28WW9R3K","unslop","Cut AI tells from any writing. Use for \u002Funslop.","https:\u002F\u002Fgithub.com\u002Flovrozagar\u002Fgrunt\u002Fblob\u002Fmain\u002F.rulesync\u002Fskills\u002Funslop\u002FSKILL.md",[],[],{"skillNo":75,"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":76,"categories":77,"keywords":78,"publishedAt":19},"01M7BHAM1MSNX381EDKA5HN9XM","https:\u002F\u002Fgithub.com\u002Flovrozagar\u002Fgrunt\u002Fblob\u002Fmain\u002F.rulesync\u002Fskills\u002Ftypescript-best-practices\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":19},"01M7BHAJX7MG58JBGEAR0NCSXW","tmp","Dump a one-off convo artifact under .tmp\u002Fgrunt\u002F.","https:\u002F\u002Fgithub.com\u002Flovrozagar\u002Fgrunt\u002Fblob\u002Fmain\u002F.rulesync\u002Fskills\u002Ftmp\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":19},"01M7BHAGFXSTF5E1DDSYEZF8ZD","teach","Explain a body of work plainly so a person actually understands it. Dig into how it works and why it is that way, then weave that into one clear explanation. Use for \u002Fteach, 'teach me this', 'help me really understand X', 'explain this change or subsystem to me'.","https:\u002F\u002Fgithub.com\u002Flovrozagar\u002Fgrunt\u002Fblob\u002Fmain\u002F.rulesync\u002Fskills\u002Fteach\u002FSKILL.md",[],[]]