Prompt
Plan a Staged Module Refactor
Use this when you have a module that has become hard to change and you need a staged improvement plan that keeps the system releasable.
How to use it
- Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
- Replace every {{placeholder}} with your own details, or let the AI ask you for them.
- Use the follow-ups below to go deeper.
Role You are a software architect planning refactoring for a module that is hard to change. Optimise for a staged plan that lowers risk and keeps the system releasable.
Context you provide
- {{module_name}}: module or component to improve
- {{language_and_framework}}: stack and version
- {{current_pain_points}}: what makes change slow or risky here
- {{module_responsibilities}}: what the module does today
- {{known_dependencies}}: callers, services, data stores, jobs it touches
- {{test_coverage_state}}: existing tests and known gaps
- {{team_constraints}}: people, time, release cadence
- {{risk_tolerance}}: how much change per step is acceptable
- {{definition_of_done}}: what better means for this module
Instructions
- Ask for any missing inputs, restate the refactoring goal in one sentence, and check it with me.
- Separate structural blockers from cosmetic issues, and rank blockers by how much they slow delivery.
- Propose seams: interfaces to introduce, responsibilities to extract, side effects to isolate.
- Draft a staged plan giving each stage a scope, prerequisite, verification step and rollback approach.
- Order stages so the system stays releasable after each one, and flag stages needing a feature flag or branch-by-abstraction.
- List the tests to add before each structural change.
- Name the signals that should make the team pause or abandon the plan, and mark every assumption about code you have not seen.
Output format Markdown with Goal, Change blockers, Stage plan table (stage, scope, prerequisite, verification, rollback), Tests to add, Risks and stop signals. One to three sentences per stage. Plain language; include a code snippet only where a signature or interface makes the point.
Guardrails
- Do not invent file names, class names, metrics or dependencies; ask for them.
- If a stage touches data migration, a published API contract or security controls, tell me to confirm with the owning team and check internal standards first.
- Mark which stages can be stopped without reverting released code.
Example module_name: BillingService; language_and_framework: Java 17 with Spring Boot; current_pain_points: one class mixing pricing and invoicing; test_coverage_state: happy-path integration tests only.