typescript-conventions

Enforces TypeScript naming, typing, and file-structure conventions for non-component code.

1|Updated Jan 14, 2024
One-click install
npx skills add https://github.com/Eyhenij/rt-tools --skill typescript-conventions-eyhenij
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript-conventions
Source: https://github.com/Eyhenij/rt-tools/tree/main/.claude/skills/typescript-conventions
Command: npx skills add https://github.com/Eyhenij/rt-tools --skill typescript-conventions-eyhenij

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? TypeScript codebases drift into inconsistent naming, unsafe casts, and oversized files when conventions live only in developers' heads. This Skill encodes the code-structure rules for any .ts file that is not a component, service, directive, pipe, guard, or interceptor, so edits follow the same strict standard every time. ## Core Features & Use Cases - Naming and typing rules: Enforces I/T/E prefixes on interfaces, types, and enums, #field private fields, Source/$ suffixes for subjects and observables, and explicit type annotations everywhere. - Safety constraints: Forbids the two-step as unknown as cast, requires enums for closed value sets, and mandates taking types from the package where they are declared rather than copying them. - File discipline: Caps files at 500 lines, ties deprecation marks to a walk over all consumers, and maps each rule to its enforcing ESLint rule in the repository. - Use Case: When editing a plain utility or mapper file in an Nx/Angular workspace, load this Skill so the AI applies the correct prefixes, avoids forbidden casts, and respects the file-length limit automatically. ## Quick Start Apply the typescript-conventions rules while editing this plain TypeScript file and fix any naming, casting, or file-length violations you find.

Frequently Asked Questions about typescript-conventions

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enforce TypeScript naming conventions with ESLint?

Use custom ESLint rules that require prefixes on declarations: `I` for interfaces, `T` for type aliases, and `E` for enums, raised as errors on all `.ts` files. This Skill documents exactly which rules hold each convention and where they live in the repository.

When should I use an enum instead of a string in TypeScript?

Use an enum whenever a value comes from a closed set, such as tab names, record kinds, or translation keys, so the value is findable and editable in one place. Single addresses or separators without a closed set stay as named file constants.

Why is the `as unknown as` double cast forbidden?

The two-step cast bypasses all type checking and hides mismatches silently. Instead, declare an honest type, narrow with a check, or read fields by shape with `Reflect.get`, marking unavoidable cases with a spot disable and an inline reason.

Does this convention set apply to Angular components and NestJS backend code?

No. Components, services, directives, pipes, guards, and interceptors have their own rules, and NestJS code under `apps/api` uses constructor DI instead of `inject`. This Skill covers only plain `.ts` files with no more specific rule.

What is the maximum file length for TypeScript files?

Files are capped at 500 lines counting everything, including blank lines and comments, enforced by the `max-lines` ESLint rule. Files that predate the rule are tracked by name and leave the exception list only when split.