typescript-coding-standards
БесплатноЗапускает вложенные скриптыНе проверенTypeScript coding standards covering strict type system, advanced types, decorators, generics, and best practices for type-safe applications. Use for…
Об этом скилле
TypeScript Coding Standards
Quick Navigation: Level 1: Quick Start (5 min) → Level 2: Implementation (30 min) → Level 3: Mastery (Extended)
Level 1: Quick Start (<2,000 tokens, 5 minutes)
Core Principles
- Strict Type Safety: Enable strict mode and leverage TypeScript's type system fully
- Type Inference: Use type inference when obvious, explicit types when clarity matters
- No Any: Avoid
anytype; useunknownfor truly dynamic data - Immutability: Prefer readonly properties and immutable data structures
- Modern Tooling: Use tsconfig strict mode, ESLint, and Prettier
Essential Checklist
- Strict Mode: Enable all strict compiler options in tsconfig.json
- No Implicit Any: All variables have explicit or inferred types
- Proper Generics: Use generics for reusable type-safe functions and classes
- Testing: Jest with TypeScript support, type testing with tsd
- Documentation: TSDoc comments for public APIs
- Module System: ES6 modules with proper imports/exports
- Linting: ESLint with TypeScript plugin configured
- Build: Proper tsconfig with source maps and declaration files
Quick Example
/**
* Authentication service with type-safe error handling.
*/
import { hash, compare } from 'bcrypt';
import jwt from 'jsonwebtoken';
// Type definitions
interface User {
readonly id: string;
readonly username: string;
readonly email: string;
readonly passwordHash: string;
}
interface AuthResult<T> {
readonly success: boolean;
readonly data?: T;
readonly error?: Error;
}
// Custom errors
class AuthError extends Error {
constructor(message: string, public readonly code: string) {
super(message);
this.name = 'AuthError';
}
}
// Service implementation
class AuthService {
constructor(
private readonly repository: UserRepository,
private readonly jwtSecret: string
) {}
async authenticate(username: string, password: string): Promise<AuthResult<{ token: string }>> {
if (!username || !password) {
return { success: false, error: new AuthError('Credentials required', 'VALIDATION') };
}
const user = await this.repository.findByUsername(username);
if (!user || !await compare(password, user.passwordHash)) {
return { success: false, error: new AuthError('Invalid credentials', 'AUTH_FAILED') };
}
const token = jwt.sign({ userId: user.id, username: user.username }, this.jwtSecret, {
expiresIn: '1h',
});
return { success: true, data: { token } };
}
async hashPassword(password: string): Promise<string> {
return hash(password, 10);
}
}
Quick Links to Level 2
- Type System Fundamentals
- Advanced Types
- Generics and Constraints
- Decorators
- Testing Standards
- Error Handling Patterns
Level 2: Implementation (<5,000 tokens, 30 minutes)
Type System Fundamentals
Basic Types and Type Inference
// ✅ Good: Type inference when obvious
const username = 'alice'; // inferred as string
const count = 42; // inferred as number
const items = [1, 2, 3]; // inferred as number[]
// ✅ Good: Explicit types for clarity
function calculateTotal(items: number[]): number {
return items.reduce((sum, item) => sum + item, 0);
}
// ❌ Bad: Unnecessary explicit types
const name: string = 'bob'; // Unnecessary, inference is clear
// ✅ Good: Union types for multiple possibilities
type Status = 'pending' | 'approved' | 'rejected';
let orderStatus: Status = 'pending';
// ✅ Good: Intersection types for composition
type Timestamped = { createdAt: Date; updatedAt: Date };
type User = { id: string; name: string };
type TimestampedUser = User & Timestamped;
// ✅ Good: Readonly for immutability
interface Config {
readonly apiUrl: string;
readonly timeout: number;
}
const config: Readonly<Config> = {
apiUrl: 'https://api.example.com',
timeout: 5000,
};
Type Guards and Narrowing
// Type guard functions
function isString(value: unknown): value is string {
return typeof value === 'string';
}
function isUser(obj: unknown): obj is User {
return (
typeof obj === 'object' &&
obj !== null &&
'id' in obj &&
'username' in obj
);
}
// Using type guards
function processValue(value: string | number) {
if (typeof value === 'string') {
// value is string here
return value.toUpperCase();
}
// value is number here
return value.toFixed(2);
}
// Discriminated unions
type Success<T> = { success: true; data: T };
type Failure = { success: false; error: Error };
type Result<T> = Success<T> | Failure;
function handleResult<T>(result: Result<T>): T | null {
if (resul
Установить typescript-coding-standards в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл typescript-coding-standards?
TypeScript coding standards covering strict type system, advanced types, decorators, generics, and best practices for type-safe applications. Use for TypeScript projects requiring robust type safety and maintainable code.
Как установить скилл typescript-coding-standards?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл typescript-coding-standards запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic