ts-best-practices
Installation
SKILL.md
ts-best-practices
Write, review, and refactor TypeScript code to follow battle-tested conventions: object-arg parameters, JSDoc on exports, discriminated unions for variants, branded types for IDs, ts-pattern for multi-branch logic, and exports-first file structure.
Core conventions
Naming
| Element | Convention | Example |
|---|---|---|
| Files | kebab-case.ts |
user-service.ts, auth-types.ts |
| Variables | camelCase |
userId, isAuthenticated |
| Functions | camelCase (verbs) |
createUser, parseHeaders |
| Types/interfaces | PascalCase |
User, CreateUserParams |
| Constants | SCREAMING_SNAKE_CASE |
MAX_RETRIES = 3 |
| Const objects | SCREAMING_SNAKE_CASE keys with as const |
GITHUB_EVENTS = { PUSH: 'push' } as const |
Object properties: prefer nested when properties form a logical group; flat for standalone values.
Related skills