typescript-best-practices
/typescript-best-practices
TypeScript best practices. Use when reading or editing any .ts or .tsx file.
- Author
- v1truv1us ↗
- Repository
- ai-eng-system ↗
- Licence
- MIT
- Last repository change
- 09.08.2026
Assessment and security
- Files in this package
- 2
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 09.08.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
TypeScript best practices. Use when reading or editing any .ts or .tsx file.
Original author description
TypeScript best practices. Use when reading or editing any .ts or .tsx file.
How it works
SKILL.md has no level-two headings · 22 lines, 277 words
SKILL.md preview
---
name: typescript-best-practices
description: TypeScript best practices. Use when reading or editing any .ts or .tsx file.
metadata:
category: user-invoked
version: 1.0.0
tags: cursor-import, pstack
disable-model-invocation: true
---
Default output: return only the result, blockers, and required evidence. Omit preambles, process narration, repeated context, confidence scores, and follow-up offers. Use at most five bullets unless a required artifact or schema needs more.
# 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. |
| `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`. |
| 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`. |
| Exhaustiveness | Inline `const _exhaustive: never = x;` in default arms so the compiler errors when a new variant is added. |
| `satisfies` over `as` | Validates the value without widening literal types. |
| Boundary validation | Validate where data crosses in; trust types inside. See the **boundary-discipline** principle skill. |
| Schema-derived types | Reach for `Pick`/`Omit`/`Parameters`/`ReturnType`/`Awaited`/`typeof` before declaring a new interface. |
| Object args | Pass objects, not positional, so argument order is self-documenting. Skip on hot paths (per-frame render, tokenizers, parsers). |
Examples: `references/patterns.md`.
Files in this package (2)
- SKILL.md 2 KB
- evals/evals.json 1 KB
Versions
| Repository | Score | Licence |
|---|---|---|
| This page · v1truv1us/ai-eng-system | 87 | MIT |
| seaworld008/commonly-used-high-value-skills | 100 | MIT |
| HoangNguyen0403/agent-skills-standard | 100 | MIT |
| overextended/skills | 100 | GPL-3.0 |
| alleneubank/claude-code | 100 | Apache-2.0 |
| VdustR/vp-claude-code-marketplace | 100 | MIT |
| fcakyon/claude-codex-settings | 91 | Apache-2.0 |
| workerstack/clients | 91 | MIT |
| itsvedantkumar/vstack | 91 | MIT |
Identical content appears in 1 other GitHub folders. We show one copy with the highest score.
Database snapshot: 13.11.2026 · package version 926c7ef9e5d3 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 1 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 87mroowa-typescript-best-practices
TypeScript best practices. Use when reading or editing any .ts or .tsx file. - 100react-best-practices
Use when reading or writing React components (.tsx, .jsx files with React imports). - 100typescript
This skill should be used when writing or reviewing TypeScript or TSX code, or when the project uses "TypeScript", "React", "tsx", "SWR", "Vite", "Next.js", or TypeScript type patterns. Provides TypeScript coding conventions, React patterns, and best practices. Project-specific… - 91typescript-forms
Katara's TypeScript forms, practiced until every move is exact. Use for typescript-best-practices, /typescript-best-practices, "TypeScript best practices", and whenever reading or editing any .ts or .tsx file. Discriminated unions, branded types, constructive modeling, unknown… - 100python-best-practices
Use when reading or writing Python files (.py, pyproject.toml, requirements.txt). - 100trove-typescript
TypeScript type-system discipline for any .ts/.tsx file: make illegal states unrepresentable, validate at boundaries, avoid as/any. Use when reading or editing TypeScript that isn't covered by a framework-specific skill. Defers to trove-react / trove-react-best-practices on .tsx component work.