การใช้ Skills

การพัฒนาซอฟต์แวร์ด้วย Claude Code

Dani Zysman

AI Curriculum Manager @ DataCamp

Refactoring คืออะไร?

Excalidraw: แนวคิด Refactoring - โครงสร้างโค้ดเปลี่ยนแต่พฤติกรรมยังเหมือนเดิม

การพัฒนาซอฟต์แวร์ด้วย Claude Code

Unit Tests ช่วยให้ Refactoring ปลอดภัย

ขั้นตอน Refactoring อย่างปลอดภัย: รันเทสต์ ใช้ skill refactor ตรวจสอบ รันเทสต์อีกครั้ง แล้ว commit ถ้าผ่าน

การพัฒนาซอฟต์แวร์ด้วย Claude Code

โปรเจกต์จนถึงตอนนี้

music-analytics-api/
  app.py
  routes.py
  test_routes.py     # <- Generated by unit-tests skill
  models.py
  CLAUDE.md
  .claude/
    agents/
    skills/
      unit-tests/    # From previous video
        SKILL.md
      refactor/      # NEW: safe refactoring
        SKILL.md
การพัฒนาซอฟต์แวร์ด้วย Claude Code

สองวิธีในการเรียกใช้

สองวิธีในการเรียกใช้ skills: เรียกเองด้วย slash command หรือเรียกอัตโนมัติเมื่อ Claude จับคู่ได้

การพัฒนาซอฟต์แวร์ด้วย Claude Code

Refactoring โค้ดด้วย Skills

>/unit-tests @routes.py
Added unit tests:

Key Testing Patterns:
- Uses Flask test client for realistic HTTP testing
- Mocks external dependencies (music_store, analytics functions)
- Tests both happy paths and edge cases
- Includes validation of response formats and structure
- All tests are isolated with proper fixtures
The test file is ready to use and integrates with the project's existing pytest.
การพัฒนาซอฟต์แวร์ด้วย Claude Code

Refactoring โค้ดด้วย Skills

> /refactor @routes.py
Refactoring Complete
Changes made:
- Extracted _prepare_albums_for_stats(). Eliminates 9-line 
  list comprehension, makes intent clear
- Extracted _prepare_albums_for_average(). Removes duplicated 
  album-to-dict conversion logic
Benefits:
- Less duplication
- Cleaner route handlers
- Centralized data preparation

All 21 tests pass: behavior fully preserved
การพัฒนาซอฟต์แวร์ด้วย Claude Code

Skills ช่วยให้โค้ดสม่ำเสมอ

หากไม่มี skill: ไม่สม่ำเสมอและเกิดข้อผิดพลาดง่าย หากมี skill: สม่ำเสมอและเชื่อถือได้

การพัฒนาซอฟต์แวร์ด้วย Claude Code

มาฝึกกันเถอะ!

การพัฒนาซอฟต์แวร์ด้วย Claude Code

Preparing Video For Download...