Back to guide/Developer Tools

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.

github-copilot-vs-cursorwhat_to_refactorcurrent_approachtarget_approach
Edit View
Prompt
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

{{what_to_refactor}}{{current_approach}}{{target_approach}}{{affected_files}}

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.