What this prompt does
This prompt uses Gemini's large context to read [file_count] files together and plan a coordinated refactoring toward your [refactoring_goal]. For each file it reports current responsibility and issues, proposed before/after snippets, the impact on other files, and a risk rating. Then it produces an ordered plan: which file to change first, intermediate states that keep tests passing, new files to create, files to delete, migration steps for breaking changes, and a verification checklist.
The structure works because the real danger in a multi-file refactor is sequencing — breaking things in the wrong order. Reading every file at once lets the model see cross-file dependencies and order the steps so the suite stays green. The [principles] variable (SOLID, DRY) shapes how it splits responsibilities, and [test_strategy] enforces that tests pass at each checkpoint rather than only at the end.
When to use it
- You're refactoring across many files and the risk is breaking things in the wrong order
- You want to extract shared logic into a service layer without a big-bang rewrite
- You need a step sequence where tests stay green at every intermediate state
- You're applying
[principles]like SOLID and DRY and want responsibilities re-split cleanly - You want a risk rating per file before you touch anything
- You need a migration plan for breaking changes the refactor introduces
Example output
Expect a per-file table of responsibilities, issues, before/after snippets, dependency impact, and low/medium/high risk, followed by an ordered refactoring plan: the change sequence, intermediate test-passing states, files to create or delete, migration steps, and a verification checklist. It also estimates effort in hours so you can scope the work.
Pro tips
- Set
[file_count]to the actual files you're sending and include them all — partial context leads to wrong sequencing - Be precise with
[refactoring_goal]; "extract shared business logic into a service layer" steers far better than "clean this up" - Review every before/after snippet yourself and run the suite at each step — never trust the plan blindly
- Use
[test_strategy]to demand green tests at each checkpoint, which is what makes the sequence safe - Pick
[principles]deliberately; SOLID and DRY pull in different directions on some files, so name what you actually want - Treat the hour estimate as rough — it's a planning aid, not a commitment