What problem does it solve?
Flask codebases often drift into circular imports, tangled extension setup, and routes that contain business logic, making refactors risky and tests difficult to write. This Skill guides your coding agent toward a reliable Flask 3.x structure using an application factory, unbound extensions, and blueprint-driven separation.
Core Features & Use Cases
- Application factory structure: Enforces
create_app() to create the Flask instance only inside the factory function, enabling environment-specific configuration and test isolation.
- Unbound extension initialization: Instantiates extensions in
app/extensions.py and binds them with init_app(app) inside create_app() to prevent circular imports.
- Blueprint + service separation: Keeps
routes.py thin (validation + response) while placing business logic in services.py, models in app/models/, and domain templates under blueprint namespaces.
Use Case: You inherit a Flask app where extensions and blueprints are imported at module load time, causing startup failures and brittle tests; you need a phased, safe refactor that preserves behavior while restructuring for maintainability.
Quick Start
Ask your agent: "Generate a Flask refactor plan for a project that uses blueprints, services, models, and an application factory, then apply the first phase to fix circular imports and extension initialization."