AI CodingThrive Editorial

30 prompt IA per il debugging del codice

Il debugging parte da un problema riproducibile. Questi prompt chiedono ipotesi, un test circoscritto e la modifica minima che spiega l'errore.

16 min di letturaAggiornato
Uno sviluppatore esamina un problema software su un portatile.

La versione breve

  • Il debugging parte da un problema riproducibile. Questi prompt chiedono ipotesi, un test circoscritto e la modifica minima che spiega l'errore.
  • 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.

Il debugging parte da un problema riproducibile. Questi prompt chiedono ipotesi, un test circoscritto e la modifica minima che spiega l'errore.

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. Un valore null che blocca una pagina

Help with a null value crashing a page 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 conversione del fuso orario con un giorno di differenza

Help with a timezone conversion off by one day 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. Una risposta 401 intermittente

Help with an intermittent 401 response 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. Una race condition tra due salvataggi

Help with a race between two saves 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 elemento mancante dopo il filtro

Help with a missing list item after filtering 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. Una pagina lenta sotto carico

Help with a slow page under load 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. Un deep link che non funziona

Help with a broken deep link 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 parser che rifiuta input validi

Help with a parser rejecting valid input 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. Una risposta in cache non aggiornata

Help with a stale cached response 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 caricamento che funziona solo in locale

Help with an upload that works only locally 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.

Developer investigating a timezone bug with two clocks and a date test.

Prompt per l'implementazione

Questa sezione riguarda l'implementazione. Fornisci il codice reale e il comando di test prima di accettare la risposta.

11. Un valore null che blocca una pagina

Help with a null value crashing a page 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 conversione del fuso orario con un giorno di differenza

Help with a timezone conversion off by one day 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. Una risposta 401 intermittente

Help with an intermittent 401 response 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. Una race condition tra due salvataggi

Help with a race between two saves 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 elemento mancante dopo il filtro

Help with a missing list item after filtering 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. Una pagina lenta sotto carico

Help with a slow page under load 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. Un deep link che non funziona

Help with a broken deep link 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 parser che rifiuta input validi

Help with a parser rejecting valid input 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. Una risposta in cache non aggiornata

Help with a stale cached response 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 caricamento che funziona solo in locale

Help with an upload that works only locally 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.

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

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. Un valore null che blocca una pagina

Help with a null value crashing a page 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 conversione del fuso orario con un giorno di differenza

Help with a timezone conversion off by one day 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. Una risposta 401 intermittente

Help with an intermittent 401 response 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. Una race condition tra due salvataggi

Help with a race between two saves 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 elemento mancante dopo il filtro

Help with a missing list item after filtering 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.

26. Una pagina lenta sotto carico

Help with a slow page under load 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.

27. Un deep link che non funziona

Help with a broken deep link 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.

28. Un parser che rifiuta input validi

Help with a parser rejecting valid input 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.

29. Una risposta in cache non aggiornata

Help with a stale cached response 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.

30. Un caricamento che funziona solo in locale

Help with an upload that works only locally 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

Continua a leggere

Altri articoli del blog

Tutti gli articoli