From mk
Provides strict TypeScript patterns for type safety, null handling, ESLint configuration, and fixing type errors. Auto-activates on .ts/.tsx files.
How this skill is triggered — by the user, by Claude, or both
Slash command
/mk:typescriptWhen to use
Use when writing TypeScript or fixing type errors / configuring strict type safety. Auto-activates on .ts/.tsx files. NOT for framework-specific patterns (see mk:vue / mk:angular / mk:react-patterns).
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
<!-- Improvements over source skills:
Strict TypeScript patterns for type safety, null handling, and modern best practices.
Auto-activate on: .ts, .tsx, .js, .jsx files, type errors, ESLint issues, "fix types", "add types", "TypeScript help"
Explicit: /mk:typescript [concern]
Do NOT invoke for: Vue-specific patterns (use mk:vue), visual design (use mk:frontend-design)
Operates in Phase 3 (Build GREEN). Output supports the developer agent.
npx tsc --noEmit must pass with zero errorsany — use unknown + type guards (security-rules.md)type assertion — use unknown + type guards (security-rules.md)=== null || === undefinedstrict: true, noUncheckedIndexedAccess: truetype imports: import type { X } from 'y'| Don't | Do Instead |
|---|---|
as any or as unknown as X | Proper type narrowing with guards |
if (value) for null check | if (value !== null && value !== undefined) |
export default | export const X / export function X |
Object type | Record<string, unknown> |
| Implicit return types | Explicit return type annotations |
enum (runtime overhead) | as const satisfies or union types |
## TypeScript: {concern}
**Files:** {list of .ts/.tsx files modified}
**Config:** {tsconfig changes if any}
### Changes Applied
{numbered list of type improvements}
### Verification
{tsc --noEmit output — must show 0 errors}
| Reference | When to load | Content |
|---|---|---|
| strict-patterns.md | Type safety work | Null handling, discriminated unions, type guards, utility types |
| review-checklist.md | When reviewing TypeScript code | Prioritized checklist: CRITICAL (security), HIGH (type safety, async, errors), MEDIUM (React, perf) |
| Failure | Recovery |
|---|---|
tsc --noEmit fails after changes | Fix errors before proceeding — never ship with type errors |
| No tsconfig.json found | Suggest creating one with strict config |
| Third-party types missing | npm install @types/{package} |
as cast silences narrowing errors and hides real bugs — value as User tells TS to trust you, not validate; a malformed API response passes the cast and crashes at runtime; use a type guard or Zod parse at the boundary instead.moduleResolution: "bundler" breaks import type in non-bundler contexts — tsconfig moduleResolution: bundler (Vite/esbuild default) allows extensionless imports that Node.js --esm rejects at runtime; flip to nodenext for backend code or keep dual configs per target.noUncheckedIndexedAccess: true makes every array index T | undefined — enabling this flag (required by strict config) means arr[0] is string | undefined not string; code that was type-correct before will error until every indexed access is null-guarded..d.ts files silently adds properties to global types — a declare module 'express' block in any .d.ts in the project augments Express's types globally; two libraries doing this with conflicting shapes cause TS2300 duplicate identifier errors that appear far from the source.type UserId = \user_${string}`is not assignable fromstring; passing a plain stringwhereUserId` is expected fails even though values look identical at runtime; always brand at the input boundary with a parse function.enum generates runtime JS objects, causing tree-shaking failures — enums are not erased; a const enum inside a library published as .js is inlined at compile time but not consumable by projects that don't re-compile the source; use as const satisfies patterns for exported enums.npx claudepluginhub ngocsangyem/meowkit --plugin mkTypeScript discipline for any JavaScript/TypeScript project (frontend + backend): strict mode, type design, generics, narrowing, error types, module resolution, tsconfig hygiene. Apply when the project has `tsconfig.json` and `typescript` in devDependencies. Stack-agnostic — referenced by every JS/TS framework plugin in the marketplace. Use this skill to: - Write types that catch bugs at compile time, not runtime. - Use generics, conditional types, and discriminated unions correctly. - Avoid `any`, `unknown`, and unsafe casts. - Match the project's tsconfig strictness level. - Type third-party libraries (with @types/* or declaration files). Do NOT use this skill for: - Plain JavaScript projects (no tsconfig.json). - Framework-specific type idioms (React component props, Vue defineProps, Angular signals — those live in framework plugins' own conventions skills). - tRPC/Zod runtime-validation specifics — handled by validation libs at the boundary.
Enforces TypeScript type safety with strict mode, no `any`, and discriminated unions. Use when writing or reviewing TypeScript code.
Provides TypeScript best practices for type-safe code including strict mode, interfaces, discriminated unions, generics, async patterns, and null safety. Useful for type definitions and maintainable TS.