From vp-typescript-best-practices
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.
How this skill is triggered — by the user, by Claude, or both
Slash command
/vp-typescript-best-practices:typescript-best-practicesThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Guidelines for writing clean, type-safe, and maintainable TypeScript code.
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 filesProvides behavioral guidelines to reduce common LLM coding mistakes, focusing on simplicity, surgical changes, assumption surfacing, and verifiable success criteria.
Searches, 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.
Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.
npx claudepluginhub vdustr/vp-claude-code-marketplace --plugin vp-typescript-best-practices