스킬 활용하기

Claude Code로 배우는 Software Development

Dani Zysman

AI Curriculum Manager @ DataCamp

리팩토링이란?

Excalidraw: 리팩토링 개념 - 코드 구조는 바뀌지만 동작은 그대로 유지됨

Claude Code로 배우는 Software Development

단위 테스트로 안전한 리팩토링하기

안전한 리팩토링 워크플로: 테스트 실행, 리팩토링 스킬 적용, 검토, 테스트 재실행, 통과 시 커밋

Claude Code로 배우는 Software Development

지금까지의 프로젝트

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로 배우는 Software Development

두 가지 호출 방법

스킬을 호출하는 두 가지 방법: 슬래시 명령어로 수동 호출, Claude가 일치시킬 때 자동 호출

Claude Code로 배우는 Software Development

스킬로 코드 리팩토링하기

>/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로 배우는 Software Development

스킬로 코드 리팩토링하기

> /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로 배우는 Software Development

스킬로 일관성 확보하기

스킬이 없으면 일관성 없고 오류가 발생하기 쉬움. 스킬이 있으면 일관되고 안정적임

Claude Code로 배우는 Software Development

연습해 봅시다!

Claude Code로 배우는 Software Development

Preparing Video For Download...