TypeScript best practices. Use when reading or editing any .ts or .tsx file.
Collected from public GitHub. Every version is saved exactly as it was and never changes. Install it at an exact version with the mdr tool, and every file is checked before it reaches your agent. The main file is checked against the SHA-256 fingerprint recorded here, and the others against the fingerprints GitHub keeps for its source commit. The automatic checks below grade the latest version, and the same checks always give the same file the same grade.
What the file says
# TypeScript best practices
Apply the **type-system-discipline** principle skill first; this skill grounds it in TypeScript syntax.
| Rule | Summary |
|------|---------|
| Discriminated unions | Model variants with a `kind` literal discriminant so impossible states can't be represented. No optional-field bags. |
| Branded types | Brand primitives with `& { readonly __brand: "X" }` so they can't be mixed up. Validate once at creation. |
| 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. |
| Simplest total type | Keep `T[]` while every operation on it stays total. Strengthen to `NonEmpty<T>` only where the loose type forces `!`, a cast, or a "should never happen" throw. |
| `unknown` over `any` | External data is `unknown`. `any` disables type checking everywhere it touches. |
| No `as` casts | Every `as` is a runtime crash waiting. Cast only after validation. |
| Narrowing hierarchy | Discriminant switch > `in` operator > `typeof`/`instanceof` > user-defined type guard > `as`. |
…
The line at the top of this page pins the label git:20260827.04830a9, which is what most people want. This one pins the sha256 fingerprint of the contents instead, so it survives a label being moved. Either way the exact version is written to mdr.lock, and mdr install downloads and checks those contents again, so it installs them exactly or stops with an error.
GET https://markdownregistry.com/api/v1/artifacts/art_jal2ixdtd66mean6
GET https://markdownregistry.com/api/v1/resolve?ref=painhardcore/pstack/typescript-best-practices
GET https://markdownregistry.com/api/v1/blob/df0ecd7518b33778f4b02c2f85ee577bbaea52caa1c49df6816b0594e128bb64
Your AI assistant does the legwork. You hear about the deals worth your word. Hand yours the standing instructions at modelranch.com and it joins the network that reads files like this one.
painhardcore/pstack · .opencode/skills/architect/SKILL.md · Sketch types, signatures, and module structure before code, then stay in the loop while implementation fills in. Use…
painhardcore/pstack · .opencode/skills/arena/SKILL.md · Spawn N parallel candidates at the same task, pick a base, graft the strongest parts of the losers into it. Use for…
painhardcore/pstack · .opencode/skills/blast-radius/SKILL.md · Find what a change could break somewhere else before it ships, beyond the diff, and prove the one fact it's safe…
painhardcore/pstack · .opencode/skills/create-verification-skill/SKILL.md · Generate a project-local verification skill that drives your app the way a user does — any language, framework, or…
painhardcore/pstack · .opencode/skills/figure-it-out/SKILL.md · Design an auditable playbook when no narrower one fits: a large migration, an ambitious multi-part change, or work a…
painhardcore/pstack · .opencode/skills/how/SKILL.md · Explain how a subsystem works, trace a runtime flow, or determine where code and ownership belong before making a…
painhardcore/pstack · .opencode/skills/interrogate/SKILL.md · Use for "interrogate", "adversarial review", "multi-model review", "challenge this", "stress test this code", "find…
painhardcore/pstack · .opencode/skills/principle-boundary-discipline/SKILL.md · Apply when wiring validation, error handling, or framework adapters. Concentrate guards at system boundaries (CLI…
cursor/plugins · harness/pstack/claude-code/skills/typescript-best-practices/SKILL.md · TypeScript best practices. Use when reading or editing any .ts or .tsx file.
michael-denyer/pstack-claude · plugins/pstack/skills/typescript-best-practices/SKILL.md · TypeScript best practices. Use when reading or editing any .ts or .tsx file.
hoangnguyen0403/agent-skills-standard · .claude/skills/typescript/typescript-best-practices/SKILL.md · Write idiomatic TypeScript patterns for clean, maintainable code. Use when writing or refactoring TypeScript classes…
hoangnguyen0403/agent-skills-standard · .agents/skills/typescript/typescript-best-practices/SKILL.md · Write idiomatic TypeScript patterns for clean, maintainable code. Use when writing or refactoring TypeScript classes…
aiskillstore/marketplace · skills/0xbigboss/typescript-best-practices/SKILL.md · Use when reading or writing TypeScript or JavaScript files (.ts, .tsx, .js, tsconfig.json).
j-star-films-studios/vibecode-protocol-suite · assets/.agent/skills/web-dev-standards/typescript-standards/SKILL.md · TypeScript best practices. Use when reading or editing any .ts or .tsx file.