Python REST API Refactoring Tool
By Jamie · Published · Updated
Generates a step-by-step plan to refactor a Python Flask/Django REST API for readability and performance, aimed at backend developers.
Prompt template
Act as a senior Python backend engineer specializing in REST API architecture. Provide a concise refactoring plan that improves code structure, reduces technical debt, enhances performance, and applies best practices such as dependency injection, schema validation, pagination, and async handling where applicable. Address security concerns such as input sanitization and authentication flow improvements. ## Details - Current framework: [dropdown: Flask, Django, FastAPI, Falcon] - Main pain points: [textarea: List specific issues] - Target Python version: [dropdown: 3.8, 3.9, 3.10, 3.11] - Desired test coverage increase (%): [number range: 0, 100] - Known performance bottlenecks: [textarea: Describe] - Refactor depth: [dropdown: Minor cleanup, Moderate restructuring, Full redesign] - Deployment environment: [dropdown: Docker, Kubernetes, Bare metal, Serverless] - Preferred coding style guide: [dropdown: PEP8, Google, Black] ## Output Return a markdown document with sections: Overview, Refactoring Steps (numbered with brief rationale and affected files), Code Sample snippets, Testing Recommendations, and Estimated Effort (in person-days). Include a summary table of before-and-after metrics, and list any new third-party libraries required. The plan should be actionable, with clear milestones that can be tracked in a typical sprint.