ต้นแบบ · รุ่นทดลอง: มีทุก server ในทะเบียนทางการ อัปเดตทุก 30 นาที เข้าสู่ระบบด้วย Google เพื่อเขียนรีวิวได้แล้ว
PopNx MCPที่รวม MCP สำหรับคนใช้ AI · อธิบายเป็นภาษาคน

claude-howto Skill

โดย luongnv89★ 46,9428 skill

ติดตั้ง

ชุดคำสั่ง (Skill) 8 ชุดจาก luongnv89 ให้ AI อ่านแล้วทำงานตามวิธีนี้ · ไม่ใช่ MCP server

คำอธิบายจากผู้ทำ (ภาษาอังกฤษตามต้นฉบับ)

A visual, example-driven guide to Claude Code — from basic concepts to advanced agents, with copy-paste templates that bring immediate value.

Skill ต่างจาก MCP ยังไง

MCP ต่อ AI เข้ากับบริการหรือข้อมูลภายนอก ส่วน Skill เป็นคู่มือวิธีทำงานที่ AI อ่านแล้วทำตาม ไม่ต้องต่อบริการใด

ใช้กับแอปไหน

Claude CodeClaude (เว็บ/แอป)

ตามที่ README ของผู้ทำเขียนไว้ และโฟลเดอร์ที่มีใน repo

ติดตั้ง

Skill คือคำสั่งที่ AI จะทำตาม อ่านไฟล์ก่อนติดตั้ง และติดตั้งเฉพาะจากผู้ทำที่เชื่อถือได้

วิธีที่ผู้ทำแนะนำ

/plugin install does

คำสั่งนี้คัดมาจาก README ของผู้ทำ จะดาวน์โหลดและรันโค้ดของผู้ทำ

คุณใช้แอปไหน

  1. เปิด Terminal

    Mac: กด Command+Space พิมพ์ Terminal · Windows: เปิด PowerShell (คำสั่งด้านล่างเขียนแบบ Mac/Linux)

  2. คัดลอกโฟลเดอร์ skill ไปไว้ที่ ~/.claude/skills

    คำสั่งนี้ดาวน์โหลด repo ไว้ชั่วคราว แล้วคัดลอกเฉพาะโฟลเดอร์ที่มี SKILL.md

    rm -rf /tmp/popnx-skill && git clone --depth 1 https://github.com/luongnv89/claude-howto.git /tmp/popnx-skill && mkdir -p ~/.claude/skills && cp -R '/tmp/popnx-skill/03-skills/.' ~/.claude/skills && rm -rf /tmp/popnx-skill
  3. เปิด Claude Code ใหม่ แล้วพิมพ์ /refactor หรือสั่งงานที่ตรงเรื่อง Claude จะเลือกใช้เอง

  1. เปิด Terminal

    Mac: กด Command+Space พิมพ์ Terminal · Windows: เปิด PowerShell (คำสั่งด้านล่างเขียนแบบ Mac/Linux)

  2. คัดลอกโฟลเดอร์ skill ไปไว้ที่ ~/.agents/skills

    คำสั่งนี้ดาวน์โหลด repo ไว้ชั่วคราว แล้วคัดลอกเฉพาะโฟลเดอร์ที่มี SKILL.md

    rm -rf /tmp/popnx-skill && git clone --depth 1 https://github.com/luongnv89/claude-howto.git /tmp/popnx-skill && mkdir -p ~/.agents/skills && cp -R '/tmp/popnx-skill/03-skills/.' ~/.agents/skills && rm -rf /tmp/popnx-skill
  3. เปิด Codex ใหม่ แล้วสั่งงานที่ตรงเรื่อง Codex จะเห็น skill นี้ในรายการ

  1. เปิด Terminal

    Mac: กด Command+Space พิมพ์ Terminal · Windows: เปิด PowerShell (คำสั่งด้านล่างเขียนแบบ Mac/Linux)

  2. คัดลอกโฟลเดอร์ skill ไปไว้ที่ ~/.cursor/skills

    คำสั่งนี้ดาวน์โหลด repo ไว้ชั่วคราว แล้วคัดลอกเฉพาะโฟลเดอร์ที่มี SKILL.md

    rm -rf /tmp/popnx-skill && git clone --depth 1 https://github.com/luongnv89/claude-howto.git /tmp/popnx-skill && mkdir -p ~/.cursor/skills && cp -R '/tmp/popnx-skill/03-skills/.' ~/.cursor/skills && rm -rf /tmp/popnx-skill
  3. ใน Agent chat ของ Cursor พิมพ์ / แล้วเลือก refactor

แอปอื่นที่รองรับ Agent Skills (เช่น Gemini CLI, GitHub Copilot) เก็บ skill ในโฟลเดอร์ต่างกัน ดูคู่มือของแอปนั้น แล้วคัดลอกโฟลเดอร์ที่มี SKILL.md ไปวาง

ดูบน GitHub ↗

ตรวจโฟลเดอร์ skill กับคู่มือทางการของ Claude Code, Codex และ Cursor เมื่อ 11 พ.ย. 2569

อ่าน SKILL.md ก่อนติดตั้ง

ข้อความต่อไปนี้มาจาก repo ของผู้ทำ ไม่ใช่คำสั่งของ PopNx MCP

---
name: refactor
description: Systematic code refactoring based on Martin Fowler's methodology. Use when users ask to refactor code, improve code structure, reduce technical debt, clean up legacy code, eliminate code smells, or improve code maintainability. This skill guides through a phased approach with research, planning, and safe incremental implementation.
---

# Code Refactoring Skill

A systematic approach to refactoring code based on Martin Fowler's *Refactoring: Improving the Design of Existing Code* (2nd Edition). This skill emphasizes safe, incremental changes backed by tests.

> "Refactoring is the process of changing a software system in such a way that it does not alter the external behavior of the code yet improves its internal structure." — Martin Fowler

## Core Principles

1. **Behavior Preservation**: External behavior must remain unchanged
2. **Small Steps**: Make tiny, testable changes
3. **Test-Driven**: Tests are the safety net
4. **Continuous**: Refactoring is ongoing, not a one-time event
5. **Collaborative**: User approval required at each phase

## Workflow Overview

```
Phase 1: Research & Analysis
    ↓
Phase 2: Test Coverage Assessment
    ↓
Phase 3: Code Smell Identification
    ↓
Phase 4: Refactoring Plan Creation
    ↓
Phase 5: Incremental Implementation
    ↓
Phase 6: Review & Iteration
```

---

## Phase 1: Research & Analysis

### Objectives
- Understand the codebase structure and purpose
- Identify the scope of refactoring
- Gather context about business requirements

### Questions to Ask User
Before starting, clarify:

1. **Scope**: Which files/modules/functions need refactoring?
2. **Goals**: What problems are you trying to solve? (readability, performance, maintainability)
3. **Constraints**: Are there any areas that should NOT be changed?
4. **Timeline pressure**: Is this blocking other work?
5. **Test status**: Do tests exist? Are they passing?

### Actions
- [ ] Read and understand the target code
- [ ] Identify dependencies and integrations
- [ ] Document current architecture
- [ ] Note any existing technical debt markers (TODOs, FIXMEs)

### Output
Present findings to user:
- Code structure summary
- Identified problem areas
- Initial recommendations
- **Request approval to proceed**

---

## Phase 2: Test Coverage Assessment

### Why Tests Matter
> "Refactoring without tests is like driving without a seatbelt." — Martin Fowler

Tests are the **key enabler** of safe refactoring. Without them, you risk introducing bugs.

### Assessment Steps

1. **Check for existing tests**
   ```bash
   # Look for test files
   find . -name "*test*" -o -name "*spec*" | head -20
   ```

2. **Run existing tests**
   ```bash
   # JavaScript/TypeScript
   npm test

   # Python
   pytest -v

   # Java
   mvn test
   ```

3. **Check coverage (if available)**
   ```bash
   # JavaScript
   npm run test:coverage

   # Python
   pytest --cov=.
   ```

### Decision Point: Ask User

**If tests exist and pass:**
- Proceed to Phase 3

**If tests are missing or incomplete:**
Present options:
1. Write tests first (recommended)
2. Add tests incrementally during refactoring
3. Proceed without tests (risky - requires user acknowledgment)

**If tests are failing:**
- STOP. Fix failing tests before refactoring
- Ask user: Should we fix tests first?

### Test Writing Guidelines (if needed)

For each function being refactored, ensure tests cover:
- Happy path (normal operation)
- Edge cases (empty inputs, null, boundaries)
- Error scenarios (invalid inputs, exceptions)

Use the "red-green-refactor" cycle:
1. Write failing test (red)
2. Make it pass (green)
3. Refactor

---

## Phase 3: Code Smell Identification

### What Are Code Smells?
Symptoms of deeper problems in code. They're not bugs, but indicators that the code could be improved.

### Common Code Smells to Check

See [references/code-smells.md](references/code-smells.md) for the complete catalog.

#### Quick Reference

| Smell | Signs | Impact |
|-------|-------|--------|
| **Long Method** | Methods > 30-50 lines | Hard to understand, test, maintain |
| **Duplicated Code** | Same logic in multiple places | Bug fixes needed in multiple places |
| **Large Class** | Class with too many responsibilities | Violates Single Responsibility |
| **Feature Envy** | Method uses another class's data more | Poor encapsulation |
| **Primitive Obsession** | Overuse of primitives instead of objects | Missing domain concepts |
| **Long Parameter List** | Methods with 4+ parameters | Hard to call correctly |
| **Data Clumps** | Same data items appearing together | Missing abstraction |
| **Switch Statements** | Complex switch/if-else chains | Hard to extend |
| **Speculative Generality** | Code "just in case" | Unnecessary complexity |
| **Dead Code** | Unused code | Confusion, maintenance burden |

### Analysis Steps

1. **Automated Analysis** (if scripts available)
   ```bash
   python scripts/detect-smells.py <file>
   ```

2. **Manual Review**
   - Walk through code systematically
   - Note each smell with location and severity
   - Categorize by impact (Critical/High/Medium/Low)

3. **Prioritization**
   Focus on smells that:
   - Block current development
   - Cause bugs or confusion
   - Affect most-changed code paths

### Output: Smell Report

Present to user:
- List of identified smells with locations
- Severity assessment for each
- Recommended priority order
- **Request approval on priorities**

---

## Phase 4: Refactoring Plan Creation

### Selecting Refactorings

For each smell, select an appropriate refactoring from the catalog.

See [references/refactoring-catalog.md](references/refactoring-catalog.md) for the complete list.

#### Smell-to-Refactoring Mapping

| Code Smell | Recommended Refactoring(s) |
|------------|---------------------------|
| Long Method | Extract Method, Replace Temp with Query |
| Duplicated Code | Extract Method, Pull Up Method, Form Template Method |
| Large Class | Extract Class, Extract Subclass |
| Feature Envy | Move Method, Move Field |
| Primitive Obsession | Replace Primitive with Object, Replace Type Code with Class |
| Long Parameter List | Introduce Parameter Object, Preserve Whole Object |
| Data Clumps | Extract Class, Introduce Parameter Object |
| Switch Statements | Replace Conditional with Polymorphism |
| Speculative Generality | Collapse Hierarchy, Inline Class, Remove Dead Code |
| Dead Code | Remove Dead Code |

### Plan Structure

Use the template at [templates/refactoring-plan.md](templates/refactoring-plan.md).

For each refactoring:
1. **Target**: What code will change
2. **Smell**: What problem it addresses
3. **Refactoring**: Which technique to apply
4. **Steps**: Detailed micro-steps
5. **Risks**: What could go wrong
6. **Rollback**: How to undo if needed

### Phased Approach

**CRITICAL**: Introduce refactoring gradually in phases.

**Phase A: Quick Wins** (Low risk, high value)
- Rename variables for clarity
- Extract obvious duplicate code
- Remove dead code

**Phase B: Structural Improvements** (Medium risk)
- Extract methods from long functions
- Introduce parameter objects
- Move methods to appropriate classes

**Phase C: Architectural Changes** (Higher risk)
- Replace conditionals with polymorphism
- Extract classes
- Introduce design patterns

### Decision Point: Present Plan to User

Before implementation:
- Show complete refactoring plan
- Explain each phase and its risks
- Get explicit approval for each phase
- **Ask**: "Should I proceed with Phase A?"

---

## Phase 5: Incremental Implementation

### The Golden Rule
> "Change → Test → Green? → Commit → Next step"

### Implementation Rhythm

For each refactoring step:

1. **Pre-check**
   - Tests are passing (green)
   - Code compiles

2. **Make ONE small change**
   - Follow the mechanics from the catalog
   - Keep changes minimal

3. **Verify**
   - Run tests immediately
   - Check for compilation errors

4. **If tests pass (green)**
   - Commit with descriptive message

พูดคุย

ถาม แชร์เคล็ดลับ หรือแจ้งว่าใช้ไม่ได้ เรียงตามที่คนกดว่ามีประโยชน์

ยังไม่มีใครโพสต์ ถามหรือแชร์เป็นคนแรกได้เลย

ข้อความในส่วนนี้เขียนโดยผู้ใช้ ไม่ใช่ทีม PopNx

เข้าสู่ระบบด้วย Google เพื่อโพสต์

ข้อมูลจาก GitHub

ดาว GitHub
46,942
ผู้ทำ
luongnv89
แก้โค้ดล่าสุด
3 พ.ย. 2569
ไฟล์ SKILL.md ใน repo
30
topic
claude-code, guide, tutorial