Práce s dovednostmi

Vývoj softwaru s Claude Code

Dani Zysman

AI Curriculum Manager @ DataCamp

Co je refaktoring?

Excalidraw: koncept refaktoringu – struktura kódu se mění, chování zůstává stejné

Vývoj softwaru s Claude Code

Unit testy umožňují bezpečný refaktoring

Bezpečný postup refaktoringu: spustit testy, dovednost refactor, kontrola, znovu spustit testy, commit při úspěchu

Vývoj softwaru s Claude Code

Aktuální stav projektu

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
Vývoj softwaru s Claude Code

Dva způsoby spuštění

Dva způsoby spuštění dovedností: ručně pomocí lomítkového příkazu, automaticky, když je Claude rozpozná

Vývoj softwaru s Claude Code

Refaktoring kódu pomocí dovedností

>/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.
Vývoj softwaru s Claude Code

Refaktoring kódu pomocí dovedností

> /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
Vývoj softwaru s Claude Code

Dovednosti zajišťují konzistenci

Bez dovednosti: nekonzistentní a náchylné k chybám. S dovedností: konzistentní a spolehlivé

Vývoj softwaru s Claude Code

Pojďme cvičit!

Vývoj softwaru s Claude Code

Preparing Video For Download...