[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7ARWG34VZRC0FZTP4Z1VXFH":3,"skill-same:01M7ARWG34VZRC0FZTP4Z1VXFH":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":24,"commitSha":25,"skillDirectory":26,"forksCount":14,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":29,"install":30,"resources":43},"01M7ARWG34VZRC0FZTP4Z1VXFH","typescript-best-practices",null,"Use when writing or reviewing .ts\u002F.tsx code: types, validation boundaries, and API signatures.","gutierrezje\u002Fjstack","gutierrezje","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F32502846?v=4","01M7ARSJH934J0XXNJC02Y6PB0","Jesus E. Gutierrez","01M7ARSJJ8PN0AGVX140JK202H",0,"MIT","https:\u002F\u002Fgithub.com\u002Fgutierrezje\u002Fjstack\u002Fblob\u002Fmain\u002Fskills\u002Ftypescript-best-practices\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: typescript-best-practices\ndescription: \"Use when writing or reviewing .ts\u002F.tsx code: types, validation boundaries, and API signatures.\"\n---\n\n# TypeScript best practices\n\nUse the conventions below for the code being changed or reviewed. Consult\n[type-system-discipline](..\u002Fjesus-mode\u002Freferences\u002Fprinciples\u002Ftype-system-discipline.md)\nwhen choosing how to represent domain invariants or separate validated data from\nexternal input. Simple lookups and mechanical edits need no additional reference.\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 creation. 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`. `any` disables type checking everywhere it touches. |\n| Schemas before guards | Prefer the repository's existing runtime schema library for external data and infer the domain type from its schema. Avoid a duplicate interface and property-by-property guard. |\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 external data at the boundary into a named domain type. `Record\u003Cstring, unknown>`, however spelled, stops at that parse. Trust types inside. See [boundary-discipline](..\u002Fjesus-mode\u002Freferences\u002Fprinciples\u002Fboundary-discipline.md). |\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\nUse the conventions below for the code being changed or reviewed. Consult\n[type-system-discipline](..\u002Fjesus-mode\u002Freferences\u002Fprinciples\u002Ftype-system-discipline.md)\nwhen choosing how to represent domain invariants or separate validated data from\nexternal input. Simple lookups and mechanical edits need no additional reference.\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 creation. 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`. `any` disables type checking everywhere it touches. |\n| Schemas before guards | Prefer the repository's existing runtime schema library for external data and infer the domain type from its schema. Avoid a duplicate interface and property-by-property guard. |\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 external data at the boundary into a named domain type. `Record\u003Cstring, unknown>`, however spelled, stops at that parse. Trust types inside. See [boundary-discipline](..\u002Fjesus-mode\u002Freferences\u002Fprinciples\u002Fboundary-discipline.md). |\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,"description":7},"main","bbac2ca2c2f494880dc8aa5d58dc4f768501f290","skills\u002Ftypescript-best-practices","https:\u002F\u002Fgithub.com\u002Fgutierrezje\u002Fjstack","https:\u002F\u002Fgithub.com\u002Fgutierrezje","2026-11-11 14:57:12",{"source":8,"skillName":5,"commands":31,"prompt":41,"zipAvailable":42},[32,35,38],{"tool":33,"command":34},"npx","npx skills add gutierrezje\u002Fjstack --skill typescript-best-practices",{"tool":36,"command":37},"bunx","bunx skills add gutierrezje\u002Fjstack --skill typescript-best-practices",{"tool":39,"command":40},"pnpm","pnpm dlx skills add gutierrezje\u002Fjstack --skill typescript-best-practices","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fgutierrezje\u002Fjstack\u002Fblob\u002Fmain\u002Fskills\u002Ftypescript-best-practices\u002FSKILL.md",true,[44,50],{"path":45,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":48,"sourceHtmlUrl":49},"agents\u002Fopenai.yaml","REFERENCE","参考文档",200,"https:\u002F\u002Fgithub.com\u002Fgutierrezje\u002Fjstack\u002Fblob\u002Fmain\u002Fskills\u002Ftypescript-best-practices\u002Fagents\u002Fopenai.yaml",{"path":51,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":52,"sourceHtmlUrl":53},"references\u002Fpatterns.md",9501,"https:\u002F\u002Fgithub.com\u002Fgutierrezje\u002Fjstack\u002Fblob\u002Fmain\u002Fskills\u002Ftypescript-best-practices\u002Freferences\u002Fpatterns.md",[55,62,69,76,83,90],{"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":19},"01M7ARWNBDTFSVCHWFQ4BYWQSX","why","Why code is this way: design rationale, regressions, and history from evidence. For runtime: how.","https:\u002F\u002Fgithub.com\u002Fgutierrezje\u002Fjstack\u002Fblob\u002Fmain\u002Fskills\u002Fwhy\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":19},"01M7ARWKP5P795ZTFRJQJNK9ZK","unslop","Edit prose to remove AI writing patterns when polishing text or asked to make it sound natural.","https:\u002F\u002Fgithub.com\u002Fgutierrezje\u002Fjstack\u002Fblob\u002Fmain\u002Fskills\u002Funslop\u002FSKILL.md",[],[],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":19},"01M7ARWBBKAMRHVJH929D2TSW1","sync-pstack","Analyze upstream cursor\u002Fplugins pstack changes and guide semantic ports into Codex-native Jstack without overwriting local skills. Use when the user says \"sync pstack\", \"check pstack updates\", or asks to update Jstack from upstream.","https:\u002F\u002Fgithub.com\u002Fgutierrezje\u002Fjstack\u002Fblob\u002Fmain\u002Fskills\u002Fsync-pstack\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M7ARW853DBZYE9ETT0ZZHP9J","swarm","Fan out N parallel workers, drain them, and return one report. Use for \u002Fswarm, 'swarm this', or parallel coverage, races, gauntlets, and exploration.","https:\u002F\u002Fgithub.com\u002Fgutierrezje\u002Fjstack\u002Fblob\u002Fmain\u002Fskills\u002Fswarm\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":19},"01M7ARW5Y0CMDJCAJ1P3KKBDV8","statechart","Check a finite TLA+ model and explain its paths and rule failures as a statechart.","https:\u002F\u002Fgithub.com\u002Fgutierrezje\u002Fjstack\u002Fblob\u002Fmain\u002Fskills\u002Fstatechart\u002FSKILL.md",[],[],{"skillNo":91,"name":92,"nameZh":6,"description":93,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":19},"01M7ARW1WJPA1CDA2X4J78VYR3","show-me-your-work","Use when asked for a decision trail, or when unattended work needs a durable record of decisions and evidence.","https:\u002F\u002Fgithub.com\u002Fgutierrezje\u002Fjstack\u002Fblob\u002Fmain\u002Fskills\u002Fshow-me-your-work\u002FSKILL.md",[],[]]