[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7AKKK84WV6MBD28EM2WRPFH":3,"skill-same:01M7AKKK84WV6MBD28EM2WRPFH":58},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":31,"commitSha":32,"skillDirectory":33,"forksCount":34,"repositoryHtmlUrl":35,"repositoryHomepageUrl":6,"ownerHtmlUrl":36,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":37,"install":38,"resources":51},"01M7AKKK84WV6MBD28EM2WRPFH","flask",null,"Flask framework guardrails, patterns, and best practices for AI-assisted development.\nUse when working with Flask projects, or when the user mentions Flask.\nProvides blueprint patterns, extensions, Jinja2 templates, and REST API guidelines.","duendecillo2\u002Fskills","duendecillo2","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F110118019?v=4","01M7AH1WTFKG0DB3WRYB3DR5TB","Juan Martin Canguillen","01M7AH1WV3BECG893K2VAS92YG",1,"MIT","https:\u002F\u002Fgithub.com\u002Fduendecillo2\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fsamuel\u002Fflask\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: flask\ndescription: |\n  Flask framework guardrails, patterns, and best practices for AI-assisted development.\n  Use when working with Flask projects, or when the user mentions Flask.\n  Provides blueprint patterns, extensions, Jinja2 templates, and REST API guidelines.\nlicense: MIT\nmetadata:\n  author: samuel\n  version: \"1.0\"\n  category: framework\n  language: python\n  extensions: \".py\"\n---\n\n# Flask Framework Guide\n\n> Applies to: Flask 3.0+, REST APIs, Microservices, Web Applications\n> Language Guide: @.claude\u002Fskills\u002Fpython-guide\u002FSKILL.md\n\n## Overview\n\nFlask is a lightweight WSGI web framework providing the basics for building web applications while allowing flexibility in choosing components.\n\n**Use Flask when:**\n- Building microservices or small-to-medium APIs\n- You want flexibility to choose your own ORM, auth, etc.\n- Rapid prototyping is needed\n- You prefer explicit over implicit behavior\n\n**Consider alternatives when:**\n- You need async support (use FastAPI or Quart)\n- You want batteries-included (use Django)\n- High performance async is critical (use FastAPI)\n\n## Guardrails\n\n### Flask-Specific Guidelines\n\n- Use the application factory pattern (never use global app instances)\n- Use blueprints for modular routing\n- Use Flask extensions appropriately (init in extensions.py)\n- Configure via environment variables with class-based config\n- Use Marshmallow for validation\u002Fserialization\n- Implement proper error handlers for all error types\n- Use Flask-Migrate for database migrations\n- Use Flask-JWT-Extended for authentication\n\n### Security Guidelines\n\n- Never store plain passwords (use werkzeug.security)\n- Use environment variables for all secrets\n- Implement proper authentication and authorization\n- Validate all user input with Marshmallow schemas\n- Use HTTPS in production\n- Set secure cookie options (HTTPONLY, SECURE, SAMESITE)\n- Sanitize all database queries via SQLAlchemy ORM\n- Configure CORS restrictively in production\n\n### Testing Guidelines\n\n- Use pytest with Flask test client\n- Use fixtures for test data and app context\n- Test both success and error cases for every endpoint\n- Mock external services (never call real APIs in tests)\n- Use a separate test database\n- Coverage target: >80% for business logic\n\n## Project Structure\n\n```\nmyproject\u002F\n├── app\u002F\n│   ├── __init__.py           # Application factory\n│   ├── config.py             # Configuration classes\n│   ├── extensions.py         # Flask extensions (single init point)\n│   ├── models\u002F\n│   │   ├── __init__.py\n│   │   ├── base.py           # Base model class with mixins\n│   │   └── user.py\n│   ├── api\u002F\n│   │   ├── __init__.py       # API blueprint registration\n│   │   ├── users.py          # User endpoints\n│   │   └── auth.py           # Auth endpoints\n│   ├── services\u002F\n│   │   ├── __init__.py\n│   │   └── user_service.py   # Business logic (no Flask imports)\n│   ├── schemas\u002F\n│   │   ├── __init__.py\n│   │   └── user.py           # Marshmallow schemas\n│   └── utils\u002F\n│       ├── __init__.py\n│       ├── errors.py         # Custom exceptions and handlers\n│       └── decorators.py     # Auth and role decorators\n├── migrations\u002F               # Alembic migrations (via Flask-Migrate)\n├── tests\u002F\n│   ├── conftest.py           # Fixtures: app, client, db_session\n│   ├── test_api\u002F\n│   │   └── test_users.py\n│   └── test_services\u002F\n│       └── test_user_service.py\n├── .env.example\n├── requirements.txt\n├── requirements-dev.txt\n├── pyproject.toml\n└── run.py                    # Entry point\n```\n\nKey conventions:\n- `app\u002F__init__.py` contains `create_app()` factory only\n- `app\u002Fextensions.py` centralizes all extension instances\n- `app\u002Fservices\u002F` holds business logic, no Flask imports\n- `app\u002Fschemas\u002F` holds Marshmallow validation\u002Fserialization\n- `app\u002Futils\u002Ferrors.py` defines custom exceptions and handlers\n\n## Application Factory\n\nAlways use the factory pattern. Never use a global `app = Flask(__name__)`.\n\n```python\n\"\"\"Flask application factory.\"\"\"\nfrom flask import Flask\n\nfrom app.config import config\nfrom app.extensions import db, migrate, ma, jwt, cors\n\n\ndef create_app(config_name: str = \"development\") -> Flask:\n    \"\"\"Create and configure the Flask application.\"\"\"\n    app = Flask(__name__)\n    app.config.from_object(config[config_name])\n\n    register_extensions(app)\n    register_blueprints(app)\n    register_error_handlers(app)\n    register_commands(app)\n\n    return app\n\n\ndef register_extensions(app: Flask) -> None:\n    \"\"\"Initialize Flask extensions.\"\"\"\n    db.init_app(app)\n    migrate.init_app(app, db)\n    ma.init_app(app)\n    jwt.init_app(app)\n    cors.init_app(app)\n\n\ndef register_blueprints(app: Flask) -> None:\n    \"\"\"Register Flask blueprints.\"\"\"\n    from app.api import api_bp\n    app.register_blueprint(api_bp, url_prefix=\"\u002Fapi\u002Fv1\")\n\n\ndef register_error_handlers(app: Flask) -> None:\n    \"\"\"Register error handlers.\"\"\"\n    from app.utils.errors import (\n        handle_app_error,\n        handle_validation_error,\n        handle_not_found,\n        handle_internal_error,\n    )\n    from marshmallow import ValidationError\n\n    app.register_error_handler(ValidationError, handle_validation_error)\n    app.register_error_handler(404, handle_not_found)\n    app.register_error_handler(500, handle_internal_error)\n\n\ndef register_commands(app: Flask) -> None:\n    \"\"\"Register CLI commands.\"\"\"\n    from app.commands import seed_db\n    app.cli.add_command(seed_db)\n```\n\n## Blueprints\n\nOrganize routes into blueprints. Register them in the factory.\n\n```python\n\"\"\"API blueprint registration.\"\"\"\nfrom flask import Blueprint\n\napi_bp = Blueprint(\"api\", __name__)\n\n# Import routes to register them\nfrom app.api import users, auth  # noqa: F401, E402\n```\n\nBlueprint endpoints follow REST conventions:\n\n| Method | Route | Handler | Description |\n|--------|-------|---------|-------------|\n| GET | `\u002Fresources` | `get_resources()` | List with pagination |\n| GET | `\u002Fresources\u002F\u003Cid>` | `get_resource(id)` | Get single resource |\n| POST | `\u002Fresources` | `create_resource()` | Create resource |\n| PATCH | `\u002Fresources\u002F\u003Cid>` | `update_resource(id)` | Partial update |\n| DELETE | `\u002Fresources\u002F\u003Cid>` | `delete_resource(id)` | Delete resource |\n\n## Configuration\n\nUse class-based configuration with environment variable overrides.\n\n```python\n\"\"\"Application configuration.\"\"\"\nimport os\nfrom datetime import timedelta\nfrom typing import Type\n\n\nclass Config:\n    \"\"\"Base configuration.\"\"\"\n    SECRET_KEY = os.getenv(\"SECRET_KEY\", \"change-in-production\")\n    SQLALCHEMY_TRACK_MODIFICATIONS = False\n    SQLALCHEMY_ENGINE_OPTIONS = {\n        \"pool_pre_ping\": True,\n        \"pool_recycle\": 300,\n    }\n    JWT_SECRET_KEY = os.getenv(\"JWT_SECRET_KEY\", SECRET_KEY)\n    JWT_ACCESS_TOKEN_EXPIRES = timedelta(hours=1)\n    JWT_REFRESH_TOKEN_EXPIRES = timedelta(days=30)\n    CORS_ORIGINS = os.getenv(\"CORS_ORIGINS\", \"*\").split(\",\")\n\n\nclass DevelopmentConfig(Config):\n    DEBUG = True\n    SQLALCHEMY_DATABASE_URI = os.getenv(\n        \"DATABASE_URL\",\n        \"postgresql:\u002F\u002Fpostgres:postgres@localhost:5432\u002Fmyapp_dev\"\n    )\n    SQLALCHEMY_ECHO = True\n\n\nclass TestingConfig(Config):\n    TESTING = True\n    SQLALCHEMY_DATABASE_URI = os.getenv(\n        \"TEST_DATABASE_URL\",\n        \"postgresql:\u002F\u002Fpostgres:postgres@localhost:5432\u002Fmyapp_test\"\n    )\n\n\nclass ProductionConfig(Config):\n    DEBUG = False\n    SQLALCHEMY_DATABASE_URI = os.environ[\"DATABASE_URL\"]\n    SESSION_COOKIE_SECURE = True\n    SESSION_COOKIE_HTTPONLY = True\n    SESSION_COOKIE_SAMESITE = \"Lax\"\n\n\nconfig: dict[str, Type[Config]] = {\n    \"development\": DevelopmentConfig,\n    \"testing\": TestingConfig,\n    \"production\": ProductionConfig,\n}\n```\n\n## Extensions\n\nCentralize all Flask extension instances in a single file.\n\n```python\n\"\"\"Flask extensions initialization.\"\"\"\nfrom flask_sqlalchemy import SQLAlchemy\nfrom flask_migrate import Migrate\nfrom flask_marshmallow import Marshmallow\nfrom flask_jwt_extended import JWTManager\nfrom flask_cors import CORS\n\ndb = SQLAlchemy()\nmigrate = Migrate()\nma = Marshmallow()\njwt = JWTManager()\ncors = CORS()\n```\n\nCommon extensions and their purposes:\n\n| Extension | Purpose |\n|-----------|---------|\n| Flask-SQLAlchemy | ORM and database integration |\n| Flask-Migrate | Alembic database migrations |\n| Flask-Marshmallow | Serialization and validation |\n| Flask-JWT-Extended | JWT authentication |\n| Flask-CORS | Cross-origin resource sharing |\n| Flask-Limiter | Rate limiting |\n| Flask-Caching | Response and data caching |\n| Flask-Mail | Email sending |\n\n## Error Handling\n\nDefine a custom exception hierarchy and register handlers.\n\n```python\n\"\"\"Custom exceptions and error handlers.\"\"\"\nfrom flask import jsonify\n\n\nclass AppError(Exception):\n    \"\"\"Base application error.\"\"\"\n    def __init__(self, message: str, status_code: int = 400):\n        super().__init__(message)\n        self.message = message\n        self.status_code = status_code\n\n\nclass NotFoundError(AppError):\n    def __init__(self, message: str = \"Resource not found\"):\n        super().__init__(message, status_code=404)\n\n\nclass UnauthorizedError(AppError):\n    def __init__(self, message: str = \"Unauthorized\"):\n        super().__init__(message, status_code=401)\n\n\nclass ForbiddenError(AppError):\n    def __init__(self, message: str = \"Forbidden\"):\n        super().__init__(message, status_code=403)\n\n\nclass ConflictError(AppError):\n    def __init__(self, message: str = \"Conflict\"):\n        super().__init__(message, status_code=409)\n\n\ndef handle_validation_error(error):\n    return jsonify({\"error\": \"Validation error\", \"details\": error.messages}), 400\n\n\ndef handle_app_error(error: AppError):\n    return jsonify({\"error\": error.message}), error.status_code\n\n\ndef handle_not_found(error):\n    return jsonify({\"error\": \"Not found\"}), 404\n\n\ndef handle_internal_error(error):\n    return jsonify({\"error\": \"Internal server error\"}), 500\n```\n\n## Jinja2 Templates\n\nWhen building server-rendered pages (not just APIs):\n\n- Templates live in `app\u002Ftemplates\u002F` with a `base.html` layout\n- Use template inheritance: `{% extends \"base.html\" %}`\n- Use `{% block content %}` for page-specific content\n- Escape user content automatically (Jinja2 autoescape is on by default)\n- Use `url_for()` for all URLs in templates\n- Keep logic out of templates; use filters and context processors\n\n```html\n{# app\u002Ftemplates\u002Fbase.html #}\n\u003C!DOCTYPE html>\n\u003Chtml lang=\"en\">\n\u003Chead>\n    \u003Cmeta charset=\"UTF-8\">\n    \u003Ctitle>{% block title %}My App{% endblock %}\u003C\u002Ftitle>\n\u003C\u002Fhead>\n\u003Cbody>\n    {% with messages = get_flashed_messages(with_categories=true) %}\n        {% for category, message in messages %}\n            \u003Cdiv class=\"alert alert-{{ category }}\">{{ message }}\u003C\u002Fdiv>\n        {% endfor %}\n    {% endwith %}\n    {% block content %}{% endblock %}\n\u003C\u002Fbody>\n\u003C\u002Fhtml>\n```\n\n## CLI Commands\n\nRegister custom CLI commands via Click.\n\n```python\n\"\"\"Custom CLI commands.\"\"\"\nimport click\nfrom flask.cli import with_appcontext\nfrom app.extensions import db\n\n\n@click.command(\"seed-db\")\n@with_appcontext\ndef seed_db():\n    \"\"\"Seed database with initial data.\"\"\"\n    # Create initial records\n    db.session.commit()\n    click.echo(\"Database seeded.\")\n```\n\n## Commands Reference\n\n```bash\n# Install dependencies\npip install -r requirements.txt\npip install -r requirements-dev.txt\n\n# Set environment variables\nexport FLASK_APP=run.py\nexport FLASK_ENV=development\n\n# Initialize database\nflask db init\nflask db migrate -m \"Initial migration\"\nflask db upgrade\n\n# Seed database\nflask seed-db\n\n# Run development server\nflask run\n\n# Run with Gunicorn (production)\ngunicorn -w 4 -b 0.0.0.0:5000 \"app:create_app('production')\"\n\n# Run tests\npytest\npytest -v --cov=app --cov-report=html\n\n# Lint and format\nblack .\nisort .\nruff check .\nmypy app\u002F\n```\n\n## Dependencies\n\n### requirements.txt\n```\nFlask>=3.0.0\nFlask-SQLAlchemy>=3.1.0\nFlask-Migrate>=4.0.0\nFlask-Marshmallow>=0.15.0\nFlask-JWT-Extended>=4.6.0\nFlask-CORS>=4.0.0\nmarshmallow-sqlalchemy>=0.29.0\npsycopg2-binary>=2.9.9\npython-dotenv>=1.0.0\ngunicorn>=21.0.0\n```\n\n### requirements-dev.txt\n```\n-r requirements.txt\npytest>=7.4.0\npytest-flask>=1.2.0\npytest-cov>=4.1.0\nblack>=23.0.0\nisort>=5.12.0\nmypy>=1.5.0\nruff>=0.1.0\n```\n\n## Advanced Topics\n\nFor detailed code examples and advanced patterns, see:\n\n- [references\u002Fpatterns.md](references\u002Fpatterns.md) -- Models, schemas, services, API endpoints, authentication, decorators, testing, and deployment patterns\n\n## External References\n\n- [Flask Documentation](https:\u002F\u002Fflask.palletsprojects.com\u002F)\n- [Flask-SQLAlchemy](https:\u002F\u002Fflask-sqlalchemy.palletsprojects.com\u002F)\n- [Flask-Migrate](https:\u002F\u002Fflask-migrate.readthedocs.io\u002F)\n- [Flask-JWT-Extended](https:\u002F\u002Fflask-jwt-extended.readthedocs.io\u002F)\n- [Marshmallow](https:\u002F\u002Fmarshmallow.readthedocs.io\u002F)\n- [SQLAlchemy](https:\u002F\u002Fwww.sqlalchemy.org\u002F)\n","# Flask Framework Guide\n\n> Applies to: Flask 3.0+, REST APIs, Microservices, Web Applications\n> Language Guide: @.claude\u002Fskills\u002Fpython-guide\u002FSKILL.md\n\n## Overview\n\nFlask is a lightweight WSGI web framework providing the basics for building web applications while allowing flexibility in choosing components.\n\n**Use Flask when:**\n- Building microservices or small-to-medium APIs\n- You want flexibility to choose your own ORM, auth, etc.\n- Rapid prototyping is needed\n- You prefer explicit over implicit behavior\n\n**Consider alternatives when:**\n- You need async support (use FastAPI or Quart)\n- You want batteries-included (use Django)\n- High performance async is critical (use FastAPI)\n\n## Guardrails\n\n### Flask-Specific Guidelines\n\n- Use the application factory pattern (never use global app instances)\n- Use blueprints for modular routing\n- Use Flask extensions appropriately (init in extensions.py)\n- Configure via environment variables with class-based config\n- Use Marshmallow for validation\u002Fserialization\n- Implement proper error handlers for all error types\n- Use Flask-Migrate for database migrations\n- Use Flask-JWT-Extended for authentication\n\n### Security Guidelines\n\n- Never store plain passwords (use werkzeug.security)\n- Use environment variables for all secrets\n- Implement proper authentication and authorization\n- Validate all user input with Marshmallow schemas\n- Use HTTPS in production\n- Set secure cookie options (HTTPONLY, SECURE, SAMESITE)\n- Sanitize all database queries via SQLAlchemy ORM\n- Configure CORS restrictively in production\n\n### Testing Guidelines\n\n- Use pytest with Flask test client\n- Use fixtures for test data and app context\n- Test both success and error cases for every endpoint\n- Mock external services (never call real APIs in tests)\n- Use a separate test database\n- Coverage target: >80% for business logic\n\n## Project Structure\n\n```\nmyproject\u002F\n├── app\u002F\n│   ├── __init__.py           # Application factory\n│   ├── config.py             # Configuration classes\n│   ├── extensions.py         # Flask extensions (single init point)\n│   ├── models\u002F\n│   │   ├── __init__.py\n│   │   ├── base.py           # Base model class with mixins\n│   │   └── user.py\n│   ├── api\u002F\n│   │   ├── __init__.py       # API blueprint registration\n│   │   ├── users.py          # User endpoints\n│   │   └── auth.py           # Auth endpoints\n│   ├── services\u002F\n│   │   ├── __init__.py\n│   │   └── user_service.py   # Business logic (no Flask imports)\n│   ├── schemas\u002F\n│   │   ├── __init__.py\n│   │   └── user.py           # Marshmallow schemas\n│   └── utils\u002F\n│       ├── __init__.py\n│       ├── errors.py         # Custom exceptions and handlers\n│       └── decorators.py     # Auth and role decorators\n├── migrations\u002F               # Alembic migrations (via Flask-Migrate)\n├── tests\u002F\n│   ├── conftest.py           # Fixtures: app, client, db_session\n│   ├── test_api\u002F\n│   │   └── test_users.py\n│   └── test_services\u002F\n│       └── test_user_service.py\n├── .env.example\n├── requirements.txt\n├── requirements-dev.txt\n├── pyproject.toml\n└── run.py                    # Entry point\n```\n\nKey conventions:\n- `app\u002F__init__.py` contains `create_app()` factory only\n- `app\u002Fextensions.py` centralizes all extension instances\n- `app\u002Fservices\u002F` holds business logic, no Flask imports\n- `app\u002Fschemas\u002F` holds Marshmallow validation\u002Fserialization\n- `app\u002Futils\u002Ferrors.py` defines custom exceptions and handlers\n\n## Application Factory\n\nAlways use the factory pattern. Never use a global `app = Flask(__name__)`.\n\n```python\n\"\"\"Flask application factory.\"\"\"\nfrom flask import Flask\n\nfrom app.config import config\nfrom app.extensions import db, migrate, ma, jwt, cors\n\n\ndef create_app(config_name: str = \"development\") -> Flask:\n    \"\"\"Create and configure the Flask application.\"\"\"\n    app = Flask(__name__)\n    app.config.from_object(config[config_name])\n\n    register_extensions(app)\n    register_blueprints(app)\n    register_error_handlers(app)\n    register_commands(app)\n\n    return app\n\n\ndef register_extensions(app: Flask) -> None:\n    \"\"\"Initialize Flask extensions.\"\"\"\n    db.init_app(app)\n    migrate.init_app(app, db)\n    ma.init_app(app)\n    jwt.init_app(app)\n    cors.init_app(app)\n\n\ndef register_blueprints(app: Flask) -> None:\n    \"\"\"Register Flask blueprints.\"\"\"\n    from app.api import api_bp\n    app.register_blueprint(api_bp, url_prefix=\"\u002Fapi\u002Fv1\")\n\n\ndef register_error_handlers(app: Flask) -> None:\n    \"\"\"Register error handlers.\"\"\"\n    from app.utils.errors import (\n        handle_app_error,\n        handle_validation_error,\n        handle_not_found,\n        handle_internal_error,\n    )\n    from marshmallow import ValidationError\n\n    app.register_error_handler(ValidationError, handle_validation_error)\n    app.register_error_handler(404, handle_not_found)\n    app.register_error_handler(500, handle_internal_error)\n\n\ndef register_commands(app: Flask) -> None:\n    \"\"\"Register CLI commands.\"\"\"\n    from app.commands import seed_db\n    app.cli.add_command(seed_db)\n```\n\n## Blueprints\n\nOrganize routes into blueprints. Register them in the factory.\n\n```python\n\"\"\"API blueprint registration.\"\"\"\nfrom flask import Blueprint\n\napi_bp = Blueprint(\"api\", __name__)\n\n# Import routes to register them\nfrom app.api import users, auth  # noqa: F401, E402\n```\n\nBlueprint endpoints follow REST conventions:\n\n| Method | Route | Handler | Description |\n|--------|-------|---------|-------------|\n| GET | `\u002Fresources` | `get_resources()` | List with pagination |\n| GET | `\u002Fresources\u002F\u003Cid>` | `get_resource(id)` | Get single resource |\n| POST | `\u002Fresources` | `create_resource()` | Create resource |\n| PATCH | `\u002Fresources\u002F\u003Cid>` | `update_resource(id)` | Partial update |\n| DELETE | `\u002Fresources\u002F\u003Cid>` | `delete_resource(id)` | Delete resource |\n\n## Configuration\n\nUse class-based configuration with environment variable overrides.\n\n```python\n\"\"\"Application configuration.\"\"\"\nimport os\nfrom datetime import timedelta\nfrom typing import Type\n\n\nclass Config:\n    \"\"\"Base configuration.\"\"\"\n    SECRET_KEY = os.getenv(\"SECRET_KEY\", \"change-in-production\")\n    SQLALCHEMY_TRACK_MODIFICATIONS = False\n    SQLALCHEMY_ENGINE_OPTIONS = {\n        \"pool_pre_ping\": True,\n        \"pool_recycle\": 300,\n    }\n    JWT_SECRET_KEY = os.getenv(\"JWT_SECRET_KEY\", SECRET_KEY)\n    JWT_ACCESS_TOKEN_EXPIRES = timedelta(hours=1)\n    JWT_REFRESH_TOKEN_EXPIRES = timedelta(days=30)\n    CORS_ORIGINS = os.getenv(\"CORS_ORIGINS\", \"*\").split(\",\")\n\n\nclass DevelopmentConfig(Config):\n    DEBUG = True\n    SQLALCHEMY_DATABASE_URI = os.getenv(\n        \"DATABASE_URL\",\n        \"postgresql:\u002F\u002Fpostgres:postgres@localhost:5432\u002Fmyapp_dev\"\n    )\n    SQLALCHEMY_ECHO = True\n\n\nclass TestingConfig(Config):\n    TESTING = True\n    SQLALCHEMY_DATABASE_URI = os.getenv(\n        \"TEST_DATABASE_URL\",\n        \"postgresql:\u002F\u002Fpostgres:postgres@localhost:5432\u002Fmyapp_test\"\n    )\n\n\nclass ProductionConfig(Config):\n    DEBUG = False\n    SQLALCHEMY_DATABASE_URI = os.environ[\"DATABASE_URL\"]\n    SESSION_COOKIE_SECURE = True\n    SESSION_COOKIE_HTTPONLY = True\n    SESSION_COOKIE_SAMESITE = \"Lax\"\n\n\nconfig: dict[str, Type[Config]] = {\n    \"development\": DevelopmentConfig,\n    \"testing\": TestingConfig,\n    \"production\": ProductionConfig,\n}\n```\n\n## Extensions\n\nCentralize all Flask extension instances in a single file.\n\n```python\n\"\"\"Flask extensions initialization.\"\"\"\nfrom flask_sqlalchemy import SQLAlchemy\nfrom flask_migrate import Migrate\nfrom flask_marshmallow import Marshmallow\nfrom flask_jwt_extended import JWTManager\nfrom flask_cors import CORS\n\ndb = SQLAlchemy()\nmigrate = Migrate()\nma = Marshmallow()\njwt = JWTManager()\ncors = CORS()\n```\n\nCommon extensions and their purposes:\n\n| Extension | Purpose |\n|-----------|---------|\n| Flask-SQLAlchemy | ORM and database integration |\n| Flask-Migrate | Alembic database migrations |\n| Flask-Marshmallow | Serialization and validation |\n| Flask-JWT-Extended | JWT authentication |\n| Flask-CORS | Cross-origin resource sharing |\n| Flask-Limiter | Rate limiting |\n| Flask-Caching | Response and data caching |\n| Flask-Mail | Email sending |\n\n## Error Handling\n\nDefine a custom exception hierarchy and register handlers.\n\n```python\n\"\"\"Custom exceptions and error handlers.\"\"\"\nfrom flask import jsonify\n\n\nclass AppError(Exception):\n    \"\"\"Base application error.\"\"\"\n    def __init__(self, message: str, status_code: int = 400):\n        super().__init__(message)\n        self.message = message\n        self.status_code = status_code\n\n\nclass NotFoundError(AppError):\n    def __init__(self, message: str = \"Resource not found\"):\n        super().__init__(message, status_code=404)\n\n\nclass UnauthorizedError(AppError):\n    def __init__(self, message: str = \"Unauthorized\"):\n        super().__init__(message, status_code=401)\n\n\nclass ForbiddenError(AppError):\n    def __init__(self, message: str = \"Forbidden\"):\n        super().__init__(message, status_code=403)\n\n\nclass ConflictError(AppError):\n    def __init__(self, message: str = \"Conflict\"):\n        super().__init__(message, status_code=409)\n\n\ndef handle_validation_error(error):\n    return jsonify({\"error\": \"Validation error\", \"details\": error.messages}), 400\n\n\ndef handle_app_error(error: AppError):\n    return jsonify({\"error\": error.message}), error.status_code\n\n\ndef handle_not_found(error):\n    return jsonify({\"error\": \"Not found\"}), 404\n\n\ndef handle_internal_error(error):\n    return jsonify({\"error\": \"Internal server error\"}), 500\n```\n\n## Jinja2 Templates\n\nWhen building server-rendered pages (not just APIs):\n\n- Templates live in `app\u002Ftemplates\u002F` with a `base.html` layout\n- Use template inheritance: `{% extends \"base.html\" %}`\n- Use `{% block content %}` for page-specific content\n- Escape user content automatically (Jinja2 autoescape is on by default)\n- Use `url_for()` for all URLs in templates\n- Keep logic out of templates; use filters and context processors\n\n```html\n{# app\u002Ftemplates\u002Fbase.html #}\n\u003C!DOCTYPE html>\n\u003Chtml lang=\"en\">\n\u003Chead>\n    \u003Cmeta charset=\"UTF-8\">\n    \u003Ctitle>{% block title %}My App{% endblock %}\u003C\u002Ftitle>\n\u003C\u002Fhead>\n\u003Cbody>\n    {% with messages = get_flashed_messages(with_categories=true) %}\n        {% for category, message in messages %}\n            \u003Cdiv class=\"alert alert-{{ category }}\">{{ message }}\u003C\u002Fdiv>\n        {% endfor %}\n    {% endwith %}\n    {% block content %}{% endblock %}\n\u003C\u002Fbody>\n\u003C\u002Fhtml>\n```\n\n## CLI Commands\n\nRegister custom CLI commands via Click.\n\n```python\n\"\"\"Custom CLI commands.\"\"\"\nimport click\nfrom flask.cli import with_appcontext\nfrom app.extensions import db\n\n\n@click.command(\"seed-db\")\n@with_appcontext\ndef seed_db():\n    \"\"\"Seed database with initial data.\"\"\"\n    # Create initial records\n    db.session.commit()\n    click.echo(\"Database seeded.\")\n```\n\n## Commands Reference\n\n```bash\n# Install dependencies\npip install -r requirements.txt\npip install -r requirements-dev.txt\n\n# Set environment variables\nexport FLASK_APP=run.py\nexport FLASK_ENV=development\n\n# Initialize database\nflask db init\nflask db migrate -m \"Initial migration\"\nflask db upgrade\n\n# Seed database\nflask seed-db\n\n# Run development server\nflask run\n\n# Run with Gunicorn (production)\ngunicorn -w 4 -b 0.0.0.0:5000 \"app:create_app('production')\"\n\n# Run tests\npytest\npytest -v --cov=app --cov-report=html\n\n# Lint and format\nblack .\nisort .\nruff check .\nmypy app\u002F\n```\n\n## Dependencies\n\n### requirements.txt\n```\nFlask>=3.0.0\nFlask-SQLAlchemy>=3.1.0\nFlask-Migrate>=4.0.0\nFlask-Marshmallow>=0.15.0\nFlask-JWT-Extended>=4.6.0\nFlask-CORS>=4.0.0\nmarshmallow-sqlalchemy>=0.29.0\npsycopg2-binary>=2.9.9\npython-dotenv>=1.0.0\ngunicorn>=21.0.0\n```\n\n### requirements-dev.txt\n```\n-r requirements.txt\npytest>=7.4.0\npytest-flask>=1.2.0\npytest-cov>=4.1.0\nblack>=23.0.0\nisort>=5.12.0\nmypy>=1.5.0\nruff>=0.1.0\n```\n\n## Advanced Topics\n\nFor detailed code examples and advanced patterns, see:\n\n- [references\u002Fpatterns.md](references\u002Fpatterns.md) -- Models, schemas, services, API endpoints, authentication, decorators, testing, and deployment patterns\n\n## External References\n\n- [Flask Documentation](https:\u002F\u002Fflask.palletsprojects.com\u002F)\n- [Flask-SQLAlchemy](https:\u002F\u002Fflask-sqlalchemy.palletsprojects.com\u002F)\n- [Flask-Migrate](https:\u002F\u002Fflask-migrate.readthedocs.io\u002F)\n- [Flask-JWT-Extended](https:\u002F\u002Fflask-jwt-extended.readthedocs.io\u002F)\n- [Marshmallow](https:\u002F\u002Fmarshmallow.readthedocs.io\u002F)\n- [SQLAlchemy](https:\u002F\u002Fwww.sqlalchemy.org\u002F)\n",{"name":5,"license":15,"metadata":24,"description":30},{"author":25,"version":26,"category":27,"language":28,"extensions":29},"samuel","1.0","framework","python",".py","Flask framework guardrails, patterns, and best practices for AI-assisted development.\nUse when working with Flask projects, or when the user mentions Flask.\nProvides blueprint patterns, extensions, Jinja2 templates, and REST API guidelines.\n","main","9695ace884550553f5d99568e31c675f8c9ee395","skills\u002Fsamuel\u002Fflask",0,"https:\u002F\u002Fgithub.com\u002Fduendecillo2\u002Fskills","https:\u002F\u002Fgithub.com\u002Fduendecillo2","2026-09-23 10:05:47",{"source":8,"skillName":5,"commands":39,"prompt":49,"zipAvailable":50},[40,43,46],{"tool":41,"command":42},"npx","npx skills add duendecillo2\u002Fskills --skill flask",{"tool":44,"command":45},"bunx","bunx skills add duendecillo2\u002Fskills --skill flask",{"tool":47,"command":48},"pnpm","pnpm dlx skills add duendecillo2\u002Fskills --skill flask","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fduendecillo2\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fsamuel\u002Fflask\u002FSKILL.md",true,[52],{"path":53,"resourceType":54,"resourceTypeDesc":55,"sizeBytes":56,"sourceHtmlUrl":57},"references\u002Fpatterns.md","REFERENCE","参考文档",25429,"https:\u002F\u002Fgithub.com\u002Fduendecillo2\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fsamuel\u002Fflask\u002Freferences\u002Fpatterns.md",[59,67,74,81,88,95],{"skillNo":60,"name":61,"nameZh":6,"description":62,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":63,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":19},"01M7AKRGRNFPB490DT3ZE2AFR6","ui-styling","Create beautiful, accessible user interfaces with shadcn\u002Fui components (built on Radix UI + Tailwind), Tailwind CSS utility-first styling, and canvas-based visual designs. Use when building user interfaces, implementing design systems, creating responsive layouts, adding accessible components (dialogs, dropdowns, forms, tables), customizing themes and colors, implementing dark mode, generating visual designs and posters, or establishing consistent styling patterns across applications.","https:\u002F\u002Fgithub.com\u002Fduendecillo2\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fuiux-pro-max\u002Fui-styling\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fduendecillo2\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fuiux-pro-max\u002Fui-styling\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":19},"01M7AKR56JJGY0GR58NG8YPXZK","design","Comprehensive design skill: brand identity, design tokens, UI styling, logo generation (55 styles, Gemini or Atlas Cloud AI), corporate identity program (50 deliverables, CIP mockups), HTML presentations (Chart.js), banner design (22 styles, social\u002Fads\u002Fweb\u002Fprint), icon design (15 styles, SVG, Gemini 3.1 Pro), social photos (HTML→screenshot, multi-platform). Actions: design logo, create CIP, generate mockups, build slides, design banner, generate icon, create social photos, social media images, brand identity, design system. Platforms: Facebook, Twitter, LinkedIn, YouTube, Instagram, Pinterest, TikTok, Threads, Google Ads.","https:\u002F\u002Fgithub.com\u002Fduendecillo2\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fuiux-pro-max\u002Fdesign\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":19},"01M7AKQVD6KKVTAQC2SAVAQ3PG","banner-design","Design banners for social media, ads, website heroes, creative assets, and print. Multiple art direction options with AI-generated visuals. Actions: design, create, generate banner. Platforms: Facebook, Twitter\u002FX, LinkedIn, YouTube, Instagram, Google Display, website hero, print. Styles: minimalist, gradient, bold typography, photo-based, illustrated, geometric, retro, glassmorphism, 3D, neon, duotone, editorial, collage. Uses ui-ux-pro-max, frontend-design, ai-artist, ai-multimodal skills.","https:\u002F\u002Fgithub.com\u002Fduendecillo2\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fuiux-pro-max\u002Fbanner-design\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":19},"01M7AKKEFZJZ6YHATGQ9HYAHPX","ponytail","Forces the laziest solution that actually works, simplest, shortest, most minimal. Channels a senior dev who has seen everything: question whether the task needs to exist at all (YAGNI), reach for the standard library before custom code, native platform features before dependencies, one line before fifty. Supports intensity levels: lite, full (default), ultra. Use whenever the user says \"ponytail\", \"be lazy\", \"lazy mode\", \"simplest solution\", \"minimal solution\", \"yagni\", \"do less\", or \"shortest path\", and whenever they complain about over-engineering, bloat, boilerplate, or unnecessary dependencies.","https:\u002F\u002Fgithub.com\u002Fduendecillo2\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fponytail\u002Fponytail\u002FSKILL.md",[],[],{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":19},"01M7AKFNAXFHEW5QYZSN87PEQK","karpathy-guidelines","Behavioral guidelines to reduce common LLM coding mistakes. Use when writing, reviewing, or refactoring code to avoid overcomplication, make surgical changes, surface assumptions, and define verifiable success criteria.","https:\u002F\u002Fgithub.com\u002Fduendecillo2\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fkarpathy\u002Fkarpathy-guidelines\u002FSKILL.md",[],[],{"skillNo":96,"name":97,"nameZh":6,"description":98,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":99,"categories":100,"keywords":101,"publishedAt":19},"01M7AKFGC68G2J98NJCNWS2CGP","i-have-adhd","Shape output for a reader with ADHD: lead with the next action, number multi-step work, restate state across turns, suppress tangents, give specific time estimates, make wins visible. Invoke with \u002Fi-have-adhd; stays on until \"stop adhd mode\".","https:\u002F\u002Fgithub.com\u002Fduendecillo2\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fi-have-adhd\u002Fi-have-adhd\u002FSKILL.md",[],[]]