Catalogue / typescript-development
typescript-development
MITSignedTypeScript standards for snippets, scripts, libraries, browser apps, Node.js services, and CLIs: class-first modules, strict typing, typed lint, pnpm, module formats, and tests. Use when writing, refactoring, or reviewing TypeScript.--- name: typescript-development description: >- TypeScript standards for snippets, scripts, libraries, browser apps, Node.js services, and CLIs: class-first modules, strict typing, typed lint, pnpm, module formats, and tests. Use when writing, refactoring, or reviewing TypeScript. ---
TypeScript Development
Deliver cohesive modules, explicit contracts, and reproducible checks. Preserve the repository's supported consumers and established tooling; use the defaults below for new work.
Select scope
| Mode | Use when | Deliver | | --- | --- | --- | | OneOff | Inline answer or quick expression | Short typed snippet, no scaffold | | Script | Reusable single-file utility | Checked script and pinned repository-local dependencies when needed | | FullProject | Library, application, CLI, or multiple modules | Source in src/, tests, package metadata, lockfile, runnable checks |
Infer the smallest sufficient mode and target: Library, Browser, Service, or CLI. Inspect existing scripts, lockfile, runtime support, module format, framework, and public API before changing configuration. A narrow edit does not authorize a toolchain migration.
Core rules
Design
- Prefer classes for stateful services and application orchestration; use readonly value objects and narrow injected interfaces. Pure functions are appropriate for stateless transformations, parsers, and framework callbacks. Avoid artificial utility classes.
- Group by cohesive domain or feature. Keep domain logic independent of transport, filesystem, CLI, and framework adapters; wire implementations at the entry point. Prefer composition over inheritance.
- Keep imports free of startup, network, and filesystem side effects. No shared module-level mutable state. Use early guards and shallow control flow; split a method before nesting exceeds three levels.
- Validate external data once at each trust boundary, then enforce domain invariants where they belong. Keep parsing, I/O, and business logic separate.
Types
- Enable
strict,noUncheckedIndexedAccess,exactOptionalPropertyTypes,noImplicitOverride, andnoFallthroughCasesInSwitchfor new projects. Check tests and configuration as well as source. - Annotate public signatures and non-contextual parameters/returns; allow clear local inference and contextually typed callbacks. Prefer readonly data, discriminated unions with exhaustive handling, and generics that preserve real relationships.
- Receive JSON, environment, user input, and untyped dependencies as
unknown; validate to domain types. A genericfetch<T>, assertion, orsatisfiesdoes not validate runtime data. - Avoid
any, unsafe assertions, and non-null assertions. Isolate unavoidable external unsafety behind a typed adapter with a reason and tests. Use described@ts-expect-erroronly for a specific known diagnostic or a negative type test; never blanket-disable checks. - Prefer string unions or
as constobjects over new enums. Prefer named exports, type-only imports, and explicit public exports; preserve framework-required defaults and existing compatible API forms.
Tooling and portability
- New package-managed projects: prefer pnpm with an exact
packageManagerversion and committedpnpm-lock.yaml; preserve npm/Yarn in existing repositories. Pin the development runtime separately from the supportedenginesrange. - New comprehensive lint profile: ESLint flat config + typescript-eslint typed rules; Prettier owns formatting,
tscowns type checking. Preserve a working Biome profile when its rules meet the project requirements; do not claim that the compiler fills every typed-lint gap. - Keep lint, format checking, type checking, tests, and build independently runnable. Expose one non-mutating
checktask. Fix commands are separate; never weaken checks to obtain a pass. - Default builds: Vite for bundled browser applications;
tscfor ordinary Node.js libraries/services/CLIs. Use tsx only when useful for development. These runners/bundlers do not replace type checking. - Choose module format, resolution, extensions, runtime APIs, and output target together. Prefer ESM for new compatible projects; retain or explicitly design CommonJS/dual support when consumers require it. See profiles.
- Use local tools and cross-platform scripts. Review lifecycle scripts and dependency-build permissions for the selected manager version; do not silently enable all scripts, install global tools, or add credentials/network permissions.
Behavior and documentation
- Use conventional naming: kebab-case files, PascalCase types/classes, camelCase members; keep framework conventions. Document public contracts with concise TSDoc, especially invariants, failure modes, units, and side effects.
- Catch as
unknown, narrow deliberately, preserve causes, and use specific application error categories when callers need to distinguish them. Never silently suppress errors. - Separate machine output (stdout) from diagnostics (stderr); use an injected structured logger for services. Configure logging once and redact secrets.
- Test public behavior, invalid inputs, and boundaries; inject fake I/O and use temporary directories. Test the built artifact and package exports, not only development execution.
Work and verify
- Select mode/profile; inspect compatibility and read only the relevant references.
- Implement a cohesive vertical slice, including validation and behavior tests.
- Run frozen install when a lockfile already exists, then typecheck, lint, format check, tests, and build using the project's scripts.
- Exercise emitted code or packed consumers on the advertised runtime/module formats. Report exact commands and failures/unverified platforms; do not equate transpilation with successful checks.
- Follow the repository's existing asynchronous mutation-main/release policy with threshold alerts. These quality checks do not establish a new PR gate or authorize publication.
References
| Read | When | | --- | --- | | modes.md | Runtime, package management, module format, browser, workspace, or library decisions | | standards.md | Module boundaries, naming, typing, errors, documentation, and tests | | templates.md | New strict Node.js compiler/linter/task configuration and profile adaptations | | cli-patterns.md | Testable parsing, asynchronous entry points, CLI streams and exit codes | | examples.md | Validated boundary decoder, generic API, and refactoring examples |
Generic project setup, documentation structure, and release workflows belong to their existing skills; this skill owns TypeScript-specific decisions.
| File | Size | SHA-256 |
|---|---|---|
| INTENT.md | 5.4 kB | 41e8750507bb |
| README.md | 914 B | 85ff2b2e3e14 |
| SKILL.md | 6.8 kB | 6de98c221004 |
| SKILVAULT_SOURCE.json | 1.8 kB | 3f6bbeb7e663 |
| THIRD_PARTY_NOTICES.md | 1.1 kB | cc455b6f63ed |
| references/cli-patterns.md | 5.1 kB | 217340fde042 |
| references/examples.md | 3.8 kB | 049fe96ecca5 |
| references/modes.md | 7.0 kB | 1a0d4442d1ea |
| references/standards.md | 7.4 kB | 5868a4cd2578 |
| references/templates.md | 7.0 kB | 0f3540256f44 |
Published verbatim from the pinned commit. Nothing is rewritten.
| Version | Pinned commit | Signed | |
|---|---|---|---|
| 0.1.0 Current | 6aa8826ce406 | 29 Nov 2026 |
Locking a skill to one version needs Pro.