Skip to main content Skills Marketplace 커뮤니티가 만든 AI 스킬을 발견하고 탐색하세요.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/InugamiDev/ultrathink-oss --skill flask명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
Zip 다운로드 다운로드 중... 이 저장소의 다른 Skills Unified design foundations — design system architecture, tokens, component specs, visual principles, creative vision, figma integration, plus brand design system loader (66 real brands via DESIGN.md). Absorbs design, design-system, design-systems, design-principles, design-router, creative-vision, figma, design-md.
Render, summarize, and present markdown documents and structured content in multiple output modes
Ultra UI skill - combines Google's DESIGN.md spec (machine-readable design tokens) with the ui-ux-pro-max knowledge base (91 styles, 161 palettes, 73 font pairings, 161 products, 104 UX guidelines, 25 chart types). Generates lint-clean DESIGN.md files, validates token references and WCAG contrast, exports Tailwind/DTCG tokens, and diffs design systems version-over-version.
name flask description Flask web framework patterns, Blueprints, extensions, SQLAlchemy integration, and REST API design. layer domain category backend triggers ["flask","flask blueprint","flask extension","flask sqlalchemy","flask rest"] inputs ["Flask application architecture questions","Blueprint organization and registration","Extension integration (SQLAlchemy, Migrate, etc.)","REST API endpoint design"] outputs ["Flask application structure with Blueprints","SQLAlchemy model and query patterns","REST API endpoints with proper error handling","Extension configuration and initialization"] linksTo ["python","postgresql","redis"] linkedFrom [] preferredNextSkills ["python","postgresql","docker"] fallbackSkills ["fastapi","django"] riskLevel low memoryReadPolicy selective memoryWritePolicy none sideEffects []
Flask Web Framework Patterns
Purpose
Provide expert guidance on Flask application architecture, Blueprint organization, extension integration, REST API design, and production deployment patterns. Covers Flask 3.x with modern Python async support and type hints.
Application Factory Pattern
Always use the application factory pattern for testability and multiple configurations:
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
from flask_cors import CORS
db = SQLAlchemy()
migrate = Migrate()
def create_app (config_name: str = "default" ) -> Flask:
app = Flask(__name__)
app.config.from_object(config[config_name])
db.init_app(app)
migrate.init_app(app, db)
CORS(app, resources={r"/api/*" : {"origins" : app.config["ALLOWED_ORIGINS" ]}})
from app.api.auth import auth_bp
from app.api.users import users_bp
app.register_blueprint(auth_bp, url_prefix="/api/auth" )
app.register_blueprint(users_bp, url_prefix="/api/users" )
register_error_handlers(app)
return app
Blueprint Organization
Structure Blueprints by domain, not by technical layer:
app/
__init__.py # create_app factory
models/
__init__.py
user.py
order.py
api/
auth/
__init__.py # Blueprint definition
routes.py # Route handlers
schemas.py # Marshmallow/Pydantic schemas
services.py # Business logic
users/
__init__.py
routes.py
schemas.py
services.py
core/
config.py
errors.py
middleware.py
from flask import Blueprint
users_bp = Blueprint("users" , __name__)
from app.api.users import routes
Route handlers — keep thin, delegate to services:
from flask import request, jsonify
from app.api.users import users_bp
from app.api.users.schemas import UserCreateSchema, UserResponseSchema
from app.api.users.services import UserService
@users_bp.route("/" , methods=["POST" ] )
def create_user ():
schema = UserCreateSchema()
data = schema.load(request.get_json())
user = UserService.create(data)
return jsonify(UserResponseSchema().dump(user)), 201
@users_bp.route("/<int:user_id>" , methods=["GET" ] )
def get_user (user_id: int ):
user = UserService.get_or_404(user_id)
return jsonify(UserResponseSchema().dump(user))
SQLAlchemy Integration Model patterns with proper relationships:
from datetime import datetime
from app import db
class User (db.Model):
__tablename__ = "users"
id = db.Column(db.Integer, primary_key=True )
email = db.Column(db.String(255 ), unique=True , nullable=False , index=True )
name = db.Column(db.String(100 ), nullable=False )
password_hash = db.Column(db.String(255 ), nullable=False )
is_active = db.Column(db.Boolean, default=True , nullable=False )
created_at = db.Column(db.DateTime, default=datetime.utcnow, nullable=False )
updated_at = db.Column(
db.DateTime, default=datetime.utcnow, onupdate=datetime.utcnow
)
orders = db.relationship("Order" , back_populates="user" , lazy="dynamic" )
def __repr__ (self ) -> str :
return f"<User {self.email} >"
Query patterns — use service layer:
from flask import abort
from app import db
from app.models.user import User
class UserService :
@staticmethod
def get_or_404 (user_id: int ) -> User:
return db.get_or_404(User, user_id, description=f"User {user_id} not found" )
@staticmethod
def create (data: dict ) -> User:
user = User(**data)
db.session.add(user)
db.session.commit()
return user
@staticmethod
def list_active (page: int = 1 , per_page: int = 20 ):
return User.query.filter_by(is_active=True ).paginate(
page=page, per_page=per_page, error_out=False
)
REST API Patterns Consistent error handling:
from flask import Flask, jsonify
from werkzeug.exceptions import HTTPException
def register_error_handlers (app: Flask ):
@app.errorhandler(HTTPException )
def handle_http_error (error ):
return jsonify({
"error" : error.name,
"message" : error.description,
"status" : error.code,
}), error.code
@app.errorhandler(422 )
def handle_validation_error (error ):
return jsonify({
"error" : "Validation Error" ,
"messages" : error.description,
"status" : 422 ,
}), 422
Request validation with Marshmallow:
from marshmallow import Schema, fields, validate
class UserCreateSchema (Schema ):
email = fields.Email(required=True )
name = fields.Str(required=True , validate=validate.Length(min =1 , max =100 ))
password = fields.Str(
required=True , validate=validate.Length(min =8 ), load_only=True
)
class UserResponseSchema (Schema ):
id = fields.Int(dump_only=True )
email = fields.Email()
name = fields.Str()
is_active = fields.Bool()
created_at = fields.DateTime()
Configuration Management
import os
class Config :
SECRET_KEY = os.environ["SECRET_KEY" ]
SQLALCHEMY_TRACK_MODIFICATIONS = False
JSON_SORT_KEYS = False
class DevelopmentConfig (Config ):
DEBUG = True
SQLALCHEMY_DATABASE_URI = os.environ.get(
"DATABASE_URL" , "postgresql://localhost/myapp_dev"
)
ALLOWED_ORIGINS = ["http://localhost:3000" ]
class ProductionConfig (Config ):
SQLALCHEMY_DATABASE_URI = os.environ["DATABASE_URL" ]
SQLALCHEMY_ENGINE_OPTIONS = {
"pool_size" : 10 ,
"pool_recycle" : 300 ,
"pool_pre_ping" : True ,
}
ALLOWED_ORIGINS = os.environ["ALLOWED_ORIGINS" ].split("," )
class TestingConfig (Config ):
TESTING = True
SQLALCHEMY_DATABASE_URI = "sqlite:///:memory:"
ALLOWED_ORIGINS = ["*" ]
config = {
"development" : DevelopmentConfig,
"production" : ProductionConfig,
"testing" : TestingConfig,
"default" : DevelopmentConfig,
}
Middleware and Hooks
import time
from flask import Flask, g, request
import logging
logger = logging.getLogger(__name__)
def register_middleware (app: Flask ):
@app.before_request
def before_request ():
g.start_time = time.monotonic()
@app.after_request
def after_request (response ):
if hasattr (g, "start_time" ):
duration = time.monotonic() - g.start_time
logger.info(
"request_completed" ,
extra={
"method" : request.method,
"path" : request.path,
"status" : response.status_code,
"duration_ms" : round (duration * 1000 , 2 ),
},
)
return response
Testing
import pytest
from app import create_app, db as _db
@pytest.fixture(scope="session" )
def app ():
app = create_app("testing" )
with app.app_context():
_db.create_all()
yield app
_db.drop_all()
@pytest.fixture
def client (app ):
return app.test_client()
@pytest.fixture
def db_session (app ):
with app.app_context():
yield _db.session
_db.session.rollback()
def test_create_user (client ):
response = client.post("/api/users/" , json={
"email" : "test@example.com" ,
"name" : "Test User" ,
"password" : "securepass123" ,
})
assert response.status_code == 201
assert response.json["email" ] == "test@example.com"
Best Practices
Always use the application factory — Never use a global app object directly.
Keep route handlers thin — Delegate business logic to a service layer.
Use Blueprints for all routes — Even small apps benefit from modular organization.
Configure SQLAlchemy connection pooling — Set pool_size, pool_recycle, and pool_pre_ping in production.
Use Flask-Migrate for schema changes — Never run db.create_all() in production.
Validate all input — Use Marshmallow or Pydantic schemas on every endpoint.
Return consistent error responses — Register global error handlers for uniform JSON errors.
Use g for request-scoped data — Not module-level globals.
Pin extension versions — Flask extensions can have breaking changes between minors.
Use Gunicorn or uWSGI in production — Never use the Flask dev server.
Common Pitfalls Pitfall Problem Fix Circular imports Models import app, app imports models Use application factory + init_app() pattern Missing db.session.commit() Data never persists Always commit in service layer or use context manager No connection pool tuning DB connection exhaustion under load Set SQLALCHEMY_ENGINE_OPTIONS with pool settings Global app object Untestable, config locked at import Use create_app() factory request outside contextRuntimeError in background tasks Pass data explicitly or use app.app_context() Dev server in production Single-threaded, no SSL, debug mode Use Gunicorn: gunicorn -w 4 "app:create_app()"