typescript-best-practices
Write idiomatic TypeScript patterns for clean, maintainable code. Use when writing or refactoring TypeScript classes, functions, modules, or async logic. (triggers: **/*.ts, **/*.tsx, class, function, module, import, export, async, promise)
Best use case
typescript-best-practices is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Write idiomatic TypeScript patterns for clean, maintainable code. Use when writing or refactoring TypeScript classes, functions, modules, or async logic. (triggers: **/*.ts, **/*.tsx, class, function, module, import, export, async, promise)
Teams using typescript-best-practices should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/typescript-best-practices/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How typescript-best-practices Compares
| Feature / Agent | typescript-best-practices | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Write idiomatic TypeScript patterns for clean, maintainable code. Use when writing or refactoring TypeScript classes, functions, modules, or async logic. (triggers: **/*.ts, **/*.tsx, class, function, module, import, export, async, promise)
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
SKILL.md Source
# TypeScript Best Practices ## **Priority: P1 (OPERATIONAL)** ## Implementation Guidelines - **Naming**: Use **`PascalCase`** for Classes/Types/Interfaces, **`camelCase`** for variables/functions, and **`UPPER_SNAKE`** for static constants. - **Functions**: Use **`arrow functions`** for callbacks/logic; **`function declaration`** for top-level exports. Always type **`public API`** returns. - **Modules**: Use **`Named exports`** ONLY to enable better refactoring/auto-imports. - **Async**: Use **`async/await`** with **`Promise.all()`** for parallel execution. Implement **`try-catch`** for error handling; type **`catch(e) as unknown`** and narrow before use. Avoid **`.then().catch()`** chains. - **Classes**: Explicitly use **`private`**, **`protected`**, and **`public`** modifiers. Favor **`composition`** over inheritance and **`dependency injection`** with **`constructor injection`** and interfaces over singletons for testability. - **Type Safety**: Use **`never`** for exhaustiveness checks in switch-cases. - **Optional**: Use **`optional chaining`** (`?.`) and **`nullish coalescing`** (`??`) over manual checks. - **Imports**: Enforce **`external packages → internal modules → relative imports`** order automatically via **`eslint-plugin-import`**. Use **`import type`** for interfaces/types to ensure better tree-shaking and zero runtime overhead. - **Validation**: Use **`Zod`** or **`Tsoa`** for runtime boundary validation. ## Anti-Patterns - **No Default Exports**: Use named exports. - **No Implicit Returns**: Specify return types. - **No Unused Variables**: Enable `noUnusedLocals`. - **No `require`**: Use ES6 `import`. - **No Empty Interfaces**: Use `type` or non-empty interface. - **No `any`**: Use `unknown` or a specific type. - **No Unsafe Mocks**: Cast with `jest.Mocked<T>` or `as unknown as T`. - **No eslint-disable**: Fix root cause; never suppress warnings. ## References See [references/examples.md](references/examples.md) for Immutable Interfaces, Exhaustiveness Checking, Assertion Functions, DI Patterns, and Import Organization.
Related Skills
swift-best-practices
Apply Guard, Value Types, Immutability, and Naming conventions in Swift. Use when writing idiomatic Swift using guard, value types, immutability, or naming conventions. (triggers: **/*.swift, guard, let, struct, final)
spring-boot-best-practices
Apply core coding standards, dependency injection, and configuration for Spring Boot 3. Use when applying Spring Boot 3 coding standards or configuring dependency injection. (triggers: application.properties, **/*Service.java, autowired, requiredargsconstructor, configuration-properties, slf4j)
react-typescript
Type React components and hooks with TypeScript patterns. Use when typing React props, hooks, event handlers, or component generics in TypeScript. (triggers: **/*.tsx, ReactNode, FC, PropsWithChildren, ComponentProps)
php-best-practices
Write PHP following best practices, PSR standards, and code quality guidelines. Use when writing PHP following PSR standards, SOLID principles, or improving code quality. (triggers: **/*.php, psr-12, camelCase, PascalCase, dry, solid)
kotlin-best-practices
Core patterns for robust Kotlin code including scope functions and backing properties. Use when writing idiomatic Kotlin, choosing between scope functions (let/apply/run/also/with), encapsulating mutable state with backing properties, or exposing read-only collection interfaces. (triggers: **/*.kt, apply, let, run, also, with, runCatching, backing property, MutableList, internal, private set)
JavaScript Best Practices
Idiomatic JavaScript patterns and conventions for maintainable code. Use when writing or refactoring JavaScript following idiomatic patterns and conventions. (triggers: **/*.js, **/*.mjs, module, import, export, error, validation)
java-best-practices
Apply core Effective Java patterns for robust, maintainable code. Use when applying SOLID principles, choosing between inheritance and composition, refactoring Java code smells, or reviewing class design. (triggers: **/*.java, refactor, SOLID, builder, factory, composition, immutable, Optional, checked exception, clean code)
dart-best-practices
Dart code quality conventions: naming, const/final/var hierarchy, single quotes, trailing commas, collection idioms, tear-offs, and import organization. Use when writing new Dart code or reviewing for style violations — wrong import style, global variables, var misuse, anonymous lambdas where tear-offs fit, or missing trailing commas. (triggers: **/*.dart, naming, convention, trailing comma, import, tear-off)
typescript-tooling
Development tools, linting, and build config for TypeScript. Use when configuring ESLint, Prettier, Jest, Vitest, tsconfig, or any TS build tooling. (triggers: tsconfig.json, .eslintrc.*, jest.config.*, package.json, eslint, prettier, jest, vitest, build, compile, lint)
typescript-security
Validate input, secure auth tokens, and prevent injection attacks in TypeScript. Use when validating input, handling auth tokens, sanitizing data, or managing secrets and sensitive configuration. (triggers: **/*.ts, **/*.tsx, validate, sanitize, xss, injection, auth, password, secret, token)
typescript-language
Apply modern TypeScript standards for type safety and maintainability. Use when working with types, interfaces, generics, enums, unions, or tsconfig settings. (triggers: **/*.ts, **/*.tsx, tsconfig.json, type, interface, generic, enum, union, intersection, readonly, const, namespace)
common-best-practices
Enforce SOLID principles, guard-clause style, function size limits, and intention-revealing naming across all languages. Use when refactoring for readability, applying clean-code patterns, reviewing naming conventions, or reducing function complexity. (triggers: **/*.ts, **/*.tsx, **/*.go, **/*.dart, **/*.java, **/*.kt, **/*.swift, **/*.py, solid, kiss, dry, yagni, naming, conventions, refactor, clean code)