Automated summary
This skill helps design advanced generic types, replace `any` with strict typing, write type guards, and resolve TypeScript compiler errors.
Strengths
- A structured two-pass `tsc --noEmit` workflow that captures errors before changes and verifies the fix afterwards
- Broad coverage of advanced TypeScript: conditional types, `infer`, mapped types, template literal types, branded types, and module augmentation
- Concrete before/after examples, including removing `any` from a helper and narrowing an `unknown` API response with a type guard
- Encourages explaining the type theory behind a problem and offering several approaches instead of a single patch
Limitations
- Assumes a project with `tsc` and a strict config; offers little value on plain JavaScript
- Very advanced type gymnastics can hurt readability and compile times unless the skill is kept in scope
- No mention of compile-time type assertion tooling such as `tsd` or `expect-type` to lock in behavior
Use it whenever a task involves complex generics, stubborn TypeScript compile errors, or removing `any` across an existing codebase.
Skip it for untyped JavaScript code or when the real problem is runtime architecture rather than the type system.
Security analysis
SafeThe skill contains only TypeScript guidance and examples. Its only executable instruction is running `tsc --noEmit`, a read-only type-checking command that is non-destructive and does not touch the network or secrets. No obfuscation, exfiltration, destructive file operations, or safety-disabling behavior is present.
No concerns found
How this analysis is madeExamples
My getProperty(obj: any, key: string) helper returns any and I've lost all inference. Rewrite it as a properly constrained generic so getProperty({name: 'Alice'}, 'name') is inferred as string, then run tsc --noEmit to confirm.Remove every `any` from src/api/*.ts. For each fetch response build an `unknown`-based type guard, validate the shape before returning, and show me the before/after types.This mapped type with infer and template literal keys resolves to never for nested objects — explain the distribution and variance rules at play and give me two alternative strict solutions with type tests.name: typescript-magician
description: 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.
metadata:
tags: typescript, types, generics, type-safety, advanced-typescript
When to use
Use this skill for:
- TypeScript errors and type challenges
- Eliminating
anytypes from codebases - Complex generics and type inference issues
- When strict typing is needed
Instructions
When invoked:
- Run
tsc --noEmitto capture the full error output before making changes - Identify the root cause of type issues (unsound inference, missing constraints, implicit
any, etc.) - Craft precise, type-safe solutions using advanced TypeScript features
- Eliminate all
anytypes with proper typing — validate each replacement still satisfies call sites - Confirm the fix compiles cleanly with a second
tsc --noEmitpass
Capabilities include:
- Advanced generics and conditional types
- Template literal types and mapped types
- Utility types and type manipulation
- Brand types and nominal typing
- Complex inference patterns
- Variance and distribution rules
- Module augmentation and declaration merging
For every TypeScript challenge:
- Explain the type theory behind the problem
- Provide multiple solution approaches when applicable
- Show before/after type representations
- Include comprehensive type tests
- Ensure full IntelliSense support
Quick Examples
Eliminating any with generics
Before
function getProperty(obj: any, key: string): any {
return obj[key];
}
After
function getProperty<T, K extends keyof T>(obj: T, key: K): T[K] {
return obj[key];
}
// getProperty({ name: "Alice" }, "name") → inferred as string ✓
Narrowing an unknown API response
Before
async function fetchUser(): Promise<any> {
const res = await fetch("/api/user");
return res.json();
}
After
interface User { id: number; name: string }
function isUser(value: unknown): value is User {
return (
typeof value === "object" &&
value !== null &&
"id" in value &&
"name" in value
);
}
async function fetchUser(): Promise<User> {
const res = await fetch("/api/user");
const data: unknown = await res.json();
if (!isUser(data)) throw new Error("Invalid user shape");
return data;
}
Reference
Read individual rule files for detailed explanations and code examples:
Core Patterns
- rules/as-const-typeof.md - Deriving types from runtime values using
as constandtypeof - rules/array-index-access.md - Accessing array element types using
[number]indexing - rules/utility-types.md - Built-in utility types: Parameters, ReturnType, Awaited, Omit, Partial, Record
Advanced Generics
- rules/generics-basics.md - Fundamentals of generic types, constraints, and inference
- rules/builder-pattern.md - Type-safe builder pattern with chainable methods
- rules/deep-inference.md - Achieving deep type inference with F.Narrow and const type parameters
Type-Level Programming
- rules/conditional-types.md - Conditional types for type-level if/else logic
- rules/infer-keyword.md - Using
inferto extract types within conditional types - rules/template-literal-types.md - String manipulation at the type level
- rules/mapped-types.md - Creating new types by transforming existing type properties
Type Safety Patterns
- rules/opaque-types.md - Brand types and opaque types for type-safe identifiers
- rules/type-narrowing.md - Narrowing types through control flow analysis
- rules/function-overloads.md - Using function overloads for complex function signatures
Debugging
- rules/error-diagnosis.md - Strategies for diagnosing and understanding TypeScript type errors
From the file to a first result
The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.
View the source and supporting filesThis download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.
1. Download the file
Download SKILL.mdFrom the root of a test project, save the file as .skill-downloads/typescript-magician-mrx3xz6k/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.
Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.
mkdir -p '.skill-downloads/typescript-magician-mrx3xz6k' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/typescript-magician-mrx3xz6k/download' --output '.skill-downloads/typescript-magician-mrx3xz6k/SKILL.md.part' && mv '.skill-downloads/typescript-magician-mrx3xz6k/SKILL.md.part' '.skill-downloads/typescript-magician-mrx3xz6k/SKILL.md'2. Check prerequisites
Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.
No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.
The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.
3. Load the skill
After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.
Claude Code
test -f '.skill-downloads/typescript-magician-mrx3xz6k/SKILL.md' && test -s '.skill-downloads/typescript-magician-mrx3xz6k/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/typescript-magician' && cp -R '.skill-downloads/typescript-magician-mrx3xz6k' '.claude/skills/typescript-magician'Cursor
test -f '.skill-downloads/typescript-magician-mrx3xz6k/SKILL.md' && test -s '.skill-downloads/typescript-magician-mrx3xz6k/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/typescript-magician' && cp -R '.skill-downloads/typescript-magician-mrx3xz6k' '.cursor/skills/typescript-magician'Codex
test -f '.skill-downloads/typescript-magician-mrx3xz6k/SKILL.md' && test -s '.skill-downloads/typescript-magician-mrx3xz6k/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/typescript-magician' && cp -R '.skill-downloads/typescript-magician-mrx3xz6k' '.agents/skills/typescript-magician'OpenSkills
OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.
Official OpenSkills installationopenskills install './.skill-downloads/typescript-magician-mrx3xz6k'openskills read 'typescript-magician-mrx3xz6k'Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.
For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.
openskills syncManual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.
4. Try a first task
Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:
Read .skill-downloads/typescript-magician-mrx3xz6k/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.
React Hook Form Best Practices
Development
Master React Hook Form: avoid anti-patterns, manage subscriptions, and handle reset, dirty state, and controlled inputs correctly.
Emotion to Mantine Migration
Development
Migrate Emotion styled-components to Mantine components with style props and CSS modules. Use when converting .styled.tsx files or removing @emotion imports.
Scope Creep Detector
Development
Analyzes git diffs against a stated intent to detect scope creep, unrelated files, broad PRs, and oversized changes, then suggests keep, split, or justify actions.