Agents

TypeScript strict-mode migration subagent

A Claude Code subagent that turns on TypeScript strict checks one flag at a time and fixes the resulting errors directory by directory with real types, without falling back to `any` or blanket `@ts-ignore`.

Agent in Engineering by AISkillHub Library

What it does

Turning on `"strict": true` in an existing codebase often produces hundreds of errors at once. This subagent works through the migration incrementally so every step is a reviewable, passing change.

**How it works** - Records the current `tsconfig.json` and the baseline error count from `tsc --noEmit`. - Enables one strict-family flag at a time, in an order that keeps diffs manageable: `noImplicitAny`, `strictNullChecks`, `strictFunctionTypes`, `strictBindCallApply`, `strictPropertyInitialization`, `noImplicitThis`, `useUnknownInCatchVariables`, `alwaysStrict`, then replaces them with `"strict": true` once all pass. - Groups errors by directory and fixes one directory at a time, re-running the compiler after each. - Fixes with real types: narrowing, explicit parameter and return types, optional chaining only where `undefined` is a real case, type guards, and `unknown` with validation for external data.

**Rules** - No new `any`. No `@ts-ignore`. When a fix truly needs to wait, it uses `@ts-expect-error` with a short reason, and lists every one in its report so they can be tracked. - Non-null assertions (`!`) only where a runtime invariant guarantees the value, with a comment naming the invariant. - It does not change runtime behavior. If a type error reveals a real bug (for example a possible `undefined` access), it reports it rather than silently changing logic.

**What it will not do** It does not upgrade TypeScript, change module or target settings, or reformat files. For very large codebases it stops after a set number of directories and reports progress, so you can commit in batches.

How to use it

1. Save the file below as `.claude/agents/ts-strict-migrator.md`. 2. Commit your current state so each batch is easy to review. 3. Ask Claude Code: "Use the ts-strict-migrator agent to enable strictNullChecks in src/" or simply "migrate this project to TypeScript strict mode". 4. Review and commit after each batch it reports. Run your test suite between batches. 5. If your project uses a different typecheck command (for example `npm run typecheck` or a per-package `tsc -p`), mention it in the request or in `CLAUDE.md`.

Files

Save each file at the path shown, relative to your project root.

  • .claude/agents/ts-strict-migrator.md3.1 KB

More agents

See all

Get AISkillHub updates in your inbox.

New features as they ship, AI live chat improvements, and the best new listings in the catalog.

Product updates, new features, and guides. Unsubscribe any time.

TypeScript strict-mode migration subagent - AI agent - AISkillHub.dev