Skip to content
Back to skills

Typescript

ASecurity

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).

  • 5 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 3, 2026
ai-agentstypescriptrustgotesting

Security analysis

A100/100

Scanned December 3, 2026

npx -y skills add vectora-os/kit --skill typescript --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Typescript?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Typescript
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectora-os-typescript/badge)](https://www.skillsdirectory.com/skills/vectora-os-typescript)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
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.
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.