typescript-best-practices
TypeScript grounding for type-system discipline: discriminated unions over flags, satisfies, parse-don't-validate at boundaries, branded primitives, no non-null assertions on external data.
How do I install this agent skill?
npx skills add https://github.com/yeachan-heo/oh-my-claudecode --skill typescript-best-practicesIs this agent skill safe to install?
- Gen Agent Trust Hubpass
No security issues detected. The skill provides educational guidelines and code patterns for TypeScript best practices.
- Socketpass
No alerts
- Snykpass
Risk: LOW · No issues
What does this agent skill do?
TypeScript Best Practices
The type system is the cheapest place to make illegal states unrepresentable
(principles skill, Type system discipline). Concrete forms:
- Discriminated unions over boolean flags.
type Ev = {kind:'click'; x:number} | {kind:'focus'}— not{isClick:boolean; x?:number}. Exhaustiveswitchonkindturns missing cases into compile errors. satisfiesfor configuration literals.{...} satisfies Configkeeps literal inference while checking the shape.- Parse, don't validate, at boundaries. External data (JSON, env, CLI args, API responses) passes through one parsing function returning a typed result; downstream code takes the parsed type, never
anyre-cast.unknownin, typed out. - Brand primitives that carry meaning.
type SessionId = string & {__brand:'SessionId'}when mixing twostrings is a realistic bug. - No non-null assertions on external data.
!is allowed only where a check on a previous line proves the value; at boundaries it is a runtime crash with compile-time approval. - Return types that prevent misuse. A function that can fail returns a result union, not
Tplus a thrown maybe; callers must handle both arms to compile. readonlyby default on shared shapes, mutation as an explicit opt-in.
Reviewing
When reviewing TS, the question per diff hunk is not "does it compile" but
"which illegal state did this type just permit" — flag flags-over-unions,
boundary anys, and unbranded overlapping primitives.
Rules
- Discipline applies at the boundary and the domain model; inside a single function, pragmatism wins.
- Never introduce a type abstraction with one caller and no second one
coming (
minimal-code-discipline).
How can the creator link this skill?
Add the canonical catalog link to the repository README so users can inspect current installs and available audits. The publishing guide covers the complete discovery path.
<a href="https://skillzs.dev/skills/yeachan-heo/oh-my-claudecode/typescript-best-practices">View typescript-best-practices on skillZs</a>