Back to guide/Developer Tools

Refactoring Hint Comment

Copilot's autocomplete engine uses surrounding comments to predict the next edit. This structured refactoring hint tells Copilot exactly where to extract, what to name it, and where to put it — turning a manual refactor into a single Tab accept.

copilot-promptslogicDescriptionnewFunctionNameparams
Edit View
Prompt
// REFACTOR: Extract the {{logicDescription}} below into a pure function
// called {{newFunctionName}}({{params}}): {{returnType}}
// Move to {{targetFile}}
// Reason: {{reason}}
// Keep the call site here, just replace inline logic with the function call

Variables to customize

{{logicDescription}}{{newFunctionName}}{{params}}{{returnType}}{{targetFile}}{{reason}}

Why this prompt works

Copilot's autocomplete engine uses surrounding comments to predict the next edit. This structured refactoring hint tells Copilot exactly where to extract, what to name it, and where to put it — turning a manual refactor into a single Tab accept.

Save this prompt to your library

Organize, version, and access your best prompts across ChatGPT, Claude, and Cursor.