/typescript:typescript-build-referencesfrom typescript
Configures TypeScript project references and incremental builds (tsc -b) with composite tsconfigs and isolatedDeclarations in existing repos or monorepos without breaking the current build.
Ships in typescript. 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.
None: SKILL.md is the whole skill.
Your role is to add a TypeScript build-mode (project reference) graph to an existing repo without breaking its current build, public API, or runtime behavior.
Definition of done. You are finished only when:
build or typecheck script (or every in-scope package's build) runs the new tsc -b graph,workspaces-to-typescript-project-references --check (below) reports no differences, andbuild, typecheck, and full test surface pass with isolatedDeclarations enabled (when it was requested). The full test surface is the root test script plus every other test and API/declaration check the repo defines (§0); the root test is often only a subset.Handwritten node -e / JSON.parse checks, your own validator scripts, and editor diagnostics on JSON files are not verification. The --check run is a required lint in addition to the native build, not a substitute for it.
Configs that merely look right, or a new script that nothing calls, are not a finished migration.
If you truly cannot run something, say so and list exactly what is unverified.
Reference check. In a workspace monorepo (npm/yarn/pnpm/lerna workspaces), check that each package's references match its workspace dependencies with @monorepo-utils/workspaces-to-typescript-project-references, run from the repo root after installing:
npx --yes @monorepo-utils/workspaces-to-typescript-project-references --check: compares each workspace package's tsconfig.json references with the workspace packages it depends on in package.json, and exits 1 if they differ (§3). Add --tsconfigPath <file> if the packages' emission projects aren't named tsconfig.json. Don't add the tool to the repo's dependencies.node_modules is missing or tsc is not found, run the repo's frozen install first, chosen by lockfile:
pnpm install --frozen-lockfile (pnpm-lock.yaml), yarn install --immutable (Yarn 2+ yarn.lock), yarn install --frozen-lockfile (Yarn 1), npm ci (package-lock.json), bun install --frozen-lockfile (bun.lock/bun.lockb).
Don't use --offline, and don't skip the install to "avoid side effects": installing pinned dependencies is required to verify this task. If the install fails, report the error instead of continuing unverified.package.json scripts and the CI workflows for every test and API/declaration check, not just test. Look for test:all, other test:* scripts, unfiltered vitest run/jest, test-runner projects/workspaces that test filters out, and API checks such as test:exports, test:types, api-extractor, tsnapi, tsd, attw, and publint.build and typecheck scripts and every command on that test list, and record the results before changing configs, so you can tell your regressions from pre-existing failures. Skip only projects that genuinely cannot run here (e.g. a browser runner with no browser), and say which.
test:cov, --coverage) need not be run separately.node_modules/.bin/tsc, or the package manager's exec). Don't run npx tsc without the compiler installed: it may offer to install the unrelated tsc package. If a command is waiting for input, answer or stop it; don't leave it running.isolatedDeclarations and ${configDir} need 5.5+. If the repo deliberately pins an older compiler, don't upgrade or downgrade it just to enable an option; keep the references and skip the unsupported option, and say so.lage, nx, turbo, nr, just, ...), per-package scripts, CI workflows, and who produces declarations (tsc, a bundler plugin such as tsdown/rolldown-plugin-dts/tsup/unbuild/vite-plugin-dts, preconstruct, vue-tsc, ...).
Trace root → package command chains to the real compiler invocations. Don't stop at a package script that looks relevant.include/files/exclude, test and tooling files, generated sources, path aliases, and any inherited tsconfig settings (including allowJs/checkJs). Everything that was type-checked before must still be checked after..d.ts files or API reports from the baseline build."files": [], "references": [...]) so tsc -b at the root builds the projects and the root doesn't also check everything itself.composite (which implies declaration), rootDir/outDir or emitDeclarationOnly as appropriate, and its own tsBuildInfoFile if the default location would collide. If a bundler still produces the JavaScript, keep that; the references build only adds declarations and checking.
Keep tests, scripts, and tooling in separate projects (or the existing broad checker) when they have different options; they must still be covered.references from both package manifests (dependencies, peerDependencies, optionalDependencies, workspace links) and actual source imports (including aliases and relative cross-package imports). Check for missing direct edges, not just transitive ones, and for cycles.Package boundaries are hard rules:
rootDir above the package, and never include ../ paths into another package (e.g. ../core/**/component.ts). If package B imports package A's files, by name or by relative path, keep those files in A's project and add a references entry from B to A; tsc -b maps B's imports to A's declarations.isolatedDeclarations errors or to silence "not listed within the file list of project" (TS6307) errors. Annotate them instead (§5). Only tests, demos, scripts, and generated output may stay out of the emission project, and they must still be checked by another project."include": ["src"] or ["."] with exclude for output). If you use globs, list **/*.ts, **/*.tsx, **/*.mts, and **/*.cts: **/*.ts alone silently drops .mts, .cts, and .tsx files, including hand-written .d.mts declarations.include, files, exclude, outDir, rootDir, baseUrl, and tsBuildInfoFile in an inherited config are resolved relative to the config that declares them. A shared ../tsconfig.base.json with "include": ["src"] points at the base directory's src, not each package's. Keep path-bearing settings package-local, or use ${configDir} deliberately (TS 5.5+).extends target must exist. Validate with the compiler, not JSON.parse: tsconfig is JSONC and supports extends arrays.npx --yes @monorepo-utils/workspaces-to-typescript-project-references --check from the repo root. Fix every difference by changing references, never by moving, deleting, or excluding sources. It only compares references with package.json workspace dependencies; check package boundaries, input coverage, composite, and import-only edges yourself (§2).tsc --showConfig -p <project> or tsc -p <project> --listFilesOnly.build or typecheck script run the solution build, e.g. "typecheck": "tsc -b tsconfig.build.json && <existing check>", or put tsc -b inside each in-scope package's build script that the root build already runs.typecheck/build unchanged just to keep the diff small. A new script (types:build, typecheck:build, build:types, ...) that no root script or CI job invokes is not a migration.preconstruct, or similar pipeline with tsc -b; integrate the declaration build into it as a deliberate step.isolatedDeclarations requires declaration or composite. Enabling it is a source migration, not just a config flag: library code usually needs explicit annotations on exported functions, variables, classes, and object members.
tsdown/rolldown-plugin-dts, tsup, unbuild, vite-plugin-dts, preconstruct, vue-tsc, framework tooling) run their own declaration emit with the package's tsconfig, so enabling the flag can break them even when tsc -b passes. After enabling it, run the repo's real build, not only tsc -b.rolldown-plugin-dts switches from the tsc declaration generator to oxc when isolatedDeclarations is on. That changes the emitted .d.ts text (quote style, overload listing, ordering) even when the types are identical, so expect API/declaration snapshot tests to change (§6).--noCheck is a diagnostic only..d.ts contained):
import("…") type, and never widen to any/unknown (§6);import("m").T may now print T.allowJs cannot be specified with isolatedDeclarations): if the library's emission project has no JavaScript inputs, set "allowJs": false on that project and keep any JS files (configs, scripts) checked by a separate project or the existing broad checker.tsconfig (e.g. ts-node, test runners, scripts) may conflict with composite/declaration/isolatedDeclarations (TS5069 and similar). Give those tools a separate transpile/tooling configuration or override instead of removing the option from library emission.isolatedDeclarations enabled in a config that the native build reads while that build still fails.An annotation must describe the type that was inferred, not a looser one.
typeof hover) and copy that.any, any[], unknown, broad assertions, and widening to a supertype. Preserve generics, overloads, literal discriminants, optionality, readonly, writable vs read-only refs (e.g. WritableComputedRef vs ComputedRef), and framework component types..d.ts or API-report output before and after. Compile representative consumers, including existing tests and demos that write to or narrow the exported values.readonly, overload set, or export), fix the annotation. Don't regenerate.import("m").T vs an imported T, member or overload order, whitespace, and omitted default type arguments. If the declaration generator changed, first try keeping the previous generator through the bundler's own option (check its type definitions in node_modules).vitest run --project <name> -u).allowBreaking, api-extractor --local), scoped to that single command, and revert any temporary config change. Never leave an "allow breaking" override enabled in the repo, and never use one when a signature changed.exports/types conditions, aliases, generators, and caches before moving them. Tools like preconstruct own the package's exports/types fields: don't hand-edit them; use the tool's own fix/validate command, and run its install hook (e.g. preconstruct dev) to confirm..d.ts directories, and don't let generated declarations shadow source modules.strict, checkJs, skipLibCheck changes, new excludes, @ts-ignore). Disabling a flag for a tooling-only project is fine; disabling it for the library is not.
Exception: setting "allowJs": false on a declaration-emission project with no JS inputs is required for isolatedDeclarations (TS5053) and is not weakening, as long as the JS files stay checked elsewhere.Run, in order, and record which actually completed:
npx --yes @monorepo-utils/workspaces-to-typescript-project-references --check with no differences.git diff afterwards and revert every change that is not part of the migration (removed casts, rewritten imports, unrelated files).tsc -b --verbose, after removing outputs and build-info), then an immediate second build that reports every project up to date. Its output already shows build order and incrementality; don't add temporary probe edits or exports to test rebuilds.build, typecheck, and full test surface from §0, including the API/declaration snapshot tests (uncached), with isolatedDeclarations enabled, plus any runtime/CLI smoke tests that existed before.In the final message:
tsc -b, and show it passing.test alone as the full suite.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub microsoft/typescript-skills --plugin typescript6 skills in this plugin
/typescript-project-setupHow to set up a new TypeScript project/typescript-publish-typesHow to publish TypeScript declarations from an npm package so consumers actually resolve them. Use this when asked to add types/typings to a package, ship .d.ts files, fix "Could not find a declaration file for module", or make a package's published types resolve correctly./typescript-report-issueInvoke with `/typescript-report-issue`. Skill Version 1.0Other plugins' skills for the same job