AI CodingThrive Editorial

25 prompts d’IA pour les développeurs JavaScript

Les bugs JavaScript se cachent souvent aux limites du système : conversion de types, exécution asynchrone et état du navigateur. Ces prompts ciblent une limite à la fois et demandent un test exécutable.

14 min de lecture
Espace de développeur JavaScript avec chemins représentant les tâches asynchrones.

La version courte

  • Les bugs JavaScript se cachent souvent aux limites du système : conversion de types, exécution asynchrone et état du navigateur. Ces prompts ciblent une limite à la fois et demandent un test exécutable.
  • Ne transmettez jamais d’identifiants, de données client privées ou de dépôts propriétaires complets à un assistant non autorisé. Exécutez les commandes et les tests proposés dans votre environnement. Un correctif plausible ne prouve pas que la modification fonctionne.

Les bugs JavaScript se cachent souvent aux limites du système : conversion de types, exécution asynchrone et état du navigateur. Ces prompts ciblent une limite à la fois et demandent un test exécutable.

Ne transmettez jamais d’identifiants, de données client privées ou de dépôts propriétaires complets à un assistant non autorisé. Exécutez les commandes et les tests proposés dans votre environnement. Un correctif plausible ne prouve pas que la modification fonctionne.

Comment utiliser cette collection

Choisissez la tâche la plus proche de votre travail. Copiez le prompt, remplacez la scène ou le contexte générique par vos informations et conservez les contraintes utiles pour évaluer le résultat. Modifiez une variable à la fois afin d’identifier ce qui s’améliore.

Cette méthode reprend les recommandations du guide de prompt engineering de GitHub Copilot : fournir un contexte précis et vérifier la réponse, sans supposer qu’un premier résultat soigné est correct.

Prompts de diagnostic

Cette série porte sur le diagnostic. Fournissez votre code et votre commande de test avant de valider la réponse.

1. Un parcours de rejet de promesse

Help with a promise rejection path in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then state competing hypotheses, request a minimal reproduction and identify evidence that separates them. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Exécutez le scénario de reproduction proposé avant d’appliquer un correctif.

2. Une fermeture obsolète dans un gestionnaire d’événement

Help with a stale closure in an event handler in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then state competing hypotheses, request a minimal reproduction and identify evidence that separates them. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Exécutez le scénario de reproduction proposé avant d’appliquer un correctif.

3. Un champ de recherche avec temporisation

Help with a debounced search field in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then state competing hypotheses, request a minimal reproduction and identify evidence that separates them. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Exécutez le scénario de reproduction proposé avant d’appliquer un correctif.

4. Un bug de mutation de tableau

Help with an array mutation bug in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then state competing hypotheses, request a minimal reproduction and identify evidence that separates them. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Exécutez le scénario de reproduction proposé avant d’appliquer un correctif.

5. Une analyse de date incorrecte

Help with an incorrect date parse in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then state competing hypotheses, request a minimal reproduction and identify evidence that separates them. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Exécutez le scénario de reproduction proposé avant d’appliquer un correctif.

6. Un délai d’attente de fetch

Help with a fetch timeout in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then state competing hypotheses, request a minimal reproduction and identify evidence that separates them. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Exécutez le scénario de reproduction proposé avant d’appliquer un correctif.

7. Une migration du stockage local

Help with a local-storage migration in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then state competing hypotheses, request a minimal reproduction and identify evidence that separates them. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Exécutez le scénario de reproduction proposé avant d’appliquer un correctif.

8. Une fuite d’écouteur d’événement

Help with an event listener leak in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then state competing hypotheses, request a minimal reproduction and identify evidence that separates them. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Exécutez le scénario de reproduction proposé avant d’appliquer un correctif.

9. Un gestionnaire clavier pour l’accessibilité

Help with an accessibility keyboard handler in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then state competing hypotheses, request a minimal reproduction and identify evidence that separates them. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Exécutez le scénario de reproduction proposé avant d’appliquer un correctif.

Asynchronous event paths and browser state timeline on a developer screen.

10. Une erreur d’import ESM

Help with an ESM import error in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then state competing hypotheses, request a minimal reproduction and identify evidence that separates them. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Exécutez le scénario de reproduction proposé avant d’appliquer un correctif.

Prompts de mise en œuvre

Cette série porte sur la mise en œuvre. Fournissez votre code et votre commande de test avant de valider la réponse.

11. Un parcours de rejet de promesse

Help with a promise rejection path in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then make the smallest change that satisfies the stated behavior and show a focused diff. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Vérifiez que le diff ne contient ni modification hors sujet ni accès aux données non prévu.

12. Une fermeture obsolète dans un gestionnaire d’événement

Help with a stale closure in an event handler in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then make the smallest change that satisfies the stated behavior and show a focused diff. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Vérifiez que le diff ne contient ni modification hors sujet ni accès aux données non prévu.

13. Un champ de recherche avec temporisation

Help with a debounced search field in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then make the smallest change that satisfies the stated behavior and show a focused diff. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Vérifiez que le diff ne contient ni modification hors sujet ni accès aux données non prévu.

14. Un bug de mutation de tableau

Help with an array mutation bug in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then make the smallest change that satisfies the stated behavior and show a focused diff. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Vérifiez que le diff ne contient ni modification hors sujet ni accès aux données non prévu.

15. Une analyse de date incorrecte

Help with an incorrect date parse in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then make the smallest change that satisfies the stated behavior and show a focused diff. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Vérifiez que le diff ne contient ni modification hors sujet ni accès aux données non prévu.

16. Un délai d’attente de fetch

Help with a fetch timeout in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then make the smallest change that satisfies the stated behavior and show a focused diff. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Vérifiez que le diff ne contient ni modification hors sujet ni accès aux données non prévu.

17. Une migration du stockage local

Help with a local-storage migration in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then make the smallest change that satisfies the stated behavior and show a focused diff. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Vérifiez que le diff ne contient ni modification hors sujet ni accès aux données non prévu.

Three-step code workflow: brief the work, inspect the result, edit and verify.

18. Une fuite d’écouteur d’événement

Help with an event listener leak in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then make the smallest change that satisfies the stated behavior and show a focused diff. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Vérifiez que le diff ne contient ni modification hors sujet ni accès aux données non prévu.

19. Un gestionnaire clavier pour l’accessibilité

Help with an accessibility keyboard handler in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then make the smallest change that satisfies the stated behavior and show a focused diff. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Vérifiez que le diff ne contient ni modification hors sujet ni accès aux données non prévu.

20. Une erreur d’import ESM

Help with an ESM import error in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then make the smallest change that satisfies the stated behavior and show a focused diff. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Vérifiez que le diff ne contient ni modification hors sujet ni accès aux données non prévu.

Prompts de test des limites

Cette série porte sur les tests de limites. Fournissez votre code et votre commande de test avant de valider la réponse.

21. Un parcours de rejet de promesse

Help with a promise rejection path in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then add unit or integration cases for empty, invalid and concurrent inputs as appropriate. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Exécutez les tests et, si possible, vérifiez qu’ils échouent avant le correctif.

22. Une fermeture obsolète dans un gestionnaire d’événement

Help with a stale closure in an event handler in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then add unit or integration cases for empty, invalid and concurrent inputs as appropriate. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Exécutez les tests et, si possible, vérifiez qu’ils échouent avant le correctif.

23. Un champ de recherche avec temporisation

Help with a debounced search field in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then add unit or integration cases for empty, invalid and concurrent inputs as appropriate. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Exécutez les tests et, si possible, vérifiez qu’ils échouent avant le correctif.

24. Un bug de mutation de tableau

Help with an array mutation bug in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then add unit or integration cases for empty, invalid and concurrent inputs as appropriate. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Exécutez les tests et, si possible, vérifiez qu’ils échouent avant le correctif.

25. Une analyse de date incorrecte

Help with an incorrect date parse in my existing codebase. Ask for the relevant file, expected behavior, actual behavior and test command if I have not supplied them. Then add unit or integration cases for empty, invalid and concurrent inputs as appropriate. Preserve public interfaces unless evidence requires a change. Show assumptions, a focused diff and the exact command I should run. Do not invent files, test results or security guarantees.

Vérification : Exécutez les tests et, si possible, vérifiez qu’ils échouent avant le correctif.

Que vérifier avant d’utiliser le résultat

Ne transmettez jamais d’identifiants, de données client privées ou de dépôts propriétaires complets à un assistant non autorisé. Exécutez les commandes et les tests proposés dans votre environnement. Un correctif plausible ne prouve pas que la modification fonctionne.

Si le résultat ne répond pas à la tâche, raccourcissez le prompt et précisez l’information ou la contrainte manquante. Conservez la version utilisée pour pouvoir reproduire le visuel final ou la modification du code.

Pour aller plus loin

Poursuivre avec un guide associé

Mise en pratique

Votre prochaine étape

Vous avez une question ou une correction?

Contacter Thrive

Continuez à lire

Pour en savoir plus sur le journal

Tous les articles
25 prompts d’IA pour les développeurs JavaScript | Thrive