AI CodingThrive Editorial

30 prompt IA per la revisione del codice

Una revisione utile individua un rischio concreto e propone come verificarlo. Questi prompt distinguono correttezza, sicurezza e manutenibilità, senza limitarsi a un giudizio generico.

16 min di lettura
Due sviluppatori discutono una modifica al codice evidenziata sullo schermo.

La versione breve

  • Una revisione utile individua un rischio concreto e propone come verificarlo. Questi prompt distinguono correttezza, sicurezza e manutenibilità, senza limitarsi a un giudizio generico.
  • 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.

Una revisione utile individua un rischio concreto e propone come verificarlo. Questi prompt distinguono correttezza, sicurezza e manutenibilità, senza limitarsi a un giudizio generico.

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. Una modifica all'autenticazione

Help with an authentication change 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 migrazione dello schema

Help with a schema 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.

3. Un aggiornamento alla paginazione API

Help with an API pagination update 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 worker per una coda in background

Help with a background queue worker 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. Una route per caricare file

Help with a file upload route 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 modifica alla validazione di un modulo

Help with a form validation change 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 livello di cache

Help with a caching layer 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 webhook di pagamento

Help with a payment webhook 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 aggiornamento di una dipendenza

Help with a dependency upgrade 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 refactoring dello stato lato client

Help with a client-side state refactor 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.

Two reviewers checking a code change for correctness, security and tests.

Prompt per l'implementazione

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

11. Una modifica all'autenticazione

Help with an authentication change 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 migrazione dello schema

Help with a schema 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.

13. Un aggiornamento alla paginazione API

Help with an API pagination update 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 worker per una coda in background

Help with a background queue worker 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. Una route per caricare file

Help with a file upload route 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 modifica alla validazione di un modulo

Help with a form validation change 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 livello di cache

Help with a caching layer 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 webhook di pagamento

Help with a payment webhook 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 aggiornamento di una dipendenza

Help with a dependency upgrade 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 refactoring dello stato lato client

Help with a client-side state refactor 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. Una modifica all'autenticazione

Help with an authentication change 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 migrazione dello schema

Help with a schema migration 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 aggiornamento alla paginazione API

Help with an API pagination update 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 worker per una coda in background

Help with a background queue worker 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. Una route per caricare file

Help with a file upload route 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 modifica alla validazione di un modulo

Help with a form validation change 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 livello di cache

Help with a caching layer 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 webhook di pagamento

Help with a payment webhook 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. Un aggiornamento di una dipendenza

Help with a dependency upgrade 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 refactoring dello stato lato client

Help with a client-side state refactor 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
30 prompt IA per la revisione del codice