AI CodingThrive Editorial

25 KI-Prompts für JavaScript-Entwickler

JavaScript-Fehler entstehen häufig an Übergängen: bei Typumwandlungen, asynchronen Abläufen oder dem Browserzustand. Diese Prompts konzentrieren sich auf jeweils einen solchen Übergang und verlangen einen ausführbaren Test.

13 Min. Lesezeit
JavaScript-Arbeitsplatz mit Pfaden, die asynchrone Aufgaben darstellen.

Die Kurzfassung

  • JavaScript-Fehler entstehen häufig an Übergängen: bei Typumwandlungen, asynchronen Abläufen oder dem Browserzustand. Diese Prompts konzentrieren sich auf jeweils einen solchen Übergang und verlangen einen ausführbaren Test.
  • Gib niemals Zugangsdaten, private Kundendaten oder vollständige proprietäre Repositorys an einen nicht freigegebenen Assistenten weiter. Führe vorgeschlagene Befehle und Tests in deiner eigenen Umgebung aus. Ein plausibler Patch belegt noch nicht, dass die Änderung funktioniert.

JavaScript-Fehler entstehen häufig an Übergängen: bei Typumwandlungen, asynchronen Abläufen oder dem Browserzustand. Diese Prompts konzentrieren sich auf jeweils einen solchen Übergang und verlangen einen ausführbaren Test.

Gib niemals Zugangsdaten, private Kundendaten oder vollständige proprietäre Repositorys an einen nicht freigegebenen Assistenten weiter. Führe vorgeschlagene Befehle und Tests in deiner eigenen Umgebung aus. Ein plausibler Patch belegt noch nicht, dass die Änderung funktioniert.

So nutzt du diese Sammlung

Wähle die Aufgabe, die deiner Arbeit am nächsten kommt. Kopiere den Prompt und ersetze die allgemeine Szene oder den Code-Kontext durch deine eigenen Angaben. Behalte die Vorgaben bei, mit denen du das Ergebnis prüfen kannst. Ändere jeweils eine Variable, damit du erkennst, was besser geworden ist.

Der Ansatz folgt dem Leitfaden zum Prompt Engineering mit GitHub Copilot: Gib konkreten Kontext an und prüfe die Ausgabe, statt einen überzeugend formulierten ersten Entwurf ungeprüft zu übernehmen.

Prompts für die Fehlerdiagnose

Diese Gruppe behandelt die Fehlerdiagnose. Gib deinen tatsächlichen Quellcode und Testbefehl an, bevor du die Antwort übernimmst.

1. Ein Fehlerpfad bei einem abgelehnten Promise

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.

Prüfung: Führe die vorgeschlagene Fehlerreproduktion aus, bevor du einen Patch anwendest.

2. Eine veraltete Closure in einem Event-Handler

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.

Prüfung: Führe die vorgeschlagene Fehlerreproduktion aus, bevor du einen Patch anwendest.

3. Ein Suchfeld mit Debouncing

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.

Prüfung: Führe die vorgeschlagene Fehlerreproduktion aus, bevor du einen Patch anwendest.

4. Ein Fehler durch Array-Mutation

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.

Prüfung: Führe die vorgeschlagene Fehlerreproduktion aus, bevor du einen Patch anwendest.

5. Ein falsch eingelesenes Datum

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.

Prüfung: Führe die vorgeschlagene Fehlerreproduktion aus, bevor du einen Patch anwendest.

6. Eine Zeitüberschreitung bei 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.

Prüfung: Führe die vorgeschlagene Fehlerreproduktion aus, bevor du einen Patch anwendest.

7. Eine Local-Storage-Migration

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.

Prüfung: Führe die vorgeschlagene Fehlerreproduktion aus, bevor du einen Patch anwendest.

8. Ein Speicherleck durch Event-Listener

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.

Prüfung: Führe die vorgeschlagene Fehlerreproduktion aus, bevor du einen Patch anwendest.

9. Ein Tastatur-Handler für Barrierefreiheit

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.

Prüfung: Führe die vorgeschlagene Fehlerreproduktion aus, bevor du einen Patch anwendest.

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

10. Ein ESM-Importfehler

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.

Prüfung: Führe die vorgeschlagene Fehlerreproduktion aus, bevor du einen Patch anwendest.

Prompts für die Implementierung

Diese Gruppe behandelt die Implementierung. Gib deinen tatsächlichen Quellcode und Testbefehl an, bevor du die Antwort übernimmst.

11. Ein Fehlerpfad bei einem abgelehnten Promise

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.

Prüfung: Prüfe den Diff auf Änderungen außerhalb des Auftrags und unbeabsichtigte Datenzugriffe.

12. Eine veraltete Closure in einem Event-Handler

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.

Prüfung: Prüfe den Diff auf Änderungen außerhalb des Auftrags und unbeabsichtigte Datenzugriffe.

13. Ein Suchfeld mit Debouncing

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.

Prüfung: Prüfe den Diff auf Änderungen außerhalb des Auftrags und unbeabsichtigte Datenzugriffe.

14. Ein Fehler durch Array-Mutation

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.

Prüfung: Prüfe den Diff auf Änderungen außerhalb des Auftrags und unbeabsichtigte Datenzugriffe.

15. Ein falsch eingelesenes Datum

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.

Prüfung: Prüfe den Diff auf Änderungen außerhalb des Auftrags und unbeabsichtigte Datenzugriffe.

16. Eine Zeitüberschreitung bei 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.

Prüfung: Prüfe den Diff auf Änderungen außerhalb des Auftrags und unbeabsichtigte Datenzugriffe.

17. Eine Local-Storage-Migration

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.

Prüfung: Prüfe den Diff auf Änderungen außerhalb des Auftrags und unbeabsichtigte Datenzugriffe.

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

18. Ein Speicherleck durch Event-Listener

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.

Prüfung: Prüfe den Diff auf Änderungen außerhalb des Auftrags und unbeabsichtigte Datenzugriffe.

19. Ein Tastatur-Handler für Barrierefreiheit

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.

Prüfung: Prüfe den Diff auf Änderungen außerhalb des Auftrags und unbeabsichtigte Datenzugriffe.

20. Ein ESM-Importfehler

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.

Prüfung: Prüfe den Diff auf Änderungen außerhalb des Auftrags und unbeabsichtigte Datenzugriffe.

Prompts für Grenzfalltests

Diese Gruppe behandelt Grenzfalltests. Gib deinen tatsächlichen Quellcode und Testbefehl an, bevor du die Antwort übernimmst.

21. Ein Fehlerpfad bei einem abgelehnten Promise

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.

Prüfung: Führe die Tests aus und prüfe nach Möglichkeit, ob sie vor der Fehlerbehebung fehlschlagen.

22. Eine veraltete Closure in einem Event-Handler

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.

Prüfung: Führe die Tests aus und prüfe nach Möglichkeit, ob sie vor der Fehlerbehebung fehlschlagen.

23. Ein Suchfeld mit Debouncing

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.

Prüfung: Führe die Tests aus und prüfe nach Möglichkeit, ob sie vor der Fehlerbehebung fehlschlagen.

24. Ein Fehler durch Array-Mutation

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.

Prüfung: Führe die Tests aus und prüfe nach Möglichkeit, ob sie vor der Fehlerbehebung fehlschlagen.

25. Ein falsch eingelesenes Datum

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.

Prüfung: Führe die Tests aus und prüfe nach Möglichkeit, ob sie vor der Fehlerbehebung fehlschlagen.

Was du vor der Verwendung des Ergebnisses prüfen solltest

Gib niemals Zugangsdaten, private Kundendaten oder vollständige proprietäre Repositorys an einen nicht freigegebenen Assistenten weiter. Führe vorgeschlagene Befehle und Tests in deiner eigenen Umgebung aus. Ein plausibler Patch belegt noch nicht, dass die Änderung funktioniert.

Wenn die Ausgabe die Aufgabe verfehlt, kürze den Prompt und ergänze die fehlende Angabe oder Vorgabe. Halte fest, welche Version du verwendet hast, damit sich das fertige Material oder die Code-Änderung reproduzieren lässt.

Weiterführende Informationen

Mit einem verwandten Leitfaden fortfahren

Setzen Sie es in die Praxis um

Dein nächster Schritt

Hast du eine Frage oder Korrektur?

Thrive kontaktieren

Weiterlesen

Mehr aus dem Journal

Alle Artikel