typescript-best-practices

Applies type-system discipline rules when reading or editing TypeScript files.

Updated Mar 27, 2026
One-click install
npx skills add https://github.com/gmackie/agent-skills --skill typescript-best-practices-gmackie
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: typescript-best-practices
Source: https://github.com/gmackie/agent-skills/tree/main/skills/typescript-best-practices
Command: npx skills add https://github.com/gmackie/agent-skills --skill typescript-best-practices-gmackie

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? TypeScript codebases often accumulate unsafe patterns like any types, unchecked as casts, and loose object shapes that let invalid states compile and crash at runtime. This Skill gives the agent a concrete rule set for writing and reviewing TypeScript so type errors are caught by the compiler instead of in production. ## Core Features & Use Cases - Type modeling rules: Enforces discriminated unions, branded types, and constructive modeling so impossible states cannot be represented. - Safe narrowing guidance: Defines a narrowing hierarchy from discriminant switches down to validated as casts, plus exhaustiveness checks with never. - Boundary discipline: Requires unknown over any for external data and validation at system boundaries, with schema-derived types via Pick/Omit/Parameters. - Use Case: While refactoring a .tsx file, the agent replaces a { loading: boolean; data?: T; error?: string } bag with a discriminated union and adds an exhaustive switch so new variants trigger compile errors. ## Quick Start Review this TypeScript file and apply the typescript-best-practices rules to remove any as casts and model the state with a discriminated union.

Frequently Asked Questions about typescript-best-practices

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Does this TypeScript guidance work with schema-generated types?▼

Yes, it recommends deriving types from generated proto, OpenAPI, GraphQL, or database schema types using Pick, Omit, Parameters, ReturnType, Awaited, and typeof instead of declaring duplicate interfaces that drift when schemas change.