Lavorare con Claude Code

Come usare Claude Code con le specifiche MdExplorer per generare codice allineato

Cos'è Claude Code?

Workflow Claude Code con MdExplorer
Flusso operativo: Developer → MdExplorer → CLAUDE.md → Claude Code

Claude Code è il tool CLI ufficiale di Anthropic per lo sviluppo assistito da AI. Funziona direttamente nel terminale e ha accesso al file system del progetto. Può leggere file, scrivere codice, eseguire comandi, e interagire con Git. La chiave è che legge automaticamente il file CLAUDE.md nella root del progetto come contesto.

Questo significa che le specifiche che scrivi in MdExplorer e referenzi in CLAUDE.md diventano il contesto operativo dell'AI. Più le specifiche sono dettagliate e ben strutturate, più il codice generato sarà allineato ai requisiti.

Claude Code Workflow with MdExplorer
Operational flow: Developer → MdExplorer → CLAUDE.md → Claude Code

Claude Code is Anthropic's official CLI tool for AI-assisted development. It works directly in the terminal and has access to the project's file system. It can read files, write code, execute commands, and interact with Git. The key is that it automatically reads the CLAUDE.md file in the project root as context.

This means that the specifications you write in MdExplorer and reference in CLAUDE.md become the AI's operational context. The more detailed and well-structured your specs are, the more the generated code will be aligned with the requirements.

Il File CLAUDE.md: Il Ponte tra Progetto e AI

CLAUDE.md è il file che configura il contesto del progetto per Claude Code. Viene letto automaticamente all'avvio di ogni sessione e fornisce all'AI tutte le informazioni necessarie per comprendere il progetto: stack tecnologico, struttura cartelle, convenzioni, e soprattutto i riferimenti alle specifiche.

Struttura tipo di un CLAUDE.md efficace:

CLAUDE.md is the file that configures the project context for Claude Code. It is read automatically at the start of every session and provides the AI with all the information needed to understand the project: technology stack, folder structure, conventions, and most importantly the references to specifications.

Structure of an effective CLAUDE.md:

CLAUDE.md # CLAUDE.md ## Progetto Nome e descrizione del progetto ## Stack Tecnologico - Backend: tecnologia - Frontend: tecnologia - Database: tecnologia ## Struttura Cartelle - src/ - codice sorgente - docs/ - specifiche e documentazione - tests/ - test automatizzati ## Specifiche di Riferimento - Analisi funzionale: docs/analisi/ - Architettura: docs/ANALISI_TECNICA.md - Sprint corrente: docs/sprints/SPRINT-XX.md ## Convenzioni - Pattern di naming - Formato commit message - Standard di codice

Il punto fondamentale è che CLAUDE.md fa da ponte tra le specifiche scritte in MdExplorer e l'AI di Claude Code. Quando referenzi un file di specifica (es. docs/analisi/ANALISI_FUNZIONALE.md), Claude Code può leggerlo e usarlo come contesto per generare codice coerente con i requisiti definiti.

Suggerimento: Scrivi le specifiche in MdExplorer, versionali con Git, poi referenziale in CLAUDE.md. Questo crea un ciclo virtuoso: le specifiche guidano il codice, e il codice resta allineato alle specifiche.

The fundamental point is that CLAUDE.md acts as a bridge between the specifications written in MdExplorer and the Claude Code AI. When you reference a spec file (e.g. docs/analisi/ANALISI_FUNZIONALE.md), Claude Code can read it and use it as context to generate code consistent with the defined requirements.

Tip: Write specifications in MdExplorer, version them with Git, then reference them in CLAUDE.md. This creates a virtuous cycle: specs guide the code, and the code stays aligned with the specs.

Workflow Pratico

Ci sono 4 tipologie principali di prompt che puoi usare con Claude Code, ciascuna per una fase diversa del ciclo di sviluppo. Ecco i prompt con esempi concreti:

Prompt per Analisi Funzionale

Usa questo tipo di prompt quando devi creare o espandere i requisiti funzionali di un modulo:

There are 4 main types of prompts you can use with Claude Code, each for a different phase of the development cycle. Here are the prompts with concrete examples:

Functional Analysis Prompt

Use this type of prompt when you need to create or expand the functional requirements of a module:

Prompt: Analisi Funzionale Genera l'analisi funzionale per il modulo [nome modulo]. Segui la struttura in docs/analisi/ come riferimento. Includi: requisiti numerati (RF-XXX-NN), criteri di accettazione, flussi utente, glossario dei termini di dominio.

Prompt per Architettura Tecnica

Dopo aver definito i requisiti, usa questo prompt per generare il design tecnico:

Technical Architecture Prompt

After defining requirements, use this prompt to generate the technical design:

Prompt: Architettura Tecnica Partendo dall'analisi funzionale in docs/analisi/, genera l'analisi tecnica con: schema database, API endpoints, diagrammi PlantUML, decisioni architetturali.

Prompt per Generazione Codice

Questo è il prompt più potente: Claude Code legge le specifiche e genera codice allineato:

Code Generation Prompt

This is the most powerful prompt: Claude Code reads the specs and generates aligned code:

Prompt: Generazione Codice Implementa il task BE-05 dal file docs/sprints/SPRINT-01.md. Segui le specifiche API in docs/ANALISI_TECNICA.md. Rispetta le convenzioni in CLAUDE.md.

Prompt per Aggiornamento Sprint

Dopo aver completato un task, aggiorna la documentazione di sprint:

Sprint Update Prompt

After completing a task, update the sprint documentation:

Prompt: Aggiornamento Sprint Aggiorna il file docs/sprints/SPRINT-01.md: marca il task BE-05 come completato. Aggiorna lo stato di avanzamento.

Nota: La potenza di questo workflow sta nel fatto che Claude Code ha accesso sia alle specifiche (i file Markdown) sia al codice sorgente. Può quindi verificare la coerenza tra specifica e implementazione, e segnalare eventuali discrepanze.

Note: The power of this workflow lies in the fact that Claude Code has access to both the specifications (the Markdown files) and the source code. It can therefore verify consistency between spec and implementation, and flag any discrepancies.

Best Practices

1. Mantieni CLAUDE.md aggiornato

Aggiorna CLAUDE.md ad ogni sprint con i riferimenti alle specifiche correnti. Un file CLAUDE.md obsoleto porta Claude Code a generare codice basato su contesto non più valido. Includi sempre il riferimento allo sprint corrente e ai file di specifica più recenti.

2. Specifiche come "single source of truth" per l'AI

L'AI genera codice migliore quando ha specifiche dettagliate come contesto. Non limitarti a descrizioni generiche: includi requisiti numerati, criteri di accettazione, schema database, e API endpoints. Più dettaglio dai, più il codice generato sarà preciso e completo.

3. Review delle specifiche generate prima di procedere

Non generare codice da specifiche non revisionate. Se Claude Code genera un'analisi funzionale, rileggila e validala prima di usarla come base per l'architettura tecnica. Ogni errore nelle specifiche si propaga nel codice generato successivamente.

4. Usa tag Git per versioni delle specifiche

Crea tag Git per marcare le versioni stabili delle specifiche, ad esempio v1.0-spec, v2.0-spec. Questo ti permette di tracciare l'evoluzione delle specifiche nel tempo e di tornare a una versione precedente se necessario. Usa MdExplorer per gestire questi tag dal pannello Git integrato.

1. Keep CLAUDE.md up to date

Update CLAUDE.md at every sprint with references to current specifications. An outdated CLAUDE.md file leads Claude Code to generate code based on context that is no longer valid. Always include the reference to the current sprint and the most recent spec files.

2. Specifications as "single source of truth" for the AI

The AI generates better code when it has detailed specifications as context. Do not limit yourself to generic descriptions: include numbered requirements, acceptance criteria, database schema, and API endpoints. The more detail you provide, the more precise and complete the generated code will be.

3. Review generated specifications before proceeding

Do not generate code from unreviewed specifications. If Claude Code generates a functional analysis, read it through and validate it before using it as a basis for the technical architecture. Every error in the specs propagates into the code generated afterwards.

4. Use Git tags for specification versions

Create Git tags to mark stable versions of specifications, for example v1.0-spec, v2.0-spec. This allows you to track the evolution of specifications over time and go back to a previous version if needed. Use MdExplorer to manage these tags from the integrated Git panel.