| name | ts-refactoring |
| description | ACTIVATE when refactoring TypeScript code. ACTIVATE for 'refactor', 'extract', 'redesign', 'simplify', or 'clean up' in a TypeScript / Node / NestJS context. This skill provides TS-specific examples for the cross-language refactoring rules defined in craft:refactoring-principles. DO NOT use for: writing new features from scratch, general OOP patterns (see ts-oop). Use when this capability is needed. |
Refactoring — TypeScript Examples
The rules are defined in craft:refactoring-principles (cross-language). This skill provides TypeScript / Node examples only. Load both for the full picture.
Example — Rule 1: Trace the Complete Business Flow
const uploadFile = new UploadFile(content, fileName);
Example — Rule 2: Consumer-Driven Value Object
class UploadFile {
constructor(
readonly content: Buffer,
readonly originalFileName: string,
) {}
}
class UploadFile {
constructor(
readonly type: FileType,
readonly content: Buffer,
readonly originalFileName: string,
) {}
}
Example — Rule 3: Imports as a Coupling Signal
import { Request, Response } from 'express';
import { PrismaClient } from '@prisma/client';
import { UploadFile } from '../domain/upload-file';
import { TenantRepository } from '../domain/ports/tenant-repository';
TypeScript-specific note
See ts-oop rule #5 (Self-Descriptive Value Objects) for the branded-type pattern that complements rule 2 above.
Source: FabienSalles/claude-marketplace — distributed by TomeVault.