/typescript:ts-oopfrom typescript
Provides TypeScript-specific OOP patterns including Symbol.iterator, branded types, and Tell Don't Ask examples. Activates when designing TS classes, value objects, or collections.
Ships in typescript. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
The rules are defined in
craft:oop-principles. This skill provides TypeScript / NestJS examples plus TS-specific patterns (Symbol.iterator, branded types).
See also:
ts-conventionsfor typing rules (strict mode, etc.).
Domain models under
features/<feature>/domain/are typed, not classed —frontend-clean-architectureowns that shape. The classes below apply to value objects and collections outside that layer.
// ❌ AVOID — caller interrogates and decides
const requiredFields = identityDocument.getRequiredFieldNames();
for (const fieldName of requiredFields) {
const file = identityDocument.getFileByFieldName(fieldName);
if (file !== null) continue;
const existing = existingFiles.find(fieldName);
if (existing === null) continue;
// ... re-download logic
}
// ✅ CORRECT — object exposes behavior
for (const [fieldName, existingFile] of identityDocument.getMissingExistingFiles()) {
// Object already determined which files are missing
}
// ❌ AVOID — N separate fields with parallel handling
class FormData {
private frontFile: File | null = null;
private backFile: File | null = null;
private passportFile: File | null = null;
getFileByFieldName(name: string): File | null {
switch (name) {
case 'front_file': return this.frontFile;
case 'back_file': return this.backFile;
case 'passport_file': return this.passportFile;
default: return null;
}
}
}
// ✅ CORRECT — one keyed collection
class FormData {
private readonly files = new Map<string, File>();
addFile(fieldName: string, file: File): void {
this.files.set(fieldName, file);
}
getFiles(): ReadonlyMap<string, File> {
return this.files;
}
}
// ❌ AVOID — caller destructures
collection.add({
documentType: document.type,
documentName: document.originalFileName,
downloadUrl: url,
});
// ✅ CORRECT — pass the whole object
collection.addFromDocument(document, url);
Symbol.iteratorTS-specific: implement Symbol.iterator to allow for...of while keeping internals private.
class FilesCollection implements Iterable<[string, FileInfo]> {
private readonly files = new Map<string, FileInfo>();
add(name: string, file: FileInfo): void {
this.files.set(name, file);
}
[Symbol.iterator](): Iterator<[string, FileInfo]> {
return this.files.entries();
}
}
// Clean usage
for (const [name, file] of collection) { /* ... */ }
// ❌ AVOID — consumer needs an external mapping
class UploadFile {
constructor(
readonly content: Buffer,
readonly originalFileName: string,
) {}
}
// Controller maintains fieldName → fileType outside the object
// ✅ CORRECT — object carries its own type
class UploadFile {
constructor(
readonly type: FileType,
readonly content: Buffer,
readonly originalFileName: string,
) {}
}
Use branded types to make identifiers self-descriptive and prevent accidental swaps at compile-time:
type TenantId = string & { readonly __brand: 'TenantId' };
type LandlordId = string & { readonly __brand: 'LandlordId' };
// ❌ Compile-time error — cannot pass TenantId where LandlordId expected
function getReceipts(landlordId: LandlordId): Receipt[] { /* ... */ }
getReceipts(tenantId); // Type error
// Factory function
function toTenantId(id: string): TenantId {
return id as TenantId;
}
See also:
ts-conventionsfor more on branded types and type-safety patterns.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub fabiensalles/claude-marketplace --plugin typescriptOther plugins' skills for the same job
9 skills in this plugin
/ddd-ts-fpACTIVATE when modeling DDD aggregates, value objects and domain logic in TypeScript using functional patterns. ACTIVATE for 'aggregate', 'smart constructor', 'make*', 'validation pipeline', 'enrichment', 'domain handler' in TypeScript. Provides TypeScript-specific examples for cross-language functional DDD principles defined in craft:ddd-fp-principles. DO NOT use for: infrastructure code, general FP patterns (see ts-functional), OOP modeling (see ts-oop)./ts-code-conventionsACTIVATE whenever writing or modifying TypeScript code in src/. ACTIVATE for code review, formatting, or 'coding standards'. Provides TS-specific code style examples for the cross-language rules defined in craft:code-style-principles, plus TS-specific patterns (optional chaining, nullish coalescing, template literals, no truthy/falsy). DO NOT use for: TypeScript typing rules (see ts-conventions), test conventions, domain/infra layer boundaries (see ts-layer-boundaries)./ts-conventionsACTIVATE when writing TypeScript types, generics, branded types, discriminated unions, or configuring tsconfig. ACTIVATE for 'type vs interface', 'enum alternative', 'branded type', 'satisfies', 'strict mode'. Covers: strict mode policy, no-any/no-enum rules, type over interface, discriminated unions, satisfies operator, branded types for ID safety, utility types. DO NOT use for: code formatting (see ts-code-conventions), functional patterns (see ts-functional).