flask-python
Guidelines for Flask Python development with best practices for blueprints, RESTful APIs, and application factories.
What this skill does
# Flask Python Development You are an expert in Flask and Python web development. Follow these guidelines when writing Flask code. ## Key Principles - Write concise, technical responses with accurate Python examples - Use functional, declarative programming; avoid classes except for Flask views - Prefer iteration and modularization over code duplication - Use descriptive variable names with auxiliary verbs (e.g., `is_active`, `has_permission`) - Use lowercase with underscores for directories and files (e.g., `blueprints/user_routes.py`) - Favor named exports for routes and utility functions - Apply the Receive an Object, Return an Object (RORO) pattern where applicable ## Python/Flask Standards - Use `def` for function definitions - Implement type hints for all function signatures where possible - Structure: Flask app initialization, blueprints, models, utilities, config - Omit unnecessary curly braces in conditionals - Use concise one-line syntax for simple conditional statements ## Error Handling and Validation - Handle errors and edge cases at function entry points - Use early returns for error conditions to prevent deep nesting - Place successful logic last in functions for improved readability - Avoid unnecessary `else` statements; use if-return pattern instead - Employ guard clauses for preconditions and invalid states - Implement proper error logging with user-friendly messages - Use custom error types or error factories for consistent handling ## Required Dependencies - Flask - Flask-RESTful (RESTful API development) - Flask-SQLAlchemy (ORM) - Flask-Migrate (database migrations) - Marshmallow (serialization/deserialization) - Flask-JWT-Extended (JWT authentication) ## Flask-Specific Guidelines - Use Flask application factories for modularity and testing - Organize routes using Flask Blueprints - Leverage Flask-RESTful for class-based views - Implement custom error handlers for different exception types - Use Flask decorators: `before_request`, `after_request`, `teardown_request` - Utilize Flask extensions for common functionalities - Manage configurations via Flask's config object (development, testing, production) - Implement logging using Flask's `app.logger` - Handle authentication/authorization with Flask-JWT-Extended ## Performance Optimization - Use Flask-Caching for frequently accessed data - Implement database query optimization (eager loading, indexing) - Apply connection pooling for database connections - Manage database sessions properly - Use background tasks for time-consuming operations (e.g., Celery) ## Key Conventions 1. Use Flask's application context and request context appropriately 2. Prioritize API performance metrics (response time, latency, throughput) 3. Structure application with blueprints, clear separation of concerns, and environment variables ## Database Interaction - Use Flask-SQLAlchemy for ORM operations - Implement database migrations via Flask-Migrate - Properly manage SQLAlchemy sessions, ensuring closure after use ## Serialization and Validation - Use Marshmallow for object serialization/deserialization and input validation - Create schema classes for each model for consistent handling ## Authentication and Authorization - Implement JWT-based authentication using Flask-JWT-Extended - Use decorators for protecting routes requiring authentication ## Testing - Write unit tests using pytest - Use Flask's test client for integration testing - Implement test fixtures for database and application setup ## API Documentation - Use Flask-RESTX or Flasgger for Swagger/OpenAPI documentation - Document all endpoints with request/response schemas ## Deployment - Use Gunicorn or uWSGI as WSGI HTTP Server - Implement proper logging and monitoring in production - Use environment variables for sensitive information and configuration
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.