TypeScript coding guidelines with dos and don'ts for type design and patterns. Use when writing, reviewing, or refactoring TypeScript code in projects with tsconfig.json or .ts/.tsx files. Trigger when the user asks to "review TypeScript code", "check my TS code", "write TypeScript", or when creating or modifying any .ts/.tsx file. Also applies when discussing type design, generics, naming conventions, interface vs type decisions, or TypeScript patterns. Boundary: not for JavaScript-only projects without TypeScript configuration.
From vp-typescript-best-practicesnpx claudepluginhub vdustr/vp-claude-code-marketplace --plugin vp-typescript-best-practicesThis skill uses the workspace's default tool permissions.
references/branded-types.mdreferences/code-style.mdreferences/setup.mdreferences/template-literals.mdreferences/type-patterns.mdreferences/type-testing.mdreferences/union-exhaustive.mdSearches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Searches prompts.chat for AI prompt templates by keyword or category, retrieves by ID with variable handling, and improves prompts via AI. Use for discovering or enhancing prompts.
Guides implementation of event-driven hooks in Claude Code plugins using prompt-based validation and bash commands for PreToolUse, Stop, and session events.
Guidelines for writing clean, type-safe, and maintainable TypeScript code.
Note: If the repository has established code style conventions, follow those first. These guidelines serve as defaults.
interface for objects, type for unions/mapped/conditional<const TConfig> for strict literal inferencets-reset for saner built-in types| Use | When |
|---|---|
interface | Object structures, class contracts, extensible APIs |
type | Union types, mapped types, conditional types, tuples |
| Element | Convention | Example |
|---|---|---|
| Interface/Type | PascalCase | UserProfile, ResponseData |
| Generic parameters | T prefix | TUser, TConfig (never bare T, K, V) |
| Acronyms | First cap only | userId, ApiResponse (NOT userID, APIResponse) |
| Constants | UPPER_SNAKE | MAX_RETRY_COUNT |
| Variables/Functions | camelCase | getUserById, isActive |
| DO | DON'T |
|---|---|
Array<TItem> | TItem[] |
ReadonlyArray<TItem> | readonly TItem[] |
| Use Case | DO | DON'T |
|---|---|---|
| Empty object | Record<string, never> | {} |
| Any object (extends) | Record<string, any> | Record<string, unknown> |
| Any object (annotation) | Record<string, unknown> | Record<string, any> |
| Non-primitive | object | {} |
| DO | DON'T |
|---|---|
| Zod/arktype for runtime validation | response as User |
satisfies for compile-time checks | value as unknown as Type |
Type guards (if ('prop' in obj)) | as any to silence errors |
| Explicit null checks | x! non-null assertion |
// DO: Type on the const
const myFunction: myFunction.Type = (options) => {
// implementation
};
// DO: satisfies when namespace doesn't exist
const onClick = ((event) => {
// implementation
}) satisfies React.ComponentProps<'button'>['onClick'];
// DO: Extract from existing definitions
type OnClick = React.ComponentProps<'button'>['onClick'];
type ItemIds = Array<Item['id']>;
type TimeoutType = NonNullable<typeof config['timeout']>;
// DON'T: Manually redefine types
type BadItemIds = Array<number>; // Won't update if Item.id changes
Before committing TypeScript code, verify:
interface for object types, type for unions/mapped/conditionalas or ! assertions — use Zod, satisfies, type guards, or explicit null checks.brand() or type-fest Tagged (not manual casting)T prefix for generics, Id not ID)For detailed patterns and examples, see:
*.test-d.ts files