К основному содержанию
скилл CX Codex

migrate-js-to-modern-typescript — скилл для Claude Code: установка

Скилл migrate-js-to-modern-typescript пошагово переводит проект с JavaScript на строгий TypeScript, настраивает tsconfig и помогает отказаться от any без поломки сборки.

MIT 145 установок ★ 227 обновлён 2026-08-15

Установить в Claude Code · Через Skills CLI (Vercel) Все способы и платформы ↓
npx skills add pproenca/dot-skills --skill migrate-js-to-modern-typescript -a claude-code
Открыть на GitHub

Что делает migrate-js-to-modern-typescript

Скилл содержит 42 правила в 7 категориях для постепенного перевода кодовой базы на TypeScript. Вместо рискованной разовой переписки агент ведёт миграцию поэтапно. Он начинает с настройки tsconfig через параметры allowJs и checkJs, а затем включает флаги строгости вроде noImplicitAny и strictNullChecks.

Процесс идёт от листьев графа зависимостей к корню. Скилл заменяет any и небезопасные приведения через as на тип unknown с последующим сужением. Заодно агент переводит CommonJS в ESM и прототипы в классы. Для внешних данных из JSON или переменных окружения правила требуют обязательной валидации на границах выполнения.

Если начать конвертацию сверху вниз, зависимости придётся типизировать повторно. Поэтому скилл выстраивает строгую последовательность и оставляет сборку зелёной на каждом шаге.

Какие задачи решает

  • настроить пошаговую миграцию с JavaScript на TypeScript без остановки сборки
  • включить строгие флаги компилятора noImplicitAny и strictNullChecks
  • заменить any и небезопасные приведения типов на unknown с проверками
  • перевести модули CommonJS на синтаксис ESM

Примеры запросов агенту

  • Переведи модуль utils/format.js на TypeScript и добавь строгие типы
  • Включи strict mode в tsconfig и помоги исправить первые ошибки компиляции
  • Замени все приведения as и типы any в файле src/api.ts на безопасный unknown

Как установить migrate-js-to-modern-typescript

1Через Skills CLI (Vercel)

npx skills add pproenca/dot-skills --skill migrate-js-to-modern-typescript -a claude-code

2Вручную: положить файлы

~/.claude/skills/migrate-js-to-modern-typescript/SKILL.md

Папка скилла целиком; для одного проекта — .claude/skills/migrate-js-to-modern-typescript/

По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов

Вопросы о migrate-js-to-modern-typescript

Как установить migrate-js-to-modern-typescript в Claude Code?

Выполните команду npx skills add pproenca/dot-skills --skill migrate-js-to-modern-typescript -a claude-code в терминале.

Что делает скилл migrate-js-to-modern-typescript?

Он предоставляет агенту инструкцию из 42 правил для постепенного перевода JavaScript-проекта на строгий TypeScript. Правила разделены на 7 приоритетных категорий, от настройки tsconfig до адаптации CI.

В каком порядке скилл рекомендует переводить файлы?

Миграция начинается с листьев графа зависимостей и движется внутрь к зависящим от них модулям. Такой порядок исключает двойную работу над типами одних и тех же файлов.

Исходный текст

SKILL.md · MIT
---
name: migrate-js-to-modern-typescript
description: Migrating a JavaScript codebase to TypeScript — converting .js files to .ts, adding types to existing JS, or tightening a loosely-typed TS project toward strict mode. Covers tsconfig and allowJs strategy, incremental strict-flag ratcheting (noImplicitAny, strictNullChecks, noUncheckedIndexedAccess), typing public surfaces, replacing `any` and unsafe casts with `unknown` and narrowing, validating runtime boundaries (JSON, env, API responses), converting CommonJS to ESM and prototypes to classes, and the build/CI changes a migration needs. Trigger even when the user only says "add types", "turn on strict mode", or "convert this file to TypeScript", and especially on a mixed JS/TS repo. Distinct from general TypeScript refactoring — this is the migration act itself, performed file by file while keeping the build green.
---
# JavaScript to TypeScript Migration Best Practices

Guide for taking a JavaScript codebase to strict, modern TypeScript without a big-bang rewrite. Contains 42 rules across 7 categories, prioritized by impact to drive an incremental, file-by-file migration that keeps the build compiling at every step.

## When to Apply

Reference these guidelines when:
- Converting a `.js` codebase to `.ts` (whole project or one module at a time)
- Adding types to existing JavaScript via JSDoc or annotations
- Choosing a `tsconfig` and `allowJs` strategy for a mixed JS/TS repo
- Turning on `strict` mode or individual strict flags on a large codebase
- Replacing `any`, `as` casts, and `!` assertions left over from a quick conversion
- Validating external data (JSON, env, API responses) so the types you wrote are true at runtime
- Converting CommonJS to ESM, prototypes to classes, and other JS idioms to TS
- Updating the build, runner, and CI to type-check and publish TypeScript

## How the Migration Flows

```
tsconfig & strategy → strictness ratchet → type the surfaces → kill any/casts
   → validate runtime boundaries → convert JS idioms → tooling/build/CI
```

Decisions at the front cascade: a wrong `tsconfig` or a top-down conversion order forces you to re-type modules twice, and an early `any` flood poisons everything downstream. Work from the front of this pipeline and from the leaves of the dependency graph inward.

## Rule Categories by Priority

| Priority | Category | Impact | Prefix |
|----------|----------|--------|--------|
| 1 | Migration Setup & tsconfig | CRITICAL | `setup-` |
| 2 | Strictness Ratcheting | CRITICAL | `strict-` |
| 3 | Typing Public Surfaces | HIGH | `surface-` |
| 4 | Replacing `any` & Unsafe Casts | HIGH | `unsafe-` |
| 5 | Runtime Data Validation | MEDIUM-HIGH | `runtime-` |
| 6 | JS-to-TS Idiom Conversion | MEDIUM | `idiom-` |
| 7 | Tooling & Build Migration | LOW-MEDIUM | `tooling-` |

## Quick Reference

### 1. Migration Setup & tsconfig (CRITICAL)

- [`setup-allowjs-checkjs-bridge`](references/setup-allowjs-checkjs-bridge.md) — Enable allowJs and checkJs for incremental migration
- [`setup-migrate-leaves-first`](references/setup-migrate-leaves-first.md) — Convert dependency leaves before their dependents
- [`setup-jsdoc-before-rename`](references/setup-jsdoc-before-rename.md) — Type JS with JSDoc and @ts-check before renaming
- [`setup-prefer-ts-expect-error`](references/setup-prefer-ts-expect-error.md) — Prefer @ts-expect-error over @ts-ignore for suppressions
- [`setup-skiplibcheck-during-migration`](references/setup-skiplibcheck-during-migration.md) — Set skipLibCheck to silence third-party type noise
- [`setup-modern-module-resolution`](references/setup-modern-module-resolution.md) — Set module and moduleResolution to a modern pair
- [`setup-noemitonerror-isolatedmodules`](references/setup-noemitonerror-isolatedmodules.md) — Enable isolatedModules and noEmitOnError for safe output

### 2. Strictness Ratcheting (CRITICAL)

- [`strict-enable-flags-incrementally`](references/strict-enable-flags-incrementally.md) — Enable strict flags one at a time, not all at once
- [`strict-prioritize-null-checks`](references/strict-prioritize-null-checks.md) — Prioritize strictNullChecks for the highest bug yield
- [`strict-no-implicit-any`](references/strict-no-implicit-any.md) — Enable noImplicitAny to surface every untyped value
- [`strict-no-unchecked-indexed-access`](references/strict-no-unchecked-indexed-access.md) — Enable noUncheckedIndexedAccess for index safety
- [`strict-use-unknown-in-catch`](references/strict-use-unknown-in-catch.md) — Type caught errors as unknown, not any
- [`strict-exact-optional-property-types`](references/strict-exact-optional-property-types.md) — Separate missing from undefined with exactOptionalPropertyTypes

### 3. Typing Public Surfaces (HIGH)

- [`surface-annotate-exported-signatures`](references/surface-annotate-exported-signatures.md) — Annotate exported function signatures explicitly
- [`surface-replace-jsdoc-with-types`](references/surface-replace-jsdoc-with-types.md) — Replace JSDoc type tags with real annotations
- [`surface-type-default-params`](references/surface-type-default-params.md) — Type default and optional parameters precisely
- [`surface-interface-for-object-args`](references/surface-interface-for-object-args.md) — Convert loose object arguments to named interfaces
- [`surface-type-callbacks`](references/surface-type-callbacks.md) — Type callback and higher-order parameters
- [`surface-type-class-fields`](references/surface-type-class-fields.md) — Declare class field types instead of relying on assignment

### 4. Replacing any & Unsafe Casts (HIGH)

- [`unsafe-prefer-unknown-over-any`](references/unsafe-prefer-unknown-over-any.md) — Replace any with unknown at untrusted boundaries
- [`unsafe-eliminate-as-casts`](references/unsafe-eliminate-as-casts.md) — Replace as casts with narrowing or validation
- [`unsafe-avoid-double-assertion`](references/unsafe-avoid-double-assertion.md) — Avoid double assertions that force unrelated types
- [`unsafe-type-dynamic-property-access`](references/unsafe-type-dynamic-property-access.md) — Type dynamic property access with Records or index signatures
- [`unsafe-replace-function-type`](references/unsafe-replace-function-type.md) — Replace the Function type with specific call signatures
- [`unsafe-narrow-instead-of-nonnull`](references/unsafe-narrow-instead-of-nonnull.md) — Narrow values instead of using the non-null assertion

### 5. Runtime Data Validation (MEDIUM-HIGH)

- [`runtime-validate-external-data`](references/runtime-validate-external-data.md) — Validate external data at the boundary
- [`runtime-type-environment-variables`](references/runtime-type-environment-variables.md) — Parse and type environment variables once
- [`runtime-derive-types-from-schemas`](references/runtime-derive-types-from-schemas.md) — Derive static types from runtime schemas
- [`runtime-type-guards-at-boundaries`](references/runtime-type-guards-at-boundaries.md) — Write type guards for untyped library returns
- [`runtime-type-json-parse`](references/runtime-type-json-parse.md) — Type JSON.parse results through validation

### 6. JS-to-TS Idiom Conversion (MEDIUM)

- [`idiom-require-to-import`](references/idiom-require-to-import.md) — Convert require and module.exports to ESM syntax
- [`idiom-prototype-to-class`](references/idiom-prototype-to-class.md) — Convert prototype constructors to class syntax
- [`idiom-type-only-imports`](references/idiom-type-only-imports.md) — Use import type for type-only imports
- [`idiom-replace-arguments-object`](references/idiom-replace-arguments-object.md) — Replace the arguments object with rest parameters
- [`idiom-enum-to-union-or-const`](references/idiom-enum-to-union-or-const.md) — Convert frozen-object enums to const objects or unions
- [`idiom-default-export-to-named`](references/idiom-default-export-to-named.md) — Prefer named exports over default exports
- [`idiom-optional-chaining-over-guards`](references/idiom-optional-chaining-over-guards.md) — Replace manual existence guards with optional chaining

### 7. Tooling & Build Migration (LOW-MEDIUM)

- [`tooling-declare-untyped-modules`](references/tooling-declare-untyped-modules.md) — Provide ambient declarations for untyped dependencies
- [`tooling-install-types-packages`](references/tooling-install-types-packages.md) — Install @types packages before casting library returns
- [`tooling-use-tsx-over-ts-node`](references/tooling-use-tsx-over-ts-node.md) — Run TypeScript directly with tsx instead of ts-node flags
- [`tooling-emit-declaration-files`](references/tooling-emit-declaration-files.md) — Emit declaration files for migrated libraries
- [`tooling-typecheck-in-ci`](references/tooling-typecheck-in-ci.md) — Add a type-check step to CI separate from the build

## How to Use

Read individual reference files for detailed explanations and code examples:

- [Section definitions](references/_sections.md) — Category structure and impact levels
- [Rule template](assets/templates/_template.md) — Template for adding new rules

## Related Skills

- `typescript-refactor` — Refactoring and modernizing code that is already TypeScript
- `typescript-advanced-patterns` — Advanced type-level patterns once the migration is done

## Reference Files

| File | Description |
|------|-------------|
| [references/_sections.md](references/_sections.md) | Category definitions and ordering |
| [assets/templates/_template.md](assets/templates/_template.md) | Template for new rules |
| [metadata.json](metadata.json) | Version and reference information |

© pproenca · MIT · pproenca/dot-skills

Похожие скиллы

Все скиллы по теме «Код-ревью и рефакторинг» →
typescript-strict-migrator patricio0312rev Скилл typescript-strict-migrator для Claude Code переводит TypeScript-проект на strict по одному флагу после аудита ошибок. Миграция начинается с noImplicitAny, затем включает strictNullChecks и остальные флаги. CX Codex +1 280установок typescript-development sammcj Скилл typescript-development активирует строгую типизацию и лучшие практики TypeScript в Claude Code. Автоматически применяет правила кода для проектов на TypeScript и JavaScript. CX Codex +1 ★ 173звёзд репо experience-lwc-typescript-migrate forcedotcom Скилл experience-lwc-typescript-migrate переводит Lightning Web Component из JavaScript в TypeScript с полной аннотацией типов и .d.ts, который открывает только публичный API компонента. CX Codex +1 2 400установок migrate-to-typescript davila7 Команда migrate-to-typescript для Claude Code переводит JavaScript-проект на TypeScript и настраивает типизацию. Стратегию можно задать аргументом: постепенную, полную, строгую или инкрементальную. CX Codex +1 230установок typescript-patterns oakoss Скилл typescript-patterns учит ИИ-агента сложным приёмам TypeScript в строгом режиме. Он помогает избежать сбоев во время выполнения за счёт проверок на этапе сборки. CX Codex +1 202установок typescript-pro https://github.com/Jeffallan Скилл typescript-pro настраивает строгую типизацию TypeScript, генерирует брендированные типы и связывает tRPC. Пригодится при проектировании надёжных API и сложных generic-структур. CX Codex +1 14 900установок

Из того же набора139

Весь набор →
codebase-comprehension-algorithms Скилл codebase-comprehension-algorithms раскладывает незнакомый репозиторий на функциональные домены: какие файлы стоят за фичей и где проходит архитектурный каркас. CX Codex +1 148установок storybook Помогает настраивать Storybook и писать истории для TypeScript/React-компонентов. Описывает интерактивные тесты, проверку доступности и сборку документации. CX Codex +1 145установок code-map-visualization Скилл code-map-visualization учит агента рисовать карту кодовой базы: какие данные класть на цвет и размер, как уложиться в 16 мс на кадр и не потерять читаемость. CX Codex +1 145установок nuqs-scaffolder Скилл nuqs-scaffolder собирает из одного JSON-описания четыре файла для фильтров в URL на Next.js: карту парсеров, серверный загрузчик, клиентский компонент и тест. CX Codex +1 145установок radical-simplification Скилл radical-simplification для Claude Code разбирает сложные инженерные и продуктовые задачи через смену рамки, упрощение и проверку предположений. Помогает выйти из тупика. CX Codex +1 144установок base-ui-migrator Скилл base-ui-migrator переводит React-компоненты с Radix UI, Headless UI или самописных оверлеев на Base UI (@base-ui/react). Помогает стандартизировать интерфейс без потери стилей. CX Codex +1 144установок implementation-design-patterns-python Скилл implementation-design-patterns-python для Claude Code помогает выбирать и применять паттерны проектирования в современном Python. Он помогает разбираться с разрастающимися ветвлениями, наследованием и связями между объектами. CX Codex +1 143установок better-auth-scaffold Скилл better-auth-scaffold раскладывает Better Auth по файлам в проекте Next.js с App Router и Drizzle: шаблоны, три набора плагинов, генерация схемы и миграции. CX Codex +1 143установок

Спонсоры проекта

Компании, которые помогают держать аналитику открытой