skills/code-style-typescript/SKILL.md
TypeScript style rules for writing, reviewing, and refactoring `.ts` code. Use when working on TypeScript formatting, semicolon conventions, object layout, function call structure, or interface definitions. Also use when reviewing or writing TypeScript interfaces, type aliases, or any nested object type shapes.
npx skillsauth add perdolique/workflow code-style-typescriptInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
.ts filesFull code examples for all rules are in references/examples.md.
No semicolons at the end of statements.
Exception: TypeScript interfaces, types, and similar type definitions MUST use semicolons as property separators.
// Statements - no semicolons
const result = calculateValue()
// Interfaces - semicolons required
interface User {
id: number;
}
type Config = {
timeout: number;
}
See examples → No semicolons for more.
Extract method calls to separate variables before using them in conditional statements (if, while, for, etc.).
See examples → No method calls.
When checking whether a typed value exists, use explicit comparisons such as value === undefined, value !== undefined, value === null, or value === ''.
Do not rely on truthy/falsy narrowing for presence checks in normal application code.
See examples → Explicit presence checks.
Extract function calls to separate variables before using them as arguments to other functions.
Exception: In rare cases (e.g., validator schemas, DSL configurations, query builders, matcher APIs) when a nested call is necessary for readability, keep it on separate lines. See examples → Nested function calls.
See examples → No function calls as arguments.
One-line const and let declarations should stay together without blank lines. Add a blank line when moving between one-line and multiline declarations, or between separate multiline declarations.
See examples → Group one-line declarations.
Use clear local variable names. Avoid non-obvious abbreviations such as pv, prop, cat, or cfg when a full word is short and clearer.
Well-known technical identifiers such as id, db, URL, and HTML are fine.
See examples → Clear local names.
One-line JSDoc comments should be on the same line with /** and */.
See examples → Inline JSDoc comments.
Shorthand properties come first, then regular properties. Both groups are ordered alphabetically.
const config = {
isActive,
timeout,
apiKey: 'secret-key',
baseUrl: 'https://api.example.com'
}
See examples → Object key ordering for full examples.
Single-key objects and single-item arrays may stay on one line. Objects with more than one key and arrays with more than one item should use one entry per line.
See examples → Expand multi-value literals.
Multiline values in objects should be separated by blank lines.
See examples → Separate multiline object values.
Never use trailing commas in arrays, objects, or other structures.
See examples → No trailing commas.
returnWhen a handler or function needs derived data, compute it in a separate variable first and keep the final return simple and explicit.
Avoid rebuilding objects through ...spread just to replace one field when an explicit object is clearer.
See examples → Derived data before return.
Multiline blocks (if/else, loops, try/catch, functions, etc.) should be separated from other code with blank lines, unless they are at the start or end of a parent block. Add the same blank line before return when earlier statements appear in the same block.
See examples → Separate multiline blocks.
Every interface (and named type alias) must have only one level of named properties. If a property's type is an object shape, extract it as a separate named interface.
// ✅ Correct - extracted interfaces
interface Brand {
name: string;
slug: string;
}
interface Item {
brand: Brand;
id: string;
name: string;
}
// ❌ Wrong - nested object shapes inline
interface Item {
id: string;
brand: { name: string; slug: string; };
name: string;
}
See examples → Flat interface structure for a deeply nested example.
development
Plan and drive non-trivial coding work from ambiguous request to scoped implementation and verification. Use when the user asks to plan before coding, plan then implement, split work into iterations or PR-sized tasks, tackle a risky multi-file feature, refactor, migration, or recover after failed work. Do not use for simple one-step edits, commit or PR creation, pure framework/domain conventions, or repo-specific roadmap docs where a more specific planning skill applies.
development
TypeScript coding conventions for writing, reviewing, and refactoring typed code. Use when working on `.ts`, `.tsx`, or files that embed TypeScript such as Vue, Astro, or Svelte components. Also use for TypeScript snippets, typed refactors, and review comments about code organization or function structure.
development
Write and maintain Vitest unit tests for TypeScript code. Use when the user needs unit coverage for utilities, services, or stores, or asks for Vitest-based tests with mocks, spies, and assertions.
development
Create GitHub pull requests from code changes via API or generate PR content in chat. Use when user wants to create/open/submit PR, mentions pull request/PR/merge request/code review, or asks to show/generate/display/output PR content in chat (give me PR, PR to chat, send PR to chat, etc).