[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6P81DN87SWBVNGHRAAMD7JM":3,"skill-same:01M6P81DN87SWBVNGHRAAMD7JM":72},{"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":28,"linkOnly":29,"markdownContent":30,"markdownBody":31,"frontMatter":32,"refName":37,"commitSha":38,"skillDirectory":39,"forksCount":14,"repositoryHtmlUrl":40,"repositoryHomepageUrl":6,"ownerHtmlUrl":41,"ownerBlogUrl":6,"ownerDescription":42,"updatedAt":43,"install":44,"resources":56},"01M6P81DN87SWBVNGHRAAMD7JM","typescript-best-practices",null,"TypeScript best practices. Use when reading or editing any .ts or .tsx file.","sarthchawla\u002FSetupMyAI","sarthchawla","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F41484686?v=4","01M6P7D22NFMY9MA11Q2YGPKV2","Sarthak Chawla","01M6P7D26JJ9KW98SD1G8BB83R",0,"MIT","https:\u002F\u002Fgithub.com\u002Fsarthchawla\u002FSetupMyAI\u002Fblob\u002Fmain\u002Fpackages\u002Fpstack\u002Fskills\u002Ftypescript-best-practices\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27],"typescript","best practices","typescript best practices","file","editing","use","tsx","reading","true","2026-11-10 10:12:30",false,"---\nname: typescript-best-practices\ndescription: TypeScript best practices. Use when reading or editing any .ts or .tsx file.\npaths: [\"**\u002F*.ts\", \"**\u002F*.tsx\"]\ndisable-model-invocation: true\n---\n\n# TypeScript best practices\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\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":33,"description":7,"disable-model-invocation":36},[34,35],"**\u002F*.ts","**\u002F*.tsx",true,"main","3934845b800ff514cb89eb81d43f3dc4cbf51ff2","packages\u002Fpstack\u002Fskills\u002Ftypescript-best-practices","https:\u002F\u002Fgithub.com\u002Fsarthchawla\u002FSetupMyAI","https:\u002F\u002Fgithub.com\u002Fsarthchawla","there ain't no problem i can't solve","2026-10-23 01:26:57",{"source":8,"skillName":5,"commands":45,"prompt":55,"zipAvailable":36},[46,49,52],{"tool":47,"command":48},"npx","npx skills add sarthchawla\u002FSetupMyAI --skill typescript-best-practices",{"tool":50,"command":51},"bunx","bunx skills add sarthchawla\u002FSetupMyAI --skill typescript-best-practices",{"tool":53,"command":54},"pnpm","pnpm dlx skills add sarthchawla\u002FSetupMyAI --skill typescript-best-practices","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fsarthchawla\u002FSetupMyAI\u002Fblob\u002Fmain\u002Fpackages\u002Fpstack\u002Fskills\u002Ftypescript-best-practices\u002FSKILL.md",[57,63,68],{"path":58,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":61,"sourceHtmlUrl":62},"agents\u002Fopenai.yaml","REFERENCE","参考文档",43,"https:\u002F\u002Fgithub.com\u002Fsarthchawla\u002FSetupMyAI\u002Fblob\u002Fmain\u002Fpackages\u002Fpstack\u002Fskills\u002Ftypescript-best-practices\u002Fagents\u002Fopenai.yaml",{"path":64,"resourceType":64,"resourceTypeDesc":65,"sizeBytes":66,"sourceHtmlUrl":67},"LICENSE","许可证",1067,"https:\u002F\u002Fgithub.com\u002Fsarthchawla\u002FSetupMyAI\u002Fblob\u002Fmain\u002Fpackages\u002Fpstack\u002Fskills\u002Ftypescript-best-practices\u002FLICENSE",{"path":69,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":70,"sourceHtmlUrl":71},"references\u002Fpatterns.md",9287,"https:\u002F\u002Fgithub.com\u002Fsarthchawla\u002FSetupMyAI\u002Fblob\u002Fmain\u002Fpackages\u002Fpstack\u002Fskills\u002Ftypescript-best-practices\u002Freferences\u002Fpatterns.md",[73,86,103,112,122,142],{"skillNo":74,"name":75,"nameZh":6,"description":6,"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":83,"publishedAt":28},"01M6P8953HNC422WFQSPP2FMQE","sample-skill","https:\u002F\u002Fgithub.com\u002Fsarthchawla\u002FSetupMyAI\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fmock-repo\u002F.claude\u002Fskills\u002Fsample-skill\u002FSKILL.md",[78],{"categoryNo":79,"categoryName":80,"taxonomyType":81,"taxonomyTypeDesc":82},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[84,85],"sample","sample skill",{"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":28},"01M6P8924ZSDAZ88Y5Q9P3KAQV","synthetic-review-candidate","Candidate for smoke testing an evaluation runner only.","https:\u002F\u002Fgithub.com\u002Fsarthchawla\u002FSetupMyAI\u002Fblob\u002Fmain\u002Fscripts\u002Fskill-eval\u002Ffixtures\u002Fcandidate\u002FSKILL.md",[],[93,94,95,96,97,98,99,100,101,102],"synthetic review candidate","candidate","synthetic","review","only","testing","Evaluation","smoke","runner","for",{"skillNo":104,"name":105,"nameZh":6,"description":106,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":107,"categories":108,"keywords":109,"publishedAt":28},"01M6P88FEGGNH8EZY0PDHD9KQA","synthetic-review-baseline","Baseline for smoke testing an evaluation runner only.","https:\u002F\u002Fgithub.com\u002Fsarthchawla\u002FSetupMyAI\u002Fblob\u002Fmain\u002Fscripts\u002Fskill-eval\u002Ffixtures\u002Fbaseline\u002FSKILL.md",[],[110,95,111,96,100,101,102,97,98,99],"synthetic review baseline","baseline",{"skillNo":113,"name":96,"nameZh":6,"description":114,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":115,"categories":116,"keywords":117,"publishedAt":28},"01M6P87ZXVEHRM860960DB5FEQ","Run the existing user-invoked review bundle and independently adjudicate its findings.","https:\u002F\u002Fgithub.com\u002Fsarthchawla\u002FSetupMyAI\u002Fblob\u002Fmain\u002Fpackages\u002Funiversal\u002Fskills\u002Freview\u002FSKILL.md",[],[96,118,119,120,121],"run","user","bundle","Existing",{"skillNo":123,"name":124,"nameZh":6,"description":125,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":126,"categories":127,"keywords":128,"publishedAt":28},"01M6P87FC73MZTRB6ZBP4GR1VQ","review-adjudication","Verify generated or human review findings before fixing, defending, replying, resolving, or reusing them as learned guidance. Use within a review, review-comment fix, monitor, or readiness workflow.","https:\u002F\u002Fgithub.com\u002Fsarthchawla\u002FSetupMyAI\u002Fblob\u002Fmain\u002Fpackages\u002Funiversal\u002Fskills\u002Freview-adjudication\u002FSKILL.md",[],[129,96,130,131,132,133,134,135,136,137,138,139,24,140,141],"review adjudication","workflow","generated","human review","guidance","human","as","readiness","learned","review findings","fix","verify","monitor",{"skillNo":143,"name":144,"nameZh":6,"description":145,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":146,"categories":147,"keywords":148,"publishedAt":28},"01M6P871Q44KQES293T60JQETA","monitor-mr","Monitor review findings and CI using the shared adjudication procedure.","https:\u002F\u002Fgithub.com\u002Fsarthchawla\u002FSetupMyAI\u002Fblob\u002Fmain\u002Fpackages\u002Funiversal\u002Fskills\u002Fmonitor-mr\u002FSKILL.md",[],[141,149,150,138,151,152,96],"mr","monitor mr","shared","ci"]