[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7EXW7M17CN7V62E25PM4QAJ":3,"skill-same:01M7EXW7M17CN7V62E25PM4QAJ":65},{"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":16,"sourceHtmlUrl":17,"categories":18,"keywords":19,"publishedAt":20,"linkOnly":21,"markdownContent":22,"markdownBody":23,"frontMatter":24,"refName":28,"commitSha":29,"skillDirectory":30,"forksCount":31,"repositoryHtmlUrl":32,"repositoryHomepageUrl":6,"ownerHtmlUrl":33,"ownerBlogUrl":34,"ownerDescription":6,"updatedAt":35,"install":36,"resources":49},"01M7EXW7M17CN7V62E25PM4QAJ","typescript-best-practices",null,"TypeScript type-safety rules: discriminated unions, branded types, no `as`, exhaustive switches, schema-derived types. Use when writing, editing, or reviewing TypeScript.","ravnhq\u002Fravn-core","ravnhq","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F32917297?v=4","01M7EXRETGEZ3CYCQTXRQ83BTJ","Ravn","01M7EXREV559052BB2B6AX8X5K",2,"MIT","https:\u002F\u002Fgithub.com\u002Fravnhq\u002Fravn-core\u002Fblob\u002Fmain\u002Fplugins\u002Fagent\u002Fravn-core\u002Fskills\u002Ftypescript-best-practices\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fravnhq\u002Fravn-core\u002Fblob\u002Fmain\u002Fplugins\u002Fagent\u002Fravn-core\u002Fskills\u002Ftypescript-best-practices\u002FSKILL.md",[],[],"2026-11-16 10:05:34",false,"---\nname: typescript-best-practices\ndescription: >-\n  TypeScript type-safety rules: discriminated unions, branded types, no `as`,\n  exhaustive switches, schema-derived types. Use when writing, editing, or\n  reviewing TypeScript.\nlicense: See LICENSE.txt\nmetadata:\n  proof: subjective\n---\n\n# TypeScript Best Practices\n\nAdapted from pstack `typescript-best-practices`, MIT License, Copyright (c) 2026 Lauren Tan. See [LICENSE.txt](LICENSE.txt).\n\nApply [Type System Discipline](..\u002Fprinciple-type-system-discipline\u002FSKILL.md) first. Apply every rule below; [references\u002Fpatterns.md](references\u002Fpatterns.md) holds the examples, under a heading per rule. Read it for a rule you cannot apply from its row alone.\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\" }`. 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. No runtime guard, no 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 it (`z.infer`). Add no schema dependency for one 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 | Verify the claim: a lying guard is worse than `as`, since its name says it's safe. Name them `isX` or `hasX`. |\n| Exhaustiveness | Assign the discriminant to `const _exhaustive: never = x;` in default arms so a new variant fails to compile. |\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 [Boundary Discipline](..\u002Fprinciple-boundary-discipline\u002FSKILL.md). |\n| Schema-derived types | Reach for `Pick`\u002F`Omit`\u002F`Parameters`\u002F`ReturnType`\u002F`Awaited`\u002F`typeof`, or generated types from a `.proto`, OpenAPI, GraphQL, or migration, before declaring a new interface. |\n| Object args | Pass objects, not positional args, so order is self-documenting. Skip on hot paths (per-frame render, tokenizers, parsers). |\n| Real tests | Mock only what you can't run locally. Prefer the framework's real test primitives with leak\u002Fdisposable checks, and verify UI in a running build. |\n| Structured telemetry | Use structured logger diagnostics with enough context to debug from an id; `console.log` stays out of shipped code. |\n","# TypeScript Best Practices\n\nAdapted from pstack `typescript-best-practices`, MIT License, Copyright (c) 2026 Lauren Tan. See [LICENSE.txt](LICENSE.txt).\n\nApply [Type System Discipline](..\u002Fprinciple-type-system-discipline\u002FSKILL.md) first. Apply every rule below; [references\u002Fpatterns.md](references\u002Fpatterns.md) holds the examples, under a heading per rule. Read it for a rule you cannot apply from its row alone.\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\" }`. 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. No runtime guard, no 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 it (`z.infer`). Add no schema dependency for one 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 | Verify the claim: a lying guard is worse than `as`, since its name says it's safe. Name them `isX` or `hasX`. |\n| Exhaustiveness | Assign the discriminant to `const _exhaustive: never = x;` in default arms so a new variant fails to compile. |\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 [Boundary Discipline](..\u002Fprinciple-boundary-discipline\u002FSKILL.md). |\n| Schema-derived types | Reach for `Pick`\u002F`Omit`\u002F`Parameters`\u002F`ReturnType`\u002F`Awaited`\u002F`typeof`, or generated types from a `.proto`, OpenAPI, GraphQL, or migration, before declaring a new interface. |\n| Object args | Pass objects, not positional args, so order is self-documenting. Skip on hot paths (per-frame render, tokenizers, parsers). |\n| Real tests | Mock only what you can't run locally. Prefer the framework's real test primitives with leak\u002Fdisposable checks, and verify UI in a running build. |\n| Structured telemetry | Use structured logger diagnostics with enough context to debug from an id; `console.log` stays out of shipped code. |\n",{"name":5,"license":25,"metadata":26,"description":7},"See LICENSE.txt",{"proof":27},"subjective","main","8debc762560573209acaf70a1a66f1061d7c8060","plugins\u002Fagent\u002Fravn-core\u002Fskills\u002Ftypescript-best-practices",0,"https:\u002F\u002Fgithub.com\u002Fravnhq\u002Fravn-core","https:\u002F\u002Fgithub.com\u002Fravnhq","https:\u002F\u002Fwww.ravn.co","2026-11-13 05:50:45",{"source":8,"skillName":5,"commands":37,"prompt":47,"zipAvailable":48},[38,41,44],{"tool":39,"command":40},"npx","npx skills add ravnhq\u002Fravn-core --skill typescript-best-practices",{"tool":42,"command":43},"bunx","bunx skills add ravnhq\u002Fravn-core --skill typescript-best-practices",{"tool":45,"command":46},"pnpm","pnpm dlx skills add ravnhq\u002Fravn-core --skill typescript-best-practices","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fravnhq\u002Fravn-core\u002Fblob\u002Fmain\u002Fplugins\u002Fagent\u002Fravn-core\u002Fskills\u002Ftypescript-best-practices\u002FSKILL.md",true,[50,56,61],{"path":51,"resourceType":52,"resourceTypeDesc":53,"sizeBytes":54,"sourceHtmlUrl":55},"agents\u002Fopenai.yaml","REFERENCE","参考文档",118,"https:\u002F\u002Fgithub.com\u002Fravnhq\u002Fravn-core\u002Fblob\u002Fmain\u002Fplugins\u002Fagent\u002Fravn-core\u002Fskills\u002Ftypescript-best-practices\u002Fagents\u002Fopenai.yaml",{"path":57,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":60,"sourceHtmlUrl":16},"LICENSE.txt","LICENSE","许可证",1201,{"path":62,"resourceType":52,"resourceTypeDesc":53,"sizeBytes":63,"sourceHtmlUrl":64},"references\u002Fpatterns.md",5863,"https:\u002F\u002Fgithub.com\u002Fravnhq\u002Fravn-core\u002Fblob\u002Fmain\u002Fplugins\u002Fagent\u002Fravn-core\u002Fskills\u002Ftypescript-best-practices\u002Freferences\u002Fpatterns.md",[66,74,82,90,98,106],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":70,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":20},"01M7EXWEDTSBBB0DQENHSBXCV5","writing-for-agents","Writing documents for agents. Use when creating or editing skills, or modifying AGENTS.md or CLAUDE.md.","https:\u002F\u002Fgithub.com\u002Fravnhq\u002Fravn-core\u002Fblob\u002Fmain\u002Fplugins\u002Fagent\u002Fravn-core\u002Fskills\u002Fwriting-for-agents\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fravnhq\u002Fravn-core\u002Fblob\u002Fmain\u002Fplugins\u002Fagent\u002Fravn-core\u002Fskills\u002Fwriting-for-agents\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":78,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":20},"01M7EXWA9QD5H1Z7ZNZHFV7M5E","why","Use for 'why does X work this way', 'why we picked Y', design rationale, regressions, postmortems, or data-backed thresholds. Queries every available evidence MCP in parallel and returns a cited read on decisions and tradeoffs. Use how for runtime behavior.","https:\u002F\u002Fgithub.com\u002Fravnhq\u002Fravn-core\u002Fblob\u002Fmain\u002Fplugins\u002Fagent\u002Fravn-core\u002Fskills\u002Fwhy\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fravnhq\u002Fravn-core\u002Fblob\u002Fmain\u002Fplugins\u002Fagent\u002Fravn-core\u002Fskills\u002Fwhy\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":86,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":20},"01M7EXW4Q6KTG9RM0R1MB29H9D","show-me-your-work","Keep a reviewable decision trail for unattended or multi-phase work: a TSV log with one row per decision (what, why, evidence, result).","https:\u002F\u002Fgithub.com\u002Fravnhq\u002Fravn-core\u002Fblob\u002Fmain\u002Fplugins\u002Fagent\u002Fravn-core\u002Fskills\u002Fshow-me-your-work\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fravnhq\u002Fravn-core\u002Fblob\u002Fmain\u002Fplugins\u002Fagent\u002Fravn-core\u002Fskills\u002Fshow-me-your-work\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":94,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":20},"01M7EXW00F0AQWA8F8ANCN2ZZT","ship","Take a change from idea to a ready PR with passing CI, running research, grilling, design, verification, and the pr skill in sequence.","https:\u002F\u002Fgithub.com\u002Fravnhq\u002Fravn-core\u002Fblob\u002Fmain\u002Fplugins\u002Fagent\u002Fravn-core\u002Fskills\u002Fship\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fravnhq\u002Fravn-core\u002Fblob\u002Fmain\u002Fplugins\u002Fagent\u002Fravn-core\u002Fskills\u002Fship\u002FSKILL.md",[],[],{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":102,"sourceHtmlUrl":103,"categories":104,"keywords":105,"publishedAt":20},"01M7EXVTVXP3RB0NPVTPG05YC4","session-pickup","Resume unfinished work from a handoff note or prior coding-agent session. Use before reading a supplied handoff, even when its next action is only an inspection or report. Also use to pick up, continue where you left off, or take over from a transcript, agent URL, or pushed branch. Use pause-safely to write a handoff.","https:\u002F\u002Fgithub.com\u002Fravnhq\u002Fravn-core\u002Fblob\u002Fmain\u002Fplugins\u002Fagent\u002Fravn-core\u002Fskills\u002Fsession-pickup\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fravnhq\u002Fravn-core\u002Fblob\u002Fmain\u002Fplugins\u002Fagent\u002Fravn-core\u002Fskills\u002Fsession-pickup\u002FSKILL.md",[],[],{"skillNo":107,"name":108,"nameZh":6,"description":109,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":110,"categories":111,"keywords":112,"publishedAt":20},"01M7EXVQQTDTTQEAX2YY73RF7H","review-and-simplify","Review the current branch or a GitHub PR with risk-tiered specialist subagents, judge their findings, apply safe simplifications to your own branch, and post to the PR on request.","https:\u002F\u002Fgithub.com\u002Fravnhq\u002Fravn-core\u002Fblob\u002Fmain\u002Fplugins\u002Fagent\u002Fravn-core\u002Fskills\u002Freview-and-simplify\u002FSKILL.md",[],[]]