Install any skill in seconds. Free to start, no credit card required.
Get Started Free →bluelovers/code-refactoring-expert-typescript
Modern TypeScript/Node.js refactoring and design guide, focusing on type safety, async flow optimization, single source of truth, and other modern design principles. Suitable for: (1) refactoring existing TypeScript/Node.js code, (2) design decision reference when implementing new features, (3) identifying and fixing TS/Node-specific code smells, (4) establishing team coding standards and best practices. Use this Skill when users request "Refactor TS", "Refactor TypeScript", "Node.js code improv
Passed 22 of 23 test cases with the skill, and 16 of 23 without it.
and 6 more in the full report
7 fixed15 passed either way0 still failing1 broke
Tokens, turns and time describe resource use, not a dollar price.
This benchmark measured an earlier version of the skill.
A newer attempt on gemini-3.6-flash on 10/15/2026 did not produce a publishable comparison (not comparable). The snapshot above is the previously measured run.
One of 7 test cases the skill fixed. Same model, same prompt, with and without the skill.
We have a legacy Node.js/TypeScript checkout module where tax and discount calculations are copied across both checkoutCart and generateInvoice functions, and user roles are defined as string union literals like 'admin' | 'editor' | 'viewer'. Can you review this code and create a refactoring proposal? Please structure your answer using sections for Current Issues, Proposed Changes, Step-by-Step Plan, Risk Assessment, and a Type Safety Checklist.
| Checked | Without skill | With skill |
|---|---|---|
| Recommends an explicit TypeScript enum declaration for user roles instead of string unions. | Missed | Passed |
| Recommends extracting tax calculation math into a shared helper function. | Passed | Passed |
| Includes a Type Safety Checklist in the output report. | Passed | Passed |
The instructions your model reads when the skill loads.
You are an expert in modern TypeScript and Node.js development refactoring. You follow classic refactoring principles (Martin Fowler) while incorporating modern professional considerations for type systems, asynchronous flows, and Node.js runtime characteristics.
📋 Dual Purpose of This Guide:
- Refactor existing code: Identify smells, safe refactoring, gradual improvement
- Design reference for new features: Prevent smells, establish correct type structures, follow best practices
Refactoring is not just about "fixing past mistakes" but "establishing future standards". The principles and techniques in this document apply equally to design decisions starting from scratch.
| Smell | Description | TS/Node Adjustment |
|---|---|---|
| Long Method | Method >20 lines | If contains multiple async/await, treat as Asynchronous Bottleneck, decompose I/O operations |
| Large Class | Class >200 lines | Applicable |
| Primitive Obsession | Primitive type obsession | Use interface/enum to build type hierarchy; use { lng, lat } object instead of [number, number] for coordinates, avoiding implicit errors caused by order confusion between [lat, lng] and [lng, lat] (see geo-transform case) |
| Long Parameter List | Parameter list >3 items | Modern TS uses Options Pattern, relax to complexity-driven |
| Data Clumps | Data clumps | Apply SSoT principle, use extends or nested composition |
| Smell | Description | TS/Node Adjustment |
|---|---|---|
| Switch Statements | Switch statements | Discriminated Unions with switch are type-safe best practices, not inherently bad |
test cases passed, vs 16 / 23 without
More skills from the same source and nearby in the registry, with their headline benchmark lift.