typescript-magician/SKILL.md
Resolves TypeScript type errors, eliminates `any`, and designs advanced generic types. Use when asked about TS types, generics, `infer`, conditional types, mapped types, template literal types, branded types, type narrowing, utility types, or diagnosing type errors. Do not use for runtime JS logic, Node.js APIs, bundler config, or ESLint rules.
npx skillsauth add sanurb/skills typescript-magicianInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Type-level problem solver. Every any is a bug, every loose optional is a risk, every compiler error is a puzzle with one correct fix. The agent reads tsc output, routes to the right pattern via the decision tree, applies the fix, and proves it compiles clean. No guessing — the compiler is the judge.
tsc --noEmit. Read the error. Route to the matching reference using the decision tree below.tsc --noEmit. Zero errors. If errors remain, return to step 1.Problem?
├─ Compiler error → references/error-diagnosis.md
├─ `any` to eliminate
│ ├─ API response / external data → references/type-narrowing.md
│ ├─ Object property access → references/generics-basics.md
│ └─ Function signature → references/function-overloads.md
├─ Design a generic type
│ ├─ Basic constraint / inference → references/generics-basics.md
│ ├─ Extract inner type (`infer`) → references/infer-keyword.md
│ ├─ Conditional type-level logic → references/conditional-types.md
│ ├─ Transform all properties → references/mapped-types.md
│ ├─ String manipulation at type level → references/template-literal-types.md
│ ├─ Deep inference / const params → references/deep-inference.md
│ └─ Fluent / chainable API → references/builder-pattern.md
├─ Prevent value mix-ups (IDs, units) → references/opaque-types.md
├─ Derive types from runtime values
│ ├─ Object literal → references/as-const-typeof.md
│ └─ Array elements → references/array-index-access.md
├─ Model props with coupled optionals → Non-Negotiable #5
├─ Define string/number constants → Non-Negotiable #3
└─ Use built-in utility types → references/utility-types.md
Deliver nothing if any criterion fails.
any in touched code. Replace with unknown + type guard, a generic, or a concrete type.@ts-ignore, @ts-expect-error, or as any.typeof for unions. Derive union types from as const objects, never from direct string/number literals:
const STATUS = { ACTIVE: "active", INACTIVE: "inactive" } as const;
type Status = (typeof STATUS)[keyof typeof STATUS];
never:
type On = { enabled: true; value: number; onChange: (v: number) => void };
type Off = { enabled: false; value?: never; onChange?: never };
type Props = On | Off;
import type for type-only imports. Mixed: import { fn, type T } from "./mod".tsc --noEmit exits 0 after the fix.Every response uses this exact structure:
### Diagnosis
{Root cause — 1-3 sentences. Reference the tsc error code if applicable.}
### Before
{Minimal code showing the problem.}
### After
{Complete fix. Every Non-Negotiable enforced.}
### Verification
`tsc --noEmit` — 0 errors.
Multiple files: one Diagnosis → Before → After block per file. Single Verification block at the end.
development
Sets up an `## Agent skills` block in AGENTS.md/CLAUDE.md and `docs/agents/` so the engineering skills know this repo's issue tracker (GitHub, GitLab, fp, or local markdown), triage label vocabulary, and domain doc layout. Run before first use of `fp-plan`, `fp-implement`, `fp-review`, `to-issues`, `to-prd`, `triage`, `diagnose`, `tdd`, `improve-codebase-architecture`, or `zoom-out` — or if those skills appear to be missing context about the issue tracker, triage labels, or domain docs.
development
Build a throwaway prototype to flush out a design before committing to it. Routes between two branches — a runnable terminal app for state/business-logic questions, or several radically different UI variations toggleable from one route. Use when the user wants to prototype, sanity-check a data model or state machine, mock up a UI, explore design options, or says "prototype this", "let me play with it", "try a few designs".
tools
Control herdr (a terminal-native agent multiplexer) from inside it. Manage workspaces and tabs, split panes, spawn sibling agents, read pane output, and wait for state changes — all via CLI commands that talk to the running herdr instance over a local unix socket. Use when running inside herdr (HERDR_ENV=1). Do not use outside herdr.
documentation
Compact the current conversation into a handoff document for another agent to pick up.