Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Typescript?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/vectora-os-typescript)
---
name: typescript
description: TypeScript — strict configuration, modelling with discriminated unions and branded types, narrowing, generics with constraints, avoiding any, runtime validation at boundaries (zod or similar), module resolution, type-level testing. Use for TypeScript code design and review (TypeScript, types, strict mode, generics, discriminated unions).
metadata:
category: languages-frameworks
---
# TypeScript
## Purpose
Use the type system to make invalid states unrepresentable.
**Use when:** writing or reviewing TypeScript.
**Not for:** replacing runtime validation at trust boundaries.
## Inputs
- Code, tsconfig.
## Outputs
- Typed code, tsconfig recommendations.
## Read first
- [Project Brain](../../../project-brain/README.md) — `npm run brain -- query "typescript"` for prior decisions, patterns and anti-patterns.
## Steps
1. **Config.** Enable `strict`, `noUncheckedIndexedAccess`, `exactOptionalPropertyTypes` where feasible.
Done when strict flags on.
2. **Model.** Discriminated unions for states; branded types for ids.
Done when impossible states fail to compile.
3. **Boundaries.** Validate external input at runtime and infer types from schemas.
Done when no unchecked casts from input.
4. **Hygiene.** Ban `any`; use `unknown` and narrow.
Done when lint enforces.
## Best practices
- Exhaustive `switch` with `never` checks.
- Prefer types inferred from a single schema.
## Common mistakes
- `as` casts to silence errors.
- Optional properties for every field.
## Example
`type Payment = {status:"pending"} | {status:"paid"; paidAt: Date}`; `OrderId` branded; zod schema for webhook payloads.
## Reusable prompt
```text
Apply the TypeScript skill (.agents/skills/typescript/SKILL.md).
Context: {{task card or question; links to PRD, ADRs, code paths}}
Constraints: {{approved thresholds, deadlines, allowed files}}
Review or design the types: strict config, unions for states, branded ids and runtime validation at boundaries.
Return: Typed code, tsconfig recommendations..
Cite evidence (file:line, command output, source) for every claim; list open questions separately.
```