writing-typescript
Installation
SKILL.md
TypeScript Development (5.x)
Critical Output Rules
- State strict TypeScript choices explicitly:
strict,noUncheckedIndexedAccess,exactOptionalPropertyTypes, noanyby default, andunknownfor untrusted input. - Validate untrusted API/JSON responses at the boundary before returning typed data.
- Favor composition and small functions/hooks over large classes, global state, or mixed concerns.
- Handle async errors explicitly with
Result/discriminated unions or typed thrown errors at boundaries. - Always mention behavior tests for success and failure paths. For React, include component or user-behavior tests for loading, success, error, and validation states.
- Include verification commands when code changes:
bunx tsc --noEmit,bun test, and lint/format commands when configured. - Keep dependencies minimal; add schema/form libraries only when real complexity beats a small type guard or helper.
- Do not run destructive shell commands. For broad or risky changes, state the risk and ask before acting.
Core Philosophy
Strict-mode-always, interface-vs-type, discriminated unions, flat control flow, the Result-type error pattern, the no-destructive-commands safety rule, and the post-generation verification loop are in references/principles.md — read it before generating code.