/major-ai-skills:typescriptfrom major-ai-skills
Ship strict TypeScript with sound tsconfig (NodeNext/Bundler), unknown-at-boundaries narrowing, discriminated unions, satisfies, and runtime validation—without silencing errors with any or unsafe assertions.
Ships in major-ai-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
TypeScript adds a structural type system that erases at compile time. The compiler (tsc) and language service enforce contracts; tsconfig.json chooses module resolution, emit, and strictness. Agents prefer precise types over any, model closed states with discriminated unions, validate untrusted input at runtime (types do not exist at runtime), and fix errors at API boundaries instead of silencing them with assertions.
┌─────────────────────────────────────────────────────────────┐
│ TypeScript check → run path │
│ │
│ .ts / .tsx │
│ ├── tsc / IDE language service (types only) │
│ └── emit or noEmit → JS (+ .d.ts) as configured │
│ │
│ Module mode │
│ ├── Node apps: module NodeNext (+ .js extensions in src) │
│ └── Bundler apps: module bundler / preserve (Next/Vite) │
│ │
│ Boundaries │
│ └── unknown → narrow / Zod → typed domain │
└─────────────────────────────────────────────────────────────┘
Use when
tsconfig (strict, NodeNext vs Bundler, noUncheckedIndexedAccess).Do not use when
@nodejs / @express.@prisma (consume generated types here).// @ts-nocheck, global any, or as unknown as T to “make CI green” without fixing the boundary → refuse the silencing; fix or isolate with a typed adapter.strict: true for application code; add noUncheckedIndexedAccess for arrays/records (index → T | undefined).unknown over any at boundaries; narrow before use (or parse with Zod/Valibot).type: 'loading' | 'ok' | 'err').as assertions unless you can state why the compiler cannot prove the truth; prefer satisfies for literal checking without widening.module/moduleResolution NodeNext (relative imports need .js extensions in source); Vite/Next bundlers → Bundler (do not mix conflicting modes).skipLibCheck: true as pragmatism for deps; still type your code correctly.npx tsc --noEmit (and project references in monorepos) before calling typed work done.type Result<T> =
| { ok: true; value: T }
| { ok: false; error: string };
function readUser(json: unknown): Result<{ id: string }> {
if (typeof json !== "object" || json === null) {
return { ok: false, error: "not an object" };
}
if (!("id" in json) || typeof (json as { id: unknown }).id !== "string") {
return { ok: false, error: "id missing" };
}
return { ok: true, value: { id: (json as { id: string }).id } };
}
// Prefer: Zod parse at HTTP edge, then trust inferred type inward
// const User = z.object({ id: z.string().min(1) });
// const user = User.parse(await req.json());
tsconfig.json (Node app — typecheck only):
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"strict": true,
"noUncheckedIndexedAccess": true,
"noEmit": true,
"skipLibCheck": true,
"verbatimModuleSyntax": true,
"isolatedModules": true,
"esModuleInterop": true,
"resolveJsonModule": true
},
"include": ["src"]
}
Bundler / @nextjs apps: use the framework’s generated config; typically moduleResolution: "bundler"—do not force NodeNext relative .js rules into a Webpack/Turbopack graph unless the project already did.
Commands:
npx tsc --noEmit
npx tsc -p tsconfig.json
# monorepo: tsc -b
Pair with @nodejs for runtime ESM/CJS, @express/@nextjs for HTTP frameworks, @prisma for generated DB types.
| Signature | Likely cause | Fix path |
|---|---|---|
Cannot find module './foo' under NodeNext | Missing .js extension in relative import | Import ./foo.js (points at emit); or switch to Bundler mode for bundler apps |
X is possibly undefined on arr[0] | noUncheckedIndexedAccess | Guard / optional chain / definite length check |
| Runtime crash, types green | Trusted as / no runtime parse | Validate unknown at edge (Zod); stop lying with assertions |
Library types “broken” with strict: false | Forked TS expectations | Turn strict on; fix incrementally with paths allowlist if needed |
| Dual package hazard / CJS default import | Wrong interop settings | Align module with package "type"; prefer named ESM exports |
| Emit works locally, Node fails | module/target ≠ runtime | Match Node version; use NodeNext for native ESM |
CI only fails on tsc | IDE using different tsconfig | Pin -p in scripts; same TS version in CI |
export type for type-only exports; with verbatimModuleSyntax, use import type.satisfies for config objects: check shape without widening inferred type.@graphql-apis).@react), type props explicitly; follow team stance on React.FC.any.exactOptionalPropertyTypes and noUncheckedIndexedAccess catch real bugs but increase friction—adopt deliberately.paths) need runtime mirrors (bundler/Node loaders) or they typecheck-only.@nodejs — runtime modules TypeScript compiles to@express / @nextjs — common app hosts and their tsconfig conventions@react — component/hook typing@prisma — generated client types for DB access@graphql-apis — schema-driven types and codegenMANDATORY: Keep
stricton for new app code. Preferunknown+ narrowing (or Zod) overany/as. Alignmodule/moduleResolutionwith Node vs bundler. Runtsc --noEmitbefore declaring typed work complete. Do not “fix” CI by disabling checks globally.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub alivirgo/major-ai-skills --plugin major-ai-skills412 skills in this plugin
/3d-slicerAutomate 3D Slicer research workflows with MRML, VTK/ITK, DICOM data, and Segment Editor. Use for software workflows, not clinical interpretation./abbreviated-git-statusInspect Git branch, staging, and working-tree changes with short or porcelain status output when a compact repository check is needed./ableton-liveAutomate Ableton Live sessions with Python MIDI Remote Scripts, Max for Live, AbletonOSC, and Link synchronization./act-as-a-personal-tutorExplain a subject step by step, assess prior knowledge, and use short exercises to check understanding before advancing.Other plugins' skills for the same job