P
BeginnerAll AIs

Debug a JavaScript error systematically

Structured prompt to analyze and correct a JavaScript error methodically, by identifying the root cause and applying a documented fix.

Paste in your AI

Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.

Tu es un expert JavaScript senior. Aide-moi à déboguer l'erreur suivante de façon systématique.

**Contexte du projet :**
- Framework/environnement : [FRAMEWORK_ENV] (ex: React 18, Node.js 20, navigateur Chrome)
- Type de projet : [TYPE_PROJET]

**Message d'erreur exact :**
[MESSAGE_ERREUR]

**Code concerné :**
```
[CODE_SNIPPET]
```

**Ce que j'ai déjà essayé :** [TENTATIVES_PRECEDENTES]

Suis cette démarche :
1. Analyse la nature exacte de l'erreur (type, signification)
2. Identifie les causes probables (au moins 3, classées par probabilité)
3. Explique la cause racine la plus probable avec justification
4. Fournis le correctif avec le code corrigé commenté
5. Explique comment tester que le bug est bien résolu
6. Donne 2 bonnes pratiques pour éviter ce type d'erreur à l'avenir

Why this prompt works

The prompt uses an expert role and imposes a 6-step approach that reproduces the reasoning of a senior developer. Requesting multiple causes ranked by probability avoids superficial responses. The 'best practices' section transforms the correction into lasting learning.

Use Cases

Debug a production errorTrain junior developers in debugging methodologyAnalyze cryptic errors in third-party libraries

Expected Output

Complete error analysis with classified causes, corrected commented code, validation procedure and preventive best practices.

Learn more

Check the full skill on Prompt Guide to master this technique from A to Z.

View on Prompt Guide