UB TS
Overview
Use this skill to enforce latest stable TypeScript modern defaults and patterns across app and library codebases. Generate modern-only output for new code, and allow legacy retention only as a bounded migration exception.
Implement against the detected project TypeScript and runtime truth, but bias
design toward forward-compatible migration rather than compatibility layers or
legacy fallbacks.
Bundled Assets
This skill ships reusable tsconfig starter scaffolding and an optional ESLint
flat-config starter under assets/, plus a deterministic helper under
scripts/.
Use them when a repository wants this house-style starting point and does not
yet have active TypeScript config of its own.
Load References On Demand
- Read
references/ts-modern-patterns.md for archetype selection, tsconfig baselines, and modern typing patterns.
- Read
references/ts-legacy-to-modern-migration.md for old-to-new migrations, banned patterns, and exception handling.
- Read
references/ts-config-resolution.md when local TypeScript config
discovery, starter scaffolding, or optional ESLint support matters.
- Read
references/task-bundle.md only when the target repository wants an
optional Task-based automation overlay for this skill's starter profile.
- Use
scripts/scaffold_ts_baseline.py with assets/tsconfig-template/ and
assets/eslint-template/ when a target repository needs a deterministic
starter instead of ad hoc config creation.
Skill Coordination
- Co-load this skill with
ub-vuejs or ub-nuxt when TypeScript issues live
inside framework projects.
- Defer framework runtime, routing, and app-structure decisions to the sibling
skill that owns them.
Core Workflow
- Detect the project archetype from
package.json, lockfiles, runtime targets, build tooling, and existing tsconfig*.json files.
- Choose module strategy that matches runtime truth:
- Node runtime:
module as node20 or nodenext
- Bundler runtime:
moduleResolution as bundler with module as esnext
- Library publishing: prefer Node-faithful resolution for compatibility checks
- Type-stripping runtime: enforce erasable TypeScript subset
- Compare official guidance, repo truth, and observed code reality for
non-trivial or version-sensitive recommendations.
- Surface
OFFICIAL_CONFLICT when authoritative sources, repo truth, or live
code reality materially disagree on a non-trivial recommendation.
- Surface
UNVERIFIED when a non-trivial claim could not be confirmed in
official sources after targeted research.
- Apply strict safety baseline and module hygiene defaults from
references/ts-modern-patterns.md.
- Implement modern type patterns first (
satisfies, const type parameters, NoInfer, discriminated unions, explicit boundary typing).
- Reject legacy output for new code and apply migration mapping from
references/ts-legacy-to-modern-migration.md when touching existing code.
- Validate with available typecheck, lint, tests, and build commands in the target project.
- If a repository wants this baseline but lacks TypeScript config, scaffold
the bundled starter and explain the remaining repo-local adaptations.
Version & Research Policy
- Target the latest stable release of TypeScript.
- Detect the project's actual TypeScript version from
package.json and lockfiles.
- Use web search to verify current best practices, API availability, and migration guidance against official TypeScript documentation.
- Treat repo truth as the gold implementation standard when deciding what can
actually ship safely in the current project.
- Treat official TypeScript docs as the preferred guidance baseline for
forward-looking design and migration-ready patterns.
- If official guidance and repo truth diverge materially on a non-trivial
recommendation, surface
OFFICIAL_CONFLICT, implement the repo-safe path,
and explain the migration path.
- If official sources disagree with each other on a non-trivial recommendation,
also surface
OFFICIAL_CONFLICT instead of silently collapsing the
disagreement.
- If a non-trivial claim cannot be confirmed in official sources after targeted
research, mark it
UNVERIFIED or avoid presenting it as settled guidance.
- Keep conflict and uncertainty disclosure scoped to non-trivial,
version-sensitive, or contested guidance rather than trivial edits.
- Do not emit beta-only syntax unless the user explicitly requests it.
- When the project's installed version is behind latest stable, note the version gap and recommend an upgrade path.
- Inspect the host repository's
AGENTS.md or equivalent instructions when
present for project-specific version policy and tooling; do not assume it
contains this catalog's defaults.
- Do not hardcode version numbers in generated guidance — keep recommendations evergreen.
Freshness Review
- Volatility: high
- Review recommendation: review on touch and during periodic maintenance, targeting a quarterly rhythm when practical.
- Trigger signals: TypeScript release changes, compiler-flag behavior shifts, new module-resolution guidance, or runtime-platform updates that affect tsconfig strategy.
- Enforcement: advisory only; freshness should inform review priority, not become a blocking requirement by itself.
- Stable core: runtime-faithful module strategy, strict typing, and explicit boundary modeling remain the durable guidance even when compiler defaults evolve.
Implementation Rules
Project Archetype and Modules
- Decide archetype before changing compiler options.
- Keep module settings runtime-faithful, not preference-driven.
- Keep
moduleDetection as force unless a known compatibility constraint requires otherwise.
Import and Export Hygiene
- Keep
verbatimModuleSyntax enabled.
- Use
import type and export type for type-only symbols.
- Keep side-effect imports explicit and resolvable.
Type System Patterns
- Prefer
satisfies to validate shapes without widening literals.
- Prefer
const type parameters in reusable APIs that benefit from literal preservation.
- Use built-in
NoInfer when inference must be constrained.
- Model state with discriminated unions when behavior depends on variants.
- Use
unknown at trust boundaries, then narrow with validation.
Compiler Baseline
- Keep
strict: true.
- Keep
noUncheckedIndexedAccess: true.
- Keep
exactOptionalPropertyTypes: true.
- Enable
isolatedModules in toolchain-mixed repos.
- Enable
isolatedDeclarations for declaration-heavy library workflows.
- Use
noUncheckedSideEffectImports when side-effect imports are present.
Config Resolution And Scaffolding
Treat real project config as the source of truth:
- inspect
tsconfig*.json, eslint.config.*, package.json, and lockfiles
first when they exist
- match local runtime, bundler, and package-manager truth before choosing a
starter
- use the bundled
tsconfig scaffold only when the repository lacks active
config and wants this house-style baseline
- treat the ESLint starter as optional strong-default support for TS repos,
not as universal TypeScript policy
- do not silently install dependencies or mutate CI as part of scaffolding
Tradeoff Handling
- Use the shared
ub-quality decision-analysis baseline for major TypeScript
decisions.
- State TypeScript-specific pros and cons for each option, especially around
correctness, compatibility, DX, and migration cost.
- Default to the safest modern option unless user constraints indicate otherwise.
Legacy-Avoidance Guardrails
- Do not generate legacy experimental decorator patterns for new code.
- Do not generate
namespace-centric architecture for new code.
- Do not rely on implicit type-only import elision.
- Do not use assertion-heavy shortcuts (
as any, chained assertions) where narrowing is possible.
- Do not introduce legacy module ambiguity between ESM and CJS.
Migration-aware exception policy:
- Allow temporary legacy retention only for explicit compatibility constraints in existing code.
- Document exactly what is retained, why it is retained, and the concrete follow-up modernization step.
- Scope each exception narrowly and avoid introducing new dependency on retained legacy behavior.
Output Requirements
When generating or reviewing code, include:
- Environment note: detected archetype, runtime target, and toolchain context.
- Source truth note: detected project version/toolchain reality and any
material gap versus latest stable guidance.
- Version note: TypeScript baseline and any intentional deviations.
- Decision note: chosen module and compiler strategy with one alternative.
- Tradeoff note: concise pros and cons for chosen path and rejected option.
- Legacy note: removed legacy patterns or bounded exceptions with rationale.
- Validation note: what checks were run and outcomes.
- Conflict note when relevant:
OFFICIAL_CONFLICT or UNVERIFIED with a
concise explanation and the implementation consequence.
When this skill is used to scaffold TypeScript config into another repository,
also include:
- which files were created or skipped
- which archetype was chosen and one rejected alternative
- which repo-local settings or dependencies still need adaptation
- the exact next validation command to run
Completion Checklist
- Latest stable TypeScript modern baseline is enforced.
- Project archetype was detected before config or code changes.
- Module strategy matches runtime behavior.
- Strict safety flags are enabled intentionally.
- New code avoids legacy patterns.
- Any retained legacy pattern is documented with a migration path.
- Typecheck and relevant project validations were executed when available.
- Any material official-source conflict or unverified non-trivial guidance is
disclosed explicitly when relevant.
- Any scaffolded baseline was reported as a starter profile rather than silent
repo policy.
1---2name: ub-ts3description: Use this skill for TypeScript typing and compiler configuration in Node, bundler, library, Vue, Nuxt, and other TypeScript projects. Apply it when the task involves tsconfig, module or moduleResolution behavior, compiler flags, emitted types, type errors, project-wide TS modernization, or boundary typing.4---5
6# UB TS
7
8## Overview
9
10Use this skill to enforce latest stable TypeScript modern defaults and patterns across app and library codebases. Generate modern-only output for new code, and allow legacy retention only as a bounded migration exception.
11
12Implement against the detected project TypeScript and runtime truth, but bias
13design toward forward-compatible migration rather than compatibility layers or
14legacy fallbacks.
15
16## Bundled Assets
17
18This skill ships reusable `tsconfig` starter scaffolding and an optional ESLint
19flat-config starter under `assets/`, plus a deterministic helper under
20`scripts/`.
21
22Use them when a repository wants this house-style starting point and does not
23yet have active TypeScript config of its own.
24
25## Load References On Demand
26
27- Read `references/ts-modern-patterns.md` for archetype selection, tsconfig baselines, and modern typing patterns.
28- Read `references/ts-legacy-to-modern-migration.md` for old-to-new migrations, banned patterns, and exception handling.
29- Read `references/ts-config-resolution.md` when local TypeScript config
30 discovery, starter scaffolding, or optional ESLint support matters.
31- Read `references/task-bundle.md` only when the target repository wants an
32 optional Task-based automation overlay for this skill's starter profile.
33- Use `scripts/scaffold_ts_baseline.py` with `assets/tsconfig-template/` and
34 `assets/eslint-template/` when a target repository needs a deterministic
35 starter instead of ad hoc config creation.
36
37## Skill Coordination
38
39- Co-load this skill with `ub-vuejs` or `ub-nuxt` when TypeScript issues live
40 inside framework projects.
41- Defer framework runtime, routing, and app-structure decisions to the sibling
42 skill that owns them.
43
44## Core Workflow
45
461. Detect the project archetype from `package.json`, lockfiles, runtime targets, build tooling, and existing `tsconfig*.json` files.
472. Choose module strategy that matches runtime truth:
48 - Node runtime: `module` as `node20` or `nodenext`
49 - Bundler runtime: `moduleResolution` as `bundler` with `module` as `esnext`
50 - Library publishing: prefer Node-faithful resolution for compatibility checks
51 - Type-stripping runtime: enforce erasable TypeScript subset
523. Compare official guidance, repo truth, and observed code reality for
53 non-trivial or version-sensitive recommendations.
544. Surface `OFFICIAL_CONFLICT` when authoritative sources, repo truth, or live
55 code reality materially disagree on a non-trivial recommendation.
565. Surface `UNVERIFIED` when a non-trivial claim could not be confirmed in
57 official sources after targeted research.
586. Apply strict safety baseline and module hygiene defaults from `references/ts-modern-patterns.md`.
597. Implement modern type patterns first (`satisfies`, `const` type parameters, `NoInfer`, discriminated unions, explicit boundary typing).
608. Reject legacy output for new code and apply migration mapping from `references/ts-legacy-to-modern-migration.md` when touching existing code.
619. Validate with available typecheck, lint, tests, and build commands in the target project.
6210. If a repository wants this baseline but lacks TypeScript config, scaffold
63 the bundled starter and explain the remaining repo-local adaptations.
64
65## Version & Research Policy
66
67- Target the latest stable release of TypeScript.
68- Detect the project's actual TypeScript version from `package.json` and lockfiles.
69- Use web search to verify current best practices, API availability, and migration guidance against official TypeScript documentation.
70- Treat repo truth as the gold implementation standard when deciding what can
71 actually ship safely in the current project.
72- Treat official TypeScript docs as the preferred guidance baseline for
73 forward-looking design and migration-ready patterns.
74- If official guidance and repo truth diverge materially on a non-trivial
75 recommendation, surface `OFFICIAL_CONFLICT`, implement the repo-safe path,
76 and explain the migration path.
77- If official sources disagree with each other on a non-trivial recommendation,
78 also surface `OFFICIAL_CONFLICT` instead of silently collapsing the
79 disagreement.
80- If a non-trivial claim cannot be confirmed in official sources after targeted
81 research, mark it `UNVERIFIED` or avoid presenting it as settled guidance.
82- Keep conflict and uncertainty disclosure scoped to non-trivial,
83 version-sensitive, or contested guidance rather than trivial edits.
84- Do not emit beta-only syntax unless the user explicitly requests it.
85- When the project's installed version is behind latest stable, note the version gap and recommend an upgrade path.
86- Inspect the host repository's `AGENTS.md` or equivalent instructions when
87 present for project-specific version policy and tooling; do not assume it
88 contains this catalog's defaults.
89- Do not hardcode version numbers in generated guidance — keep recommendations evergreen.
90
91## Freshness Review
92
93- Volatility: high
94- Review recommendation: review on touch and during periodic maintenance, targeting a quarterly rhythm when practical.
95- Trigger signals: TypeScript release changes, compiler-flag behavior shifts, new module-resolution guidance, or runtime-platform updates that affect tsconfig strategy.
96- Enforcement: advisory only; freshness should inform review priority, not become a blocking requirement by itself.
97- Stable core: runtime-faithful module strategy, strict typing, and explicit boundary modeling remain the durable guidance even when compiler defaults evolve.
98
99## Implementation Rules
100
101### Project Archetype and Modules
102
103- Decide archetype before changing compiler options.
104- Keep module settings runtime-faithful, not preference-driven.
105- Keep `moduleDetection` as `force` unless a known compatibility constraint requires otherwise.
106
107### Import and Export Hygiene
108
109- Keep `verbatimModuleSyntax` enabled.
110- Use `import type` and `export type` for type-only symbols.
111- Keep side-effect imports explicit and resolvable.
112
113### Type System Patterns
114
115- Prefer `satisfies` to validate shapes without widening literals.
116- Prefer `const` type parameters in reusable APIs that benefit from literal preservation.
117- Use built-in `NoInfer` when inference must be constrained.
118- Model state with discriminated unions when behavior depends on variants.
119- Use `unknown` at trust boundaries, then narrow with validation.
120
121### Compiler Baseline
122
123- Keep `strict: true`.
124- Keep `noUncheckedIndexedAccess: true`.
125- Keep `exactOptionalPropertyTypes: true`.
126- Enable `isolatedModules` in toolchain-mixed repos.
127- Enable `isolatedDeclarations` for declaration-heavy library workflows.
128- Use `noUncheckedSideEffectImports` when side-effect imports are present.
129
130## Config Resolution And Scaffolding
131
132Treat real project config as the source of truth:
133
1341. inspect `tsconfig*.json`, `eslint.config.*`, `package.json`, and lockfiles
135 first when they exist
1362. match local runtime, bundler, and package-manager truth before choosing a
137 starter
1383. use the bundled `tsconfig` scaffold only when the repository lacks active
139 config and wants this house-style baseline
1404. treat the ESLint starter as optional strong-default support for TS repos,
141 not as universal TypeScript policy
1425. do not silently install dependencies or mutate CI as part of scaffolding
143
144### Tradeoff Handling
145
146- Use the shared `ub-quality` decision-analysis baseline for major TypeScript
147 decisions.
148- State TypeScript-specific pros and cons for each option, especially around
149 correctness, compatibility, DX, and migration cost.
150- Default to the safest modern option unless user constraints indicate otherwise.
151
152## Legacy-Avoidance Guardrails
153
154- Do not generate legacy experimental decorator patterns for new code.
155- Do not generate `namespace`-centric architecture for new code.
156- Do not rely on implicit type-only import elision.
157- Do not use assertion-heavy shortcuts (`as any`, chained assertions) where narrowing is possible.
158- Do not introduce legacy module ambiguity between ESM and CJS.
159
160Migration-aware exception policy:
161
162- Allow temporary legacy retention only for explicit compatibility constraints in existing code.
163- Document exactly what is retained, why it is retained, and the concrete follow-up modernization step.
164- Scope each exception narrowly and avoid introducing new dependency on retained legacy behavior.
165
166## Output Requirements
167
168When generating or reviewing code, include:
169
1701. Environment note: detected archetype, runtime target, and toolchain context.
1712. Source truth note: detected project version/toolchain reality and any
172 material gap versus latest stable guidance.
1733. Version note: TypeScript baseline and any intentional deviations.
1744. Decision note: chosen module and compiler strategy with one alternative.
1755. Tradeoff note: concise pros and cons for chosen path and rejected option.
1766. Legacy note: removed legacy patterns or bounded exceptions with rationale.
1777. Validation note: what checks were run and outcomes.
1788. Conflict note when relevant: `OFFICIAL_CONFLICT` or `UNVERIFIED` with a
179 concise explanation and the implementation consequence.
180
181When this skill is used to scaffold TypeScript config into another repository,
182also include:
183
1841. which files were created or skipped
1852. which archetype was chosen and one rejected alternative
1863. which repo-local settings or dependencies still need adaptation
1874. the exact next validation command to run
188
189## Completion Checklist
190
191- Latest stable TypeScript modern baseline is enforced.
192- Project archetype was detected before config or code changes.
193- Module strategy matches runtime behavior.
194- Strict safety flags are enabled intentionally.
195- New code avoids legacy patterns.
196- Any retained legacy pattern is documented with a migration path.
197- Typecheck and relevant project validations were executed when available.
198- Any material official-source conflict or unverified non-trivial guidance is
199 disclosed explicitly when relevant.
200- Any scaffolded baseline was reported as a starter profile rather than silent
201 repo policy.