Tworzenie skutecznych plików CLAUDE.md

Tworzenie oprogramowania z Claude Code

Dani Zysman

AI Curriculum Manager @ DataCamp

Najlepsze praktyki dla CLAUDE.md

  • Zacznij od /init, potem iteruj
    • Dodawaj kontekst, gdy Claude popełnia błędy
    • Uwzględniaj zmiany konwencji
  • Cel: żywy dokument, który rozwija się wraz z projektem
Tworzenie oprogramowania z Claude Code

Projekt do tej pory

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
Tworzenie oprogramowania z Claude Code

Co zawrzeć, a co pominąć w CLAUDE.md

recraft: co zawrzeć, a co pominąć w CLAUDE.md

Zasada: jeśli coś nie zmieści się na karteczce samoprzylepnej, nie powinno tam być.

Tworzenie oprogramowania z Claude Code

Iteracyjne doskonalenie 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.
Tworzenie oprogramowania z Claude Code

Dobry vs. rozdęty plik CLAUDE.md

Rozdęty (200+ linijek)

# 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...

Dobry (15 linijek)

# Inventory API
Flask REST API for inventory.

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

## Conventions
- Use type hints
- Keep routes thin
Tworzenie oprogramowania z Claude Code

Odwołania do plików – użycie @

> @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.
Tworzenie oprogramowania z Claude Code

CLAUDE.md + @ razem

# 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 zapewnia trwały kontekst. Używaj @, aby Claude zawsze znał twoje kluczowe pliki.

Tworzenie oprogramowania z Claude Code

Trzy poziomy kontekstu

Trzy poziomy kontekstu w CLAUDE.md

Tworzenie oprogramowania z Claude Code

Kiedy używać którego pliku

  • CLAUDE.md (projekt, współdzielony)

    • komendy testowe, konwencje kodowania, struktura projektu
  • CLAUDE.local.md (projekt, osobisty)

    • lokalne ścieżki, klucze API, osobiste preferencje dotyczące pracy
  • ~/.claude/CLAUDE.md (globalny, osobisty)

    • preferencje stylu we wszystkich projektach
    • domyślne zachowania, które zawsze chcesz mieć
Tworzenie oprogramowania z Claude Code

Podsumowanie rozdziału 1

  • /init i CLAUDE.md → trwały kontekst projektu
  • Shift+Tab lub /plan → przełączanie trybu Plan
  • think ... ultrathink → głębokie rozumowanie (5 poziomów)
Tworzenie oprogramowania z Claude Code

Czas na praktykę!

Tworzenie oprogramowania z Claude Code

Preparing Video For Download...