.agent/skills/refactoring/SKILL.md
ปรับปรุงโค้ดให้ดีขึ้นโดยไม่เปลี่ยน behavior
npx skillsauth add saknarinz/agent_skills_gemini RefactoringInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Skill สำหรับปรับปรุงคุณภาพโค้ด ทำให้อ่านง่าย maintain ง่าย และมีประสิทธิภาพมากขึ้น
| Smell | Solution | | ----------------------- | -------------------------------------------------- | | Long Method | Extract Method - แยกเป็น functions เล็กๆ | | Large Class | Extract Class - แยกเป็น classes | | Long Parameter List | Parameter Object - รวมเป็น object | | Data Clumps | Extract Class - สร้าง class รวม data ที่ใช้ด้วยกัน |
| Smell | Solution | | ------------------------ | ----------------------------------- | | Switch Statements | Replace with Polymorphism | | Parallel Inheritance | Merge hierarchies | | Refused Bequest | Replace Inheritance with Delegation |
| Smell | Solution | | -------------------- | ------------------------------------ | | Divergent Change | Extract Class - แยก concerns | | Shotgun Surgery | Move Method/Field - รวม related code |
| Smell | Solution | | ------------------------ | ------------------------------------------ | | Dead Code | ลบทิ้ง | | Duplicate Code | Extract Method/Class | | Lazy Class | Inline Class - รวมกับ class อื่น | | Comments (excessive) | Rename/Extract - ให้ code self-documenting |
| Smell | Solution | | ------------------ | ----------------------------------------- | | Feature Envy | Move Method - ย้ายไปที่ class ที่ใช้ data | | Message Chains | Hide Delegate - สร้าง wrapper method | | Middle Man | Remove Middle Man - เรียกตรง |
// Before
function printUserInfo(user) {
console.log("---USER INFO---");
console.log(`Name: ${user.name}`);
console.log(`Email: ${user.email}`);
console.log(`Age: ${user.age}`);
console.log("---------------");
}
// After
function printUserInfo(user) {
printHeader();
printDetails(user);
printFooter();
}
function printHeader() {
console.log("---USER INFO---");
}
function printDetails(user) {
console.log(`Name: ${user.name}`);
console.log(`Email: ${user.email}`);
console.log(`Age: ${user.age}`);
}
function printFooter() {
console.log("---------------");
}
// Before
function calculateArea(shape: Shape): number {
switch (shape.type) {
case "circle":
return Math.PI * shape.radius ** 2;
case "rectangle":
return shape.width * shape.height;
case "triangle":
return (shape.base * shape.height) / 2;
}
}
// After
interface Shape {
calculateArea(): number;
}
class Circle implements Shape {
constructor(private radius: number) {}
calculateArea(): number {
return Math.PI * this.radius ** 2;
}
}
class Rectangle implements Shape {
constructor(
private width: number,
private height: number,
) {}
calculateArea(): number {
return this.width * this.height;
}
}
// Before
function createUser(name: string, email: string, age: number,
address: string, phone: string) { ... }
// After
interface UserData {
name: string;
email: string;
age: number;
address: string;
phone: string;
}
function createUser(data: UserData) { ... }
testing
เขียน Tests ทุกประเภทอย่างมีประสิทธิภาพ
tools
สร้างโปรเจคใหม่ทุก Tech Stack พร้อม setup ที่สมบูรณ์
development
พัฒนา Frontend ด้วย Angular, React, Vue, Next.js อย่างมืออาชีพ
development
ทำงานกับ Docker, Kubernetes, CI/CD อย่างมืออาชีพ