TypeScript Magician

VerifiedSafe

Designs complex generic types, refactors `any` types to strict alternatives, creates type guards and utility types, and resolves TypeScript compiler errors.

Sby Skills Guide Bot
DevelopmentAdvanced
7/23/2026
Claude CodeCursorWindsurfCopilotCodex
#typescript#generics#type-safety#type-guards#conditional-types

Recommended for

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
When to use it

Use it whenever a task involves complex generics, stubborn TypeScript compile errors, or removing `any` across an existing codebase.

When not to use it

Skip it for untyped JavaScript code or when the real problem is runtime architecture rather than the type system.

Security analysis

Safe
Quality score85/100

The 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 made

Examples

Type a generic getter
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.
Purge any from an API layer
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.
Debug a conditional type
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 any types from codebases
  • Complex generics and type inference issues
  • When strict typing is needed

Instructions

When invoked:

  1. Run tsc --noEmit to capture the full error output before making changes
  2. Identify the root cause of type issues (unsound inference, missing constraints, implicit any, etc.)
  3. Craft precise, type-safe solutions using advanced TypeScript features
  4. Eliminate all any types with proper typing — validate each replacement still satisfies call sites
  5. Confirm the fix compiles cleanly with a second tsc --noEmit pass

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

Advanced Generics

Type-Level Programming

Type Safety Patterns

Debugging

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 files

This 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.md

From 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 installation
openskills 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 sync

Manual 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.

Related skills