name: ub-ts description: 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.
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.mdfor archetype selection, tsconfig baselines, and modern typing patterns. - Read
references/ts-legacy-to-modern-migration.mdfor old-to-new migrations, banned patterns, and exception handling. - Read
references/ts-config-resolution.mdwhen local TypeScript config discovery, starter scaffolding, or optional ESLint support matters. - Read
references/task-bundle.mdonly when the target repository wants an optional Task-based automation overlay for this skill's starter profile. - Use
scripts/scaffold_ts_baseline.pywithassets/tsconfig-template/andassets/eslint-template/when a target repository needs a deterministic starter instead of ad hoc config creation.
Skill Coordination
- Co-load this skill with
ub-vuejsorub-nuxtwhen 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 existingtsconfig*.jsonfiles. - Choose module strategy that matches runtime truth:
- Node runtime:
moduleasnode20ornodenext - Bundler runtime:
moduleResolutionasbundlerwithmoduleasesnext - Library publishing: prefer Node-faithful resolution for compatibility checks
- Type-stripping runtime: enforce erasable TypeScript subset
- Node runtime:
- Compare official guidance, repo truth, and observed code reality for non-trivial or version-sensitive recommendations.
- Surface
OFFICIAL_CONFLICTwhen authoritative sources, repo truth, or live code reality materially disagree on a non-trivial recommendation. - Surface
UNVERIFIEDwhen 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,consttype parameters,NoInfer, discriminated unions, explicit boundary typing). - Reject legacy output for new code and apply migration mapping from
references/ts-legacy-to-modern-migration.mdwhen 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.jsonand 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_CONFLICTinstead of silently collapsing the disagreement. - If a non-trivial claim cannot be confirmed in official sources after targeted
research, mark it
UNVERIFIEDor 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.mdor 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
moduleDetectionasforceunless a known compatibility constraint requires otherwise.
Import and Export Hygiene
- Keep
verbatimModuleSyntaxenabled. - Use
import typeandexport typefor type-only symbols. - Keep side-effect imports explicit and resolvable.
Type System Patterns
- Prefer
satisfiesto validate shapes without widening literals. - Prefer
consttype parameters in reusable APIs that benefit from literal preservation. - Use built-in
NoInferwhen inference must be constrained. - Model state with discriminated unions when behavior depends on variants.
- Use
unknownat trust boundaries, then narrow with validation.
Compiler Baseline
- Keep
strict: true. - Keep
noUncheckedIndexedAccess: true. - Keep
exactOptionalPropertyTypes: true. - Enable
isolatedModulesin toolchain-mixed repos. - Enable
isolatedDeclarationsfor declaration-heavy library workflows. - Use
noUncheckedSideEffectImportswhen 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
tsconfigscaffold 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-qualitydecision-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_CONFLICTorUNVERIFIEDwith 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.