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.
// 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
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.
Related prompts
Get thorough code reviews with actionable feedback tailored to your language, framework, and standards.
Context-Aware Code CompletionProviding the surrounding code and project context lets the model match existing patterns exactly. The constraint against modifying existing code prevents unwanted side effects.
Inline Code SuggestionConstraining suggestions to match existing style and scope produces insertions that feel native to the codebase. The 'no explanation' rule mimics real inline completion behavior.
Code ExplanationThe audience level parameter adjusts complexity automatically. Requiring a usage example ensures the explanation is practical, not just theoretical.