Jak vytvořit efektivní soubory CLAUDE.md

Vývoj softwaru s Claude Code

Dani Zysman

AI Curriculum Manager @ DataCamp

Osvědčené postupy pro CLAUDE.md

  • Začni příkazem /init a pak postupně vylepšuj
    • Přidej kontext, když Claude udělá chybu
    • Zaznamenávej změny konvencí
  • Cíl: Živý dokument, který se vyvíjí spolu s projektem
Vývoj softwaru s Claude Code

Stav projektu doposud

music-analytics-api/
  app.py           # Application entry point
  routes.py        # API endpoints
  models.py        # Artist/Album models
  analytics.py     # Statistics functions
  middleware.py    # Request logging
  config.py        # Session settings
  CLAUDE.md        # <- Project memory file
Vývoj softwaru s Claude Code

Co patří do CLAUDE.md a co ne

recraft: Co do CLAUDE.md patří a co ne

Pravidlo: Pokud je to delší než lepicí lístek, do souboru to nepatří.

Vývoj softwaru s Claude Code

Postupné vylepšování CLAUDE.md

> Add error handling to the /artists endpoint.
Done. I've added error handling to /artists (routes.py:9-19):
- Try-except block wrapping retrieval and serialization
- AttributeError handler if the data store isn't initialized
- General exception handler returning error details with 500 status

return jsonify({'error': f'Failed to retrieve artists: {str(e)}'}), 500
> Don't expose exception details to users, that's a security risk. Log internally 
and return a generic message.  Update CLAUDE.md.
Updated /artists to log errors internally and return a 
generic 500 message. CLAUDE.md updated with the convention: 
never expose exception details in responses.
Vývoj softwaru s Claude Code

Dobrý vs. přebujelý CLAUDE.md

Přebujelý (200+ řádků)

# Inventory API
This is an Inventory Management 
API built with Flask...

## Full Source Code
### routes.py
from flask import jsonify...
[entire file pasted]

### models.py
[entire file pasted]

## API Documentation
GET /items returns...

Dobrý (15 řádků)

# Inventory API
Flask REST API for inventory.

## Commands
- Run: flask run --port 5001
- Test: pytest tests/

## Conventions
- Use type hints
- Keep routes thin
Vývoj softwaru s Claude Code

Odkazy na soubory – použití @

> @routes.py what endpoints does this API have?
API Endpoints (6 GET routes)

Artists
- GET /artists              All artists
- GET /artists/<id>         Single artist by ID
- GET /artists/<id>/albums  Albums for an artist
Albums
- GET /albums               All albums
- GET /stats/albums         Album popularity statistics
- GET /stats/average-tracks Average track count per album

All endpoints return JSON.
Vývoj softwaru s Claude Code

CLAUDE.md a @ společně

# CLAUDE.md - Music Analytics API
A Flask-based REST API for music data analytics, providing endpoints for artists,
albums, and statistics.
...

## Key Files @routes.py - API endpoint definition @models.py - Artist and Album data models with in-memory store ...

CLAUDE.md poskytuje trvalý kontext. Použij @, aby Claude vždy znal tvoje klíčové soubory.

Vývoj softwaru s Claude Code

Tři úrovně kontextu

Tři úrovně kontextu CLAUDE.md

Vývoj softwaru s Claude Code

Kdy který použít

  • CLAUDE.md (projekt, sdílený)

    • Testovací příkazy, konvence kódu, struktura projektu
  • CLAUDE.local.md (projekt, osobní)

    • Lokální cesty, API klíče, osobní preference workflow
  • ~/.claude/CLAUDE.md (globální, osobní)

    • Stylové preference napříč všemi projekty
    • Výchozí chování, které chceš vždy
Vývoj softwaru s Claude Code

Shrnutí kapitoly 1

  • /init a CLAUDE.md → Trvalý kontext projektu
  • Shift+Tab nebo /plan → Přepnutí režimu Plan
  • think ... ultrathink → Hluboké uvažování (5 úrovní)
Vývoj softwaru s Claude Code

Pojďme cvičit!

Vývoj softwaru s Claude Code

Preparing Video For Download...