Skip to main content
Prompting guide

The art of prompting
with Claude Code

Master the art of communicating with AI. A good prompt makes the difference between a generic answer and a result perfectly tailored to your needs.

Fundamentals

The 5 principles of good prompting

These principles are the foundation of every effective interaction with Claude Code. Master them and you will get 10x better results.

Principle 1

Be specific

Provide context and clear constraints. The more precise your prompt, the more relevant the response.

exemple-principe-1.mdmarkdown
# Vague
"Make me a form"
# Specific
"Create a contact form in React with TypeScript.
Fields: name (required), email (required, valid), message (required, min 20 chars).
Use react-hook-form with Zod validation.
Style with Tailwind CSS, responsive mobile-first.
Show a confirmation toast after submission."
Principle 2

Define a role

Give Claude an identity to frame its responses. The role influences the level of detail, vocabulary and approach.

exemple-principe-2.mdmarkdown
"You are a senior software architect specializing in React and Next.js.
You prioritize maintainability, performance and best practices.
You comment your code in English and explain each architectural decision."
Principle 3

Specify the expected format

Clearly indicate the desired response structure: code, list, table, JSON, markdown, etc.

exemple-principe-3.mdmarkdown
"Generate the response in the following format:
1. A summary in 2-3 sentences
2. The complete code with inline comments
3. A table of required dependencies (name | version | usage)
4. Step-by-step installation instructions"
Principle 4

Give examples (few-shot)

Show Claude what you expect with concrete examples. This is the most powerful technique for getting the exact format you want.

exemple-principe-4.mdmarkdown
"Generate variable names following this pattern:
Example 1: logged in user → isUserLoggedIn
Example 2: number of products in cart → cartItemCount
Example 3: last update date → lastUpdatedAt
Now generate for:
- form being submitted
- email validation error
- filtered orders list"
Principle 5

Iterate and refine

Prompting is a dialogue. Progressively refine your requests based on the responses you get.

exemple-principe-5.mdmarkdown
# Iteration 1
"Create a Button component"
# Iteration 2
"Add variants: primary, secondary, ghost and danger"
# Iteration 3
"Add icon support on left and right,
a loading state with a spinner, and the disabled prop"
# Iteration 4
"Add unit tests with Testing Library
and Storybook stories for each variant"
Templates

Ready-to-use prompts

Copy, adapt and use these templates for your projects. Each template follows the 5 principles and has been optimized for the best results.

Web development

To create components, pages or complete web features.

template-web-dev.txtmarkdown
You are a senior React/Next.js/TypeScript developer.
Create a React component that [COMPONENT DESCRIPTION].
Technical context:
- Framework: Next.js 14 (App Router)
- Language: TypeScript (strict mode)
- Styling: Tailwind CSS
- State management: [zustand / React Context / none]
Functional specifications:
- [Feature 1]
- [Feature 2]
- [Feature 3]
Constraints:
- Responsive mobile-first
- Accessible (ARIA, focus management)
- Performance optimized (memo, lazy loading if needed)
- Error handling and loading states
Generate the complete code with:
1. The main component
2. TypeScript types/interfaces
3. A usage example
4. Unit tests (Vitest + Testing Library)

Documentation

To generate clear and structured technical documentation.

template-documentation.txtmarkdown
You are a senior technical writer.
Write the technical documentation for [PROJECT/MODULE NAME].
Target audience: [junior developers / internal team / open-source]
Expected structure:
1. Overview (2-3 sentences)
2. Installation and prerequisites
3. Configuration
4. Quick Start guide
5. API Reference (each function with parameters, return, example)
6. Advanced usage examples
7. FAQ and troubleshooting
Conventions:
- Code examples in [TypeScript/Python/etc.]
- All snippets must be copyable and functional
- Use admonitions (note, warning, tip) when relevant
- Include a navigable table of contents at the beginning

Automation

To create robust automation scripts and pipelines.

template-automation.txtmarkdown
You are a senior DevOps/SRE engineer.
Create a script that automates [TASK DESCRIPTION].
Environment:
- OS: [Linux/macOS/Windows]
- Language: [Bash/Python/Node.js]
- Available tools: [Docker, GitHub Actions, etc.]
Expected behavior:
1. [Step 1 of the process]
2. [Step 2 of the process]
3. [Step 3 of the process]
Requirements:
- Robust error handling (exit codes, try/catch)
- Logging with levels (info, warn, error)
- Dry-run mode for testing without executing
- Configurable variables via .env or CLI arguments
- Idempotent (can be re-run without side effects)
Generate:
1. The complete commented script
2. The .env.example file
3. The usage README
4. A cron/schedule example if relevant

Data analysis

To explore, transform and visualize data effectively.

template-data-analysis.txtmarkdown
You are a senior data analyst expert in Python.
Analyze this CSV dataset and [ANALYSIS OBJECTIVE].
Data information:
- Source: [source description]
- Main columns: [col1, col2, col3, ...]
- Volume: [approximate number of rows]
- Period: [time range of data]
Requested analysis:
1. Exploration: descriptive statistics, missing values, distributions
2. Cleaning: outlier handling, normalization, encoding
3. Analysis: [correlations / trends / segmentation / prediction]
4. Visualization: relevant charts with matplotlib/seaborn
Output format:
- Complete Python code (pandas, numpy, matplotlib)
- Comments explaining each step
- Interpretation of results in non-technical language
- Recommendations based on insights

Content creation

To write structured, engaging and optimized content.

template-content.txtmarkdown
You are a senior web writer specializing in [DOMAIN].
Write a blog post about [TOPIC].
Parameters:
- Tone: [professional / casual / educational]
- Length: [800-1200 words]
- Target audience: [typical reader description]
- Objective: [inform / persuade / tutorial]
Structure:
1. Catchy title (max 60 characters)
2. Introduction with hook (problem/question)
3. 3-5 sections with H2 subheadings
4. Concrete examples and data
5. Conclusion with call-to-action
SEO:
- Main keyword: [keyword]
- Secondary keywords: [keyword-2, keyword-3]
- Meta description (max 155 characters)
- Internal link suggestions
Constraints:
- No unnecessary jargon
- Short sentences (max 20 words)
- One paragraph = one idea
- Include bullet lists for readability
Avoid

Common prompting mistakes

Learn to recognize and fix ineffective prompts. Each example shows a concrete before/after.

Too vague

Don't do this
bad-prompt.mdmarkdown
"Make me a website"
Do this instead
good-prompt.mdmarkdown
"Create a landing page for a project management SaaS app.
Stack: Next.js 14, TypeScript, Tailwind CSS.
Sections: hero with CTA, features (3 columns), pricing (3 plans), FAQ accordion.
Design: modern, dark mode, subtle scroll animations."

No context

Don't do this
bad-prompt.mdmarkdown
"Fix this bug"
Do this instead
good-prompt.mdmarkdown
"I have a 'TypeError: Cannot read property map of undefined' error
in my ProductList.tsx component (line 42).
This component receives a 'products' prop from a REST API.
The error only appears on first render, before the API responds.
Here is the component: [code]"

Asking for everything at once

Don't do this
bad-prompt.mdmarkdown
"Build me a complete app with auth, dashboard, API, database, tests, CI/CD and deployment"
Do this instead
good-prompt.mdmarkdown
"Let's start with the database.
Create the Prisma schema for a task management app with:
- Table User (id, email, name, createdAt)
- Table Project (id, name, ownerId, createdAt)
- Table Task (id, title, status, projectId, assigneeId, dueDate)
Relations: User 1-N Project, Project 1-N Task, User 1-N Task"

Not iterating

Don't do this
bad-prompt.mdmarkdown
"That's not what I wanted" (without more details)
Do this instead
good-prompt.mdmarkdown
"The component is well structured, but I'd like 3 changes:
1. Replace the blue button with a teal-to-cyan gradient
2. Add a fadeIn animation on component mount
3. The email field should validate the format in real-time (not only on submit)"
Advanced

Advanced prompting for power users

Go beyond the basics with techniques that leverage the full power of Claude Code.

Prompt chaining (multi-step sequencing)

Break down a complex task into a sequence of prompts where each step feeds the next.

prompt-chaining.mdmarkdown
# Etape 1 : Analyse
"Analyse ce codebase et identifie les problemes de performance.
Liste chaque probleme avec : fichier, ligne, severite, description."
# Etape 2 : Priorisation (utilise la sortie de l'etape 1)
"A partir de cette liste de problemes, cree un plan d'action priorise.
Criteres : impact utilisateur, complexite de correction, risque de regression."
# Etape 3 : Implementation (utilise la sortie de l'etape 2)
"Implemente la correction du probleme #1 : [description].
Genere le code corrige, les tests de non-regression, et un benchmark avant/apres."
# Etape 4 : Validation
"Revois les corrections appliquees. Verifie qu'elles ne cassent rien
et que les tests passent. Suggere des ameliorations supplementaires si pertinent."

Multi-agent orchestration

Use multiple specialized agents working in parallel on different aspects of a problem.

multi-agent.mdmarkdown
# Dans votre CLAUDE.md, definissez des agents specialises :
## Agents disponibles
| Agent | Role | Quand l'utiliser |
|----------------|-----------------------------|-------------------------------|
| planner | Planification | Avant toute feature complexe |
| tdd-guide | Test-Driven Development | Nouvelles features, bug fixes |
| code-reviewer | Revue de code | Apres chaque implementation |
| security-check | Analyse de securite | Avant chaque commit |
| architect | Decisions d'architecture | Choix techniques importants |
# Exemple d'utilisation dans un prompt :
"Utilise l'agent planner pour decomposer cette feature en taches.
Puis lance en parallele :
- Agent 1 (tdd-guide) : ecrit les tests pour le module auth
- Agent 2 (tdd-guide) : ecrit les tests pour le module API
- Agent 3 (security-check) : analyse les implications securite
Une fois les tests ecrits, implemente le code pour les faire passer."

Complex workflows with agents

Combine chaining, multi-agents and persistent context for production workflows.

workflow-complet.mdmarkdown
# Workflow complet : nouvelle feature du planning a la production
## Phase 1 : Recherche et planification
"Recherche les implementations existantes de [feature] sur GitHub.
Evalue les 3 meilleures options selon : securite, extensibilite, pertinence.
Genere un plan d'implementation detaille avec phases et risques."
## Phase 2 : TDD (Test-Driven Development)
"En suivant le plan, ecris d'abord les tests (RED).
Pour chaque module :
1. Ecris le test → verifie qu'il echoue
2. Ecris l'implementation minimale → verifie qu'il passe (GREEN)
3. Refactorise → verifie que tout passe toujours (REFACTOR)"
## Phase 3 : Revue et securite
"Lance en parallele :
- Code review : qualite, patterns, maintenabilite
- Security review : injections, auth, secrets, XSS
- Performance review : N+1, memory leaks, bundle size
Corrige les issues CRITICAL et HIGH avant de continuer."
## Phase 4 : Integration et deploiement
"Cree la PR avec un resume complet des changements.
Verifie que le CI passe. Deploie en staging pour validation."
Secret weapon

CLAUDE.md: Your secret weapon

The CLAUDE.md file is the persistent context that Claude Code reads at every session. It is the key to getting consistent, project-tailored results.

Structure of an effective CLAUDE.md

A good CLAUDE.md turns Claude into a team member who knows your project inside out.

CLAUDE.mdmarkdown
# CLAUDE.md
## Projet
Nom : MonApp, Application SaaS de gestion de projet
Stack : Next.js 14, TypeScript, Tailwind CSS, Prisma, PostgreSQL
Repo : monorepo avec apps/ (web, api) et packages/ (ui, utils, config)
## Conventions de code
- Immutabilite : toujours creer de nouveaux objets, jamais muter
- Fichiers < 400 lignes, fonctions < 50 lignes
- Nommage : camelCase (variables), PascalCase (composants), kebab-case (fichiers)
- Commentaires en francais, code en anglais
- Gestion d'erreurs explicite a chaque niveau
## Architecture
- Feature-based : src/features/[feature]/{components,hooks,utils,types}
- Repository pattern pour l'acces aux donnees
- API responses : { success, data, error, meta }
## Tests
- Minimum 80% de couverture
- TDD obligatoire : RED → GREEN → REFACTOR
- Stack : Vitest + Testing Library + MSW pour les mocks API
## Git
- Conventional commits : feat:, fix:, refactor:, test:, docs:
- PR avec description detaillee et test plan
- Jamais de push force sur main
## Securite
- Pas de secrets en dur, utiliser .env
- Validation des inputs a toutes les frontieres
- Requetes parametrees (pas de concatenation SQL)
## Agents
| Agent | Usage |
|-------|-------|
| planner | Avant toute feature complexe |
| tdd-guide | Nouvelles features, corrections |
| code-reviewer | Apres chaque implementation |
| security-reviewer | Avant chaque commit |

The 3 levels of CLAUDE.md

Global

~/.claude/CLAUDE.md
Personal preferences applied to all your projects (language, style, general conventions).

Project

./CLAUDE.md
Project-specific context: stack, architecture, team conventions, configured agents.

Module

./src/features/auth/CLAUDE.md
Ultra-specific context for a module: schema, API, particular business constraints.