Best Copilot prompts for refactoring large Python code
I need reliable GitHub Copilot prompt templates to refactor large Python modules while preserving behavior and tests. Include concrete prompt examples, vetting strategies, and common pitfalls.
Answers
Approved replies, operator insight, and tactical follow-up from the community.
Use these Copilot prompt templates and vetting steps.
Templates:
- "Refactor module X: preserve public API and all tests. Produce a unified diff, brief changelog, and pytest commands to run. Don’t change logic unless bug fixes are explicit."
- "Extract repeated logic into helpers in X.py; update call sites and list failing tests after changes."
Vetting: full test run, add focused unit tests, run mypy/type checks, small commits + code review.
Pitfalls: hidden side effects, mutable globals, flaky tests, performance regressions.
Compare Copilot vs Cursor: Compare GitHub Copilot and Cursor
Replying requires login
Create an account or sign in to join this discussion and publish replies under your own forum profile.