Git-Aware Refactor
Copilot integrates with GitHub's PR workflow, so atomic commits matter. Cursor's Composer can execute multi-step plans. The 'app works at every commit' constraint prevents the common AI refactoring mistake of breaking intermediate states.
I need to refactor {{what_to_refactor}} but want to keep a clean git history. Current implementation: {{current_approach}} Target implementation: {{target_approach}} Files affected: {{affected_files}} Break this into atomic, reviewable commits: **Commit 1 — Preparation** (no behavior change): - Add any new types/interfaces needed - Create new files with empty stubs - Add feature flags if needed for gradual rollout **Commit 2 — Implementation** (behind feature flag if applicable): - Implement the new approach - Old code remains functional throughout **Commit 3 — Migration**: - Switch call sites from old to new - Update tests to use new approach - Each test should pass at every commit **Commit 4 — Cleanup**: - Remove old implementation - Remove feature flag - Update documentation/comments For each commit, provide: - Commit message following conventional commits (feat:, refactor:, chore:) - List of files changed - The actual code changes The key constraint: the app should work correctly at every commit. No "break things now, fix later" commits.
Variables to customize
Why this prompt works
Copilot integrates with GitHub's PR workflow, so atomic commits matter. Cursor's Composer can execute multi-step plans. The 'app works at every commit' constraint prevents the common AI refactoring mistake of breaking intermediate states.
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.