---
name: "flask-application-factory-blueprints"
description: "Structure scalable, testable Flask applications using the Application Factory pattern."
metadata:
  author: "Pallets"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "flask application factory pattern"
  - "register flask blueprint"
  - "configure flask extensions"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# Flask Application Factory Pattern & Modular Blueprints

Architects Flask applications: create_app() factory function, registering modular Blueprints, configuring extensions (SQLAlchemy, Migrate, Login), configuration classes (DevelopmentConfig, ProductionConfig), and CLI commands.

## When to Invoke
Invoke this skill whenever you need to:
- flask application factory pattern
- register flask blueprint
- configure flask extensions

## Execution SOP & Rules
1. Define factory function: def create_app(config_name): app = Flask(__name__); app.config.from_object(...); return app.
2. Initialize extensions detached from app: db = SQLAlchemy(); in create_app: db.init_app(app).
3. Create Blueprints: auth_bp = Blueprint('auth', __name__, url_prefix='/auth').
4. Register Blueprints inside create_app: app.register_blueprint(auth_bp).

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
