La versione breve
- Gli errori JavaScript spesso emergono nei punti di confine: conversioni di tipo, operazioni asincrone e stato del browser. Questi prompt si concentrano su un problema e richiedono un test eseguibile.
- Non incollare credenziali, dati privati dei clienti o interi repository proprietari in un assistente non autorizzato. Esegui i comandi e i test proposti nel tuo ambiente. Una patch plausibile non dimostra che la modifica funzioni.
Gli errori JavaScript spesso emergono nei punti di confine: conversioni di tipo, operazioni asincrone e stato del browser. Questi prompt si concentrano su un problema e richiedono un test eseguibile.
Non incollare credenziali, dati privati dei clienti o interi repository proprietari in un assistente non autorizzato. Esegui i comandi e i test proposti nel tuo ambiente. Una patch plausibile non dimostra che la modifica funzioni.
Come usare questa raccolta
Scegli l'attività più vicina al tuo lavoro. Copia il prompt, sostituisci la scena generica o il contesto del codice con i tuoi dati e mantieni i vincoli utili a valutare il risultato. Modifica una variabile alla volta per capire cosa migliora.
Il metodo segue la guida al prompt engineering di GitHub Copilot: fornisci un contesto preciso e controlla il risultato, senza dare per corretta una prima bozza ben presentata.
Prompt per la diagnosi
Questa sezione riguarda la diagnosi dei problemi. Fornisci il codice reale e il comando di test prima di accettare la risposta.
1. La gestione di una Promise rifiutata
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.Verifica: Esegui il caso di riproduzione proposto prima di applicare una patch.
2. Una closure non aggiornata in un gestore di eventi
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.Verifica: Esegui il caso di riproduzione proposto prima di applicare una patch.
3. Un campo di ricerca con debounce
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.Verifica: Esegui il caso di riproduzione proposto prima di applicare una patch.
4. Un errore nella modifica di un array
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.Verifica: Esegui il caso di riproduzione proposto prima di applicare una patch.
5. Un'interpretazione errata di una data
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.Verifica: Esegui il caso di riproduzione proposto prima di applicare una patch.
6. Un timeout di 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.Verifica: Esegui il caso di riproduzione proposto prima di applicare una patch.
7. Una migrazione del local storage
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.Verifica: Esegui il caso di riproduzione proposto prima di applicare una patch.
8. Un listener di eventi non rimosso
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.Verifica: Esegui il caso di riproduzione proposto prima di applicare una patch.
9. Un gestore di tastiera per 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.Verifica: Esegui il caso di riproduzione proposto prima di applicare una patch.

10. Un errore di importazione 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.Verifica: Esegui il caso di riproduzione proposto prima di applicare una patch.
Prompt per l'implementazione
Questa sezione riguarda l'implementazione. Fornisci il codice reale e il comando di test prima di accettare la risposta.
11. La gestione di una Promise rifiutata
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.Verifica: Controlla nella patch le modifiche non pertinenti e gli accessi ai dati non previsti.
12. Una closure non aggiornata in un gestore di eventi
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.Verifica: Controlla nella patch le modifiche non pertinenti e gli accessi ai dati non previsti.
13. Un campo di ricerca con debounce
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.Verifica: Controlla nella patch le modifiche non pertinenti e gli accessi ai dati non previsti.
14. Un errore nella modifica di un array
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.Verifica: Controlla nella patch le modifiche non pertinenti e gli accessi ai dati non previsti.
15. Un'interpretazione errata di una data
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.Verifica: Controlla nella patch le modifiche non pertinenti e gli accessi ai dati non previsti.
16. Un timeout di 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.Verifica: Controlla nella patch le modifiche non pertinenti e gli accessi ai dati non previsti.
17. Una migrazione del local storage
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.Verifica: Controlla nella patch le modifiche non pertinenti e gli accessi ai dati non previsti.

18. Un listener di eventi non rimosso
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.Verifica: Controlla nella patch le modifiche non pertinenti e gli accessi ai dati non previsti.
19. Un gestore di tastiera per 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.Verifica: Controlla nella patch le modifiche non pertinenti e gli accessi ai dati non previsti.
20. Un errore di importazione 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.Verifica: Controlla nella patch le modifiche non pertinenti e gli accessi ai dati non previsti.
Prompt per i casi limite
Questa sezione riguarda i test dei casi limite. Fornisci il codice reale e il comando di test prima di accettare la risposta.
21. La gestione di una Promise rifiutata
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.Verifica: Esegui i test e, quando possibile, verifica che falliscano prima della correzione.
22. Una closure non aggiornata in un gestore di eventi
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.Verifica: Esegui i test e, quando possibile, verifica che falliscano prima della correzione.
23. Un campo di ricerca con debounce
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.Verifica: Esegui i test e, quando possibile, verifica che falliscano prima della correzione.
24. Un errore nella modifica di un array
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.Verifica: Esegui i test e, quando possibile, verifica che falliscano prima della correzione.
25. Un'interpretazione errata di una data
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.Verifica: Esegui i test e, quando possibile, verifica che falliscano prima della correzione.
Cosa verificare prima di usare il risultato
Non incollare credenziali, dati privati dei clienti o interi repository proprietari in un assistente non autorizzato. Esegui i comandi e i test proposti nel tuo ambiente. Una patch plausibile non dimostra che la modifica funzioni.
Se il risultato non risponde al compito, accorcia il prompt e precisa il fatto o il vincolo mancante. Conserva la versione usata per poter riprodurre il contenuto finale o la modifica al codice.
Approfondimenti
Continua con una guida correlata
Mettilo in pratica
Il prossimo passo
Hai una domanda o una correzione?
Contatta Thrive


