Back to Skills

typescript-magician

Designs complex generic types, refactors `any` types to strict alternatives, creates type guards and utility types, and resolves TypeScript compiler errors. Use when the user asks about TypeScript (TS) types, generics, type inference, type guards, removing `any` types, strict typing, type errors, `infer`, `extends`, conditional types, mapped types, template literal types, branded/opaque types, or utility types like `Partial`, `Record`, `ReturnType`, and `Awaited`.

1,851stars150forksUpdated 7/5/2026

Security Assessment

Low Risk(85/100)

Detected risks:

Secret Exposure([rules/opaque-types.md] Password =)
Security Score85/100

About typescript-magician

A focused assistant for advanced TypeScript typing work: designing complex generic types, refactoring away any, building type guards and utility types, and resolving stubborn compiler errors. It is the right tool when a task involves generics, type inference, conditional or mapped types, template literal types, branded or opaque types, infer and extends, or utility types like Partial, Record, ReturnType, and Awaited - in short, whenever the type system itself is the problem.

The working method is disciplined and verification-first. It begins by running tsc --noEmit to capture the complete error output, identifies the root cause such as unsound inference, missing constraints, or implicit any, crafts a precise type-safe fix, replaces every any while confirming each change still satisfies its call sites, and finishes with a second tsc --noEmit pass to prove the code compiles cleanly. For each challenge it aims to explain the underlying type theory, offer multiple approaches where they exist, show before and after type representations, include type tests, and preserve full IntelliSense.

Its declared capabilities span advanced generics and conditional types, template literal and mapped types, utility-type manipulation, brand and nominal typing, complex inference patterns, variance and distribution rules, and module augmentation with declaration merging. Short worked examples illustrate the style - rewriting an any-based property getter into a generic constrained by keyof, and narrowing an unknown API response through a user-defined type guard before returning it. Deeper explanations live in a library of individual rule files grouped into core patterns, advanced generics, type-level programming, type-safety patterns, and error diagnosis, so a specific technique such as conditional types, the infer keyword, opaque types, or function overloads can be consulted on demand. The result is stricter, sounder types without sacrificing developer ergonomics.

FAQ

How does the workflow begin and end?

It starts by running tsc --noEmit to capture the full error output before any change, and finishes with a second tsc --noEmit pass to confirm the fix compiles cleanly.

Can it remove `any` types from a codebase?

Yes, that is a core use. It replaces any with proper typing such as generics, type guards, and unknown narrowing, validating that each replacement still satisfies its call sites.

Which advanced TypeScript features does it cover?

It covers advanced generics and conditional types, template literal and mapped types, brand/nominal typing, the infer keyword, function overloads, and utility types like Partial, Record, ReturnType, and Awaited.

Does it explain the reasoning behind a fix?

Yes. For each challenge it explains the underlying type theory, offers multiple solution approaches where applicable, shows before/after types, and includes type tests.

Where are detailed patterns documented?

In individual rule files grouped by topic, such as conditional-types, infer-keyword, opaque-types, mapped-types, and error-diagnosis, which can be read on demand.

All Files

16 files
rules/array-index-access.md4.8 KB
View
rules/error-diagnosis.md7.7 KB
View
rules/opaque-types.md6.9 KB
View
tile.json0.6 KB
View
rules/conditional-types.md6.9 KB
View
rules/infer-keyword.md7.1 KB
View
rules/utility-types.md6.5 KB
View
rules/as-const-typeof.md4.6 KB
View
rules/function-overloads.md7.4 KB
View
rules/template-literal-types.md7.3 KB
View
rules/deep-inference.md6.7 KB
View
rules/mapped-types.md7.3 KB
View
SKILL.md4.4 KB
View
rules/builder-pattern.md8.0 KB
View
rules/generics-basics.md6.9 KB
View
rules/type-narrowing.md8.5 KB
View

Install typescript-magician

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill

Repository

mcollina/skills