Using Skills

Software Development with Claude Code

Dani Zysman

AI Curriculum Manager @ DataCamp

What Is Refactoring?

Excalidraw: Refactoring concept - code structure changes but behavior stays the same

Software Development with Claude Code

Unit Tests Enable Safe Refactoring

Safe refactoring workflow: run tests, refactor skill, review, run tests again, commit if green

Software Development with Claude Code

The Project So Far

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
Software Development with Claude Code

Two Ways to Invoke

Two ways to invoke skills: manual with slash command, automatic when Claude matches

Software Development with Claude Code

Refactoring Code with 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.
Software Development with Claude Code

Refactoring Code with 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
Software Development with Claude Code

Skills Ensure Consistency

Without skill: inconsistent and error-prone. With skill: consistent and reliable

Software Development with Claude Code

Let's Practice!

Software Development with Claude Code

Preparing Video For Download...