Scaffold Flask application with blueprints and extensions
✓Works with OpenClaudeYou are a Python web developer. The user wants to scaffold a Flask application with blueprints and extensions for modular, production-ready structure.
What to check first
- Verify Python 3.8+ is installed:
python --version - Check pip is available:
pip --version - Ensure you have a project directory ready or create one with
mkdir flask_app && cd flask_app
Steps
- Create a virtual environment:
python -m venv venvand activate it (source venv/bin/activateon macOS/Linux, orvenv\Scripts\activateon Windows) - Install Flask and essential extensions:
pip install flask flask-sqlalchemy flask-migrate flask-login python-dotenv - Create the project structure with folders:
mkdir app,mkdir app/auth,mkdir app/main,mkdir migrations - Create
app/__init__.pyand initialize extensions (SQLAlchemy, Migrate, LoginManager) before blueprint registration - Create
app/auth/routes.pyandapp/main/routes.pywith blueprint definitions usingBlueprint(name, __name__) - Create
app/models.pywith database models using SQLAlchemy ORM - Create
run.pyas the entry point that creates the app withcreate_app()factory function - Create
.envfile withFLASK_ENV=developmentandSECRET_KEY=your-secret-key - Initialize the database:
flask db init, thenflask db migrate -m "Initial migration", thenflask db upgrade - Run the server:
flask runand verify it starts onhttp://127.0.0.1:5000
Code
# app/__init__.py
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
from flask_login import LoginManager
import os
from dotenv import load_dotenv
load_dotenv()
db = SQLAlchemy()
migrate = Migrate()
login_manager = LoginManager()
def create_app(config_name='development'):
app = Flask(__name__)
# Configuration
app.config['SECRET_KEY'] = os.getenv('SECRET_KEY', 'dev-secret-key')
app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv(
'DATABASE_URL',
'sqlite:///app.db'
)
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
# Initialize extensions
db.init_app(app)
migrate.init_app(app, db)
login_manager.init_app(app)
login_manager.login_view = 'auth.login'
# Register blueprints
from app.auth import auth_bp
from app.main import main_bp
app.register_blueprint(auth_bp, url_
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Python Skills
Other Claude Code skills in the same category — free to download.
Django Setup
Scaffold Django project with models, views, and URLs
FastAPI Setup
Scaffold FastAPI with async endpoints and auto-docs
Pytest Setup
Configure pytest with fixtures, plugins, and coverage
Python Venv
Set up Python virtual environments and dependency management
Poetry Setup
Set up Poetry for Python dependency and package management
Python Typing
Add comprehensive type hints and mypy configuration to Python code
Django REST Framework
Set up Django REST Framework with serializers and viewsets
Python Logging
Configure structured logging for Python applications
Want a Python skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.