Back to skills
SKILL.md
Typescript Patterns
ASecurityType-safe TypeScript: strict mode, discriminated unions, branded types, runtime validation and module boundaries.
- 2 stars
- 0 votes
- 0 copies
- 0 views
- Added December 2, 2026
Security analysis
100/100npx -y skills add karthikrshet/saarthi --skill typescript-patterns --agent claude-codeAre you the author of Typescript Patterns?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/karthikrshet-typescript-patterns)---
name: typescript-patterns
description: "Type-safe TypeScript: strict mode, discriminated unions, branded types, runtime validation and module boundaries."
tags: [typescript]
---
# Typescript Patterns
## When to use
- TypeScript code
## Procedure
1. Enable strict and noUncheckedIndexedAccess
2. Model states as discriminated unions
3. Validate external data at runtime
4. Avoid any; use unknown and narrow
5. Keep modules small with explicit exports
## Example
```ts
type PaymentState =
| { status: 'created'; orderId: string }
| { status: 'captured'; orderId: string; paymentId: string; amountPaise: number }
| { status: 'failed'; orderId: string; reason: string };
```
## Checklist
- [ ] tsc --noEmit clean
## Anti-patterns
- as any casts
- Optional fields for mutually exclusive states
Attribution
Related skills
View all in ai-agents →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.