Effectieve CLAUDE.md-bestanden maken

Softwareontwikkeling met Claude Code

Dani Zysman

AI Curriculum Manager @ DataCamp

CLAUDE.md: best practices

  • Start met /init, daarna itereren
    • Voeg context toe als Claude fouten maakt
    • Neem wijzigingen in conventies op
  • Doel: Een levend document dat met je project meegroeit
Softwareontwikkeling met Claude Code

Het project tot nu toe

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
Softwareontwikkeling met Claude Code

Wat hoort IN vs. UIT CLAUDE.md

recraft: Wat neem je op vs. laat je weg in CLAUDE.md

Regel: Is het langer dan een plakbriefje? Dan hoort het er niet in.

Softwareontwikkeling met Claude Code

Itereren op 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.
Softwareontwikkeling met Claude Code

Goed vs. opgeblazen CLAUDE.md

Opgeblazen (200+ regels)

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

Goed (15 regels)

# Inventory API
Flask REST API for inventory.

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

## Conventions
- Use type hints
- Keep routes thin
Softwareontwikkeling met Claude Code

Bestandsverwijzingen - met @

> @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.
Softwareontwikkeling met Claude Code

CLAUDE.md + @ samen

# 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 geeft blijvende context. Gebruik @ zodat Claude je kernbestanden altijd kent.

Softwareontwikkeling met Claude Code

Drie niveaus van context

Drie niveaus van CLAUDE.md-context

Softwareontwikkeling met Claude Code

Wanneer gebruik je welke

  • CLAUDE.md (project, gedeeld)

    • Testcommando's, codeconventies, projectstructuur
  • CLAUDE.local.md (project, persoonlijk)

    • Lokale paden, API-sleutels, persoonlijke workflowvoorkeuren
  • ~/.claude/CLAUDE.md (globaal, persoonlijk)

    • Stijlvoorkeuren voor alle projecten
    • Standaardgedrag dat je altijd wilt
Softwareontwikkeling met Claude Code

Hoofdstuk 1 samenvatting

  • /init enCLAUDE.md → Blijvende projectcontext
  • Shift+Tab of /plan → Planmodus wisselen
  • think ... ultrathink → Diep redeneren (5 niveaus)
Softwareontwikkeling met Claude Code

Laten we oefenen!

Softwareontwikkeling met Claude Code

Preparing Video For Download...