La versione breve
- Il refactoring deve preservare il comportamento del codice. Questi prompt richiedono test esistenti, una modifica circoscritta e una patch da verificare prima di accettarla.
- 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 refactoring deve preservare il comportamento del codice. Questi prompt richiedono test esistenti, una modifica circoscritta e una patch da verificare prima di accettarla.
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 lunga catena di condizioni
Help with a long conditional chain 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 regola di validazione duplicata
Help with a duplicated validation rule 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 funzione di supporto al database con effetti collaterali
Help with a database helper with side effects 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 componente React troppo grande
Help with a large React component 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 controller API difficile da seguire
Help with a tangled API controller 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 configurazione con stringhe non documentate
Help with a magic-string configuration 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 funzione con nomi poco chiari
Help with a utility with vague names 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 ciclo lento
Help with a slow loop 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 catena di callback legacy
Help with a legacy callback chain 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. Una verifica dei permessi distribuita nel codice
Help with a scattered permission check 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. Una lunga catena di condizioni
Help with a long conditional chain 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 regola di validazione duplicata
Help with a duplicated validation rule 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 funzione di supporto al database con effetti collaterali
Help with a database helper with side effects 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 componente React troppo grande
Help with a large React component 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 controller API difficile da seguire
Help with a tangled API controller 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 configurazione con stringhe non documentate
Help with a magic-string configuration 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 funzione con nomi poco chiari
Help with a utility with vague names 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 ciclo lento
Help with a slow loop 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 catena di callback legacy
Help with a legacy callback chain 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. Una verifica dei permessi distribuita nel codice
Help with a scattered permission check 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. Una lunga catena di condizioni
Help with a long conditional chain 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 regola di validazione duplicata
Help with a duplicated validation rule 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 funzione di supporto al database con effetti collaterali
Help with a database helper with side effects 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 componente React troppo grande
Help with a large React component 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 controller API difficile da seguire
Help with a tangled API controller 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


