
Teaches you to use TypeScript's type system to make invalid states impossible at compile time. You'll write discriminated unions instead of boolean soup, use branded types to prevent mixing up IDs, and enforce exhaustive switch statements with never checks. The Zod section is practical: schema as source of truth, safeParse for user input, parse at API boundaries. It assumes you know TypeScript syntax already and focuses on patterns that prevent bugs before runtime. If you're still writing types with a bunch of optional fields and crossing your fingers, this will change how you model data.
$ npx -y skills add 0xbigboss/claude-code --skill typescript-best-practices --agent claude-codeInstalls into .claude/skills of the current project.
Follows type-first, functional, and error handling patterns from CLAUDE.md. This skill covers language-specific idioms only.
When working with React components (.tsx, .jsx files or @react imports), always load react-best-practices alongside this skill. This skill covers TypeScript fundamentals; React-specific patterns (effects, hooks, refs, component design) are in the dedicated React skill.
Use the type system to prevent invalid states at compile time.
Discriminated unions for mutually exclusive states:
// Good: only valid combinations possible
type RequestState<T> =
| { status: 'idle' }
| { status: 'loading' }
| { status: 'success'; data: T }
| { status: 'error'; error: Error };
// Bad: allows invalid combinations like { loading: true, error: Error }
type RequestState<T> = {
loading: boolean;
data?: T;
error?: Error;
};
Branded types for domain primitives:
type UserId = string & { readonly __brand: 'UserId' };
type OrderId = string & { readonly __brand: 'OrderId' };
Sponsors