TypeScript Agent Skill
Strict TypeScript — discriminated unions, branded types, no any.
The Skill
Full content, every format. Copy it, download it, or install with one command.
---
description: Strict TypeScript — discriminated unions, branded types, no any.
homepage: https://yepapi.com/skills/typescript
metadata:
tags: [typescript, types, strict, type-safety]
---
# TypeScript
## Rules
- `strict: true` in tsconfig — non-negotiable
- Discriminated unions over enums: `type Status = "active" | "inactive"` not `enum Status { Active, Inactive }`
- `satisfies` operator for type-safe object literals: `const config = { ... } satisfies Config`
- `as const` for literal types: `const routes = ["/home", "/about"] as const`
- Branded types for IDs: `type UserId = string & { __brand: "UserId" }`
- No `any` — use `unknown` and narrow with type guards
- Generic constraints: `<T extends Record<string, unknown>>` not `<T extends object>`
- `Record<K, V>` over index signatures
- Exhaustive switch with `never`: `default: const _exhaustive: never = value`
- Return types on exported functions (inference for internal)
## Avoid
- `any` anywhere — including `catch (e: any)`
- Numeric enums — use string unions or const objects
- Type assertions (`as Type`) — use type guards instead
- `@ts-ignore` — use `@ts-expect-error` if absolutely necessary
- Non-null assertion (`!`) — handle the null case explicitlyInstall
Why Use the TypeScript Skill?
Without this skill, your AI guesses at typescript patterns. It might hallucinate deprecated APIs, use outdated conventions, or miss best practices entirely. With it, your AI follows a proven ruleset — every suggestion aligns with current standards.
Drop this skill into your project and your AI instantly knows the rules. Better code suggestions, fewer errors, faster shipping.
Try These Prompts
These prompts work better with the TypeScript skill installed. Your AI knows the context and writes code that fits.
"Refactor this code to use strict TypeScript with discriminated unions and branded types"
"Create type-safe utility functions with proper generics and no use of any"
"Build a TypeScript-first API client with inferred types and runtime validation"
TypeScript skill — FAQ
It enforces strict TypeScript with discriminated unions, branded types, and no use of any. Your AI generates fully type-safe code that catches errors at compile time.
Run `npx skills add YepAPI/skills --skill typescript` in your project root. This copies the skill file into your repo where your AI coding tool can read it automatically.
No. The skill enforces strict mode with no implicit any. It uses discriminated unions, branded types, and proper generics to maintain full type safety throughout your codebase.