Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

typescript

БесплатноБез исполняемых скриптовНе проверен

WHEN writing or reviewing TypeScript, defining types/schemas, or building type-safe apps; NOT for JavaScript-only files, framework architecture choices, or…

mintuzот mintuz★ 38 звёзд на GitHub

Об этом скилле

TypeScript Best Practices

Schema-first design, strict type safety, and immutable patterns.

Core Principles

  1. Type safety at all boundaries: runtime validation (schemas) plus compile-time safety (TypeScript) (principle-parse-at-the-boundary).
  2. Schema-first at trust boundaries: where data enters the system, define the schema first and derive the type from it (principle-type-system-discipline).
  3. Immutability at the boundary: never mutate a value a caller owns or a value you have already returned. Local mutation is allowed inside the function that created the value, if the value cannot escape before the function returns.
  4. Explicit types: no implicit any; strict mode enabled.
  5. Behaviour over implementation: focus on contracts and outcomes.

Rules for Hard Cases

No schema library is available

A trust boundary still needs a runtime check. When the dependency set is frozen, add no dependency and do not skip the check. Write a decoder that accepts unknown. Narrow each field with typeof, Array.isArray, or a type predicate. Report an invalid value through the failure path the function already contracts, such as a Result variant or a null return (principle-parse-at-the-boundary).

Building a collection in a hot path

Create the accumulator inside the function, append with push or assign by key, and return it under a readonly type. Do not build a growing collection with [...accumulator, item] or { ...accumulator, [key]: value } inside a loop: each step copies the growing accumulator, so the loop becomes quadratic.

The request or a reused helper mutates in place

When a request says "update it in place", or a helper that you must reuse writes into its argument, return a new value and leave the caller's value unchanged. Give a mutating helper only a value that you created, and keep the helper's behaviour unchanged for its other callers. When you return a new value against the request's wording, say so in your answer, and state that neither a documented mutable API nor a measured hot path requires mutation.

When the caller's contract does require mutation through a documented mutable API or a measured hot path, both mutating and returning a new value break a rule. Write neither as the final patch. Name the conflict between that contract and Core Principle 3, and ask the contract's owner to choose (principle-rank-sources-by-authority).

External data that is not fully documented

Validate every field the source documents. Type each undocumented part as unknown; do not guess its field names. State in your answer what the validator does not check, and why, so a reader sees how far validation reaches without reading the code.

An assertion the type system cannot avoid

Never use as to state a fact you have not checked, including a shape that a document, contract, or upstream promise describes. Narrow a value you have just checked with a user-defined type predicate, or with one assertion placed immediately after the check. Name the checked condition in the predicate name or in a comment on the assertion (principle-type-system-discipline, principle-observe-dont-infer).

Reference Guides

Guide Read for
schemas.md Schema-first patterns; when a schema is required vs optional; trust boundary identification; test data factories with schema validation; schema examples (API responses, business validation)
types-interfaces.md Type vs interface; any vs unknown; type assertions; strict mode and tsconfig.json settings
immutability.md Immutability patterns (spread operators); readonly; forbidden array methods; options objects vs positional parameters; boolean parameter anti-patterns; Result types; early returns
utilities.md Branded types for domain concepts; built-in utility types (Pick, Omit, Partial, etc.); custom utility types; code smell tables
patterns.md Worked examples: schema-first at trust boundaries; internal types without schemas; schema with test factory; Result type; branded types; immutable array operations; options object

Decision Trees

Should I use a schema?

Does data come from outside the application?
├── Yes → Schema required
└── No → Does it have validation rules (format, range, enum)?
    ├── Yes → Schema required
Полный SKILL.md на GitHub

Установить typescript в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

references/immutability.mdreferences/patterns.mdreferences/schemas.mdreferences/types-interfaces.mdreferences/utilities.md

FAQ

Что делает скилл typescript?

WHEN writing or reviewing TypeScript, defining types/schemas, or building type-safe apps; NOT for JavaScript-only files, framework architecture choices, or bundler configuration; outputs strict, schema-first, production-ready code.

Как установить скилл typescript?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл typescript запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

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

Сравнить typescript с