
Flask Api Development
Scaffold a Flask REST API with an application factory, environment configs, SQLAlchemy, JWT auth, and blueprints.
Overview
flask-api-development is an agent skill for the Build phase that bootstraps Flask APIs using an application factory, layered config, SQLAlchemy, and JWT authentication blueprints.
Install
npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill flask-api-developmentWhat is this skill?
- Application factory with Development, Production, and Testing config classes
- SQLAlchemy integration and in-memory SQLite for tests
- Flask-JWT-Extended setup with environment-driven secrets in production
- Blueprint registration pattern for auth and users routes
- Separation of config.py, factory.py, and route modules
- 3 environment config classes: Development, Production, Testing
Adoption & trust: 1.1k installs on skills.sh; 250 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You need a real Flask API layout but the agent keeps dumping everything into one app.py without configs or auth structure.
Who is it for?
Solo builders creating JSON APIs in Python who want factory pattern and JWT scaffolding fast.
Skip if: Greenfield teams standardized on FastAPI or Django, or builders who only need static serverless functions without SQL.
When should I use this skill?
When scaffolding or extending a Flask JSON API with factory pattern, SQLAlchemy, and JWT.
What do I get? / Deliverables
You get a modular factory-based Flask skeleton with registered blueprints and JWT hooks ready for models and endpoint implementation.
- config.py environment classes
- create_app factory module
- Auth and users blueprint stubs
Recommended Skills
Journey fit
Flask factory and route modules are classic backend build work before you wire a separate frontend or ship to production. Content focuses on create_app, database URIs, JWTManager, and auth/users blueprints—backend API implementation.
How it compares
Backend template skill—not a managed BaaS integration or OpenAPI generator.
Common Questions / FAQ
Who is flask-api-development for?
Independent developers and tiny teams using AI agents to stand up Flask REST services with database and JWT plumbing.
When should I use flask-api-development?
During Build backend work when defining create_app, environment configs, SQLAlchemy, and auth/user blueprints before connecting a client.
Is flask-api-development safe to install?
Review the Security Audits panel on this Prism page; treat JWT secrets and DATABASE_URL as sensitive and never commit production values.
SKILL.md
READMESKILL.md - Flask Api Development
# Application Factory and Configuration ## Application Factory and Configuration ```python # config.py import os class Config: SQLALCHEMY_TRACK_MODIFICATIONS = False JSON_SORT_KEYS = False class DevelopmentConfig(Config): DEBUG = True TESTING = False SQLALCHEMY_DATABASE_URI = 'sqlite:///app.db' class ProductionConfig(Config): DEBUG = False TESTING = False SQLALCHEMY_DATABASE_URI = os.getenv('DATABASE_URL') JWT_SECRET_KEY = os.getenv('JWT_SECRET_KEY') class TestingConfig(Config): TESTING = True SQLALCHEMY_DATABASE_URI = 'sqlite:///:memory:' # factory.py from flask import Flask from flask_sqlalchemy import SQLAlchemy from flask_jwt_extended import JWTManager def create_app(config_name='development'): app = Flask(__name__) if config_name == 'production': from config import ProductionConfig app.config.from_object(ProductionConfig) else: from config import DevelopmentConfig app.config.from_object(DevelopmentConfig) db = SQLAlchemy(app) jwt = JWTManager(app) # Register blueprints from routes.auth import auth_bp from routes.users import users_bp app.register_blueprint(auth_bp) app.register_blueprint(users_bp) return app ``` # Authentication and JWT ## Authentication and JWT ```python # auth.py from flask import request, jsonify from flask_jwt_extended import create_access_token, jwt_required, get_jwt_identity from functools import wraps from models import User, db def authenticate_user(email, password): user = User.query.filter_by(email=email).first() if user and user.verify_password(password): return user return None def login_required(f): @wraps(f) @jwt_required() def decorated_function(*args, **kwargs): identity = get_jwt_identity() user = User.query.get(identity) if not user or not user.is_active: return jsonify({'error': 'User not found or inactive'}), 401 request.current_user = user return f(*args, **kwargs) return decorated_function def admin_required(f): @wraps(f) @login_required def decorated_function(*args, **kwargs): if request.current_user.role != 'admin': return jsonify({'error': 'Admin access required'}), 403 return f(*args, **kwargs) return decorated_function # routes/auth.py from flask import Blueprint, request, jsonify from auth import authenticate_user, login_required from models import User, db from flask_jwt_extended import create_access_token auth_bp = Blueprint('auth', __name__, url_prefix='/api/auth') @auth_bp.route('/login', methods=['POST']) def login(): data = request.get_json() if not data or not data.get('email') or not data.get('password'): return jsonify({'error': 'Missing credentials'}), 400 user = authenticate_user(data['email'], data['password']) if not user: return jsonify({'error': 'Invalid credentials'}), 401 access_token = create_access_token(identity=str(user.id)) return jsonify({ 'access_token': access_token, 'user': user.to_dict() }), 200 @auth_bp.route('/register', methods=['POST']) def register(): data = request.get_json() if User.query.filter_by(email=data['email']).first(): return jsonify({'error': 'Email already exists'}), 409 user = User(email=data['email'], first_name=data.get('first_name')) user.set_password(data['password']) db.session.add(user) db.session.commit() return jsonify({'user': user.to_dict()}), 201 @auth_bp.route('/profile', methods=['GET']) @login_required def get_profile(): return jsonify({'user': request.current_user.to_dict()}), 200 ``` # Blueprints for Modular API Design ## Blueprints for Modular API Design ```python # routes/users.py from flask import Blueprint, request, jsonify from auth import login_required, admin_required from models import User, db from sqlalchemy import or_ users_bp =